From b42a1788738c518f008d9f04214dcb81f0e45048 Mon Sep 17 00:00:00 2001 From: liujie_answer Date: Wed, 26 Mar 2025 15:36:58 +0800 Subject: [PATCH] Linkdata inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IBD4T8 CVE: NA ------------------------------------------ This commit is to support Linkdata HBA/RAID controllers. Signed-off-by: liujie_answer --- drivers/scsi/linkdata/changes.patch | 19494 ++++++++++++++++ drivers/scsi/linkdata/ps3stor/Makefile | 78 +- .../ps3stor/include/htp_v200/ps3_htp.h | 379 +- .../ps3stor/include/htp_v200/ps3_htp_def.h | 681 +- .../ps3stor/include/htp_v200/ps3_htp_dev.h | 458 +- .../ps3stor/include/htp_v200/ps3_htp_event.h | 73 +- .../ps3stor/include/htp_v200/ps3_htp_ioctl.h | 131 +- .../ps3stor/include/htp_v200/ps3_htp_pci.h | 79 +- .../include/htp_v200/ps3_htp_req_frame_hw.h | 126 +- .../include/htp_v200/ps3_htp_reqframe.h | 470 +- .../ps3stor/include/htp_v200/ps3_htp_sas.h | 554 +- .../s1861_regs/s1861_global_baseaddr.h | 13 +- .../s1861_hil_reg0_ps3_register_f_reg.h | 1322 +- .../s1861_hil_reg0_ps3_register_s_reg.h | 34 +- .../s1861_hil_reg0_ps3_request_queue_reg.h | 547 +- .../ps3stor/include/ps3_evtcode_trans.h | 865 +- .../ps3stor/include/ps3_htp_dev_info.h | 88 - .../linkdata/ps3stor/include/ps3_htp_meta.h | 127 - .../ps3stor/include/ps3_htp_mgr_evt.h | 16 - .../ps3stor/include/ps3_htp_mgr_evt_raidhba.h | 1866 -- .../ps3stor/include/ps3_htp_nvme_spec.h | 191 - .../ps3stor/include/ps3_htp_register_fifo.h | 41 - .../ps3stor/include/ps3_htp_trace_id.h | 21 - .../ps3stor/include/ps3_mgr_evt_common.h | 107 +- .../scsi/linkdata/ps3stor/linux/ps3_base.c | 1049 +- drivers/scsi/linkdata/ps3stor/linux/ps3_cli.c | 121 +- drivers/scsi/linkdata/ps3stor/linux/ps3_cli.h | 20 +- .../linkdata/ps3stor/linux/ps3_cli_debug.c | 4199 ++-- .../linkdata/ps3stor/linux/ps3_cli_debug.h | 12 +- .../linkdata/ps3stor/linux/ps3_driver_log.c | 608 +- .../linkdata/ps3stor/linux/ps3_driver_log.h | 885 +- .../scsi/linkdata/ps3stor/linux/ps3_dump.c | 567 +- .../ps3stor/linux/ps3_pcie_err_handle.c | 138 +- .../ps3stor/linux/ps3_pcie_err_handle.h | 5 +- .../scsi/linkdata/ps3stor/ps3_cmd_channel.c | 929 +- .../scsi/linkdata/ps3stor/ps3_cmd_channel.h | 354 +- .../scsi/linkdata/ps3stor/ps3_cmd_complete.c | 301 +- .../scsi/linkdata/ps3stor/ps3_cmd_complete.h | 14 +- .../scsi/linkdata/ps3stor/ps3_cmd_stat_def.h | 160 +- .../linkdata/ps3stor/ps3_cmd_statistics.c | 906 +- .../linkdata/ps3stor/ps3_cmd_statistics.h | 459 +- drivers/scsi/linkdata/ps3stor/ps3_debug.c | 890 +- drivers/scsi/linkdata/ps3stor/ps3_debug.h | 162 +- .../linkdata/ps3stor/ps3_device_manager.c | 1594 +- .../linkdata/ps3stor/ps3_device_manager.h | 646 +- .../linkdata/ps3stor/ps3_device_manager_sas.c | 1476 +- .../linkdata/ps3stor/ps3_device_manager_sas.h | 121 +- .../scsi/linkdata/ps3stor/ps3_device_update.c | 1295 +- .../scsi/linkdata/ps3stor/ps3_device_update.h | 32 +- drivers/scsi/linkdata/ps3stor/ps3_drv_ver.h | 14 +- drivers/scsi/linkdata/ps3stor/ps3_dump.h | 139 +- drivers/scsi/linkdata/ps3stor/ps3_err_def.h | 65 +- drivers/scsi/linkdata/ps3stor/ps3_event.c | 1283 +- drivers/scsi/linkdata/ps3stor/ps3_event.h | 37 +- .../scsi/linkdata/ps3stor/ps3_inner_data.h | 492 +- .../linkdata/ps3stor/ps3_instance_manager.c | 433 +- .../linkdata/ps3stor/ps3_instance_manager.h | 487 +- drivers/scsi/linkdata/ps3stor/ps3_io_trace.c | 90 +- drivers/scsi/linkdata/ps3stor/ps3_io_trace.h | 24 +- drivers/scsi/linkdata/ps3stor/ps3_ioc_adp.c | 339 +- .../scsi/linkdata/ps3stor/ps3_ioc_manager.c | 776 +- .../scsi/linkdata/ps3stor/ps3_ioc_manager.h | 863 +- drivers/scsi/linkdata/ps3stor/ps3_ioc_state.c | 699 +- drivers/scsi/linkdata/ps3stor/ps3_ioc_state.h | 91 +- drivers/scsi/linkdata/ps3stor/ps3_ioctl.c | 547 +- drivers/scsi/linkdata/ps3stor/ps3_ioctl.h | 30 +- drivers/scsi/linkdata/ps3stor/ps3_irq.c | 1043 +- drivers/scsi/linkdata/ps3stor/ps3_irq.h | 106 +- .../linkdata/ps3stor/ps3_kernel_version.h | 31 - drivers/scsi/linkdata/ps3stor/ps3_load.c | 317 +- drivers/scsi/linkdata/ps3stor/ps3_load.h | 5 +- .../scsi/linkdata/ps3stor/ps3_mgr_channel.c | 307 +- .../scsi/linkdata/ps3stor/ps3_mgr_channel.h | 28 +- drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.c | 1332 +- drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.h | 95 +- .../scsi/linkdata/ps3stor/ps3_mgr_cmd_err.c | 184 +- .../scsi/linkdata/ps3stor/ps3_mgr_cmd_err.h | 16 +- .../scsi/linkdata/ps3stor/ps3_module_para.c | 514 +- .../scsi/linkdata/ps3stor/ps3_module_para.h | 126 +- .../linkdata/ps3stor/ps3_nvme_resp_to_scsi.c | 351 +- .../linkdata/ps3stor/ps3_nvme_resp_to_scsi.h | 21 +- drivers/scsi/linkdata/ps3stor/ps3_pci.c | 679 +- drivers/scsi/linkdata/ps3stor/ps3_pci.h | 63 +- .../linkdata/ps3stor/ps3_platform_utils.c | 386 +- .../linkdata/ps3stor/ps3_platform_utils.h | 479 +- drivers/scsi/linkdata/ps3stor/ps3_qos.c | 2528 +- drivers/scsi/linkdata/ps3stor/ps3_qos.h | 250 +- .../linkdata/ps3stor/ps3_r1x_write_lock.c | 1448 +- .../linkdata/ps3stor/ps3_r1x_write_lock.h | 56 +- drivers/scsi/linkdata/ps3stor/ps3_rb_tree.c | 1124 +- drivers/scsi/linkdata/ps3stor/ps3_rb_tree.h | 407 +- drivers/scsi/linkdata/ps3stor/ps3_recovery.c | 2924 ++- drivers/scsi/linkdata/ps3stor/ps3_recovery.h | 130 +- .../scsi/linkdata/ps3stor/ps3_sas_transport.c | 565 +- .../scsi/linkdata/ps3stor/ps3_sas_transport.h | 25 +- .../scsi/linkdata/ps3stor/ps3_scsi_cmd_err.c | 988 +- .../scsi/linkdata/ps3stor/ps3_scsi_cmd_err.h | 114 +- drivers/scsi/linkdata/ps3stor/ps3_scsih.c | 2689 +-- drivers/scsi/linkdata/ps3stor/ps3_scsih.h | 147 +- .../linkdata/ps3stor/ps3_scsih_cmd_parse.c | 590 +- .../linkdata/ps3stor/ps3_scsih_cmd_parse.h | 179 +- .../linkdata/ps3stor/ps3_scsih_raid_engine.c | 1125 +- .../linkdata/ps3stor/ps3_scsih_raid_engine.h | 17 +- .../linkdata/ps3stor/ps3_trace_id_alloc.c | 38 +- .../linkdata/ps3stor/ps3_trace_id_alloc.h | 23 +- drivers/scsi/linkdata/ps3stor/ps3_util.h | 204 +- drivers/scsi/linkdata/ps3stor/ps3_watchdog.c | 266 +- drivers/scsi/linkdata/ps3stor/ps3_watchdog.h | 11 +- 108 files changed, 44790 insertions(+), 28254 deletions(-) create mode 100644 drivers/scsi/linkdata/changes.patch delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_dev_info.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_meta.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt_raidhba.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_nvme_spec.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_register_fifo.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_trace_id.h delete mode 100644 drivers/scsi/linkdata/ps3stor/ps3_kernel_version.h diff --git a/drivers/scsi/linkdata/changes.patch b/drivers/scsi/linkdata/changes.patch new file mode 100644 index 000000000000..3edd15eb44dd --- /dev/null +++ b/drivers/scsi/linkdata/changes.patch @@ -0,0 +1,19494 @@ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/dkms.conf ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/dkms.conf +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/dkms.conf 1970-01-01 08:00:00.000000000 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/dkms.conf 2025-06-10 20:13:00.347057888 +0800 +@@ -0,0 +1,17 @@ ++# ++# Master copy of dkms.conf for ps3stor. ++# Dont edit this file manually. Auto build script makes necessary changes. ++# ++ ++PACKAGE_NAME="ps3stor" ++PACKAGE_VERSION=0.0.0.0 ++MOD_PATH=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION} ++ ++MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${MOD_PATH}/build modules" ++CLEAN="make -C ${kernel_source_dir} SUBDIRS=${MOD_PATH}/build clean" ++ ++BUILT_MODULE_NAME[0]="ps3stor" ++DEST_MODULE_LOCATION[0]="/kernel/drivers/scsi/" ++MODULES_CONF_ALIAS_TYPE[0]="scsi_hostadapter" ++ ++REMAKE_INITRD="yes" +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_def.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_def.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_def.h 2025-06-10 20:13:00.180052062 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_def.h 2025-06-10 20:13:00.361058376 +0800 +@@ -5,16 +5,23 @@ + #include "ps3_types.h" + + typedef unsigned char Bool; +- +- +- + #define PCIE_DMA_HOST_ADDR_BIT_POS (44) + + #define PCIE_DMA_HOST_ADDR_BIT_POS_SET(addr) \ +- (((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS)) | (addr)) ++ (((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS)) | (addr)) + + #define PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR(addr) \ +- ((~((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS))) & (addr)) ++ ((~((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS))) & (addr)) ++ ++#define PCIE_DMA_HOST_ADDR_BIT_POS_F0 (54) ++#define PCIE_DMA_HOST_ADDR_BIT_POS_F1 (53) ++#define PCIE_DMA_HOST_ADDR_BIT_POS_VALID (52) ++ ++#define PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(bit_pos, addr) \ ++ ((addr) + ((1ULL) << (bit_pos))) ++ ++#define PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, addr) \ ++ ((addr) - ((1ULL) << (bit_pos))) + + + enum PS3FWDiagKey { +@@ -55,6 +62,22 @@ + }; + + ++enum PS3BitPos { ++ PS3_BIT_POS_DEFAULT = 0, ++ PS3_BIT_POS_44 = 1, ++ PS3_BIT_POS_45 = 2, ++ PS3_BIT_POS_46 = 3, ++ PS3_BIT_POS_47 = 4, ++ PS3_BIT_POS_48 = 5, ++ PS3_BIT_POS_49 = 6, ++ PS3_BIT_POS_50 = 7, ++ PS3_BIT_POS_51 = 8, ++ PS3_BIT_POS_52 = 9, ++ PS3_BIT_POS_53 = 10, ++ PS3_BIT_POS_54 = 11, ++}; ++ ++ + enum PS3CmdType { + PS3_CMD_INIT_IOC = 0x0, + PS3_CMD_VD_SCSI_IO_RW = 0x1, +@@ -115,7 +138,7 @@ + + #define PS3_HOT_RESET_OFFSET (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG10_ADDR - HIL_REG1_PS3_REGISTER_F_BASEADDR) + +-typedef union HilRegPs3RegisterHotReset{ ++union HilRegPs3RegisterHotReset { + U64 val; + struct{ + +@@ -123,7 +146,32 @@ + U8 reserved0 : 7; + U8 reserved1[7] ; + }reg; +-}HilRegPs3RegisterHotReset_u; ++}; ++ ++ ++#define PS3_ATU_SUPPORT_OFFSET (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG8_ADDR - HIL_REG1_PS3_REGISTER_F_BASEADDR) ++ ++union HilRegPs3RegisterFPs3AtuSupport { ++ U64 val; ++ struct{ ++ ++ U8 bitPos; ++ U8 reserved[7]; ++ } reg; ++}; ++ ++ ++#define PS3_CAN_HARD_RESET_OFFSET (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG9_ADDR - HIL_REG1_PS3_REGISTER_F_BASEADDR) ++ ++union HilRegPs3RegisterFPs3CanHardReset { ++ U64 val; ++ struct{ ++ ++ U8 canHardReset : 1; ++ U8 reserved0 : 7; ++ U8 reserved1[7]; ++ } reg; ++}; + + + typedef enum PS3FWRunState { +@@ -498,4 +546,10 @@ + PS3_IOCTL_STATUS_NEED_RETRY = 7, + }; + ++ ++enum PS3HwVdMaxIOSize { ++ PS3_ENUM_HW_VD_MAX_IO_SIZE_1M = 0, ++ PS3_ENUM_HW_VD_MAX_IO_SIZE_OTHER, ++}; ++ + #endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_dev.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_dev.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_dev.h 2025-06-10 20:13:00.180052062 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_dev.h 2025-06-10 20:13:00.348057923 +0800 +@@ -10,7 +10,6 @@ + #define PS3_SECURITY_CIPHER_NUM_MAX 2 + #define PS3_STABLE_WRITES_MASK (0x1) + +- + struct PS3IocCtrlProp { + U32 enableSnapshot : 1; + U32 enableSoftReset : 1; +@@ -18,7 +17,6 @@ + U32 reserved2; + }; + +- + struct PS3IocCtrlCapable { + U32 supportUnevenSpans : 1; + U32 supportJbodSecure : 1; +@@ -57,41 +55,26 @@ + + + struct PS3IocCtrlInfo { +- + U16 maxVdCount; +- + U16 maxPdCount; +- +- + U32 maxSectors; + struct PS3IocCtrlProp properties; + struct PS3IocCtrlCapable capabilities; +- + U8 scsiTaskAbortTimeout; + U8 scsiTaskResetTimeout; +- + U16 offsetOfVDID; + U8 reserved1[2]; +- + U16 cancelTimeOut; +- +- + U32 vdIOThreshold; +- + U8 iocPerfMode; +- + U8 vdQueueNum; +- + U8 ioTimeOut; +- U8 reserved2[1]; +- ++ U8 hwVdMaxIOSize:4; ++ U8 reserved2:4; + struct PS3ChannelInfo channelInfo; +- + struct PS3QosInfo qosInfo; + U16 isotoneTimeOut; + U8 reserved3[2]; +- +- + U8 reserved4[32]; + + }; +@@ -168,7 +151,8 @@ + struct { + U8 supportNCQ:1; + U8 protect:1; +- U8 reserved:6; ++ U8 isDirectDisable:1; ++ U8 reserved:5; + }; + U8 pdFlags; + }; +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_event.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_event.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_event.h 2025-06-10 20:13:00.180052062 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_event.h 2025-06-10 20:13:00.348057923 +0800 +@@ -32,7 +32,6 @@ + }; + #endif + +- + struct PS3EventDetail { + U32 eventCode; + U32 timestamp; +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_pci.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_pci.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_pci.h 2025-06-10 20:13:00.180052062 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_pci.h 2025-06-10 20:13:00.350057992 +0800 +@@ -17,6 +17,7 @@ + PCI_DEVICE_ID_PS3_RAID_FPGA = 0xabcd, + PCI_DEVICE_ID_STARS_HBA_2120_16i = 0x20a1, + PCI_DEVICE_ID_STARS_IOC_2020_18i = 0x20a2, ++ PCI_DEVICE_ID_STARS_IOC_2213_16i = 0x20a3, + PCI_DEVICE_ID_STARS_ROC_2020_10i = 0x30a2, + PCI_SUBVERDOR_PS3_SWITCH_FPGA = 0x1eb6, + PCI_SUBSYSTEM_PS3_SWITCH_FPGA = 0x6004, +@@ -42,6 +43,8 @@ + return "PCI_DEVICE_ID_STARS_IOC_2020_18i"; + case PCI_DEVICE_ID_STARS_ROC_2020_10i: + return "PCI_DEVICE_ID_STARS_ROC_2020_10i"; ++ case PCI_DEVICE_ID_STARS_IOC_2213_16i: ++ return "PCI_DEVICE_ID_STARS_IOC_2213_16i"; + default: + return "PCI_DEVICE_ID_INVALID"; + } +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_reqframe.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_reqframe.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_reqframe.h 2025-06-10 20:13:00.181052097 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_reqframe.h 2025-06-10 20:13:00.350057992 +0800 +@@ -45,7 +45,7 @@ + enum { + PS3_COMPAT_VER_DEFAULT = 0, + PS3_COMPAT_VER_1 = 1, +- PS3_COMPAT_VER_MAX = 0xffff, ++ PS3_COMPAT_VER_MAX = 0xffff, + }; + + typedef struct PS3Sge { +@@ -230,9 +230,11 @@ + U64 bus; + U8 dev:5; + U8 func:3; +- U8 reserved; ++ U8 domain_support:1; ++ U8 reserved:7; + U16 compatVer; +- U8 reserved1[60]; ++ U32 domain; ++ U8 reserved1[56]; + } PS3DrvInfo_s; + + +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_req_frame_hw.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_req_frame_hw.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/htp_v200/ps3_htp_req_frame_hw.h 2025-06-10 20:13:00.181052097 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/htp_v200/ps3_htp_req_frame_hw.h 2025-06-10 20:13:00.350057992 +0800 +@@ -11,7 +11,6 @@ + #pragma pack(push, 1) + #endif + +- + struct PS3NvmeSglDesc { + U64 addr; + union { +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_cs100/s1861_regs/s1861_global_baseaddr.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_cs100/s1861_regs/s1861_global_baseaddr.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_cs100/s1861_regs/s1861_global_baseaddr.h 2025-06-10 20:13:00.182052132 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_cs100/s1861_regs/s1861_global_baseaddr.h 1970-01-01 08:00:00.000000000 +0800 +@@ -1,8 +0,0 @@ +-#ifndef __S1861_GLOBAL_BASEADDR_REG_H__ +-#define __S1861_GLOBAL_BASEADDR_REG_H__ +-#define HIL_REG0_PS3_REGISTER_F_BASEADDR 0x24000000UL +-#define HIL_REG0_PS3_REGISTER_F_SIZE 0x10000UL +-#define HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR 0x24010000UL +-#define HIL_REG0_PS3_REQUEST_QUEUE_SIZE 0x200UL +-#define HIL_REG0_PS3_REGISTER_S_SIZE 0x1FE00UL +-#endif +\ No newline at end of file +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h 2025-06-10 20:13:00.182052132 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h 1970-01-01 08:00:00.000000000 +0800 +@@ -1,1053 +0,0 @@ +-#ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_H__ +-#define __S1861_HIL_REG0_PS3_REGISTER_F_REG_H__ +-#include "s1861_global_baseaddr.h" +-#ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_MACRO__ +-#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x40) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x48) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x50) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x58) +-#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x100) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x108) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x110) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x118) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x120) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x128) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x130) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x138) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x140) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x200) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x208) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x210) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x218) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x220) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x228) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x230) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x238) +-#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_RST (0x0000000002FAF080) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x240) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x248) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_RST (0x0000000000000001) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x300) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x308) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_RST (0x0000000000001FFF) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x310) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_RST (0x0000000000000FFF) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x318) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x320) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x328) +-#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_RST (0x0000000000000007) +-#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x330) +-#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x338) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_RST (0x000000000000007F) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x340) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x348) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_RST (0x0000000000000400) +-#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x350) +-#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_RST (0x0000000000001000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x358) +-#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_RST (0x0000000000000400) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x360) +-#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x400) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x408) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x410) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x418) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x420) +-#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x440) +-#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x500) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x508) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x510) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x518) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x520) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x600) +-#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x608) +-#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x610) +-#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x618) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x620) +-#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x628) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x630) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x638) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x640) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x648) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x650) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x658) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x660) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x668) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x670) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x678) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x680) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x688) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x690) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x698) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a0) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a8) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b0) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b8) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c0) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c8) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d0) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d8) +-#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x700) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_RST (0xFFFFFFFFFFFFFFFF) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x708) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x710) +-#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_RST (0x0000000000000000) +-#endif +- +-#ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_STRUCT__ +-typedef union HilReg0Ps3RegisterFPs3Doorbell{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 16; +- U64 reserved1 : 48; +- }reg; +-}HilReg0Ps3RegisterFPs3Doorbell_u; +- +-typedef union HilReg0Ps3RegisterFPs3DoorbellIrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3DoorbellIrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3DoorbellIrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3DoorbellIrqMask_u; +- +-typedef union HilReg0Ps3RegisterFPs3IrqControl{ +- +- volatile U64 val; +- struct{ +- +- U64 global : 1; +- U64 fwState : 1; +- U64 tbd : 30; +- U64 reserved3 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3IrqControl_u; +- +-typedef union HilReg0Ps3RegisterFPs3SoftresetKey{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3SoftresetKey : 8; +- U64 reserved1 : 56; +- }reg; +-}HilReg0Ps3RegisterFPs3SoftresetKey_u; +- +-typedef union HilReg0Ps3RegisterFPs3SoftresetState{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3SoftresetState_u; +- +-typedef union HilReg0Ps3RegisterFPs3Softreset{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 8; +- U64 reserved1 : 56; +- }reg; +-}HilReg0Ps3RegisterFPs3Softreset_u; +- +-typedef union HilReg0Ps3RegisterFPs3SoftresetIrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3SoftresetIrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3SoftresetIrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3SoftresetIrqMask_u; +- +-typedef union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow_u; +- +-typedef union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 8; +- U64 reserved1 : 56; +- }reg; +-}HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh_u; +- +-typedef union HilReg0Ps3RegisterFPs3SoftresetTimeCnt{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3SoftresetTimeCnt_u; +- +-typedef union HilReg0Ps3RegisterFPs3SoftresetTimeOutEn{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3SoftresetTimeOutEn_u; +- +-typedef union HilReg0Ps3RegisterFPs3HardresetKey{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3HardresetKey : 8; +- U64 reserved1 : 56; +- }reg; +-}HilReg0Ps3RegisterFPs3HardresetKey_u; +- +-typedef union HilReg0Ps3RegisterFPs3HardresetState{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3HardresetState_u; +- +-typedef union HilReg0Ps3RegisterFPs3Hardreset{ +- +- volatile U64 val; +- struct{ +- +- U64 config : 8; +- U64 reserved1 : 56; +- }reg; +-}HilReg0Ps3RegisterFPs3Hardreset_u; +- +-typedef union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow_u; +- +-typedef union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 8; +- U64 reserved1 : 56; +- }reg; +-}HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh_u; +- +-typedef union HilReg0Ps3RegisterFPs3HardresetTimeCnt{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3HardresetTimeCnt_u; +- +-typedef union HilReg0Ps3RegisterFPs3HardresetTimeOutEn{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3HardresetTimeOutEn_u; +- +-typedef union HilReg0Ps3RegisterFPs3KeyGapCfg{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3KeyGapCfg : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3KeyGapCfg_u; +- +-typedef union HilReg0Ps3RegisterFPs3HardresetIrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3HardresetIrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3HardresetIrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3HardresetIrqMask_u; +- +-typedef union HilReg0Ps3RegisterFPs3SocFwState{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3SocFwState : 8; +- U64 ps3SocFwStartState : 8; +- U64 ps3SocBootState : 8; +- U64 tbd : 8; +- U64 reserved4 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3SocFwState_u; +- +-typedef union HilReg0Ps3RegisterFPs3MaxFwCmd{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3MaxFwCmd : 16; +- U64 reserved1 : 48; +- }reg; +-}HilReg0Ps3RegisterFPs3MaxFwCmd_u; +- +-typedef union HilReg0Ps3RegisterFPs3MaxChainSize{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3MaxChainSize : 32; +- U64 reserved1 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3MaxChainSize_u; +- +-typedef union HilReg0Ps3RegisterFPs3MaxVdInfoSize{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3MaxVdInfoSize : 32; +- U64 reserved1 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3MaxVdInfoSize_u; +- +-typedef union HilReg0Ps3RegisterFPs3MaxNvmePageSize{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3MaxNvmePageSize : 32; +- U64 reserved1 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3MaxNvmePageSize_u; +- +-typedef union HilReg0Ps3RegisterFPs3FeatureSupport{ +- +- volatile U64 val; +- struct{ +- +- U64 multiDevfnSupport : 1; +- U64 dmaBit64Support : 1; +- U64 debugOcmSupport : 1; +- U64 tbd1 : 13; +- U64 fwHaltSupport : 1; +- U64 sglModeSupport : 1; +- U64 dumpCrashSupport : 1; +- U64 shallowSoftRecoverySupport : 1; +- U64 deepSoftRecoverySupport : 1; +- U64 hardRecoverySupport : 1; +- U64 tbd2 : 42; +- }reg; +-}HilReg0Ps3RegisterFPs3FeatureSupport_u; +- +-typedef union HilReg0Ps3RegisterFPs3FirmwareVersion{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3FmVer : 8; +- U64 tbd : 24; +- U64 reserved2 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3FirmwareVersion_u; +- +-typedef union HilReg0Ps3RegisterFPs3MaxReplyque{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3MaxReplyque : 16; +- U64 reserved1 : 48; +- }reg; +-}HilReg0Ps3RegisterFPs3MaxReplyque_u; +- +-typedef union HilReg0Ps3RegisterFPs3HardwareVersion{ +- +- volatile U64 val; +- struct{ +- +- U64 chipId : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3HardwareVersion_u; +- +-typedef union HilReg0Ps3RegisterFPs3MgrQueueDepth{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3MgrQueueDepth : 16; +- U64 reserved1 : 48; +- }reg; +-}HilReg0Ps3RegisterFPs3MgrQueueDepth_u; +- +-typedef union HilReg0Ps3RegisterFPs3CmdQueueDepth{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3CmdQueueDepth : 16; +- U64 reserved1 : 48; +- }reg; +-}HilReg0Ps3RegisterFPs3CmdQueueDepth_u; +- +-typedef union HilReg0Ps3RegisterFPs3TfifoDepth{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3TfifoDepth : 16; +- U64 reserved1 : 48; +- }reg; +-}HilReg0Ps3RegisterFPs3TfifoDepth_u; +- +-typedef union HilReg0Ps3RegisterFPs3MaxSecR1xCmds{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3MaxSecR1xCmds : 16; +- U64 reserved1 : 48; +- }reg; +-}HilReg0Ps3RegisterFPs3MaxSecR1xCmds_u; +- +-typedef union HilReg0Ps3RegisterFPs3HilAdvice2directCnt0{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 32; +- U64 reserved1 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3HilAdvice2directCnt0_u; +- +-typedef union HilReg0Ps3RegisterFPs3HilAdvice2directCnt1{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 32; +- U64 reserved1 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3HilAdvice2directCnt1_u; +- +-typedef union HilReg0Ps3RegisterFPs3HilAdvice2directCnt2{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 32; +- U64 reserved1 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3HilAdvice2directCnt2_u; +- +-typedef union HilReg0Ps3RegisterFPs3HilAdvice2directCnt3{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 32; +- U64 reserved1 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3HilAdvice2directCnt3_u; +- +-typedef union HilReg0Ps3RegisterFPs3HilAdvice2directCntAll{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 32; +- U64 reserved1 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3HilAdvice2directCntAll_u; +- +-typedef union HilReg0Ps3RegisterFPs3IrqStatusRpt{ +- +- volatile U64 val; +- struct{ +- +- U64 doorbell : 1; +- U64 reserved1 : 3; +- U64 softreset : 1; +- U64 reserved3 : 3; +- U64 dumpCtrl : 1; +- U64 reserved5 : 3; +- U64 debug0 : 1; +- U64 reserved7 : 3; +- U64 debug1 : 1; +- U64 reserved9 : 3; +- U64 debug2 : 1; +- U64 reserved11 : 3; +- U64 debug3 : 1; +- U64 reserved13 : 3; +- U64 debug4 : 1; +- U64 reserved15 : 3; +- U64 cmdTrigger : 1; +- U64 reserved17 : 3; +- U64 hardreset : 1; +- U64 reserved19 : 3; +- U64 sessioncmdAddr : 1; +- U64 reserved21 : 23; +- }reg; +-}HilReg0Ps3RegisterFPs3IrqStatusRpt_u; +- +-typedef union HilReg0Ps3RegisterFPs3DumpCtrl{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 16; +- U64 reserved1 : 48; +- }reg; +-}HilReg0Ps3RegisterFPs3DumpCtrl_u; +- +-typedef union HilReg0Ps3RegisterFPs3DumpCtrlIrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3DumpCtrlIrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3DumpCtrlIrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3DumpCtrlIrqMask_u; +- +-typedef union HilReg0Ps3RegisterFPs3DumpStatus{ +- +- volatile U64 val; +- struct{ +- +- U64 dmaFinish : 1; +- U64 hasCrashDump : 1; +- U64 hasFwDump : 1; +- U64 hasBarDump : 1; +- U64 hasAutoDump : 2; +- U64 tbd : 10; +- U64 reserved6 : 48; +- }reg; +-}HilReg0Ps3RegisterFPs3DumpStatus_u; +- +-typedef union HilReg0Ps3RegisterFPs3DumpDataSize{ +- +- volatile U64 val; +- struct{ +- +- U64 ps3DumpDataSize : 32; +- U64 reserved1 : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3DumpDataSize_u; +- +-typedef union HilReg0Ps3RegisterFPs3CmdTrigger{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3CmdTrigger_u; +- +-typedef union HilReg0Ps3RegisterFPs3CmdTriggerIrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3CmdTriggerIrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3CmdTriggerIrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3CmdTriggerIrqMask_u; +- +-typedef union HilReg0Ps3RegisterFPs3SoftresetCounter{ +- +- volatile U64 val; +- struct{ +- +- U64 rpt : 32; +- U64 tbd : 32; +- }reg; +-}HilReg0Ps3RegisterFPs3SoftresetCounter_u; +- +-typedef union HilReg0Ps3RegisterFPs3RegCmdState{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3RegCmdState_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug0{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug0_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug0IrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug0IrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug0IrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug0IrqMask_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug1{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug1_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug1IrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug1IrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug1IrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug1IrqMask_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug2{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug2_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug2IrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug2IrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug2IrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug2IrqMask_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug3{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug3_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug3IrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug3IrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug3IrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug3IrqMask_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug4{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug4_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug4IrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug4IrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug4IrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug4IrqMask_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug5{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug5_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug6{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug6_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug7{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug7_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug8{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug8_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug9{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug9_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug10{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug10_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug11{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug11_u; +- +-typedef union HilReg0Ps3RegisterFPs3Debug12{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3Debug12_u; +- +-typedef union HilReg0Ps3RegisterFPs3SessioncmdAddr{ +- +- volatile U64 val; +- struct{ +- +- U64 cmd : 64; +- }reg; +-}HilReg0Ps3RegisterFPs3SessioncmdAddr_u; +- +-typedef union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear{ +- +- volatile U64 val; +- struct{ +- +- U64 pulse : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear_u; +- +-typedef union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask{ +- +- volatile U64 val; +- struct{ +- +- U64 level : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask_u; +- +-typedef struct HilReg0Ps3RegisterF{ +- +- U64 reserved0[8]; +- HilReg0Ps3RegisterFPs3Doorbell_u ps3Doorbell; +- HilReg0Ps3RegisterFPs3DoorbellIrqClear_u ps3DoorbellIrqClear; +- HilReg0Ps3RegisterFPs3DoorbellIrqMask_u ps3DoorbellIrqMask; +- HilReg0Ps3RegisterFPs3IrqControl_u ps3IrqControl; +- U64 reserved1[20]; +- HilReg0Ps3RegisterFPs3SoftresetKey_u ps3SoftresetKey; +- HilReg0Ps3RegisterFPs3SoftresetState_u ps3SoftresetState; +- HilReg0Ps3RegisterFPs3Softreset_u ps3Softreset; +- HilReg0Ps3RegisterFPs3SoftresetIrqClear_u ps3SoftresetIrqClear; +- HilReg0Ps3RegisterFPs3SoftresetIrqMask_u ps3SoftresetIrqMask; +- HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow_u ps3SoftresetKeyShiftRegLow; +- HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh_u ps3SoftresetKeyShiftRegHigh; +- HilReg0Ps3RegisterFPs3SoftresetTimeCnt_u ps3SoftresetTimeCnt; +- HilReg0Ps3RegisterFPs3SoftresetTimeOutEn_u ps3SoftresetTimeOutEn; +- U64 reserved2[23]; +- HilReg0Ps3RegisterFPs3HardresetKey_u ps3HardresetKey; +- HilReg0Ps3RegisterFPs3HardresetState_u ps3HardresetState; +- HilReg0Ps3RegisterFPs3Hardreset_u ps3Hardreset; +- HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow_u ps3HardresetKeyShiftRegLow; +- HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh_u ps3HardresetKeyShiftRegHigh; +- HilReg0Ps3RegisterFPs3HardresetTimeCnt_u ps3HardresetTimeCnt; +- HilReg0Ps3RegisterFPs3HardresetTimeOutEn_u ps3HardresetTimeOutEn; +- HilReg0Ps3RegisterFPs3KeyGapCfg_u ps3KeyGapCfg; +- HilReg0Ps3RegisterFPs3HardresetIrqClear_u ps3HardresetIrqClear; +- HilReg0Ps3RegisterFPs3HardresetIrqMask_u ps3HardresetIrqMask; +- U64 reserved3[22]; +- HilReg0Ps3RegisterFPs3SocFwState_u ps3SocFwState; +- HilReg0Ps3RegisterFPs3MaxFwCmd_u ps3MaxFwCmd; +- HilReg0Ps3RegisterFPs3MaxChainSize_u ps3MaxChainSize; +- HilReg0Ps3RegisterFPs3MaxVdInfoSize_u ps3MaxVdInfoSize; +- HilReg0Ps3RegisterFPs3MaxNvmePageSize_u ps3MaxNvmePageSize; +- HilReg0Ps3RegisterFPs3FeatureSupport_u ps3FeatureSupport; +- HilReg0Ps3RegisterFPs3FirmwareVersion_u ps3FirmwareVersion; +- HilReg0Ps3RegisterFPs3MaxReplyque_u ps3MaxReplyque; +- HilReg0Ps3RegisterFPs3HardwareVersion_u ps3HardwareVersion; +- HilReg0Ps3RegisterFPs3MgrQueueDepth_u ps3MgrQueueDepth; +- HilReg0Ps3RegisterFPs3CmdQueueDepth_u ps3CmdQueueDepth; +- HilReg0Ps3RegisterFPs3TfifoDepth_u ps3TfifoDepth; +- HilReg0Ps3RegisterFPs3MaxSecR1xCmds_u ps3MaxSecR1xCmds; +- U64 reserved4[19]; +- HilReg0Ps3RegisterFPs3HilAdvice2directCnt0_u ps3HilAdvice2directCnt0; +- HilReg0Ps3RegisterFPs3HilAdvice2directCnt1_u ps3HilAdvice2directCnt1; +- HilReg0Ps3RegisterFPs3HilAdvice2directCnt2_u ps3HilAdvice2directCnt2; +- HilReg0Ps3RegisterFPs3HilAdvice2directCnt3_u ps3HilAdvice2directCnt3; +- HilReg0Ps3RegisterFPs3HilAdvice2directCntAll_u ps3HilAdvice2directCntAll; +- U64 reserved5[3]; +- HilReg0Ps3RegisterFPs3IrqStatusRpt_u ps3IrqStatusRpt; +- U64 reserved6[23]; +- HilReg0Ps3RegisterFPs3DumpCtrl_u ps3DumpCtrl; +- HilReg0Ps3RegisterFPs3DumpCtrlIrqClear_u ps3DumpCtrlIrqClear; +- HilReg0Ps3RegisterFPs3DumpCtrlIrqMask_u ps3DumpCtrlIrqMask; +- HilReg0Ps3RegisterFPs3DumpStatus_u ps3DumpStatus; +- HilReg0Ps3RegisterFPs3DumpDataSize_u ps3DumpDataSize; +- U64 reserved7[27]; +- HilReg0Ps3RegisterFPs3CmdTrigger_u ps3CmdTrigger; +- HilReg0Ps3RegisterFPs3CmdTriggerIrqClear_u ps3CmdTriggerIrqClear; +- HilReg0Ps3RegisterFPs3CmdTriggerIrqMask_u ps3CmdTriggerIrqMask; +- HilReg0Ps3RegisterFPs3SoftresetCounter_u ps3SoftresetCounter; +- HilReg0Ps3RegisterFPs3RegCmdState_u ps3RegCmdState; +- HilReg0Ps3RegisterFPs3Debug0_u ps3Debug0; +- HilReg0Ps3RegisterFPs3Debug0IrqClear_u ps3Debug0IrqClear; +- HilReg0Ps3RegisterFPs3Debug0IrqMask_u ps3Debug0IrqMask; +- HilReg0Ps3RegisterFPs3Debug1_u ps3Debug1; +- HilReg0Ps3RegisterFPs3Debug1IrqClear_u ps3Debug1IrqClear; +- HilReg0Ps3RegisterFPs3Debug1IrqMask_u ps3Debug1IrqMask; +- HilReg0Ps3RegisterFPs3Debug2_u ps3Debug2; +- HilReg0Ps3RegisterFPs3Debug2IrqClear_u ps3Debug2IrqClear; +- HilReg0Ps3RegisterFPs3Debug2IrqMask_u ps3Debug2IrqMask; +- HilReg0Ps3RegisterFPs3Debug3_u ps3Debug3; +- HilReg0Ps3RegisterFPs3Debug3IrqClear_u ps3Debug3IrqClear; +- HilReg0Ps3RegisterFPs3Debug3IrqMask_u ps3Debug3IrqMask; +- HilReg0Ps3RegisterFPs3Debug4_u ps3Debug4; +- HilReg0Ps3RegisterFPs3Debug4IrqClear_u ps3Debug4IrqClear; +- HilReg0Ps3RegisterFPs3Debug4IrqMask_u ps3Debug4IrqMask; +- HilReg0Ps3RegisterFPs3Debug5_u ps3Debug5; +- HilReg0Ps3RegisterFPs3Debug6_u ps3Debug6; +- HilReg0Ps3RegisterFPs3Debug7_u ps3Debug7; +- HilReg0Ps3RegisterFPs3Debug8_u ps3Debug8; +- HilReg0Ps3RegisterFPs3Debug9_u ps3Debug9; +- HilReg0Ps3RegisterFPs3Debug10_u ps3Debug10; +- HilReg0Ps3RegisterFPs3Debug11_u ps3Debug11; +- HilReg0Ps3RegisterFPs3Debug12_u ps3Debug12; +- U64 reserved8[4]; +- HilReg0Ps3RegisterFPs3SessioncmdAddr_u ps3SessioncmdAddr; +- HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear_u ps3SessioncmdAddrIrqClear; +- HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask_u ps3SessioncmdAddrIrqMask; +-}HilReg0Ps3RegisterF_s; +-#endif +-#endif +\ No newline at end of file +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h 2025-06-10 20:13:00.182052132 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h 1970-01-01 08:00:00.000000000 +0800 +@@ -1,38 +0,0 @@ +-#ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_H__ +-#define __S1861_HIL_REG0_PS3_REGISTER_S_REG_H__ +-#include "s1861_global_baseaddr.h" +-#ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_MACRO__ +-#define HIL_REG0_PS3_REGISTER_S_PS3_FUCNTION_LOCK_ADDR (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x0) +-#define HIL_REG0_PS3_REGISTER_S_PS3_FUCNTION_LOCK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_ADDR (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x8) +-#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_RST (0x0000000000000003) +-#endif +- +-#ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_STRUCT__ +-typedef union HilReg0Ps3RegisterSPs3FucntionLock{ +- +- volatile U64 val; +- struct{ +- +- U64 lock : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RegisterSPs3FucntionLock_u; +- +-typedef union HilReg0Ps3RegisterSPs3FunctionLockOwner{ +- +- volatile U64 val; +- struct{ +- +- U64 display : 2; +- U64 reserved1 : 62; +- }reg; +-}HilReg0Ps3RegisterSPs3FunctionLockOwner_u; +- +-typedef struct HilReg0Ps3RegisterS{ +- +- HilReg0Ps3RegisterSPs3FucntionLock_u ps3FucntionLock; +- HilReg0Ps3RegisterSPs3FunctionLockOwner_u ps3FunctionLockOwner; +-}HilReg0Ps3RegisterS_s; +-#endif +-#endif +\ No newline at end of file +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h 2025-06-10 20:13:00.182052132 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h 1970-01-01 08:00:00.000000000 +0800 +@@ -1,420 +0,0 @@ +-#ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_H__ +-#define __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_H__ +-#include "s1861_global_baseaddr.h" +-#ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_MACRO__ +-#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x0) +-#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_RST (0xFFFFFFFFFFFFFFFF) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x8) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x10) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_RST (0x0000000C1FFF0000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x18) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_RST (0x0000000300000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x20) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x28) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x30) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x38) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x40) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x48) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x50) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x58) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x60) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_ADDR(_n) (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x68 + (_n)*0x8) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_ADDR(_n) (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x88 + (_n)*0x8) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xa8) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb0) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_RST (0x0000000000000002) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb8) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc0) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc8) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd0) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd8) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_RST (0x000000000000003F) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe0) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_RST (0x0000000000000001) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe8) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf0) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf8) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x100) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x108) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_RST (0x0000000000000000) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x110) +-#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_RST (0x0000000000000000) +-#endif +- +-#ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_STRUCT__ +-typedef union HilReg0Ps3RequestQueuePs3RequestQueue{ +- +- volatile U64 val; +- struct{ +- +- U64 port : 64; +- }reg; +-}HilReg0Ps3RequestQueuePs3RequestQueue_u; +- +-typedef union HilReg0Ps3RequestQueueFifoErrCnt{ +- +- volatile U64 val; +- struct{ +- +- U64 waddrerr : 32; +- U64 reserved1 : 32; +- }reg; +-}HilReg0Ps3RequestQueueFifoErrCnt_u; +- +-typedef union HilReg0Ps3RequestQueueFifoStatus{ +- +- volatile U64 val; +- struct{ +- +- U64 filled : 16; +- U64 fifoDepth : 16; +- U64 almostfull : 1; +- U64 full : 1; +- U64 almostempty : 1; +- U64 empty : 1; +- U64 reserved6 : 28; +- }reg; +-}HilReg0Ps3RequestQueueFifoStatus_u; +- +-typedef union HilReg0Ps3RequestQueueFifoLevelConfig{ +- +- volatile U64 val; +- struct{ +- +- U64 cfgAempty : 16; +- U64 cfgAfull : 16; +- U64 emptyProtect : 1; +- U64 fullProtect : 1; +- U64 reserved4 : 30; +- }reg; +-}HilReg0Ps3RequestQueueFifoLevelConfig_u; +- +-typedef union HilReg0Ps3RequestQueueFifoRst{ +- +- volatile U64 val; +- struct{ +- +- U64 resetPls : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RequestQueueFifoRst_u; +- +-typedef union HilReg0Ps3RequestQueueFifoIOCnt{ +- +- volatile U64 val; +- struct{ +- +- U64 wr : 32; +- U64 rd : 32; +- }reg; +-}HilReg0Ps3RequestQueueFifoIOCnt_u; +- +-typedef union HilReg0Ps3RequestQueueFifoFlowCnt{ +- +- volatile U64 val; +- struct{ +- +- U64 overflow : 32; +- U64 underflow : 32; +- }reg; +-}HilReg0Ps3RequestQueueFifoFlowCnt_u; +- +-typedef union HilReg0Ps3RequestQueueFifoIntStatus{ +- +- volatile U64 val; +- struct{ +- +- U64 overflowStatus : 1; +- U64 underflowStatus : 1; +- U64 nemptyStatus : 1; +- U64 eccBadStatus : 1; +- U64 reserved4 : 60; +- }reg; +-}HilReg0Ps3RequestQueueFifoIntStatus_u; +- +-typedef union HilReg0Ps3RequestQueueFifoIntSet{ +- +- volatile U64 val; +- struct{ +- +- U64 overflowSet : 1; +- U64 underflowSet : 1; +- U64 nemptySet : 1; +- U64 eccBadSet : 1; +- U64 reserved4 : 60; +- }reg; +-}HilReg0Ps3RequestQueueFifoIntSet_u; +- +-typedef union HilReg0Ps3RequestQueueFifoIntClr{ +- +- volatile U64 val; +- struct{ +- +- U64 overflowClr : 1; +- U64 underflowClr : 1; +- U64 nemptyClr : 1; +- U64 eccBadClr : 1; +- U64 reserved4 : 60; +- }reg; +-}HilReg0Ps3RequestQueueFifoIntClr_u; +- +-typedef union HilReg0Ps3RequestQueueFifoIntMask{ +- +- volatile U64 val; +- struct{ +- +- U64 overflowMask : 1; +- U64 underflowMask : 1; +- U64 nemptyMask : 1; +- U64 eccBadMask : 1; +- U64 reserved4 : 60; +- }reg; +-}HilReg0Ps3RequestQueueFifoIntMask_u; +- +-typedef union HilReg0Ps3RequestQueueFifoCntClr{ +- +- volatile U64 val; +- struct{ +- +- U64 fifowrcntClr : 1; +- U64 fifordcntClr : 1; +- U64 fifoerrcntClr : 1; +- U64 fifoordererrwrcntClr : 1; +- U64 fifoordererrrdcntClr : 1; +- U64 fifobit1errcntClr : 1; +- U64 fifobit2errcntClr : 1; +- U64 reserved7 : 57; +- }reg; +-}HilReg0Ps3RequestQueueFifoCntClr_u; +- +-typedef union HilReg0Ps3RequestQueueFifoOrderError{ +- +- volatile U64 val; +- struct{ +- +- U64 wrcnt : 32; +- U64 rdcnt : 32; +- }reg; +-}HilReg0Ps3RequestQueueFifoOrderError_u; +- +-typedef union HilReg0Ps3RequestQueueFifoDinShift{ +- +- volatile U64 val; +- struct{ +- +- U64 val : 64; +- }reg; +-}HilReg0Ps3RequestQueueFifoDinShift_u; +- +-typedef union HilReg0Ps3RequestQueueFifoDoutShift{ +- +- volatile U64 val; +- struct{ +- +- U64 val : 64; +- }reg; +-}HilReg0Ps3RequestQueueFifoDoutShift_u; +- +-typedef union HilReg0Ps3RequestQueueFifostatusMaxlevel{ +- +- volatile U64 val; +- struct{ +- +- U64 val : 16; +- U64 reserved1 : 48; +- }reg; +-}HilReg0Ps3RequestQueueFifostatusMaxlevel_u; +- +-typedef union HilReg0Ps3RequestQueueFifoInit{ +- +- volatile U64 val; +- struct{ +- +- U64 stat : 2; +- U64 reserved1 : 62; +- }reg; +-}HilReg0Ps3RequestQueueFifoInit_u; +- +-typedef union HilReg0Ps3RequestQueueFifoinitEn{ +- +- volatile U64 val; +- struct{ +- +- U64 start : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RequestQueueFifoinitEn_u; +- +-typedef union HilReg0Ps3RequestQueueFifoinitMax{ +- +- volatile U64 val; +- struct{ +- +- U64 num : 16; +- U64 reserved1 : 48; +- }reg; +-}HilReg0Ps3RequestQueueFifoinitMax_u; +- +-typedef union HilReg0Ps3RequestQueueFifostatusEccCnt{ +- +- volatile U64 val; +- struct{ +- +- U64 bit1Err : 32; +- U64 bit2Err : 32; +- }reg; +-}HilReg0Ps3RequestQueueFifostatusEccCnt_u; +- +-typedef union HilReg0Ps3RequestQueueFifostatusEccAddr{ +- +- volatile U64 val; +- struct{ +- +- U64 errPoint : 64; +- }reg; +-}HilReg0Ps3RequestQueueFifostatusEccAddr_u; +- +-typedef union HilReg0Ps3RequestQueueFifoDecoderOverflow{ +- +- volatile U64 val; +- struct{ +- +- U64 rCmdwordEmpty : 1; +- U64 rPortindexEmpty : 1; +- U64 rCmdbackEmpty : 1; +- U64 wCmdwordEmpty : 1; +- U64 wPortindexEmpty : 1; +- U64 wCmdbackEmpty : 1; +- U64 rCmdwordFull : 1; +- U64 rPortindexFull : 1; +- U64 rCmdbackFull : 1; +- U64 wCmdwordFull : 1; +- U64 wPortindexFull : 1; +- U64 wCmdbackFull : 1; +- U64 reserved12 : 52; +- }reg; +-}HilReg0Ps3RequestQueueFifoDecoderOverflow_u; +- +-typedef union HilReg0Ps3RequestQueueFifoEccBadProject{ +- +- volatile U64 val; +- struct{ +- +- U64 en : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RequestQueueFifoEccBadProject_u; +- +-typedef union HilReg0Ps3RequestQueueFifooverflowWord{ +- +- volatile U64 val; +- struct{ +- +- U64 record : 64; +- }reg; +-}HilReg0Ps3RequestQueueFifooverflowWord_u; +- +-typedef union HilReg0Ps3RequestQueueFifoLevelMonitorCtl{ +- +- volatile U64 val; +- struct{ +- +- U64 low : 16; +- U64 high : 16; +- U64 en : 1; +- U64 reserved3 : 31; +- }reg; +-}HilReg0Ps3RequestQueueFifoLevelMonitorCtl_u; +- +-typedef union HilReg0Ps3RequestQueueFifoLevelMonitorCntClr{ +- +- volatile U64 val; +- struct{ +- +- U64 en : 1; +- U64 reserved1 : 63; +- }reg; +-}HilReg0Ps3RequestQueueFifoLevelMonitorCntClr_u; +- +-typedef union HilReg0Ps3RequestQueueFifoLevelMonitorLow{ +- +- volatile U64 val; +- struct{ +- +- U64 cnt : 64; +- }reg; +-}HilReg0Ps3RequestQueueFifoLevelMonitorLow_u; +- +-typedef union HilReg0Ps3RequestQueueFifoLevelMonitorMid{ +- +- volatile U64 val; +- struct{ +- +- U64 cnt : 64; +- }reg; +-}HilReg0Ps3RequestQueueFifoLevelMonitorMid_u; +- +-typedef union HilReg0Ps3RequestQueueFifoLevelMonitorHigh{ +- +- volatile U64 val; +- struct{ +- +- U64 cnt : 64; +- }reg; +-}HilReg0Ps3RequestQueueFifoLevelMonitorHigh_u; +- +-typedef struct HilReg0Ps3RequestQueue{ +- +- HilReg0Ps3RequestQueuePs3RequestQueue_u ps3RequestQueue; +- HilReg0Ps3RequestQueueFifoErrCnt_u fifoErrCnt; +- HilReg0Ps3RequestQueueFifoStatus_u fifoStatus; +- HilReg0Ps3RequestQueueFifoLevelConfig_u fifoLevelConfig; +- HilReg0Ps3RequestQueueFifoRst_u fifoRst; +- HilReg0Ps3RequestQueueFifoIOCnt_u fifoIOCnt; +- HilReg0Ps3RequestQueueFifoFlowCnt_u fifoFlowCnt; +- HilReg0Ps3RequestQueueFifoIntStatus_u fifoIntStatus; +- HilReg0Ps3RequestQueueFifoIntSet_u fifoIntSet; +- HilReg0Ps3RequestQueueFifoIntClr_u fifoIntClr; +- HilReg0Ps3RequestQueueFifoIntMask_u fifoIntMask; +- HilReg0Ps3RequestQueueFifoCntClr_u fifoCntClr; +- HilReg0Ps3RequestQueueFifoOrderError_u fifoOrderError; +- HilReg0Ps3RequestQueueFifoDinShift_u fifoDinShift[4]; +- HilReg0Ps3RequestQueueFifoDoutShift_u fifoDoutShift[4]; +- HilReg0Ps3RequestQueueFifostatusMaxlevel_u fifoStatusMaxLevel; +- HilReg0Ps3RequestQueueFifoInit_u fifoInit; +- HilReg0Ps3RequestQueueFifoinitEn_u fifoinitEn; +- HilReg0Ps3RequestQueueFifoinitMax_u fifoinitMax; +- HilReg0Ps3RequestQueueFifostatusEccCnt_u fifoStatusEccCnt; +- HilReg0Ps3RequestQueueFifostatusEccAddr_u fifoStatusEccAddr; +- HilReg0Ps3RequestQueueFifoDecoderOverflow_u fifoDecoderOverflow; +- HilReg0Ps3RequestQueueFifoEccBadProject_u fifoEccBadProject; +- HilReg0Ps3RequestQueueFifooverflowWord_u fifoOverFlowWord; +- HilReg0Ps3RequestQueueFifoLevelMonitorCtl_u fifoLevelMonitorCtl; +- HilReg0Ps3RequestQueueFifoLevelMonitorCntClr_u fifoLevelMonitorCntClr; +- HilReg0Ps3RequestQueueFifoLevelMonitorLow_u fifoLevelMonitorLow; +- HilReg0Ps3RequestQueueFifoLevelMonitorMid_u fifoLevelMonitorMid; +- HilReg0Ps3RequestQueueFifoLevelMonitorHigh_u fifoLevelMonitorHigh; +-}HilReg0Ps3RequestQueue_s; +-#endif +-#endif +\ No newline at end of file +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h 1970-01-01 08:00:00.000000000 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h 2025-06-10 20:13:00.367058585 +0800 +@@ -0,0 +1,10 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++ ++#ifndef __S1861_GLOBAL_BASEADDR_REG_H__ ++#define __S1861_GLOBAL_BASEADDR_REG_H__ ++#define HIL_REG0_PS3_REGISTER_F_BASEADDR 0x24000000UL ++#define HIL_REG0_PS3_REGISTER_F_SIZE 0x10000UL ++#define HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR 0x24010000UL ++#define HIL_REG0_PS3_REQUEST_QUEUE_SIZE 0x200UL ++#define HIL_REG0_PS3_REGISTER_S_SIZE 0x1FE00UL ++#endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h 1970-01-01 08:00:00.000000000 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h 2025-06-10 20:13:00.374058830 +0800 +@@ -0,0 +1,1055 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++ ++#ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_H__ ++#define __S1861_HIL_REG0_PS3_REGISTER_F_REG_H__ ++#include "s1861_global_baseaddr.h" ++#ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_MACRO__ ++#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x40) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x48) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x50) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x58) ++#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x100) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x108) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x110) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x118) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x120) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x128) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x130) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x138) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x140) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x200) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x208) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x210) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x218) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x220) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x228) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x230) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x238) ++#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_RST (0x0000000002FAF080) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x240) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x248) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_RST (0x0000000000000001) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x300) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x308) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_RST (0x0000000000001FFF) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x310) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_RST (0x0000000000000FFF) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x318) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x320) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x328) ++#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_RST (0x0000000000000007) ++#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x330) ++#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x338) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_RST (0x000000000000007F) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x340) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x348) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_RST (0x0000000000000400) ++#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x350) ++#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_RST (0x0000000000001000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x358) ++#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_RST (0x0000000000000400) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x360) ++#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x400) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x408) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x410) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x418) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x420) ++#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x440) ++#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x500) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x508) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x510) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x518) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x520) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x600) ++#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x608) ++#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x610) ++#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x618) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x620) ++#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x628) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x630) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x638) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x640) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x648) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x650) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x658) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x660) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x668) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x670) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x678) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x680) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x688) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x690) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x698) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a0) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a8) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b0) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b8) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c0) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c8) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d0) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d8) ++#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x700) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_RST (0xFFFFFFFFFFFFFFFF) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x708) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x710) ++#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_RST (0x0000000000000000) ++#endif ++ ++#ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_STRUCT__ ++union HilReg0Ps3RegisterFPs3Doorbell { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 16; ++ U64 reserved1 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3DoorbellIrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3DoorbellIrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3IrqControl { ++ ++ U64 val; ++ struct{ ++ ++ U64 global : 1; ++ U64 fwState : 1; ++ U64 tbd : 30; ++ U64 reserved3 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SoftresetKey { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3SoftresetKey : 8; ++ U64 reserved1 : 56; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SoftresetState { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Softreset { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 8; ++ U64 reserved1 : 56; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SoftresetIrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SoftresetIrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 8; ++ U64 reserved1 : 56; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SoftresetTimeCnt { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SoftresetTimeOutEn { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HardresetKey { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3HardresetKey : 8; ++ U64 reserved1 : 56; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HardresetState { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Hardreset { ++ ++ U64 val; ++ struct{ ++ ++ U64 config : 8; ++ U64 reserved1 : 56; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 8; ++ U64 reserved1 : 56; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HardresetTimeCnt { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HardresetTimeOutEn { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3KeyGapCfg { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3KeyGapCfg : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HardresetIrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HardresetIrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SocFwState { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3SocFwState : 8; ++ U64 ps3SocFwStartState : 8; ++ U64 ps3SocBootState : 8; ++ U64 tbd : 8; ++ U64 reserved4 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3MaxFwCmd { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3MaxFwCmd : 16; ++ U64 reserved1 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3MaxChainSize { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3MaxChainSize : 32; ++ U64 reserved1 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3MaxVdInfoSize { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3MaxVdInfoSize : 32; ++ U64 reserved1 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3MaxNvmePageSize { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3MaxNvmePageSize : 32; ++ U64 reserved1 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3FeatureSupport { ++ ++ U64 val; ++ struct{ ++ ++ U64 multiDevfnSupport : 1; ++ U64 dmaBit64Support : 1; ++ U64 debugOcmSupport : 1; ++ U64 tbd1 : 13; ++ U64 fwHaltSupport : 1; ++ U64 sglModeSupport : 1; ++ U64 dumpCrashSupport : 1; ++ U64 shallowSoftRecoverySupport : 1; ++ U64 deepSoftRecoverySupport : 1; ++ U64 hardRecoverySupport : 1; ++ U64 tbd2 : 42; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3FirmwareVersion { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3FmVer : 8; ++ U64 tbd : 24; ++ U64 reserved2 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3MaxReplyque { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3MaxReplyque : 16; ++ U64 reserved1 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HardwareVersion { ++ ++ U64 val; ++ struct{ ++ ++ U64 chipId : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3MgrQueueDepth { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3MgrQueueDepth : 16; ++ U64 reserved1 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3CmdQueueDepth { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3CmdQueueDepth : 16; ++ U64 reserved1 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3TfifoDepth { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3TfifoDepth : 16; ++ U64 reserved1 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3MaxSecR1xCmds { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3MaxSecR1xCmds : 16; ++ U64 reserved1 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HilAdvice2directCnt0 { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 32; ++ U64 reserved1 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HilAdvice2directCnt1 { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 32; ++ U64 reserved1 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HilAdvice2directCnt2 { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 32; ++ U64 reserved1 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HilAdvice2directCnt3 { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 32; ++ U64 reserved1 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3HilAdvice2directCntAll { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 32; ++ U64 reserved1 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3IrqStatusRpt { ++ ++ U64 val; ++ struct{ ++ ++ U64 doorbell : 1; ++ U64 reserved1 : 3; ++ U64 softreset : 1; ++ U64 reserved3 : 3; ++ U64 dumpCtrl : 1; ++ U64 reserved5 : 3; ++ U64 debug0 : 1; ++ U64 reserved7 : 3; ++ U64 debug1 : 1; ++ U64 reserved9 : 3; ++ U64 debug2 : 1; ++ U64 reserved11 : 3; ++ U64 debug3 : 1; ++ U64 reserved13 : 3; ++ U64 debug4 : 1; ++ U64 reserved15 : 3; ++ U64 cmdTrigger : 1; ++ U64 reserved17 : 3; ++ U64 hardreset : 1; ++ U64 reserved19 : 3; ++ U64 sessioncmdAddr : 1; ++ U64 reserved21 : 23; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3DumpCtrl { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 16; ++ U64 reserved1 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3DumpCtrlIrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3DumpCtrlIrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3DumpStatus { ++ ++ U64 val; ++ struct{ ++ ++ U64 dmaFinish : 1; ++ U64 hasCrashDump : 1; ++ U64 hasFwDump : 1; ++ U64 hasBarDump : 1; ++ U64 hasAutoDump : 2; ++ U64 tbd : 10; ++ U64 reserved6 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3DumpDataSize { ++ ++ U64 val; ++ struct{ ++ ++ U64 ps3DumpDataSize : 32; ++ U64 reserved1 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3CmdTrigger { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3CmdTriggerIrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3CmdTriggerIrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SoftresetCounter { ++ ++ U64 val; ++ struct{ ++ ++ U64 rpt : 32; ++ U64 tbd : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3RegCmdState { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug0 { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug0IrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug0IrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug1 { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug1IrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug1IrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug2 { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug2IrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug2IrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug3 { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug3IrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug3IrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug4 { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug4IrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug4IrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug5 { ++ ++ U64 val; ++ struct { ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug6 { ++ ++ U64 val; ++ struct { ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug7 { ++ ++ U64 val; ++ struct { ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug8 { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug9 { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug10 { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug11 { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3Debug12 { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SessioncmdAddr { ++ ++ U64 val; ++ struct{ ++ ++ U64 cmd : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear { ++ ++ U64 val; ++ struct{ ++ ++ U64 pulse : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 level : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++struct HilReg0Ps3RegisterF { ++ ++ U64 reserved0[8]; ++ union HilReg0Ps3RegisterFPs3Doorbell ps3Doorbell; ++ union HilReg0Ps3RegisterFPs3DoorbellIrqClear ps3DoorbellIrqClear; ++ union HilReg0Ps3RegisterFPs3DoorbellIrqMask ps3DoorbellIrqMask; ++ union HilReg0Ps3RegisterFPs3IrqControl ps3IrqControl; ++ U64 reserved1[20]; ++ union HilReg0Ps3RegisterFPs3SoftresetKey ps3SoftresetKey; ++ union HilReg0Ps3RegisterFPs3SoftresetState ps3SoftresetState; ++ union HilReg0Ps3RegisterFPs3Softreset ps3Softreset; ++ union HilReg0Ps3RegisterFPs3SoftresetIrqClear ps3SoftresetIrqClear; ++ union HilReg0Ps3RegisterFPs3SoftresetIrqMask ps3SoftresetIrqMask; ++ union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow ps3SoftresetKeyShiftRegLow; ++ union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh ps3SoftresetKeyShiftRegHigh; ++ union HilReg0Ps3RegisterFPs3SoftresetTimeCnt ps3SoftresetTimeCnt; ++ union HilReg0Ps3RegisterFPs3SoftresetTimeOutEn ps3SoftresetTimeOutEn; ++ U64 reserved2[23]; ++ union HilReg0Ps3RegisterFPs3HardresetKey ps3HardresetKey; ++ union HilReg0Ps3RegisterFPs3HardresetState ps3HardresetState; ++ union HilReg0Ps3RegisterFPs3Hardreset ps3Hardreset; ++ union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow ps3HardresetKeyShiftRegLow; ++ union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh ps3HardresetKeyShiftRegHigh; ++ union HilReg0Ps3RegisterFPs3HardresetTimeCnt ps3HardresetTimeCnt; ++ union HilReg0Ps3RegisterFPs3HardresetTimeOutEn ps3HardresetTimeOutEn; ++ union HilReg0Ps3RegisterFPs3KeyGapCfg ps3KeyGapCfg; ++ union HilReg0Ps3RegisterFPs3HardresetIrqClear ps3HardresetIrqClear; ++ union HilReg0Ps3RegisterFPs3HardresetIrqMask ps3HardresetIrqMask; ++ U64 reserved3[22]; ++ union HilReg0Ps3RegisterFPs3SocFwState ps3SocFwState; ++ union HilReg0Ps3RegisterFPs3MaxFwCmd ps3MaxFwCmd; ++ union HilReg0Ps3RegisterFPs3MaxChainSize ps3MaxChainSize; ++ union HilReg0Ps3RegisterFPs3MaxVdInfoSize ps3MaxVdInfoSize; ++ union HilReg0Ps3RegisterFPs3MaxNvmePageSize ps3MaxNvmePageSize; ++ union HilReg0Ps3RegisterFPs3FeatureSupport ps3FeatureSupport; ++ union HilReg0Ps3RegisterFPs3FirmwareVersion ps3FirmwareVersion; ++ union HilReg0Ps3RegisterFPs3MaxReplyque ps3MaxReplyque; ++ union HilReg0Ps3RegisterFPs3HardwareVersion ps3HardwareVersion; ++ union HilReg0Ps3RegisterFPs3MgrQueueDepth ps3MgrQueueDepth; ++ union HilReg0Ps3RegisterFPs3CmdQueueDepth ps3CmdQueueDepth; ++ union HilReg0Ps3RegisterFPs3TfifoDepth ps3TfifoDepth; ++ union HilReg0Ps3RegisterFPs3MaxSecR1xCmds ps3MaxSecR1xCmds; ++ U64 reserved4[19]; ++ union HilReg0Ps3RegisterFPs3HilAdvice2directCnt0 ps3HilAdvice2directCnt0; ++ union HilReg0Ps3RegisterFPs3HilAdvice2directCnt1 ps3HilAdvice2directCnt1; ++ union HilReg0Ps3RegisterFPs3HilAdvice2directCnt2 ps3HilAdvice2directCnt2; ++ union HilReg0Ps3RegisterFPs3HilAdvice2directCnt3 ps3HilAdvice2directCnt3; ++ union HilReg0Ps3RegisterFPs3HilAdvice2directCntAll ps3HilAdvice2directCntAll; ++ U64 reserved5[3]; ++ union HilReg0Ps3RegisterFPs3IrqStatusRpt ps3IrqStatusRpt; ++ U64 reserved6[23]; ++ union HilReg0Ps3RegisterFPs3DumpCtrl ps3DumpCtrl; ++ union HilReg0Ps3RegisterFPs3DumpCtrlIrqClear ps3DumpCtrlIrqClear; ++ union HilReg0Ps3RegisterFPs3DumpCtrlIrqMask ps3DumpCtrlIrqMask; ++ union HilReg0Ps3RegisterFPs3DumpStatus ps3DumpStatus; ++ union HilReg0Ps3RegisterFPs3DumpDataSize ps3DumpDataSize; ++ U64 reserved7[27]; ++ union HilReg0Ps3RegisterFPs3CmdTrigger ps3CmdTrigger; ++ union HilReg0Ps3RegisterFPs3CmdTriggerIrqClear ps3CmdTriggerIrqClear; ++ union HilReg0Ps3RegisterFPs3CmdTriggerIrqMask ps3CmdTriggerIrqMask; ++ union HilReg0Ps3RegisterFPs3SoftresetCounter ps3SoftresetCounter; ++ union HilReg0Ps3RegisterFPs3RegCmdState ps3RegCmdState; ++ union HilReg0Ps3RegisterFPs3Debug0 ps3Debug0; ++ union HilReg0Ps3RegisterFPs3Debug0IrqClear ps3Debug0IrqClear; ++ union HilReg0Ps3RegisterFPs3Debug0IrqMask ps3Debug0IrqMask; ++ union HilReg0Ps3RegisterFPs3Debug1 ps3Debug1; ++ union HilReg0Ps3RegisterFPs3Debug1IrqClear ps3Debug1IrqClear; ++ union HilReg0Ps3RegisterFPs3Debug1IrqMask ps3Debug1IrqMask; ++ union HilReg0Ps3RegisterFPs3Debug2 ps3Debug2; ++ union HilReg0Ps3RegisterFPs3Debug2IrqClear ps3Debug2IrqClear; ++ union HilReg0Ps3RegisterFPs3Debug2IrqMask ps3Debug2IrqMask; ++ union HilReg0Ps3RegisterFPs3Debug3 ps3Debug3; ++ union HilReg0Ps3RegisterFPs3Debug3IrqClear ps3Debug3IrqClear; ++ union HilReg0Ps3RegisterFPs3Debug3IrqMask ps3Debug3IrqMask; ++ union HilReg0Ps3RegisterFPs3Debug4 ps3Debug4; ++ union HilReg0Ps3RegisterFPs3Debug4IrqClear ps3Debug4IrqClear; ++ union HilReg0Ps3RegisterFPs3Debug4IrqMask ps3Debug4IrqMask; ++ union HilReg0Ps3RegisterFPs3Debug5 ps3Debug5; ++ union HilReg0Ps3RegisterFPs3Debug6 ps3Debug6; ++ union HilReg0Ps3RegisterFPs3Debug7 ps3Debug7; ++ union HilReg0Ps3RegisterFPs3Debug8 ps3Debug8; ++ union HilReg0Ps3RegisterFPs3Debug9 ps3Debug9; ++ union HilReg0Ps3RegisterFPs3Debug10 ps3Debug10; ++ union HilReg0Ps3RegisterFPs3Debug11 ps3Debug11; ++ union HilReg0Ps3RegisterFPs3Debug12 ps3Debug12; ++ U64 reserved8[4]; ++ union HilReg0Ps3RegisterFPs3SessioncmdAddr ps3SessioncmdAddr; ++ union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear ps3SessioncmdAddrIrqClear; ++ union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask ps3SessioncmdAddrIrqMask; ++}; ++#endif ++#endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h 1970-01-01 08:00:00.000000000 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h 2025-06-10 20:13:00.380059039 +0800 +@@ -0,0 +1,40 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++ ++#ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_H__ ++#define __S1861_HIL_REG0_PS3_REGISTER_S_REG_H__ ++#include "s1861_global_baseaddr.h" ++#ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_MACRO__ ++#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_ADDR (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x0) ++#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_ADDR (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x8) ++#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_RST (0x0000000000000003) ++#endif ++ ++#ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_STRUCT__ ++union HilReg0Ps3RegisterSPs3FucntionLock { ++ ++ U64 val; ++ struct{ ++ ++ U64 lock : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RegisterSPs3FunctionLockOwner { ++ ++ U64 val; ++ struct{ ++ ++ U64 display : 2; ++ U64 reserved1 : 62; ++ } reg; ++}; ++ ++struct HilReg0Ps3RegisterS { ++ ++ union HilReg0Ps3RegisterSPs3FucntionLock ps3FucntionLock; ++ union HilReg0Ps3RegisterSPs3FunctionLockOwner ps3FunctionLockOwner; ++}; ++#endif ++#endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h 1970-01-01 08:00:00.000000000 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h 2025-06-10 20:13:00.388059318 +0800 +@@ -0,0 +1,422 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++ ++#ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_H__ ++#define __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_H__ ++#include "s1861_global_baseaddr.h" ++#ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_MACRO__ ++#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x0) ++#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_RST (0xFFFFFFFFFFFFFFFF) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x8) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x10) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_RST (0x0000000C1FFF0000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x18) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_RST (0x0000000300000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x20) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x28) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x30) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x38) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x40) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x48) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x50) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x58) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x60) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_ADDR(_n) (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x68 + (_n)*0x8) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_ADDR(_n) (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x88 + (_n)*0x8) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xa8) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb0) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_RST (0x0000000000000002) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb8) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc0) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc8) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd0) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd8) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_RST (0x000000000000003F) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe0) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_RST (0x0000000000000001) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe8) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf0) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf8) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x100) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x108) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_RST (0x0000000000000000) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x110) ++#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_RST (0x0000000000000000) ++#endif ++ ++#ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_STRUCT__ ++union HilReg0Ps3RequestQueuePs3RequestQueue { ++ ++ U64 val; ++ struct{ ++ ++ U64 port : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoErrCnt { ++ ++ U64 val; ++ struct{ ++ ++ U64 waddrerr : 32; ++ U64 reserved1 : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoStatus { ++ ++ U64 val; ++ struct{ ++ ++ U64 filled : 16; ++ U64 fifoDepth : 16; ++ U64 almostfull : 1; ++ U64 full : 1; ++ U64 almostempty : 1; ++ U64 empty : 1; ++ U64 reserved6 : 28; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoLevelConfig { ++ ++ U64 val; ++ struct{ ++ ++ U64 cfgAempty : 16; ++ U64 cfgAfull : 16; ++ U64 emptyProtect : 1; ++ U64 fullProtect : 1; ++ U64 reserved4 : 30; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoRst { ++ ++ U64 val; ++ struct{ ++ ++ U64 resetPls : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoIOCnt { ++ ++ U64 val; ++ struct{ ++ ++ U64 wr : 32; ++ U64 rd : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoFlowCnt { ++ ++ U64 val; ++ struct{ ++ ++ U64 overflow : 32; ++ U64 underflow : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoIntStatus { ++ ++ U64 val; ++ struct{ ++ ++ U64 overflowStatus : 1; ++ U64 underflowStatus : 1; ++ U64 nemptyStatus : 1; ++ U64 eccBadStatus : 1; ++ U64 reserved4 : 60; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoIntSet { ++ ++ U64 val; ++ struct{ ++ ++ U64 overflowSet : 1; ++ U64 underflowSet : 1; ++ U64 nemptySet : 1; ++ U64 eccBadSet : 1; ++ U64 reserved4 : 60; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoIntClr { ++ ++ U64 val; ++ struct{ ++ ++ U64 overflowClr : 1; ++ U64 underflowClr : 1; ++ U64 nemptyClr : 1; ++ U64 eccBadClr : 1; ++ U64 reserved4 : 60; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoIntMask { ++ ++ U64 val; ++ struct{ ++ ++ U64 overflowMask : 1; ++ U64 underflowMask : 1; ++ U64 nemptyMask : 1; ++ U64 eccBadMask : 1; ++ U64 reserved4 : 60; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoCntClr { ++ ++ U64 val; ++ struct{ ++ ++ U64 fifowrcntClr : 1; ++ U64 fifordcntClr : 1; ++ U64 fifoerrcntClr : 1; ++ U64 fifoordererrwrcntClr : 1; ++ U64 fifoordererrrdcntClr : 1; ++ U64 fifobit1errcntClr : 1; ++ U64 fifobit2errcntClr : 1; ++ U64 reserved7 : 57; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoOrderError { ++ ++ U64 val; ++ struct{ ++ ++ U64 wrcnt : 32; ++ U64 rdcnt : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoDinShift { ++ ++ U64 val; ++ struct{ ++ ++ U64 val : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoDoutShift { ++ ++ U64 val; ++ struct{ ++ ++ U64 val : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifostatusMaxlevel { ++ ++ U64 val; ++ struct{ ++ ++ U64 val : 16; ++ U64 reserved1 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoInit { ++ ++ U64 val; ++ struct{ ++ ++ U64 stat : 2; ++ U64 reserved1 : 62; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoinitEn { ++ ++ U64 val; ++ struct{ ++ ++ U64 start : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoinitMax { ++ ++ U64 val; ++ struct{ ++ ++ U64 num : 16; ++ U64 reserved1 : 48; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifostatusEccCnt { ++ ++ U64 val; ++ struct{ ++ ++ U64 bit1Err : 32; ++ U64 bit2Err : 32; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifostatusEccAddr { ++ ++ U64 val; ++ struct{ ++ ++ U64 errPoint : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoDecoderOverflow { ++ ++ U64 val; ++ struct{ ++ ++ U64 rCmdwordEmpty : 1; ++ U64 rPortindexEmpty : 1; ++ U64 rCmdbackEmpty : 1; ++ U64 wCmdwordEmpty : 1; ++ U64 wPortindexEmpty : 1; ++ U64 wCmdbackEmpty : 1; ++ U64 rCmdwordFull : 1; ++ U64 rPortindexFull : 1; ++ U64 rCmdbackFull : 1; ++ U64 wCmdwordFull : 1; ++ U64 wPortindexFull : 1; ++ U64 wCmdbackFull : 1; ++ U64 reserved12 : 52; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoEccBadProject { ++ ++ U64 val; ++ struct{ ++ ++ U64 en : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifooverflowWord { ++ ++ U64 val; ++ struct{ ++ ++ U64 record : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoLevelMonitorCtl { ++ ++ U64 val; ++ struct{ ++ ++ U64 low : 16; ++ U64 high : 16; ++ U64 en : 1; ++ U64 reserved3 : 31; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoLevelMonitorCntClr { ++ ++ U64 val; ++ struct{ ++ ++ U64 en : 1; ++ U64 reserved1 : 63; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoLevelMonitorLow { ++ ++ U64 val; ++ struct{ ++ ++ U64 cnt : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoLevelMonitorMid { ++ ++ U64 val; ++ struct{ ++ ++ U64 cnt : 64; ++ } reg; ++}; ++ ++union HilReg0Ps3RequestQueueFifoLevelMonitorHigh { ++ ++ U64 val; ++ struct{ ++ ++ U64 cnt : 64; ++ } reg; ++}; ++ ++struct HilReg0Ps3RequestQueue { ++ ++ union HilReg0Ps3RequestQueuePs3RequestQueue ps3RequestQueue; ++ union HilReg0Ps3RequestQueueFifoErrCnt fifoErrCnt; ++ union HilReg0Ps3RequestQueueFifoStatus fifoStatus; ++ union HilReg0Ps3RequestQueueFifoLevelConfig fifoLevelConfig; ++ union HilReg0Ps3RequestQueueFifoRst fifoRst; ++ union HilReg0Ps3RequestQueueFifoIOCnt fifoIOCnt; ++ union HilReg0Ps3RequestQueueFifoFlowCnt fifoFlowCnt; ++ union HilReg0Ps3RequestQueueFifoIntStatus fifoIntStatus; ++ union HilReg0Ps3RequestQueueFifoIntSet fifoIntSet; ++ union HilReg0Ps3RequestQueueFifoIntClr fifoIntClr; ++ union HilReg0Ps3RequestQueueFifoIntMask fifoIntMask; ++ union HilReg0Ps3RequestQueueFifoCntClr fifoCntClr; ++ union HilReg0Ps3RequestQueueFifoOrderError fifoOrderError; ++ union HilReg0Ps3RequestQueueFifoDinShift fifoDinShift[4]; ++ union HilReg0Ps3RequestQueueFifoDoutShift fifoDoutShift[4]; ++ union HilReg0Ps3RequestQueueFifostatusMaxlevel fifoStatusMaxLevel; ++ union HilReg0Ps3RequestQueueFifoInit fifoInit; ++ union HilReg0Ps3RequestQueueFifoinitEn fifoinitEn; ++ union HilReg0Ps3RequestQueueFifoinitMax fifoinitMax; ++ union HilReg0Ps3RequestQueueFifostatusEccCnt fifoStatusEccCnt; ++ union HilReg0Ps3RequestQueueFifostatusEccAddr fifoStatusEccAddr; ++ union HilReg0Ps3RequestQueueFifoDecoderOverflow fifoDecoderOverflow; ++ union HilReg0Ps3RequestQueueFifoEccBadProject fifoEccBadProject; ++ union HilReg0Ps3RequestQueueFifooverflowWord fifoOverFlowWord; ++ union HilReg0Ps3RequestQueueFifoLevelMonitorCtl fifoLevelMonitorCtl; ++ union HilReg0Ps3RequestQueueFifoLevelMonitorCntClr fifoLevelMonitorCntClr; ++ union HilReg0Ps3RequestQueueFifoLevelMonitorLow fifoLevelMonitorLow; ++ union HilReg0Ps3RequestQueueFifoLevelMonitorMid fifoLevelMonitorMid; ++ union HilReg0Ps3RequestQueueFifoLevelMonitorHigh fifoLevelMonitorHigh; ++}; ++#endif ++#endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_define.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_define.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_define.h 2025-06-10 20:13:00.183052167 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_define.h 2025-06-10 20:13:00.402059806 +0800 +@@ -241,3 +241,4 @@ + #endif + + #endif ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_evtcode_trans.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_evtcode_trans.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_evtcode_trans.h 2025-06-10 20:13:00.183052167 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_evtcode_trans.h 2025-06-10 20:13:00.403059841 +0800 +@@ -17,6 +17,21 @@ + "MGR_EVT_SAS_EXPANDER_OUT", + "MGR_EVT_SAS_EXPANDER_UPDATE", + "MGR_EVT_SAS_EXPANDER_CHANGE", ++ "MGR_EVT_ENCL_TEMP_NORMAL", ++ "MGR_EVT_ENCL_TEMP_WARNING", ++ "MGR_EVT_ENCL_TEMP_CRITICAL", ++ "MGR_EVT_TOPO_LOOP", ++ "MGR_EVT_LOOP_RESOLUTION", ++ "MGR_EVT_CASCADED_SCAN_SMP_FAIL", ++ "MGR_EVT_ENCL_EXCEED", ++ "MGR_EVT_TRI_MODE_SWITCH", ++ "MGR_EVT_CHANGE_PHY_BY_USER", ++ "MGR_EVT_REV_HIBERNATE_CMD", ++ "MGR_EVT_PHY_CHANGE", ++ "MGR_EVT_INQUIRY_INFO", ++ "MGR_EVT_SAS_SATA_LINK_SPEED_NOMATCH", ++ "MGR_EVT_SAS_SATA_LN_EXCEPTION", ++ "MGR_EVT_SAS_SATA_DRIVER_INFO", + }, + { + "MGR_EVT_PD_COUNT_START", +@@ -101,6 +116,14 @@ + "MGR_EVT_SPOR", + "MGR_EVT_ONF_ABNORMAL", + "MGR_EVT_CTRL_LOADED", ++ "MGR_EVT_CACHE_PROTECTION_CMPT_READY", ++ "MGR_EVT_CACHE_PROTECTION_CMPT_NOT_READY", ++ "MGR_EVT_CACHE_PROTECTION_CMPT_INSTABLE", ++ "MGR_EVT_MAIN_MEDIUM_NOT_AVAILABLE", ++ "MGR_EVT_BACKUP_MEDIUM_NOT_AVAILABLE", ++ "MGR_EVT_MEDIUM_DATA_RECOVER", ++ "MGR_EVT_INIT_FAIL", ++ "MGR_EVT_CTRL_POWER_MODE_CHANGED", + }, + { + "MGR_EVT_PD_ATTR_START", +@@ -259,6 +282,7 @@ + "MGR_EVT_VD_FLUSH_CACHE_DISCARDED_DEL", + "MGR_EVT_VD_FLUSH_CACHE_DESTAGED", + "MGR_EVT_VD_CM_RECOVERY_CRC_FAIL", ++ "MGR_EVT_VD_BGI_COMPLETE_UNCOR", + }, + { + "MGR_EVT_DG_INFO_START", +@@ -324,11 +348,16 @@ + "MGR_EVT_IO_TEST", + "MGR_EVT_IO_SENSE_DATA", + "MGR_EVT_DEVICE_RESET", ++ "MGR_EVT_NVME_DEVICE_RESET", ++ "MGR_EVT_DEVICE_ABNORMAL", ++ "MGR_EVT_IO_SENSE", + }, + { + "MGR_EVT_UKEY_START", + "MGR_EVT_UKEY_INSERT", + "MGR_EVT_UKEY_DEGRADE", ++ "MGR_EVT_RAID_KEY_OVERCURRENT", ++ "MGR_EVT_RAID_KEY_OVERCURRENT_RECOVER", + }, + { + "MGR_EVT_HWR_START", +@@ -363,6 +392,9 @@ + "MGR_EVT_FLASH_GENERAL_ERROR", + "MGR_EVT_FLASH_TIMEOUT", + "MGR_EVT_UPGRADE_SUCCESS", ++ "MGR_EVT_UPGRADE_SYNC_START", ++ "MGR_EVT_UPGRADE_SYNC_FAILED", ++ "MGR_EVT_UPGRADE_SYNC_SUCCESS", + }, + { + "MGR_EVT_TEMP_START", +@@ -416,6 +448,27 @@ + "MGR_EVT_PD_MOVEBACK_NON_UNMAP_PD", + "MGR_EVT_PD_PDM_NON_UNMAP_PD", + "MGR_EVT_PD_RBLD_FAILED", ++ "MGR_EVT_PD_SANITIZE_FAILED", ++ "MGR_EVT_PD_SPIN_FAIL", ++ "MGR_EVT_PD_RBLD_MEDIA_MIX_NOT_SUPPORT", ++ "MGR_EVT_PD_RBLD_DRIVE_MIX_NOT_SUPPORT", ++ "MGR_EVT_PD_PDM_MEDIA_MIX_NOT_SUPPORT", ++ "MGR_EVT_PD_PDM_DRIVE_MIX_NOT_SUPPORT", ++ "MGR_EVT_PD_MOVEBACK_MEDIA_MIX_NOT_SUPPORT", ++ "MGR_EVT_PD_MOVEBACK_DRIVE_MIX_NOT_SUPPORT", ++ "MGR_EVT_NFR_FAILED", ++ "MGR_EVT_PD_RBLD_SMALL_SIZE", ++ "MGR_EVT_PD_MOVEBACK_SMALL_SIZE", ++ "MGR_EVT_NEGO_LOWER_LINK_SPEED", ++ "MGR_EVT_PD_NVME_CMD_ERR", ++ "MGR_EVT_PD_NVME_CMD_TO", ++ "MGR_EVT_PD_NVME_INSERT_FAIL", ++ "MGR_EVT_PCIE_LINK_NEGO_ABNORMAL", ++ "MGR_EVT_PD_ISOLATION", ++ "MGR_EVT_PD_REPAIR_FAILED", ++ "MGR_EVT_PD_PCIE_LINK_UP_WITHOUT_I2C", ++ "MGR_EVT_PD_PCIE_ENUMERATE_FAILED", ++ "MGR_EVT_PD_MISS_LIGHTING", + }, + }; + +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3lib/ps3lib_event.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3lib/ps3lib_event.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3lib/ps3lib_event.h 2025-06-10 20:13:00.183052167 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3lib/ps3lib_event.h 2025-06-10 20:13:00.393059492 +0800 +@@ -2,6 +2,10 @@ + #ifndef __PS3LIB_EVENT_H__ + #define __PS3LIB_EVENT_H__ + ++#if defined(__cplusplus) ++extern "C" { ++#endif ++ + #define PS3LIB_MAX_VD_NAME_BYTES (16) + #define PS3LIB_CTRL_AUTOCONFIG_EVTDATA_SIZE (8) + #define PS3LIB_BBM_ERRTBL_NAME_LEN (6) +@@ -9,7 +13,7 @@ + #define PS3LIB_FGI_MODE_LEN (5) + #define PS3LIB_EVT_LOG_INFO_MAX_SIZE (116) + #define PS3LIB_EXP_EVENT_DATA_COLLECT_MAX_NUM (256) +-#define PS3LIB_MAX_EVENT_REG_CNT (32) ++#define PS3LIB_MAX_EVENT_REG_CNT (128) + + enum { + PS3LIB_EVT_LOG_OLDEST, +@@ -100,7 +104,8 @@ + U16 oldState : 4; + U16 newState : 4; + U16 isEnclPd : 1; +- U16 pad1 : 7; ++ U16 longFault : 1; ++ U16 reason : 6; + U16 arrayId : 8; + U16 rowId : 8; + U16 prevState : 8; +@@ -203,7 +208,7 @@ + + + +- U32 ctrlBootCount; ++ U32 regBootValue; + }Ps3LibCtrlRebootInfo_s; + + typedef struct Ps3LibDgAttrInfo { +@@ -213,7 +218,8 @@ + + typedef struct Ps3LibExpanderInfo { + U8 EnclId; +- U8 reserved[7]; ++ U8 port; ++ U8 reserved[6]; + }Ps3LibExpanderInfo_s; + + typedef struct Ps3LibCfgAttrInfo { +@@ -225,6 +231,11 @@ + S8 cfgName[PS3LIB_CTRL_AUTOCONFIG_EVTDATA_SIZE]; + }Ps3LibCfgAutoConfig_s; + ++struct Ps3LibCtrlPowerMode { ++ U8 mode; ++ U8 rsv[3]; ++}; ++ + typedef struct Ps3LibBgtRebuildInfo { + U16 newPDFlatId; + U16 newEnclosureId; +@@ -311,7 +322,7 @@ + U32 enclosureId:8, + slotId:8, + phyId:8, +- reserved:8; ++ reason:8; + } Ps3LibPhyEvtInfo_s; + + typedef struct Ps3LibVdBbmEvtInfo { +@@ -464,6 +475,21 @@ + U64 path; + } Ps3LibSenseDataEvtInfo_s; + ++struct Ps3LibErrSenseEvtInfo { ++ U16 enclosureId; ++ U16 slotId; ++ U16 phyDiskID; ++ U8 CDBLen; ++ U8 senseLen; ++ U8 cdb[32]; ++ U8 senseData[56]; ++ U8 sk; ++ U8 asc; ++ U8 ascq; ++ U8 resv; ++ U64 path; ++}; ++ + typedef struct Ps3LibPdDownloadInfo { + U32 downloadMode; + S32 isSuccess; +@@ -516,6 +542,21 @@ + U16 invaildCount; + } Ps3LibNvDataInvaildInfo_s; + ++struct Ps3LibSpeedNegoInfo { ++ U16 enclosureId; ++ U16 slotId; ++ S8 isPcie; ++ S8 speed; ++ U8 width; ++ U8 type; ++}; ++ ++struct Ps3LibInitFailInfo { ++ U64 errCode; ++ U8 initFailCnt; ++ U8 pad[3]; ++}; ++ + typedef struct Ps3LibOemInfo { + S8 oemData[PS3LIB_EVT_LOG_INFO_MAX_SIZE]; + } Ps3LibOemInfo_s; +@@ -524,6 +565,82 @@ + S8 bplaneData[PS3LIB_EVT_LOG_INFO_MAX_SIZE]; + } Ps3LibBplaneEvtInfo_s; + ++struct Ps3LibTriModeInfo { ++ U8 connectorId; ++ U8 subConnectorId; ++ U8 curMode; ++ U8 rev; ++}; ++ ++struct Ps3LibPhyChgInfo { ++ U8 portId; ++ U8 phyId; ++ U8 reason; ++ U8 rev; ++}; ++ ++struct Ps3LibPhyInquiryInfo { ++ U32 pdId; ++ U16 slotId; ++ U16 enclosureId; ++ S8 vendor[9]; ++ S8 diskModelNum[41]; ++ S8 diskSerialNum[25]; ++ U8 isEnclPd:1; ++ U8 rev:7; ++ U16 sectorSize; ++ U16 res; ++ U64 physicalSize; ++}; ++ ++struct Ps3LibSmpFailInfo { ++ U8 enclId; ++ U8 function; ++ U8 rev[2]; ++ U32 code; ++}; ++ ++union Ps3LibNvmeEvtInfo { ++ struct { ++ U8 sqe[64]; ++ U64 path; ++ U16 enclosureId; ++ U16 slotId; ++ U16 phyDiskId; ++ U16 sf; ++ U32 cmdSpecfic; ++ U32 type:8; ++ U32 isAdminCmd:1; ++ U32 rsvd:23; ++ }; ++}; ++ ++struct Ps3LibSasSataLinkSpeedMatchInfo { ++ U8 channelId; ++ U8 lPhyId; ++ U8 linkSpeed; ++ U8 pad1; ++ U32 pad2; ++}; ++ ++struct Ps3LibSasSataLNExceptionInfo { ++ U8 channelId; ++ U8 lPhyId; ++ U16 pad1; ++ U32 type; ++ U32 status; ++ U32 pad2; ++}; ++ ++struct Ps3LibSasSataDriverInfo { ++ U8 channelId; ++ U8 lPhyId; ++ U16 pad1; ++ U32 type; ++ U32 status; ++ U32 pad2; ++}; ++ + typedef union Ps3LibReportEvtData + { + Ps3LibPdAttrInfo_s pdInfo; +@@ -570,6 +687,7 @@ + Ps3LibTempEvtInfo_s tempEvtInfo; + Ps3LibDeviceResetEvtInfo_s deviceResetEvtInfo; + Ps3LibSenseDataEvtInfo_s senseDataEvtInfo; ++ struct Ps3LibErrSenseEvtInfo errSenseEvtInfo; + Ps3LibPdDownloadInfo_s pdDldEvtInfo; + Ps3LibSanitizeEvtInfo_s sanitizeInfo; + Ps3LibFormatEvtInfo_s formatInfo; +@@ -577,6 +695,17 @@ + Ps3LibPdPreFailInfo_s pdPrefailInfo; + Ps3LibDiskPFCfgModifyEvtInfo_s diskPFCfgModifyEvtInfo; + Ps3LibNvDataInvaildInfo_s nvDataInvaildInfo; ++ struct Ps3LibCtrlPowerMode powerMode; ++ struct Ps3LibSpeedNegoInfo speedNegoInfo; ++ struct Ps3LibInitFailInfo initFailInfo; ++ struct Ps3LibTriModeInfo triModeInfo; ++ struct Ps3LibPhyChgInfo phyChgInfo; ++ struct Ps3LibPhyInquiryInfo phyInquiryInfo; ++ struct Ps3LibSmpFailInfo smpFailInfo; ++ union Ps3LibNvmeEvtInfo nvmeInfo; ++ struct Ps3LibSasSataLinkSpeedMatchInfo sasSataLinkSpeedNoMatchInfo; ++ struct Ps3LibSasSataLNExceptionInfo sasSataLNExceptionInfo; ++ struct Ps3LibSasSataDriverInfo sasSataDriverInfo; + + + U64 value; +@@ -590,10 +719,10 @@ + U32 seqNum; + Ps3LibEvtLogHeader_s head; + Ps3LibReportEvtData_u evtInfo; +- CtrlId_t ctrlId; +- U8 pad[4]; +- CtrlId_t regCtrlId; ++ U32 ctrlId; ++ U32 regCtrlId; + U32 registerId; ++ U32 pad; + } Ps3LibEvtLogEntry_s; + + typedef struct Ps3LibEvtLogList { +@@ -638,18 +767,24 @@ + (Ps3LibEventDataCollection_s *eventDataCollection, Ps3LibEvtLogEntry_s *event, S32 len, S8 *buff, S32 buffLen); + }Ps3LibEvtPrintFunc_t; + +-Ps3LibEvtPrintFunc_t *ps3libEventPrintFunc(CtrlId_t ctrlId, U8 eventType); ++Ps3LibEvtPrintFunc_t *ps3libEventPrintFunc(U32 ctrlId, U8 eventType); + +-Ps3Errno ps3libCtrlEvtlogPerGet(CtrlId_t ctrlId, Ps3LibEvtPersistInfo_s *evtlogRdInfo); ++Ps3Errno ps3libCtrlEvtlogPerGet(U32 ctrlId, Ps3LibEvtPersistInfo_s *evtlogRdInfo); + +-Ps3Errno ps3libEventLogGet(CtrlId_t ctrlId, U32 sinceSeqNum, Ps3LibEvtLog_s **ppEvtLog); ++Ps3Errno ps3libEventLogGet(U32 ctrlId, U32 sinceSeqNum, Ps3LibEvtLog_s **ppEvtLog); + + void ps3libEventLogDestroy(Ps3LibEvtLog_s *pEvtLog); + + S32 ps3libEvtLevelCompare(U8 levelA, U8 levelB); + +-Ps3Errno ps3libCtrlEventLogsDelete(CtrlId_t ctrlId); ++Ps3Errno ps3libCtrlEventLogsDelete(U32 ctrlId); ++ ++U32 ps3libEventUinqueIdToCtrlId(U32 uniqueId); + +-U16 ps3libEventUinqueIdToCtrlId(U32 uniqueId); ++ ++ ++#if defined(__cplusplus) ++} ++#endif + + #endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_meta.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_meta.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_meta.h 2025-06-10 20:13:00.183052167 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_meta.h 2025-06-10 20:13:00.432060853 +0800 +@@ -27,6 +27,13 @@ + }MicPdState_e; + + ++enum PhyProtoType { ++ PHY_PROTO_SAS_SATA, ++ PHY_PROTO_PCIE, ++ PHY_PROTO_BOTTOM, ++}; ++ ++ + static inline const char *getPdStateName(MicPdState_e pdSate, unsigned char isRaid) + { + static const char *raidPdName[] = { +@@ -89,6 +96,22 @@ + MIC_VD_STATE_DEGRADE + }MicVdState_e; + ++ ++enum InquiryFailReason { ++ INSERT_INQUIRY_ERR = 0, ++ INSERT_TUR_ERR = 1, ++}; ++ ++ ++enum pdUnspReason { ++ PD_UNSP_EXCEED_MAX_SIZE = 0, ++ PD_UNSP_EXCEED_MAX_NUM = 1, ++ PD_UNSP_TUR_ERR, ++ PD_UNSP_SANITIZE, ++ PD_UNSP_INQUIRY_FAIL, ++ PD_UNSP_RESET_FAIL, ++}; ++ + static inline const char *getVdStateName(MicVdState_e vdSate) + { + static const char *vdStateName[] = { +@@ -102,6 +125,16 @@ + return vdStateName[vdSate]; + } + ++static inline const char *triModeNameGet(enum PhyProtoType protoType) ++{ ++ static const char * const protoTypeName[] = { ++ [PHY_PROTO_SAS_SATA] = "SAS/SATA", ++ [PHY_PROTO_PCIE] = "PCIe", ++ [PHY_PROTO_BOTTOM] = "DEFAULT", ++ }; ++ return protoTypeName[protoType]; ++} ++ + + typedef enum RaidLevel { + RAID0 = 0x00, +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_mgr_evt_common.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_mgr_evt_common.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_mgr_evt_common.h 2025-06-10 20:13:00.184052202 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_mgr_evt_common.h 2025-06-10 20:13:00.409060051 +0800 +@@ -13,8 +13,6 @@ + MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1) \ + + MGR_EVT_TYPE_EXTEND_OFFSET * (sn - MGR_EVT_EXTEND_TYPE_START)) + +- +- + #define MGR_EVENT_CODE_2_TYPE(code) (code <= MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1) ? \ + ((code) / MGR_EVT_TYPE_OFFSET + 1) : \ + (code - MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1)) / MGR_EVT_TYPE_EXTEND_OFFSET \ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_mgr_evt_raidhba.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_mgr_evt_raidhba.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_mgr_evt_raidhba.h 2025-06-10 20:13:00.189052376 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_mgr_evt_raidhba.h 2025-06-10 20:13:00.419060399 +0800 +@@ -182,7 +182,52 @@ + MGR_EVT_SAS_EXPANDER_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0x4), +- MGR_EVT_SAS_END = (MGR_EVT_SAS_START+0x5), ++ MGR_EVT_ENCL_TEMP_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_SAS_START + 0x5), ++ MGR_EVT_ENCL_TEMP_WARNING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_SAS_START + 0x6), ++ MGR_EVT_ENCL_TEMP_CRITICAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, ++ MGR_EVT_SAS_START + 0x7), ++ MGR_EVT_TOPO_LOOP = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_SAS_START + 0x8), ++ MGR_EVT_LOOP_RESOLUTION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_SAS_START + 0x9), ++ MGR_EVT_CASCADED_SCAN_SMP_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_FATAL, ++ MGR_EVT_SAS_START + 0xa), ++ MGR_EVT_ENCL_EXCEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_SAS_START + 0xb), ++ MGR_EVT_TRI_MODE_SWITCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_SAS_START + 0xc), ++ MGR_EVT_CHANGE_PHY_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_SAS_START + 0xd), ++ MGR_EVT_REV_HIBERNATE_CMD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_SAS_START + 0xe), ++ MGR_EVT_PHY_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_SAS_START + 0xf), ++ MGR_EVT_INQUIRY_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_SAS_START + 0x10), ++ MGR_EVT_SAS_SATA_LINK_SPEED_NOMATCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_SAS_START + 0x11), ++ MGR_EVT_SAS_SATA_LN_EXCEPTION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_SAS_START + 0x12), ++ MGR_EVT_SAS_SATA_DRIVER_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_SAS_START + 0x13), ++ MGR_EVT_SAS_END = (MGR_EVT_SAS_START+0x14), + }; + + enum MgrEvtPdCountCode +@@ -333,7 +378,7 @@ + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x14), + MGR_EVT_CTRL_PR_CANT_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x15), + MGR_EVT_CTRL_PR_PROP_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, +@@ -425,7 +470,31 @@ + MGR_EVT_CTRL_LOADED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x33), +- MGR_EVT_CTRL_INFO_END = (MGR_EVT_CTRL_INFO_START+0x34), ++ MGR_EVT_CACHE_PROTECTION_CMPT_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_CTRL_INFO_START + 0x34), ++ MGR_EVT_CACHE_PROTECTION_CMPT_NOT_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_CTRL_INFO_START + 0x35), ++ MGR_EVT_CACHE_PROTECTION_CMPT_INSTABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_CTRL_INFO_START + 0x36), ++ MGR_EVT_MAIN_MEDIUM_NOT_AVAILABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, ++ MGR_EVT_CTRL_INFO_START + 0x37), ++ MGR_EVT_BACKUP_MEDIUM_NOT_AVAILABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_CTRL_INFO_START + 0x38), ++ MGR_EVT_MEDIUM_DATA_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_CTRL_INFO_START + 0x39), ++ MGR_EVT_INIT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_CTRL_INFO_START + 0x3a), ++ MGR_EVT_CTRL_POWER_MODE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_CTRL_INFO_START + 0x3b), ++ MGR_EVT_CTRL_INFO_END = (MGR_EVT_CTRL_INFO_START+0x3c), + }; + + enum MgrEvtPdAttrCode +@@ -534,7 +603,7 @@ + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x22), + MGR_EVT_PD_MOVEBACK_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x23), + MGR_EVT_PD_MOVEBACK_ABORT_FOR_REBUILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, +@@ -561,7 +630,7 @@ + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_START + 0x2b), + MGR_EVT_PD_MOVEBACK_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x2c), + MGR_EVT_PD_MOVEBACK_ABORT_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, +@@ -582,13 +651,13 @@ + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_PD_ATTR_START + 0x32), + MGR_EVT_PD_FGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x33), + MGR_EVT_PD_PR_ABORTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_START + 0x34), + MGR_EVT_PD_PR_CORRECTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x35), + MGR_EVT_PD_PR_UNCORRECTABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, +@@ -711,7 +780,7 @@ + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_VD_ATTR_START + 0xc), + MGR_EVT_VD_FGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0xd), + MGR_EVT_VD_BGI_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, +@@ -738,7 +807,7 @@ + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x15), + MGR_EVT_VD_BGI_CORRECTABLE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x16), + MGR_EVT_VD_BGI_UNCORRECTABLE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, +@@ -768,10 +837,10 @@ + PS3_EVT_IS_BATCH_TRUE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x1f), + MGR_EVT_VD_CC_ABORTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x20), + MGR_EVT_VD_CC_CORRECTED_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x21), + MGR_EVT_VD_CC_DOUBLE_MEDIUM_ERRORS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, +@@ -893,7 +962,10 @@ + MGR_EVT_VD_CM_RECOVERY_CRC_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_VD_ATTR_START + 0x49), +- MGR_EVT_VD_ATTR_END = (MGR_EVT_VD_ATTR_START+0x4a), ++ MGR_EVT_VD_BGI_COMPLETE_UNCOR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, ++ MGR_EVT_VD_ATTR_START + 0x4a), ++ MGR_EVT_VD_ATTR_END = (MGR_EVT_VD_ATTR_START+0x4b), + }; + + enum MgrEvtDgInfoCode +@@ -1076,7 +1148,16 @@ + MGR_EVT_DEVICE_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_IO_START + 0x3), +- MGR_EVT_IO_END = (MGR_EVT_IO_START+0x4), ++ MGR_EVT_NVME_DEVICE_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_IO_START + 0x4), ++ MGR_EVT_DEVICE_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_IO_START + 0x5), ++ MGR_EVT_IO_SENSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_IO_START + 0x6), ++ MGR_EVT_IO_END = (MGR_EVT_IO_START+0x7), + }; + + enum MgrEvtUkeyInfoCode +@@ -1088,7 +1169,13 @@ + MGR_EVT_UKEY_DEGRADE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_UKEY_START + 0x2), +- MGR_EVT_UKEY_END = (MGR_EVT_UKEY_START+0x3), ++ MGR_EVT_RAID_KEY_OVERCURRENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_UKEY_START + 0x3), ++ MGR_EVT_RAID_KEY_OVERCURRENT_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_UKEY_START + 0x4), ++ MGR_EVT_UKEY_END = (MGR_EVT_UKEY_START+0x5), + }; + + enum MgrEvtHwRInfoCode +@@ -1178,7 +1265,16 @@ + MGR_EVT_UPGRADE_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_UPGRADE_START + 0xc), +- MGR_EVT_UPGRADE_END = (MGR_EVT_UPGRADE_START+0xd), ++ MGR_EVT_UPGRADE_SYNC_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_UPGRADE_START + 0xd), ++ MGR_EVT_UPGRADE_SYNC_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_UPGRADE_START + 0xe), ++ MGR_EVT_UPGRADE_SYNC_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_UPGRADE_START + 0xf), ++ MGR_EVT_UPGRADE_END = (MGR_EVT_UPGRADE_START+0x10), + }; + + enum MgrEvtTempInfoCode +@@ -1224,7 +1320,7 @@ + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x7), + MGR_EVT_PD_PDM_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x8), + MGR_EVT_PD_PDM_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, +@@ -1233,7 +1329,7 @@ + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0xa), + MGR_EVT_PD_PDM_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, +- PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0xb), + MGR_EVT_PD_PDM_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, +@@ -1331,7 +1427,70 @@ + MGR_EVT_PD_RBLD_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, + PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x2b), +- MGR_EVT_PD_ATTR_EXTEND_END = (MGR_EVT_PD_ATTR_EXTEND_START+0x2c), ++ MGR_EVT_PD_SANITIZE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x2c), ++ MGR_EVT_PD_SPIN_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x2d), ++ MGR_EVT_PD_RBLD_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x2e), ++ MGR_EVT_PD_RBLD_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x2f), ++ MGR_EVT_PD_PDM_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x30), ++ MGR_EVT_PD_PDM_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x31), ++ MGR_EVT_PD_MOVEBACK_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x32), ++ MGR_EVT_PD_MOVEBACK_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x33), ++ MGR_EVT_NFR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x34), ++ MGR_EVT_PD_RBLD_SMALL_SIZE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x35), ++ MGR_EVT_PD_MOVEBACK_SMALL_SIZE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x36), ++ MGR_EVT_NEGO_LOWER_LINK_SPEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x37), ++ MGR_EVT_PD_NVME_CMD_ERR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x38), ++ MGR_EVT_PD_NVME_CMD_TO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x39), ++ MGR_EVT_PD_NVME_INSERT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x3a), ++ MGR_EVT_PCIE_LINK_NEGO_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x3b), ++ MGR_EVT_PD_ISOLATION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x3c), ++ MGR_EVT_PD_REPAIR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x3d), ++ MGR_EVT_PD_PCIE_LINK_UP_WITHOUT_I2C = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x3e), ++ MGR_EVT_PD_PCIE_ENUMERATE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x3f), ++ MGR_EVT_PD_MISS_LIGHTING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_INTERNAL, ++ PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, ++ MGR_EVT_PD_ATTR_EXTEND_START + 0x40), ++ MGR_EVT_PD_ATTR_EXTEND_END = (MGR_EVT_PD_ATTR_EXTEND_START+0x41), + }; + + static inline U32 ps3EvtCodeExtendToNormal(U32 evtcode) +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_nvme_spec.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_nvme_spec.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_nvme_spec.h 2025-06-10 20:13:00.189052376 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_nvme_spec.h 2025-06-10 20:13:00.411060120 +0800 +@@ -681,6 +681,14 @@ + }; + + ++enum NvmeGetFeatSel { ++ NVME_GET_FEA_SEL_CURRENT = 0x0, ++ NVME_GET_FEA_SEL_DEFAULT = 0x1, ++ NVME_GET_FEA_SEL_SAVED = 0x2, ++ NVME_GET_FEA_SEL_SUP_CAPABILITY = 0x3, ++}; ++ ++ + enum NvmeDsmAttribute { + NVME_DSM_ATTR_INTEGRAL_READ = 0x1, + NVME_DSM_ATTR_INTEGRAL_WRITE = 0x2, +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_register_fifo.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_register_fifo.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_register_fifo.h 2025-06-10 20:13:00.189052376 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_register_fifo.h 2025-06-10 20:13:00.429060748 +0800 +@@ -2,27 +2,27 @@ + #ifndef __PS3_REGISTER_FIFO_H__ + #define __PS3_REGISTER_FIFO_H__ + +-#include "hwapi/include_cs100/s1861_regs/s1861_global_baseaddr.h" +-#include "hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h" +-#include "hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h" +-#include "hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h" ++#include "hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h" ++#include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h" ++#include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h" ++#include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h" + + #ifdef __cplusplus + extern "C" { + #endif + typedef union ps3RequestFifo { + U8 reserved0[HIL_REG0_PS3_REQUEST_QUEUE_SIZE]; +- HilReg0Ps3RequestQueue_s request_fifo; ++ struct HilReg0Ps3RequestQueue request_fifo; + } ps3RequestFifo_u; + + typedef union ps3RegShare{ + U8 reserved0[HIL_REG0_PS3_REGISTER_S_SIZE]; +- HilReg0Ps3RegisterS_s share_reg; ++ struct HilReg0Ps3RegisterS share_reg; + } ps3RegShare_u; + + typedef union ps3RegExclusive{ + U8 reserved0[HIL_REG0_PS3_REGISTER_F_SIZE]; +- HilReg0Ps3RegisterF_s Excl_reg; ++ struct HilReg0Ps3RegisterF Excl_reg; + } ps3RegExclusive_u; + + typedef struct Ps3Fifo{ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_types.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_types.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/include/ps3_types.h 2025-06-10 20:13:00.190052411 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/include/ps3_types.h 2025-06-10 20:13:00.425060609 +0800 +@@ -22,7 +22,6 @@ + typedef long Long; + typedef long long S64; + +-typedef U16 CtrlId_t; + typedef S32 Ps3Errno; + typedef U16 DgId_t; + typedef U16 VdId_t; +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/Kconfig ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/Kconfig +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/Kconfig 2025-06-10 20:13:00.190052411 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/Kconfig 2025-06-10 20:13:00.432060853 +0800 +@@ -1,14 +1,8 @@ +-# +-# Kernel configuration file for the ps3stor +-# +-config PS3STOR +- tristate "LD raid Adapter" +- depends on PCI && SCSI +- depends on X86_64 +- select SCSI_SAS_ATTRS +- default m +- help +- This driver supports LD serial RAID controller, which has +- PCI Express Gen4 interface with host and supports SAS/SATA HDD/SSD. +- To compile this driver as a module, choose M here: the module will +- be called ps3stor. ++config SCSI_PS3STOR ++ tristate "Linkdata ps3stor Storage Controller Device Driver" ++ depends on PCI && SCSI ++ select SCSI_SAS_ATTRS ++ select RAID_ATTRS ++ select IRQ_POLL ++ help ++ This driver supports Linkdata HBA & RAID controllers. +\ No newline at end of file +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_base.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_base.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_base.c 2025-06-10 20:13:00.190052411 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_base.c 2025-06-10 20:13:00.462061899 +0800 +@@ -45,6 +45,7 @@ + #include "ps3_pci.h" + #endif + #include "ps3_cli_debug.h" ++#include "ps3_recovery.h" + + const char *const PS3_CHRDEV_NAME = "ps3stor-ioctl"; + #define PS3_PCI_DRIVER_NAME "ps3stor" +@@ -60,7 +61,8 @@ + + #define IS_DMA64 (sizeof(dma_addr_t) == 8) + #define PS3_HOST_UUIID(_dev) (_dev->bus->number << 8 | _dev->devfn) +-static const U8 DMA_MASK_BIT_62 = PCIE_DMA_HOST_ADDR_BIT_POS; ++static const U8 DMA_MASK_BIT_44 = PCIE_DMA_HOST_ADDR_BIT_POS; ++static const U8 DMA_MASK_BIT_52 = PCIE_DMA_HOST_ADDR_BIT_POS_VALID; + static const U8 DMA_MASK_BIT_32 = 32; + static const U32 PS3_REGISTER_BAR_INDEX = 0x02; + +@@ -86,6 +88,7 @@ + {PCI_DEVICE(PCI_VENDOR_ID_STARS, PCI_DEVICE_ID_STARS_ROC_2020_10i)}, + {PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_IOC_2020_18i)}, + {PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_ROC_2020_10i)}, ++ {PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_IOC_2213_16i)}, + {0, 0, 0, 0}}; + + MODULE_DEVICE_TABLE(pci, ps3_pci_table); +@@ -457,6 +460,10 @@ + .map_queues = ps3_map_queues, + #endif + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) ++ .track_queue_depth = 1, ++#endif ++ + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)) + .shost_groups = ps3_host_groups, + #else +@@ -480,7 +487,7 @@ + struct ps3_instance *instance = NULL; + + if (pdev == NULL) { +- LOG_ERROR( "pci_dev is null!\n"); ++ LOG_ERROR("pci_dev is null!\n"); + return NULL; + } + +@@ -488,7 +495,7 @@ + sizeof(struct ps3_instance)); + + if (!host) { +- LOG_ERROR( "pci_id[%u] scsi_host_alloc failed!\n", pdev->dev.id); ++ LOG_ERROR("pci_id[%u] scsi_host_alloc failed!\n", pdev->dev.id); + return NULL; + } + +@@ -502,7 +509,8 @@ + ps3_set_product_model(instance, id->device); + instance->dev_id = id->device; + instance->state_machine.can_hostreset = PS3_FALSE; +- instance->state_machine.is_res_online = PS3_FALSE; ++ instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_CLEAN; ++ instance->is_pcie_err_detected = PS3_FALSE; + mb(); + + if (ps3_instance_add(instance) != PS3_SUCCESS) { +@@ -527,8 +535,11 @@ + S32 ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance) + { + resource_size_t base_addr = 0; ++ S32 ret = PS3_SUCCESS; + +- if (pci_enable_device_mem(pdev)) { ++ ret = pci_enable_device_mem(pdev); ++ INJECT_START(PS3_ERR_IJ_FORCE_PCI_EN_MEM_FAILED, &ret) ++ if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u pci id[%u] pci enable failed\n", + PS3_HOST(instance), pdev->dev.id); + goto l_pci_enable_device_mem_failed; +@@ -537,18 +548,24 @@ + pci_set_master(pdev); + + instance->reg_bar = PS3_REGISTER_BAR_INDEX; +- if (!(pci_resource_flags(pdev, instance->reg_bar) & IORESOURCE_MEM)) { ++ ret = (pci_resource_flags(pdev, instance->reg_bar) & IORESOURCE_MEM); ++ INJECT_START(PS3_ERR_IJ_FORCE_PCI_RES_FLAGS_FAILED, &ret) ++ if (!ret) { + LOG_ERROR("hno:%u Bar %lu isnot IORESOURCE_MEM\n", + PS3_HOST(instance), instance->reg_bar); + goto l_bar_check_failed; + } +- if (pci_request_selected_regions(pdev, 1<reg_bar, +- "PS3 pci regions")) { ++ ret = pci_request_selected_regions(pdev, 1<reg_bar, ++ "PS3 pci regions"); ++ INJECT_START(PS3_ERR_IJ_FORCE_PCI_REQ_REGION_FAILED, &ret) ++ if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u IO memory region busy\n", + PS3_HOST(instance)); + goto l_pci_request_selected_regions_failed; + } +-#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)) ++#if ((defined(RHEL_MAJOR) && \ ++ ((RHEL_MAJOR == 8) || (RHEL_MAJOR == 9 && RHEL_MINOR < 4))) || \ ++ (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE <= KERNEL_VERSION(6, 5, 13))) + pci_enable_pcie_error_reporting(pdev); + #endif + if (instance->ioc_adpter->reg_set) { +@@ -559,8 +576,9 @@ + instance->reg_set = + (Ps3Fifo_s __iomem *)ioremap( + pci_resource_start(pdev, instance->reg_bar), +- PS3_REGISTER_SET_SIZE); ++ PS3_REGISTER_SET_SIZE); + } ++ INJECT_START(PS3_ERR_IJ_FORCE_PCI_IOREMAP_FAILED, &instance->reg_set) + if (instance->reg_set == NULL) { + LOG_ERROR("hno:%u ioremap failed\n", PS3_HOST(instance)); + goto l_ioremap_failed; +@@ -575,7 +593,9 @@ + return PS3_SUCCESS; + l_ioremap_failed: + pci_release_selected_regions(instance->pdev, 1<reg_bar); +-#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)) ++#if ((defined(RHEL_MAJOR) && \ ++ ((RHEL_MAJOR == 8) || (RHEL_MAJOR == 9 && RHEL_MINOR < 4))) || \ ++ (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE <= KERNEL_VERSION(6, 5, 13))) + pci_disable_pcie_error_reporting(pdev); + #endif + l_pci_request_selected_regions_failed: +@@ -594,7 +614,9 @@ + + if (pci_is_enabled(instance->pdev)) { + pci_release_selected_regions(instance->pdev, 1<reg_bar); +-#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)) ++#if ((defined(RHEL_MAJOR) && \ ++ ((RHEL_MAJOR == 8) || (RHEL_MAJOR == 9 && RHEL_MINOR < 4))) || \ ++ (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE <= KERNEL_VERSION(6, 5, 13))) + pci_disable_pcie_error_reporting(instance->pdev); + #endif + pci_disable_device(instance->pdev); +@@ -631,7 +653,8 @@ + + if ((instance->irq_context.valid_msix_vector_count > + instance->irq_context.high_iops_msix_vectors) && +- ps3_tagset_enable_query()) { ++ ps3_tagset_enable_query() && ++ (instance->smp_affinity_enable)) { + host->host_tagset = 1; + host->nr_hw_queues = instance->irq_context.valid_msix_vector_count - + instance->irq_context.high_iops_msix_vectors; +@@ -671,25 +694,33 @@ + return -PS3_FAILED; + } else { + instance->dma_mask = DMA_MASK_BIT_32; +- LOG_INFO("hno:%u 32 dma mask set set\n", ++ LOG_INFO("hno:%u 32 dma mask set\n", + PS3_HOST(instance)); + } + + return PS3_SUCCESS; + } + ++static inline U8 ps3_dma_mask_get(struct ps3_instance *instance) ++{ ++ return ((instance->dma_addr_bit_pos > DMA_MASK_BIT_52) ? DMA_MASK_BIT_52 : DMA_MASK_BIT_44); ++} ++ + static inline S32 __ps3_config_dma_mask(struct ps3_instance *instance) + { +- if (dma_set_mask(&instance->pdev->dev, DMA_BIT_MASK(DMA_MASK_BIT_62)) || ++ U8 dma_mask = 0; ++ ++ dma_mask = ps3_dma_mask_get(instance); ++ if (dma_set_mask(&instance->pdev->dev, DMA_BIT_MASK(dma_mask)) || + dma_set_coherent_mask(&instance->pdev->dev, +- DMA_BIT_MASK(DMA_MASK_BIT_62))) { ++ DMA_BIT_MASK(dma_mask))) { + LOG_ERROR("hno:%u 62 dma mask set failed\n", + PS3_HOST(instance)); + return __ps3_config_dma_mask32(instance); + } else { +- instance->dma_mask = DMA_MASK_BIT_62; +- LOG_INFO("hno:%u 62 dma mask set set\n", +- PS3_HOST(instance)); ++ instance->dma_mask = dma_mask; ++ LOG_INFO("hno:%u dma mask set %u\n", ++ PS3_HOST(instance), instance->dma_mask); + } + return PS3_SUCCESS; + } +@@ -716,6 +747,19 @@ + return ret; + } + ++static inline void ps3_device_busy_threshold_cfg(struct ps3_instance *instance) ++{ ++ S32 device_busy = 0; ++ ++ device_busy = ps3_device_busy_threshold_query(); ++ if (device_busy <= 0 || ++ device_busy > instance->cmd_attr.cur_can_que) { ++ instance->device_busy_threshold = PS3_DEVICE_IO_BUSY_THRESHOLD; ++ } else { ++ instance->device_busy_threshold = device_busy; ++ } ++} ++ + static void ps3_cmd_attr_context_init(struct ps3_instance *instance) + { + U32 cmd_qdepth = ps3_throttle_qdepth_query(); +@@ -734,6 +778,8 @@ + + instance->cmd_attr.vd_io_threshold = 0; + instance->cmd_attr.is_support_direct_cmd = PS3_FALSE; ++ ++ ps3_device_busy_threshold_cfg(instance); + } + + static S32 ps3_init_ioc_prepare(struct ps3_instance *instance) +@@ -747,13 +793,8 @@ + goto l_get_reg_failed; + } + +- if (!ps3_ioc_state_halt_support_get(instance)) { +- goto l_get_reg_failed; +- } +- +- if (!ps3_ioc_recovery_support_get(instance)) { ++ if (!ps3_feature_support_reg_get(instance)) + goto l_get_reg_failed; +- } + + if (ps3_ioc_init_cmd_context_init(instance) != PS3_SUCCESS) { + goto l_ioc_init_failed; +@@ -912,13 +953,14 @@ + const U32 retry_max = 9000; + + ps3_wait_scsi_cmd_done(instance, PS3_TRUE); ++ ps3_wait_mgr_cmd_done(instance, PS3_TRUE); + while (ps3_atomic_read(&instance->reg_op_count) != 0){ + ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); + + if(read_count++ > retry_max){ + LOG_INFO("hno:%u wait reg op over:%d ms, failed\n", + PS3_HOST(instance), read_count*PS3_LOOP_TIME_INTERVAL_20MS); +- ret = -PS3_FAILED; ++ ret = -PS3_FAILED; + goto l_out; + } + } +@@ -948,6 +990,31 @@ + ps3_irq_context_exit(instance); + } + ++static Bool ps3_bit_pos_set(struct ps3_instance *instance) ++{ ++ U8 bit_pos = 0; ++ Bool ret = PS3_TRUE; ++ ++ if (!ps3_ioc_atu_support_retry_read(instance, &bit_pos)) { ++ ret = PS3_FALSE; ++ goto l_out; ++ } ++ if (bit_pos <= PS3_BIT_POS_44) { ++ instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS; ++ goto l_out; ++ } ++ if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_0) ++ instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F0; ++ else ++ instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F1; ++ ++l_out: ++ mb(); /* in order to force CPU ordering */ ++ LOG_WARN("hno:%u set bit pos %u\n", ++ PS3_HOST(instance), instance->dma_addr_bit_pos); ++ return ret; ++} ++ + static S32 ps3_firmware_init(struct pci_dev *pdev, struct ps3_instance *instance) + { + S32 ret; +@@ -955,7 +1022,6 @@ + if (ps3_recovery_context_init(instance) != PS3_SUCCESS) { + goto l_recovery_context_init_failed; + } +- ps3_atomic_set(&instance->pcie_err_handle_ref, 0); + + if (ps3_pci_init(pdev, instance) != PS3_SUCCESS) { + goto l_failed; +@@ -969,19 +1035,22 @@ + INJECT_START(PS3_ERR_IJ_SET_IOC_IN_SECURITY, instance) + if (instance->ioc_adpter->ioc_security_check && + instance->ioc_adpter->ioc_security_check(instance)) { +- LOG_WARN("hno:%u:ioc is in security state\n", PS3_HOST(instance)); +- goto l_failed; ++ LOG_WARN("hno:%u:ioc is in security state\n", PS3_HOST(instance)); ++ goto l_failed; + } + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_READY, instance) + if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != PS3_SUCCESS) { + goto l_failed; + } + atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_READY); +- INJECT_START(PS3_ERR_IJ_RECOVERY_F1_A_READY, instance) ++ INJECT_START(PS3_ERR_IJ_RECOVERY_F1_A_READY, instance); ++ if (!ps3_bit_pos_set(instance)) ++ goto l_failed; + + if (ps3_pci_init_complete(instance) != PS3_SUCCESS) { + goto l_failed; + } ++ instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; + + pci_save_state(pdev); + ret = ps3_init_ioc_prepare(instance); +@@ -990,8 +1059,6 @@ + goto l_failed; + } + +- instance->state_machine.is_res_online = PS3_TRUE; +- mb(); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_INIT, instance) + if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) { + goto l_failed; +@@ -1014,7 +1081,6 @@ + l_recovery_context_init_failed: + ps3_pci_init_complete_exit(instance); + ps3_init_ioc_prepare_exit(instance); +- instance->state_machine.is_res_online = PS3_FALSE; + return -PS3_FAILED; + } + +@@ -1026,29 +1092,31 @@ + return; + } + +-static Bool ps3_get_numa_mem_addr(struct ps3_instance *instance) ++static void ps3_scsi_remove_host(struct ps3_instance *instance) + { +- Bool ret = PS3_FALSE; +- S32 node = -1; +- struct pglist_data *pgdata = NULL; +- U64 end_pfn = 0; +- node = dev_to_node(&instance->pdev->dev); +- if (node < 0) { +- goto l_out; ++ if (ps3_sas_is_support_smp(instance)) { ++ sas_remove_host(instance->host); ++ scsi_remove_host(instance->host); ++ } else { ++ scsi_remove_host(instance->host); + } +- pgdata = NODE_DATA(node); +- if (pgdata == NULL) { +- goto l_out; ++ return; ++} ++ ++static Bool ps3_cmd_context_empty(struct ps3_cmd_context *cmd_context) ++{ ++ Bool ret = PS3_TRUE; ++ U32 i = 0; ++ ++ for (i = 0; i < cmd_context->max_cmd_count; i++) { ++ if (cmd_context->cmd_buf[i]->cmd_state.state == PS3_CMD_STATE_PROCESS) { ++ ret = PS3_FALSE; ++ INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK, &ret) ++ INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_2, cmd_context) ++ break; ++ } + } +- instance->start_pfn = pgdata->node_start_pfn << PAGE_SHIFT; +- end_pfn = pgdata->node_start_pfn + pgdata->node_spanned_pages; +- if (end_pfn != 0) { +- instance->end_pfn = ((end_pfn << PAGE_SHIFT) - 1); +- } +- LOG_INFO("host_no:%u numa:%d, addr range:[0x%llx - 0x%llx]\n", PS3_HOST(instance), +- node, instance->start_pfn, instance->end_pfn); +- ret = PS3_TRUE; +-l_out: ++ + return ret; + } + +@@ -1057,6 +1125,7 @@ + struct ps3_instance *instance = NULL; + ULong flags = 0; + S32 ret; ++ + #ifdef PS3_SUPPORT_INJECT + U32 times = 180000; + #endif +@@ -1066,24 +1135,16 @@ + #endif + LOG_INFO("device[%d] ps3_probe\n", pdev->dev.id); + +- if (ps3_avaliable_func_id_query() >= PS3_FUNC_UNLIMITED) { +- LOG_INFO("Func Unlimited, PCI Device %d:%d:%d probe.\n", ps3_get_pci_bus(pdev), \ +- ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); +- +- printk("Function Unlimited, PCI Device %d:%d:%d probe.\n", ps3_get_pci_bus(pdev), \ +- ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); ++ if (ps3_available_func_id_query() >= PS3_FUNC_UNLIMITED) { ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe start.\n", ps3_get_pci_domain(pdev), ++ ps3_get_pci_bus(pdev), ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + } else { +- if ((U32)ps3_get_pci_function(pdev) != ps3_avaliable_func_id_query()) { +- LOG_INFO("Function %d not avaliable\n", ps3_get_pci_function(pdev)); +- +- printk("Function %d not avaliable\n", ps3_get_pci_function(pdev)); ++ if ((U32)ps3_get_pci_function(pdev) != ps3_available_func_id_query()) { ++ LOG2_WARN("Function %x not available\n", ps3_get_pci_function(pdev)); + goto l_func_id_error; + } else { +- LOG_INFO( "PCI Device %d:%d:%d probe.\n", ps3_get_pci_bus(pdev), \ +- ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); +- +- printk("Function PCI Device %d:%d:%d probe.\n", ps3_get_pci_bus(pdev), \ +- ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe start.\n", ps3_get_pci_domain(pdev), ++ ps3_get_pci_bus(pdev), ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + } + } + +@@ -1094,13 +1155,6 @@ + if (instance == NULL) { + goto l_ps3_instance_create_failed; + } +- if (!ps3_get_numa_mem_addr(instance)) { +- LOG_WARN("host_no:%u get numa mem addr NOK\n", PS3_HOST(instance)); +- } +- ps3_check_and_wait_pci_err_handle(instance); +- if (instance->peer_instance != NULL) { +- ps3_recovery_cancel_work_sync(instance->peer_instance); +- } + + #ifdef PS3_HARDWARE_ASIC + while(id->device == PCI_DEVICE_ID_PS3_RAID_FPGA && +@@ -1196,7 +1250,7 @@ + goto l_vd_info_subscribe_failed; + } + l_event_subscribe_recovered: +- ++ INJECT_START(PS3_ERR_IJ_WAIT_HARDRESET, instance) + instance->is_probe_finish = PS3_TRUE; + mb(); + #if 0 +@@ -1204,7 +1258,10 @@ + goto l_watch_dog_start_failed; + } + #endif ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), ++ ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + ++ ps3_ioc_can_hardreset_set(instance, PS3_IOC_CAN_HARDRESET); + return PS3_SUCCESS; + + l_vd_info_subscribe_failed: +@@ -1219,18 +1276,12 @@ + l_expander_get_failed: + l_scsi_init_failed: + instance->state_machine.is_load = PS3_FALSE; +- instance->state_machine.is_res_online = PS3_FALSE; + mb(); + ps3_device_mgr_data_exit(instance); + l_dev_info_get_failed: + ps3_watchdog_stop(instance); + l_watch_dog_start_failed: +- if (ps3_sas_is_support_smp(instance)) { +- sas_remove_host(instance->host); +- scsi_remove_host(instance->host); +- } else { +- scsi_remove_host(instance->host); +- } ++ ps3_scsi_remove_host(instance); + instance->state_machine.can_hostreset = PS3_FALSE; + mb(); + ps3_dump_work_stop(instance); +@@ -1248,6 +1299,8 @@ + l_ps3_instance_create_failed: + ps3_dma_dump_mapping(pdev); + l_func_id_error: ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe failed.\n", ps3_get_pci_domain(pdev), ++ ps3_get_pci_bus(pdev), ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + return -ENODEV; + } + +@@ -1262,7 +1315,7 @@ + INJECT_START(PS3_ERR_IJ_IOC_NOT_RUNNING, &ioc_state) + if((ioc_state != PS3_FW_STATE_RUNNING) || + (cur_state != PS3_INSTANCE_STATE_OPERATIONAL)){ +- LOG_WARN("hno:%u goto half hard reset , cur_state:%s,IOC state is %s!\n", ++ LOG_WARN("hno:%u goto half hard reset, cur_state:%s,IOC state is %s!\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state),ps3_ioc_state_print(ioc_state)); + ret = -PS3_FAILED; +@@ -1281,12 +1334,18 @@ + LOG_ERROR("device[%d] ps3_shutdown fail\n", pdev->dev.id); + return; + } +- LOG_WARN("device[%d] ps3_shutdown start\n", pdev->dev.id); ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x shutdown start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), ++ ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + +- ps3_check_and_wait_pci_err_handle(instance); + instance->state_machine.is_load = PS3_FALSE; + mb(); ++ INJECT_START(PS3_ERR_IJ_SHUTDOWN_HARDRESET, instance) + ps3_recovery_cancel_work_sync(instance); ++ if (instance->pci_err_handle_state == PS3_DEVICE_ERR_STATE_CLEAN) { ++ while (!ps3_cmd_context_empty(&instance->cmd_context)) ++ ps3_msleep(10000); ++ ++ } + if (instance ->is_half_hard_reset) { + goto l_reset_to_ready; + } +@@ -1313,10 +1372,8 @@ + goto l_reset_to_ready; + } + +- if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { +- while (ps3_atomic_read(&instance->cmd_statistics.cmd_delivering) != 0) { +- ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); +- } ++ if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { ++ ps3_wait_mgr_cmd_done(instance, PS3_TRUE); + if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { + LOG_ERROR("device[%d] web unsubscribe NOK.\n", pdev->dev.id); + goto l_reset_to_ready; +@@ -1348,19 +1405,17 @@ + } + } + +- ps3_check_and_wait_pci_err_handle(instance); + if (ps3_hard_reset_to_ready_with_doorbell(instance) != + PS3_SUCCESS) { + LOG_ERROR("device[%d] hard reset NOK.\n", + PS3_HOST(instance)); + } + l_release_res: +- instance->state_machine.is_res_online = PS3_FALSE; +- mb(); +- ps3_check_and_wait_pci_err_handle(instance); + while(atomic_read(&instance->cmd_statistics.io_outstanding) != 0) { + ps3_msleep(3000); + } ++ INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, instance) ++ + instance->state_machine.can_hostreset = PS3_FALSE; + ps3_check_and_wait_host_reset(instance); + if (!instance ->is_half_hard_reset) { +@@ -1376,7 +1431,8 @@ + + ps3_firmware_exit(instance); + ps3_instance_put(instance); +- LOG_WARN("device[%d] ps3_shutdown end\n", pdev->dev.id); ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x shutdown end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), ++ ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + return; + } + +@@ -1388,10 +1444,26 @@ + return; + } + instance->state_machine.is_load = PS3_FALSE; +- LOG_WARN("device[%d] ps3_remove start\n", pdev->dev.id); +- ps3_check_and_wait_pci_err_handle(instance); ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x remove start\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), ++ ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + mb(); + ps3_recovery_cancel_work_sync(instance); ++ if (instance->pci_err_handle_state == PS3_DEVICE_ERR_STATE_CLEAN) { ++ ps3_dump_exit(instance); ++ while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) ++ ps3_msleep(10); ++ ++ ++ while (!ps3_cmd_context_empty(&instance->cmd_context)) ++ ps3_msleep(10000); ++ ++ ++ ps3_all_reply_fifo_complete(instance); ++ ++ ps3_cmd_force_stop(instance); ++ cancel_delayed_work_sync(&instance->event_context.delay_work->event_work); ++ goto l_release_res; ++ } + if (instance ->is_half_hard_reset) { + goto l_reset_to_ready; + } +@@ -1418,10 +1490,8 @@ + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_WEB_FAIL, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_WEB_FAIL_RESUME, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_WEB_FAIL_RESUME, instance) +- if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { +- while (ps3_atomic_read(&instance->cmd_statistics.cmd_delivering) != 0) { +- ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); +- } ++ if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { ++ ps3_wait_mgr_cmd_done(instance, PS3_TRUE); + if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { + LOG_ERROR("device[%d] web unsubscribe NOK.\n", pdev->dev.id); + goto l_reset_to_ready; +@@ -1436,12 +1506,7 @@ + ps3_inject_clear(); + #endif + +- if (ps3_sas_is_support_smp(instance)) { +- sas_remove_host(instance->host); +- scsi_remove_host(instance->host); +- } else { +- scsi_remove_host(instance->host); +- } ++ ps3_scsi_remove_host(instance); + + instance->is_host_added = PS3_FALSE; + +@@ -1469,7 +1534,6 @@ + goto l_release_res; + } + } +- ps3_check_and_wait_pci_err_handle(instance); + if (ps3_hard_reset_to_ready_with_doorbell(instance) != + PS3_SUCCESS) { + LOG_ERROR("device[%d] hard reset NOK.\n", +@@ -1477,31 +1541,18 @@ + } + + l_release_res: +- instance->state_machine.is_res_online = PS3_FALSE; +- mb(); +- ps3_check_and_wait_pci_err_handle(instance); +- + while(atomic_read(&instance->cmd_statistics.io_outstanding) != 0) { + ps3_msleep(3000); + } + instance->state_machine.can_hostreset = PS3_FALSE; + ps3_check_and_wait_host_reset(instance); ++ INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, instance) + + ps3_instance_state_transfer_to_quit(instance); + ps3_recovery_destory(instance); + + if (instance->is_host_added) { +- ps3_r1x_conflict_queue_clean_all(instance, +- PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); +- +- ps3_qos_waitq_clear_all(instance, PS3_STATUS_HOST_NOT_FOUND); +- +- if (ps3_sas_is_support_smp(instance)) { +- sas_remove_host(instance->host); +- scsi_remove_host(instance->host); +- } else { +- scsi_remove_host(instance->host); +- } ++ ps3_scsi_remove_host(instance); + } + + while(ps3_atomic_read(&instance->host_reset_processing) > 0) { +@@ -1518,12 +1569,9 @@ + + ps3_instance_put(instance); + scsi_host_put(instance->host); +- +- LOG_INFO("device[%d] ready ps3_dma_dump_mapping.\n", +- pdev->dev.id); + ps3_dma_dump_mapping(pdev); +- LOG_WARN("device[%d] ps3_dma_dump_mapping end!\n", +- pdev->dev.id); ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x remove end\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), ++ ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + return; + } + +@@ -1535,29 +1583,27 @@ + struct ps3_cmd *abort_cmd = NULL; + U8 suspend_type = PS3_SUSPEND_TYPE_SLEEP; + ++ (void) state; ++ INJECT_START(PS3_ERR_IJ_WAIT_PM_INSTANCE_NULL, &instance); + if (instance == NULL) { +- LOG_INFO("device[%d] function[%d] ps3_suspend fail\n", pdev->dev.id, \ +- ps3_get_pci_function(pdev)); +- printk("device[%d] function[%d] ps3_suspend fail\n", pdev->dev.id, \ +- ps3_get_pci_function(pdev)); +- ++ LOG2_ERROR("device[%d] %s NOK\n", pdev->dev.id, __func__); + return PS3_SUCCESS; + } + +- LOG_INFO("device[%d] function[%d] ps3_suspend start\n", pdev->dev.id, \ +- ps3_get_pci_function(pdev)); +- printk("device[%d] function[%d] ps3_suspend start\n", pdev->dev.id, \ +- ps3_get_pci_function(pdev)); +- ps3_check_and_wait_pci_err_handle(instance); +- ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), ++ ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); + instance->is_suspend = PS3_TRUE; + mb(); +- instance->state_machine.is_load = PS3_FALSE; +- instance->is_probe_finish = PS3_FALSE; + instance->state_machine.is_suspend = PS3_TRUE; + mb(); ++ INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY_1, instance) + ps3_recovery_cancel_work_sync(instance); ++ if (instance->pci_err_handle_state == PS3_DEVICE_ERR_STATE_CLEAN) { ++ while (!ps3_cmd_context_empty(&instance->cmd_context)) ++ ps3_msleep(10000); + ++ } ++ INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET, instance) + if (instance ->is_half_hard_reset) { + goto l_reset_to_ready; + } +@@ -1584,10 +1630,9 @@ + goto l_reset_to_ready; + } + ++ INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED, instance) + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { +- while (ps3_atomic_read(&instance->cmd_statistics.cmd_delivering) != 0) { +- ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); +- } ++ ps3_wait_mgr_cmd_done(instance, PS3_TRUE); + if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { + LOG_ERROR("device[%d] web unsubscribe NOK.\n", pdev->dev.id); + goto l_reset_to_ready; +@@ -1602,6 +1647,7 @@ + ps3_watchdog_stop(instance); + ps3_recovery_cancel_work_sync(instance); + ++ INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_2, instance) + if (instance ->is_half_hard_reset) { + goto l_release_res; + } +@@ -1615,7 +1661,7 @@ + } + LOG_INFO("event[%d] suspend_type[%d].\n", state.event, suspend_type); + if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_SUSPEND, suspend_type) != PS3_SUCCESS) { +- LOG_ERROR("device[%d] unload failed.\n", pdev->dev.id); ++ LOG_ERROR("device[%d] unload NOK.\n", pdev->dev.id); + if (ps3_hard_reset_to_ready_with_doorbell(instance) != + PS3_SUCCESS) { + LOG_ERROR("device[%d] hard reset NOK.\n", +@@ -1625,6 +1671,7 @@ + + goto l_release_res; + l_reset_to_ready: ++ INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_1, instance) + if (!instance ->is_half_hard_reset) { + instance->ioc_adpter->irq_disable(instance); + ps3_irqs_sync(instance); +@@ -1637,7 +1684,6 @@ + if (instance ->is_half_hard_reset) { + goto l_release_res; + } +- ps3_check_and_wait_pci_err_handle(instance); + + if (ps3_hard_reset_to_ready_with_doorbell(instance) != + PS3_SUCCESS) { +@@ -1667,14 +1713,16 @@ + #endif + scsi_block_requests(instance->host); + l_release_res: ++ INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, instance) ++ + pci_set_drvdata(instance->pdev, instance); + pci_save_state(pdev); + instance ->is_half_hard_reset = PS3_FALSE; ++ ps3_base_free_resources(instance); ++ ps3_instance_put(instance); + +- LOG_INFO("device[%d] function[%d] ps3_suspend end\n", pdev->dev.id, \ +- ps3_get_pci_function(pdev)); +- printk("device[%d] function[%d] ps3_suspend end\n", pdev->dev.id, \ +- ps3_get_pci_function(pdev)); ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), ++ ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); + instance->is_suspend = PS3_FALSE; + return PS3_SUCCESS; + } +@@ -1684,48 +1732,42 @@ + S32 ret = PS3_SUCCESS; + struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); + ++ INJECT_START(PS3_ERR_IJ_WAIT_PM_INSTANCE_NULL, &instance); + if (instance == NULL) { +- LOG_INFO("device[%d] ps3_resume fail\n", pdev->dev.id); +- printk("device[%d] ps3_resume fail\n", pdev->dev.id); ++ LOG2_ERROR("device[%d] %s NOK\n", pdev->dev.id, __func__); + return PS3_SUCCESS; + } + +- LOG_INFO("device[%d] ps3_resume start\n", pdev->dev.id); +- printk("device[%d] ps3_resume start\n", pdev->dev.id); +- ps3_check_and_wait_pci_err_handle(instance); ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), ++ ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); + instance->is_resume = PS3_TRUE; + mb(); + ps3_recovery_cancel_work_sync(instance); + pci_restore_state(pdev); + +- if (ps3_avaliable_func_id_query() >= PS3_FUNC_UNLIMITED) { +- LOG_INFO("Function Unlimited, PCI Device %d:%d:%d probe.\n", ps3_get_pci_bus(pdev), \ +- ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); +- +- printk("Function Unlimited, PCI Device %d:%d:%d probe.\n", ps3_get_pci_bus(pdev), \ +- ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); +- } else { +- if ((U32)ps3_get_pci_function(pdev) != ps3_avaliable_func_id_query()) { +- LOG_INFO("Function %d not avaliable\n", ps3_get_pci_function(pdev)); +- +- printk("Function %d not avaliable\n", ps3_get_pci_function(pdev)); +- goto l_out; +- } else { +- LOG_INFO( "PCI Device %d:%d:%d probe.\n", ps3_get_pci_bus(pdev), \ +- ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); ++ instance->pdev = pdev; ++ if (ps3_instance_add(instance) != PS3_SUCCESS) ++ goto l_out; + +- printk("Function PCI Device %d:%d:%d probe.\n", ps3_get_pci_bus(pdev), \ +- ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); +- } ++ INJECT_START(PS3_ERR_IJ_WAIT_RESUME_FUNCID_INVALID, instance); ++ if (ps3_available_func_id_query() < PS3_FUNC_UNLIMITED && ++ (U32)ps3_get_pci_function(pdev) != ps3_available_func_id_query()) { ++ LOG2_WARN("Function %d not available\n", ps3_get_pci_function(pdev)); ++ goto l_out; + } + +- instance->pdev = pdev; ++ ret = ps3_base_init_resources(instance); ++ if (ret != PS3_SUCCESS) { ++ LOG_ERROR("hno:%u base init resources NOK, ret: %d\n", PS3_HOST(instance), ret); ++ goto l_out; ++ } ++ instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; + + if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != PS3_SUCCESS) { + goto l_out; + } + +- atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_READY); ++ ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_READY); + + ps3_all_reply_fifo_init(instance); + +@@ -1733,7 +1775,7 @@ + goto l_out; + } + +- atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_PRE_OPERATIONAL); ++ ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_PRE_OPERATIONAL); + + instance->ioc_adpter->irq_enable(instance); + +@@ -1743,16 +1785,17 @@ + scsi_unblock_requests(instance->host); + + ps3_dump_ctrl_set_int_ready(instance); ++ INJECT_START(PS3_ERR_IJ_WAIT_RESUME_WAIT_RECOVERY, instance); + + ret = ps3_watchdog_start(instance); + if (ret != PS3_SUCCESS) { +- goto l_watch_dog_start_failed; ++ goto l_out; + } + + instance->event_req_info.eventTypeMapProcResult = instance->event_req_info.eventTypeMap; + ret = ps3_event_subscribe(instance); + if (ret == -PS3_FAILED) { +- goto l_event_subscribe_failed; ++ goto l_out; + } else if (ret == -PS3_RECOVERED) { + LOG_INFO("device[%d] skip event/vd info subscribe due to recovery during probe\n", + pdev->dev.id); +@@ -1761,15 +1804,15 @@ + + ret = ps3_dev_mgr_vd_info_subscribe(instance); + if (ret != PS3_SUCCESS && ret != -PS3_RECOVERED) { +- LOG_INFO("device[%d] vd info subscribe failed, ret: %d\n", ++ LOG_INFO("device[%d] vd info subscribe NOK, ret: %d\n", + pdev->dev.id, ret); +- goto l_vd_info_subscribe_failed; ++ goto l_out; + } + + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { + ret = ps3_web_subscribe(instance); + if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) { +- goto l_vd_info_subscribe_failed; ++ goto l_out; + } + } + +@@ -1777,41 +1820,22 @@ + instance->state_machine.is_suspend = PS3_FALSE; + instance->is_probe_finish = PS3_TRUE; + instance->is_resume = PS3_FALSE; +- LOG_WARN("device[%d] function[%d] ps3_resume end\n", pdev->dev.id, \ +- ps3_get_pci_function(pdev)); +- printk("device[%d] function[%d] ps3_resume end\n", pdev->dev.id, \ +- ps3_get_pci_function(pdev)); ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), ++ ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); + ++ ps3_ioc_can_hardreset_set(instance, PS3_IOC_CAN_HARDRESET); + return PS3_SUCCESS; +-l_vd_info_subscribe_failed: +-l_event_subscribe_failed: +- ps3_dev_mgr_vd_info_unsubscribe(instance); +- ps3_event_unsubscribe(instance); +-l_watch_dog_start_failed: +- ps3_watchdog_stop(instance); +- ps3_dump_work_stop(instance); + l_out: + instance->state_machine.is_suspend = PS3_FALSE; +- instance->is_probe_failed = PS3_TRUE; + instance->is_resume = PS3_FALSE; +- scsi_host_put(instance->host); ++ instance->state_machine.is_load = PS3_TRUE; ++ ps3_instance_state_transfer_to_dead(instance); ++ scsi_unblock_requests(instance->host); + ps3_dma_dump_mapping(pdev); +- pci_disable_device(pdev); +- LOG_INFO("device[%d] function[%d] ps3_resume fail end\n", pdev->dev.id, \ +- ps3_get_pci_function(pdev)); +- printk("device[%d] function[%d] ps3_resume fail end\n", pdev->dev.id, \ +- ps3_get_pci_function(pdev)); ++ LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s NOK.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), ++ ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); + return -ENODEV; + } +- +-int ps3_cli_suspend(struct pci_dev *pdev, pm_message_t state) { +- return ps3_suspend(pdev, state); +-} +- +-int ps3_cli_resume(struct pci_dev *pdev) { +- return ps3_resume(pdev); +-} +- + #endif + + static ssize_t version_show(struct device_driver *dd, char *buf) +@@ -1864,7 +1888,7 @@ + static int __init ps3stor_init(void) + { + int ret = PS3_SUCCESS; +- printk(KERN_WARNING "ps3stor driver init start, version[%s], commit_id[%s]," ++ LOG2_WARN("ps3stor driver init start, version[%s], commit_id[%s], " + "build_time[%s], toolchain_id[%s]\n", + PS3_DRV_VERSION, PS3_DRV_COMMIT_ID, + PS3_DRV_BUILD_TIME, PS3_DRV_TOOLCHAIN_ID); +@@ -1875,7 +1899,7 @@ + printk(KERN_ERR "ps3stor log init fail\n"); + goto l_debug_init_failed; + } +- ++ ps3_host_info_get(); + ps3cmd_init(); + ps3_mgmt_info_init(); + +@@ -1936,6 +1960,7 @@ + l_sas_transport_failed: + ps3_debug_exit(); + ps3cmd_exit(); ++ ps3_mgmt_exit(); + l_debug_init_failed: + return ret; + } +@@ -1951,12 +1976,12 @@ + ps3_sas_release_transport(); + ps3_debug_exit(); + ps3cmd_exit(); ++ ps3_mgmt_exit(); + return; + } + + MODULE_INFO(private_version, PS3_PRIVATE_VERSION); + MODULE_INFO(product_support, PS3_DRV_PRODUCT_SUPPORT); +-MODULE_INFO(arch, PS3_DRV_ARCH); + MODULE_INFO(build_time, PS3_DRV_BUILD_TIME); + MODULE_INFO(toolchain_id, PS3_DRV_TOOLCHAIN_ID); + MODULE_INFO(commit_id, PS3_DRV_COMMIT_ID); +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_cli.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_cli.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_cli.c 2025-06-10 20:13:00.190052411 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_cli.c 2025-06-10 20:13:00.437061027 +0800 +@@ -10,10 +10,12 @@ + #include + #include + #include ++#include + #include "ps3_cli.h" ++#include "ps3_instance_manager.h" + +-#define PS3_CLI_MINOR 26 +- ++#define PS3_CLI_STATIC_MINOR 26 ++#define PS3_CLI_DYNAMIC_MINOR MISC_DYNAMIC_MINOR + #define PS3_CLI_HASH_LEN 256 + + struct ps3_cli_cmd_s { +@@ -24,7 +26,7 @@ + }; + + static int misc_registered; +-static int dev_opened; ++static ps3_atomic32 dev_opened; + static int cmd_ready; + static char ps3_cli_input[PS3_CLI_INPUT_LEN]; + static char ps3_cli_output[PS3_CLI_OUTLINE_LEN]; +@@ -41,6 +43,20 @@ + #define __pl() + #endif + ++static inline S32 ps3_cli_minor_get(void) ++{ ++ if (strstr(ps3_host_release_get(), "5.10.134-16.2.an8")) ++ return PS3_CLI_DYNAMIC_MINOR; ++ ++#if ((defined(RHEL_MAJOR) && \ ++ ((RHEL_MAJOR < 9) || (RHEL_MAJOR == 9 && RHEL_MINOR < 3))) || \ ++ (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0))) ++ return PS3_CLI_STATIC_MINOR; ++#else ++ return PS3_CLI_DYNAMIC_MINOR; ++#endif ++} ++ + static ssize_t ps3_cli_write(struct file *fp, const char __user *buffer, + size_t nbytes, loff_t *ppos) + { +@@ -227,7 +243,7 @@ + { + (void)ip; + (void)fp; +- if (!__sync_bool_compare_and_swap(&dev_opened, 0, 1)) { ++ if (atomic_cmpxchg(&dev_opened, 0, 1) == 1) { + pr_err("/dev/ps3stor_cli has already been opened\n"); + return -EBUSY; + } +@@ -239,7 +255,7 @@ + { + (void)ip; + (void)fp; +- dev_opened = 0; ++ ps3_atomic_set(&dev_opened, 0); + return 0; + } + +@@ -255,7 +271,7 @@ + }; + + static struct miscdevice ps3_cli_device = { +- .minor = PS3_CLI_MINOR, ++ .minor = PS3_CLI_STATIC_MINOR, + .name = "ps3stor_cli", + .fops = &ps3_cli_fops, + }; +@@ -295,8 +311,10 @@ + if (misc_registered != 0) + return -EBUSY; + ++ ps3_atomic_set(&dev_opened, 0); + mutex_init(&ps3_cli_mutex); + ++ ps3_cli_device.minor = ps3_cli_minor_get(); + err = misc_register(&ps3_cli_device); + if (err) { + pr_warn("Couldn't initialize miscdevice /dev/ps3stor_cli.\n"); +@@ -316,3 +334,4 @@ + misc_registered = 0; + mutex_destroy(&ps3_cli_mutex); + } ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_cli_debug.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_cli_debug.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_cli_debug.c 2025-06-10 20:13:00.199052725 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_cli_debug.c 2025-06-10 20:13:00.448061411 +0800 +@@ -64,7 +64,6 @@ + static void ps3_no_wait_cli_cmd(int argc, char *argv[]); + static void ps3_cli_qos_info(int argc, char *argv[]); + static void ps3_cli_special_log(int argc, char *argv[]); +-static void ps3_cli_r1x_delay(int argc, char *argv[]); + + static Bool ps3_cli_wait_flag = PS3_FALSE; + #ifdef PS3_SUPPORT_INJECT +@@ -83,11 +82,6 @@ + static void ps3_show_all_inject(int argc, char *argv[]); + static void ps3_clear_hit_cmd(int argc, char *argv[]); + #endif +-#ifdef CONFIG_PM +-static void ps3_suspend_cb(int argc, char *argv[]); +-static void ps3_resume_cb(int argc, char *argv[]); +-#endif +- + struct ps3_cli_debug_cmd { + ps3_cli_func_t func; + const char *func_name; +@@ -158,8 +152,6 @@ + "hardreset_cnt_show host_no xxx(host number)"}, + {ps3_cli_ramfs_test_set, "ramfs_test_set", + "set or clear filesystem type to ramfs: (0: clear, 1: set)"}, +- {ps3_cli_r1x_delay, "r1x_delay", +- "set r1x send interval delay: (x)ms"}, + {ps3_cli_err_inject_active, "err_inject", + "err_inject err_type count"}, + {ps3_cli_err_inject_clear, "cli_err_clear", +@@ -197,12 +189,6 @@ + {ps3_clear_hit_cmd, "ps3_clear_hit_cmd", + "ps3_clear_hit_cmd"}, + #endif +-#ifdef CONFIG_PM +- {ps3_suspend_cb, "ps3_suspend", +- "ps3_suspend host_no xxx(host number)"}, +- {ps3_resume_cb, "ps3_resume", +- "ps3_resume host_no xxx(host number)"}, +-#endif + }; + + #define DRIVER_REGISTER_DEBUG_SIMULATOR +@@ -586,6 +572,8 @@ + (p_entry->isNvme) ? "true" : "false"); + ps3stor_cli_printf("vd isSsd: %s\n", + (p_entry->isSsd) ? "true" : "false"); ++ ps3stor_cli_printf("vd isWriteDirectEnable: %s\n", ++ (p_entry->isWriteDirectEnable) ? "true" : "false"); + ps3stor_cli_printf("vd raidLevel: %u\n", p_entry->raidLevel); + ps3stor_cli_printf("vd spanCount: %u\n", p_entry->spanCount); + ps3stor_cli_printf("vd diskState: %u\n", p_entry->diskState); +@@ -684,6 +672,8 @@ + p_entry->task_reset_timeout); + ps3stor_cli_printf("pd max_io_size: %u\n", + p_entry->max_io_size); ++ ps3stor_cli_printf("pd is_direct_disable: %s\n", ++ (p_entry->is_direct_disable) ? "true" : "false"); + ps3stor_cli_printf("pd dev_queue_depth: %u\n", + p_entry->dev_queue_depth); + ps3stor_cli_printf("pd sector_size: %u\n", +@@ -1415,7 +1405,7 @@ + return ; + } + +- spin_lock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + if (strcmp(argv[1], "host") == 0) { + ps3_host_info_detail_dump(); + goto l_out; +@@ -1433,7 +1423,7 @@ + } + + l_out: +- spin_unlock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + return ; + } + +@@ -1982,11 +1972,12 @@ + ssize_t len = 0; + struct scsi_device *sdev = NULL; + struct ps3_scsi_priv_data *scsi_priv = NULL; +- struct ps3_dev_io_statis *disk_io_statis = NULL; ++ struct ps3_dev_io_statis disk_io_statis; + U32 i = 0; + const U32 temp_array_len = 256; + char temp[256] = {0}; + ssize_t temp_len = 0; ++ U8 dev_type = 0; + + if (!instance || !buf || total_len <= 0) { + ps3stor_cli_printf("invalid parameters"); +@@ -2004,8 +1995,18 @@ + if (scsi_device_get(sdev)) + continue; + ++ ps3_mutex_lock(&instance->dev_context.dev_priv_lock); + scsi_priv = (struct ps3_scsi_priv_data*)sdev->hostdata; +- disk_io_statis = &scsi_priv->statis; ++ if (scsi_priv == NULL) { ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ++ scsi_device_put(sdev); ++ continue; ++ } ++ ++ memset(&disk_io_statis, 0, sizeof(struct ps3_dev_io_statis)); ++ memcpy(&disk_io_statis, &scsi_priv->statis, sizeof(struct ps3_dev_io_statis)); ++ dev_type = scsi_priv->dev_type; ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + + memset(temp, 0, temp_array_len); + temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "index", i); +@@ -2027,19 +2028,19 @@ + + memset(temp, 0, temp_array_len); + temp_len = snprintf(temp, temp_array_len, "%-20s:%s\n", "diskType", +- (scsi_priv->dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); ++ (dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); + if ((len + temp_len) > total_len) { + scsi_device_put(sdev); + goto l_out; + } + len += snprintf(buf + len, total_len - len, "%-20s:%s\n", "diskType", +- (scsi_priv->dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); ++ (dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); + + if (len >= total_len) { + scsi_device_put(sdev); + break; + } +- len += ps3_io_statis_to_str(disk_io_statis, buf + len, total_len - len); ++ len += ps3_io_statis_to_str(&disk_io_statis, buf + len, total_len - len); + + scsi_device_put(sdev); + i++; +@@ -2075,12 +2076,13 @@ + ssize_t len = 0; + struct scsi_device *sdev = NULL; + struct ps3_scsi_priv_data *scsi_priv = NULL; +- struct ps3_dev_io_statis *disk_io_statis = NULL; ++ struct ps3_dev_io_statis disk_io_statis; + struct ps3_dev_io_statis disk_io_statis_total; + U32 pd_cnt = 0, vd_cnt = 0; + const U32 temp_array_len = 256; + char temp[256] = {0}; + ssize_t temp_len = 0; ++ U8 dev_type = 0; + + if (!instance || !buf || total_len <= 0) { + ps3stor_cli_printf("invalid parameters"); +@@ -2092,28 +2094,42 @@ + if (scsi_device_get(sdev)) + continue; + ++ ps3_mutex_lock(&instance->dev_context.dev_priv_lock); + scsi_priv = (struct ps3_scsi_priv_data*)sdev->hostdata; +- disk_io_statis = &scsi_priv->statis; ++ if (scsi_priv == NULL) { ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ++ scsi_device_put(sdev); ++ continue; ++ } ++ memset(&disk_io_statis, 0, sizeof(struct ps3_dev_io_statis)); ++ memcpy(&disk_io_statis, &scsi_priv->statis, sizeof(struct ps3_dev_io_statis)); + +- atomic64_add(atomic64_read(&disk_io_statis->read_send_cnt), &disk_io_statis_total.read_send_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->read_send_ok_cnt), &disk_io_statis_total.read_send_ok_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->read_send_err_cnt), &disk_io_statis_total.read_send_err_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->read_send_wait_cnt), &disk_io_statis_total.read_send_wait_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->read_recv_cnt), &disk_io_statis_total.read_recv_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->read_recv_err_cnt), &disk_io_statis_total.read_recv_err_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->read_recv_ok_cnt), &disk_io_statis_total.read_recv_ok_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->read_ok_bytes), &disk_io_statis_total.read_ok_bytes); +- +- atomic64_add(atomic64_read(&disk_io_statis->write_send_cnt), &disk_io_statis_total.write_send_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->write_send_ok_cnt), &disk_io_statis_total.write_send_ok_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->write_send_err_cnt), &disk_io_statis_total.write_send_err_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->write_send_wait_cnt), &disk_io_statis_total.write_send_wait_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->write_recv_cnt), &disk_io_statis_total.write_recv_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->write_recv_err_cnt), &disk_io_statis_total.write_recv_err_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->write_recv_ok_cnt), &disk_io_statis_total.write_recv_ok_cnt); +- atomic64_add(atomic64_read(&disk_io_statis->write_ok_bytes), &disk_io_statis_total.write_ok_bytes); ++ dev_type = scsi_priv->dev_type; ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + +- if (scsi_priv->dev_type == PS3_DEV_TYPE_VD) { ++ atomic64_add(atomic64_read(&disk_io_statis.read_send_cnt), &disk_io_statis_total.read_send_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.read_send_ok_cnt), &disk_io_statis_total.read_send_ok_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.read_send_err_cnt), &disk_io_statis_total.read_send_err_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.read_send_wait_cnt), ++ &disk_io_statis_total.read_send_wait_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.read_recv_cnt), &disk_io_statis_total.read_recv_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.read_recv_err_cnt), &disk_io_statis_total.read_recv_err_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.read_recv_ok_cnt), &disk_io_statis_total.read_recv_ok_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.read_ok_bytes), &disk_io_statis_total.read_ok_bytes); ++ ++ atomic64_add(atomic64_read(&disk_io_statis.write_send_cnt), &disk_io_statis_total.write_send_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.write_send_ok_cnt), &disk_io_statis_total.write_send_ok_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.write_send_err_cnt), ++ &disk_io_statis_total.write_send_err_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.write_send_wait_cnt), ++ &disk_io_statis_total.write_send_wait_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.write_recv_cnt), &disk_io_statis_total.write_recv_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.write_recv_err_cnt), ++ &disk_io_statis_total.write_recv_err_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.write_recv_ok_cnt), &disk_io_statis_total.write_recv_ok_cnt); ++ atomic64_add(atomic64_read(&disk_io_statis.write_ok_bytes), &disk_io_statis_total.write_ok_bytes); ++ ++ if (dev_type == PS3_DEV_TYPE_VD) { + vd_cnt++; + } else { + pd_cnt++; +@@ -2122,7 +2138,7 @@ + scsi_device_put(sdev); + } + +- disk_io_statis = &disk_io_statis_total; ++ memcpy(&disk_io_statis, &disk_io_statis_total, sizeof(struct ps3_dev_io_statis)); + + memset(temp, 0, temp_array_len); + temp_len = snprintf(temp, temp_array_len, "%s\n", "disk io statistics summary:"); +@@ -2148,7 +2164,7 @@ + if (len >= total_len) { + goto l_out; + } +- len += ps3_io_statis_to_str(disk_io_statis, buf, total_len - len); ++ len += ps3_io_statis_to_str(&disk_io_statis, buf, total_len - len); + + l_out: + return len; +@@ -2501,13 +2517,13 @@ + { + (void)argc; + (void)argv; +- spin_lock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + + ps3stor_cli_printf("force_to_stop begain.... !\n"); + ps3_cli_stop_all_instance(); + ps3stor_cli_printf("force_to_stop success !\n"); + +- spin_unlock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + } + + static void ps3_debug_mem_dump(struct ps3_instance *ins, U16 entry, U32 len) +@@ -2614,7 +2630,7 @@ + goto l_out; + } + if (!(dir == 0 || dir == 1)) { +- ps3stor_cli_printf("Invalid dir %u , need is 0 or 1 !\n", dir); ++ ps3stor_cli_printf("Invalid dir %u, need is 0 or 1 !\n", dir); + goto l_out; + } + +@@ -2633,11 +2649,10 @@ + goto l_out; + } + +- if (dir == 1) { ++ if (dir == 1) + ps3_debug_mem_write(instance, entry, len); +- } else { ++ else + ps3_debug_mem_dump(instance, entry, len); +- } + + l_out: + return; +@@ -2702,8 +2717,8 @@ + + static void ps3_scsi_device_loop_dump(struct ps3_instance *instance) + { +- struct scsi_device *sdev; +- ULong flags; ++ struct scsi_device *sdev = NULL; ++ ULong flags = 0; + struct Scsi_Host *shost = instance->host; + + if (instance->host == NULL) { +@@ -2796,17 +2811,13 @@ + PS3_HOST(instance)); + goto l_out; + } +- if (ps3_no_need_recovery(instance)) { +- goto l_out; +- } +- + if (ps3_need_block_hard_reset_request(instance)) { + LOG_WARN("hno:%u can not start hard reset\n", + PS3_HOST(instance)); + goto l_out; + } + +- ps3_hard_recovery_request(instance); ++ ps3_hard_recovery_request_with_retry(instance); + LOG_WARN("hno:%u cli call recovery request!\n", + PS3_HOST(instance)); + +@@ -2814,93 +2825,6 @@ + return; + } + +-#ifdef CONFIG_PM +-extern int ps3_cli_suspend(struct pci_dev *pdev, pm_message_t state); +-extern int ps3_cli_resume(struct pci_dev *pdev); +- +-static void ps3_suspend_cb(int argc, char *argv[]) +-{ +- struct ps3_instance *instance = NULL; +- U16 host_no = 0; +- pm_message_t state; +- +- if (argc < 3) { +- ps3stor_cli_printf("Too few args, must input 3 args!\n"); +- goto l_out; +- } +- +- if (strcmp(argv[1], "host_no") != 0) { +- ps3stor_cli_printf("host_no is needed!\n"); +- goto l_out; +- } +- +- if (kstrtou16(argv[2], 0, &host_no) != 0) { +- ps3stor_cli_printf("Can not parse host_no!\n"); +- goto l_out; +- } +- state.event = 0; +- instance = ps3_instance_lookup(host_no); +- if (instance == NULL) { +- ps3stor_cli_printf("Invalid host_no %u !\n", host_no); +- goto l_out; +- } +- if (instance->peer_instance != NULL) { +- if (host_no > instance->peer_instance->host->host_no) { +- ps3_cli_suspend(instance->pdev, state); +- ps3_cli_suspend(instance->peer_instance->pdev, state); +- } else { +- ps3_cli_suspend(instance->peer_instance->pdev, state); +- ps3_cli_suspend(instance->pdev, state); +- } +- goto l_out; +- } +- ps3_cli_suspend(instance->pdev, state); +- +-l_out: +- return; +-} +- +-static void ps3_resume_cb(int argc, char *argv[]) +-{ +- struct ps3_instance *instance = NULL; +- U16 host_no = 0; +- +- if (argc < 3) { +- ps3stor_cli_printf("Too few args, must input 3 args!\n"); +- goto l_out; +- } +- +- if (strcmp(argv[1], "host_no") != 0) { +- ps3stor_cli_printf("host_no is needed!\n"); +- goto l_out; +- } +- +- if (kstrtou16(argv[2], 0, &host_no) != 0) { +- ps3stor_cli_printf("Can not parse host_no!\n"); +- goto l_out; +- } +- instance = ps3_instance_lookup(host_no); +- if (instance == NULL) { +- ps3stor_cli_printf("Invalid host_no %u !\n", host_no); +- goto l_out; +- } +- if (instance->peer_instance != NULL) { +- if (host_no < instance->peer_instance->host->host_no) { +- ps3_cli_resume(instance->pdev); +- ps3_cli_resume(instance->peer_instance->pdev); +- } else { +- ps3_cli_resume(instance->peer_instance->pdev); +- ps3_cli_resume(instance->pdev); +- } +- goto l_out; +- } +- ps3_cli_resume(instance->pdev); +-l_out: +- return; +-} +- +-#endif +- + static void ps3_soc_halt_cb(int argc, char *argv[]) + { + struct ps3_instance *instance = NULL; +@@ -3528,29 +3452,6 @@ + return; + } + +-static void ps3_cli_r1x_delay(int argc, char *argv[]) +-{ +- U32 r1x_interval_delay = 0; +- S32 ret = PS3_SUCCESS; +- +- if (argc < 2) { +- ps3stor_cli_printf("Too few args, must input 2 args!\n"); +- goto l_out; +- } +- +- ret = kstrtouint(argv[1], 0, &r1x_interval_delay); +- if (ret != 0) { +- ps3stor_cli_printf("Can not parse r1x_interval_delay!\n"); +- goto l_out; +- } +- +- ps3_r1x_interval_delay_set(r1x_interval_delay); +- +- ps3stor_cli_printf("set r1x_interval_delay to %ums\n", r1x_interval_delay); +-l_out: +- return; +-} +- + static void ps3_cli_err_inject_active(int argc, char *argv[]) + { + U32 err_inject_type = 0; +@@ -3584,8 +3485,8 @@ + } + static void ps3_cli_err_inject_clear(int argc, char *argv[]) + { +- argc = argc; +- argv = argv; ++ (void)argc; ++ (void)argv; + INJECT_EXIT() + } + +@@ -3652,8 +3553,9 @@ + + if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { + waitq = &qos_pd_mgr->waitqs[0]; +- ps3stor_cli_printf(" direct_used_quota[%u] qid[%u] waitq_cnt[%u]\n", +- ps3_atomic_read(&qos_pd_mgr->direct_used_quota), waitq->count); ++ ps3stor_cli_printf(" direct_used_quota[%u] direct_quota[%u] waitq_cnt[%u]\n", ++ ps3_atomic_read(&qos_pd_mgr->direct_used_quota), ++ qos_pd_mgr->direct_quota, waitq->count); + } + + } else { +@@ -3726,7 +3628,7 @@ + cmd_waitq = &qos_tg_ctx ->vd_cmd_waitqs[i]; + if (cmd_waitq->count) { + len += snprintf(buf + len, total_len - len, +- "vd[%u] cmd waitq_count[%u]\n", i, cmd_waitq->count); ++ "vd[%u] cmd waitq_count[%u]\n", i, cmd_waitq->count); + if (len >= total_len) { + goto l_out; + } +@@ -3737,7 +3639,7 @@ + if (qos_cq_ctx->cmdqs) { + qos_softq_mgr = &qos_cq_ctx->mgrq; + len += snprintf(buf + len, total_len - len, +- "mgrq: free[%u] waitq_count[%u]\n", ps3_atomic_read(&qos_softq_mgr->free_cnt), ++ "mgrq: free[%u] waitq_count[%u]\n", ps3_atomic_read(&qos_softq_mgr->free_cnt), + qos_softq_mgr->total_wait_cmd_cnt); + if (len >= total_len) { + goto l_out; +@@ -3759,7 +3661,7 @@ + qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[i]; + if (qos_pd_mgr->total_wait_cmd_cnt) { + len += snprintf(buf + len, total_len - len, +- "pid[%u] vid[%u] valid[%u] used_quota[%u] waitq_count[%u]\n", ++ "pid[%u] vid[%u] valid[%u] used_quota[%u] waitq_count[%u]\n", + qos_pd_mgr->disk_id, qos_pd_mgr->vd_id, ps3_atomic_read(&qos_pd_mgr->valid), + ps3_atomic_read(&qos_pd_mgr->pd_used_quota),qos_pd_mgr->total_wait_cmd_cnt); + if (len >= total_len) { +@@ -3769,7 +3671,7 @@ + + if (qos_pd_mgr->total_waited_direct_cmd) { + len += snprintf(buf + len, total_len - len, +- "pid[%u] valid[%u] direct_used_quota[%u] waitq_count[%u]\n", ++ "pid[%u] valid[%u] direct_used_quota[%u] waitq_count[%u]\n", + qos_pd_mgr->disk_id, qos_pd_mgr->vd_id, ps3_atomic_read(&qos_pd_mgr->direct_used_quota), + qos_pd_mgr->total_waited_direct_cmd); + if (len >= total_len) { +@@ -4070,8 +3972,8 @@ + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + +- argc = argc; +- argv = argv; ++ (void)argc; ++ (void)argv; + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->scsi_rw_list)) { + ps3stor_cli_printf("rw inject list is empty!\n"); +@@ -4146,8 +4048,8 @@ + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + +- argc = argc; +- argv = argv; ++ (void)argc; ++ (void)argv; + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->scsi_task_list)) { + ps3stor_cli_printf("task inject list is empty!\n"); +@@ -4172,8 +4074,8 @@ + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + +- argc = argc; +- argv = argv; ++ (void)argc; ++ (void)argv; + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->mgr_list)) { + goto l_out; +@@ -5054,9 +4956,8 @@ + + static void ps3_clear_all_inject(int argc, char *argv[]) + { +- argc = argc; +- argv = argv; +- ++ (void)argc; ++ (void)argv; + ps3_clear_all_inject_scsi_rw(); + ps3_clear_all_inject_scsi_task(); + ps3_clear_all_inject_mgr(); +@@ -5399,9 +5300,8 @@ + + static void ps3_clear_hit_cmd(int argc, char *argv[]) + { +- argc = argc; +- argv = argv; +- ++ (void)argc; ++ (void)argv; + ps3_scsi_rw_cmd_clear_all(); + ps3_scsi_task_cmd_clear_all(); + ps3_mgr_cmd_clear_all(); +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_cli_debug.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_cli_debug.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_cli_debug.h 2025-06-10 20:13:00.200052760 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_cli_debug.h 2025-06-10 20:13:00.448061411 +0800 +@@ -15,3 +15,4 @@ + void ps3_inject_clear(void); + #endif + #endif ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_cli.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_cli.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_cli.h 2025-06-10 20:13:00.191052446 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_cli.h 2025-06-10 20:13:00.437061027 +0800 +@@ -2,8 +2,8 @@ + #ifndef _PS3_CLI_H_ + #define _PS3_CLI_H_ + +-#define PS3_CLI_INPUT_LEN 2048 +-#define PS3_CLI_OUTPUT_MAX (16*1024*1024) ++#define PS3_CLI_INPUT_LEN 2048 ++#define PS3_CLI_OUTPUT_MAX (16*1024*1024) + #define PS3_CLI_OUTLINE_LEN 4096 + #define PS3_CLI_HELP_LEN 256 + #define PS3_CLI_CMD_MAXLEN 32 +@@ -21,3 +21,4 @@ + + + #endif ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_driver_log.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_driver_log.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_driver_log.c 2025-06-10 20:13:00.200052760 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_driver_log.c 2025-06-10 20:13:00.448061411 +0800 +@@ -1055,3 +1055,4 @@ + } + + #endif ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_driver_log.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_driver_log.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_driver_log.h 2025-06-10 20:13:00.200052760 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_driver_log.h 2025-06-10 20:13:00.448061411 +0800 +@@ -91,6 +91,7 @@ + + #include + #include ++#include + #define __percpu + + static inline U64 get_now_ms() { +@@ -103,7 +104,10 @@ + + #define filename_printf(x) strrchr((x),'/')?strrchr((x),'/')+1:(x) + +-#define ps3_print(level,fmt,...) do { \ ++#define ps3_print(lock_chk, level, fmt, ...) do { \ ++ if (level != LEVEL_DEBUG && lock_chk) { \ ++ EXPECT_EQ(ps3_get_irq_spin_lock_count(), 0); \ ++ } \ + if (level <= ps3_level_get()) { \ + if (level == LEVEL_DEBUG) { \ + printf("DEBUG:%llu:%s:%s():%d:[%lu];" fmt, get_now_ms(), filename_printf(__FILE__), \ +@@ -269,6 +273,22 @@ + #define LOG_WARN_LIM(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) + #define LOG_ERROR_LIM(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) + ++#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ ++ (void)caller_jiffies; \ ++ (void)time; \ ++ WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__); \ ++} while (0) ++#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ ++ (void)caller_jiffies; \ ++ (void)time; \ ++ WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__); \ ++} while (0) ++#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ ++ (void)caller_jiffies; \ ++ (void)time; \ ++ WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ ++} while (0) ++ + #define LOG2_INFO_LIM(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) + #define LOG2_WARN_LIM(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) + #define LOG2_ERROR_LIM(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) +@@ -283,10 +303,13 @@ + #define LOG_WARN_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) + #define LOG_ERROR_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) + ++#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) ++#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) ++#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) ++ + #define LOG_SYNC() ps3_log_sync() + #define DATA_DUMP(ptr, size, str) \ + ps3_log_binary(__FILE__, __LINE__, (char*)ptr, size, str) +- + #else + + #define LOG_DEBUG(fmt, ...) ps3_printk(LEVEL_DEBUG, fmt, ##__VA_ARGS__); +@@ -294,15 +317,31 @@ + #define LOG_WARN(fmt, ...) ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); + #define LOG_ERROR(fmt, ...) ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); + +-#define LOG2_DEBUG(fmt, ...) ps3_printk(LEVEL_DEBUG, fmt, ##__VA_ARGS__); +-#define LOG2_INFO(fmt, ...) ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); +-#define LOG2_WARN(fmt, ...) ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); +-#define LOG2_ERROR(fmt, ...) ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); ++#define LOG2_DEBUG(fmt, ...) do { ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__); } while (0) ++#define LOG2_INFO(fmt, ...) do { ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__); } while (0) ++#define LOG2_WARN(fmt, ...) do { ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__); } while (0) ++#define LOG2_ERROR(fmt, ...) do { ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__); } while (0) + + #define LOG_INFO_LIM(fmt, ...) ps3_printk_ratelimited(LEVEL_INFO, fmt, ##__VA_ARGS__); + #define LOG_WARN_LIM(fmt, ...) ps3_printk_ratelimited(LEVEL_WARN, fmt, ##__VA_ARGS__); + #define LOG_ERROR_LIM(fmt, ...) ps3_printk_ratelimited(LEVEL_ERROR, fmt, ##__VA_ARGS__); + ++#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ ++ if (printk_timed_ratelimit(caller_jiffies, time)) { \ ++ ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); \ ++ } \ ++} while (0) ++#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ ++ if (printk_timed_ratelimit(caller_jiffies, time)) { \ ++ ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); \ ++ } \ ++} while (0) ++#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ ++ if (printk_timed_ratelimit(caller_jiffies, time)) { \ ++ ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ ++ } \ ++} while (0) ++ + #define LOG2_INFO_LIM(fmt, ...) LOG_INFO_LIM(fmt, ##__VA_ARGS__) + #define LOG2_WARN_LIM(fmt, ...) LOG_WARN_LIM(fmt, ##__VA_ARGS__) + #define LOG2_ERROR_LIM(fmt, ...) LOG_ERROR_LIM(fmt, ##__VA_ARGS__) +@@ -333,9 +372,32 @@ + } \ + }while(0) + ++#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ ++ if (need_prk_err) { \ ++ LOG_INFO_LIM(fmt, ##__VA_ARGS__); \ ++ } else { \ ++ LOG_INFO_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ ++ } \ ++} while (0) ++ ++#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ ++ if (need_prk_err) { \ ++ LOG_WARN_LIM(fmt, ##__VA_ARGS__); \ ++ } else { \ ++ LOG_WARN_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ ++ } \ ++} while (0) ++ ++#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ ++ if (need_prk_err) { \ ++ LOG_ERROR_LIM(fmt, ##__VA_ARGS__); \ ++ } else { \ ++ LOG_ERROR_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ ++ } \ ++} while (0) ++ + #define LOG_SYNC() + #define DATA_DUMP(ptr, size, str) +- + #endif + + static inline Bool ps3_fs_requires_dev(struct file *fp) +@@ -348,21 +410,37 @@ + + #else + +-#define LOG_DEBUG(fmt, ...) ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__) +-#define LOG_INFO(fmt, ...) ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__) +-#define LOG_WARN(fmt, ...) ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__) +-#define LOG_ERROR(fmt, ...) ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__) +- +-#define LOG2_DEBUG(fmt, ...) ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__) +-#define LOG2_INFO(fmt, ...) ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__) +-#define LOG2_WARN(fmt, ...) ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__) +-#define LOG2_ERROR(fmt, ...) ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__) +- +-#define LOG_LEVEL(log_lvl, fmt, ...) ps3_print(log_lvl, fmt, ##__VA_ARGS__) +- +-#define LOG_INFO_LIM(fmt, ...) ps3_print(LEVEL_INFO, fmt, ##__VA_ARGS__) +-#define LOG_WARN_LIM(fmt, ...) ps3_print(LEVEL_WARN, fmt, ##__VA_ARGS__) +-#define LOG_ERROR_LIM(fmt, ...) ps3_print(LEVEL_ERROR, fmt, ##__VA_ARGS__) ++#define LOG_DEBUG(fmt, ...) ps3_print(PS3_TRUE, PRINT_DEBUG, fmt, ##__VA_ARGS__) ++#define LOG_INFO(fmt, ...) ps3_print(PS3_TRUE, PRINT_INFO, fmt, ##__VA_ARGS__) ++#define LOG_WARN(fmt, ...) ps3_print(PS3_TRUE, PRINT_WARN, fmt, ##__VA_ARGS__) ++#define LOG_ERROR(fmt, ...) ps3_print(PS3_TRUE, PRINT_ERR, fmt, ##__VA_ARGS__) ++ ++#define LOG2_DEBUG(fmt, ...) ps3_print(PS3_TRUE, PRINT_DEBUG, fmt, ##__VA_ARGS__) ++#define LOG2_INFO(fmt, ...) ps3_print(PS3_TRUE, PRINT_INFO, fmt, ##__VA_ARGS__) ++#define LOG2_WARN(fmt, ...) ps3_print(PS3_TRUE, PRINT_WARN, fmt, ##__VA_ARGS__) ++#define LOG2_ERROR(fmt, ...) ps3_print(PS3_TRUE, PRINT_ERR, fmt, ##__VA_ARGS__) ++ ++#define LOG_LEVEL(log_lvl, fmt, ...) ps3_print(PS3_TRUE, log_lvl, fmt, ##__VA_ARGS__) ++ ++#define LOG_INFO_LIM(fmt, ...) ps3_print(PS3_TRUE, LEVEL_INFO, fmt, ##__VA_ARGS__) ++#define LOG_WARN_LIM(fmt, ...) ps3_print(PS3_TRUE, LEVEL_WARN, fmt, ##__VA_ARGS__) ++#define LOG_ERROR_LIM(fmt, ...) ps3_print(PS3_TRUE, LEVEL_ERROR, fmt, ##__VA_ARGS__) ++ ++#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ ++ (void)caller_jiffies; \ ++ (void)time; \ ++ ps3_print(PS3_TRUE, LEVEL_INFO, fmt, ##__VA_ARGS__); \ ++} while (0) ++#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ ++ (void)caller_jiffies; \ ++ (void)time; \ ++ ps3_print(PS3_TRUE, LEVEL_WARN, fmt, ##__VA_ARGS__); \ ++} while (0) ++#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ ++ (void)caller_jiffies; \ ++ (void)time; \ ++ ps3_print(PS3_TRUE, LEVEL_ERROR, fmt, ##__VA_ARGS__); \ ++} while (0) + + #define LOG2_INFO_LIM(fmt, ...) LOG_INFO_LIM(fmt, ##__VA_ARGS__) + #define LOG2_WARN_LIM(fmt, ...) LOG_WARN_LIM(fmt, ##__VA_ARGS__) +@@ -376,17 +454,32 @@ + + #define LOG_INFO_IN_IRQ(ins, fmt, ...) do { \ + (void)ins; \ +- ps3_print(LEVEL_INFO, fmt, ##__VA_ARGS__); \ ++ ps3_print(PS3_FALSE, LEVEL_INFO, fmt, ##__VA_ARGS__); \ + }while(0) + #define LOG_WARN_IN_IRQ(ins, fmt, ...) do { \ + (void)ins; \ +- ps3_print(LEVEL_WARN, fmt, ##__VA_ARGS__); \ ++ ps3_print(PS3_FALSE, LEVEL_WARN, fmt, ##__VA_ARGS__); \ + }while(0) + #define LOG_ERROR_IN_IRQ(ins, fmt, ...) do { \ + (void)ins; \ +- ps3_print(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ ++ ps3_print(PS3_FALSE, LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + }while(0) + ++#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ ++ (void)ins; \ ++ ps3_print((need_prk_err), LEVEL_INFO, fmt, ##__VA_ARGS__); \ ++} while (0) ++ ++#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ ++ (void)ins; \ ++ ps3_print((need_prk_err), LEVEL_WARN, fmt, ##__VA_ARGS__); \ ++} while (0) ++ ++#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ ++ (void)ins; \ ++ ps3_print((need_prk_err), LEVEL_ERROR, fmt, ##__VA_ARGS__); \ ++} while (0) ++ + #define LOG_SYNC() + #define DATA_DUMP(ptr, size, str) + +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_dump.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_dump.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_dump.c 2025-06-10 20:13:00.200052760 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_dump.c 2025-06-10 20:13:00.463061934 +0800 +@@ -103,7 +103,7 @@ + + if (ps3_dump_filename_build(ctxt->instance, (char*)filename, + PS3_DUMP_FILE_NAME_LEN, p_prefix) != 0) { +- LOG_INFO("dump file create: filename build failed\n"); ++ LOG_INFO("dump file create: filename build NOK\n"); + ret = -PS3_FAILED; + goto l_out; + } +@@ -227,24 +227,27 @@ + return &instance->dump_context; + } + +-static inline U64 ps3_dump_ctrl_get(struct ps3_instance *instance) ++static inline Bool ps3_dump_ctrl_get(struct ps3_instance *instance, U64 *dump_ctrl) + { +- U64 dump_ctrl = 0; ++ Bool ret = PS3_TRUE; + +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpCtrl, dump_ctrl); +- if (dump_ctrl != U64_MAX) { +- dump_ctrl &= 0xff; +- } else { +- LOG_WARN("dump ctrl value invalid\n"); +- dump_ctrl = 0; ++ PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpCtrl, *dump_ctrl); ++ INJECT_START(PS3_ERR_IJ_DUMP_CTRL_ERR, dump_ctrl); ++ if (*dump_ctrl == U64_MAX) { ++ LOG_INFO("hno:%u read reg ps3DumpCtrl NOK!\n", ++ PS3_HOST(instance)); ++ ret = PS3_FALSE; ++ goto l_out; + } +- return dump_ctrl; ++ *dump_ctrl &= 0xff; ++ ++l_out: ++ return ret; + } + + static inline void ps3_dump_ctrl_set(struct ps3_instance *instance, + U64 value) + { +- + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpCtrl, value); + } + +@@ -252,19 +255,24 @@ + { + struct ps3_dump_context * ctxt = &instance->dump_context; + U64 dump_ctrl; ++ Bool ret = PS3_TRUE; + + if (ctxt->dump_state == PS3_DUMP_STATE_ABORTED || + ctxt->dump_state == PS3_DUMP_STATE_INVALID ) { + goto l_ret; + } + +- dump_ctrl = ps3_dump_ctrl_get(instance); +- if (dump_ctrl) { +- LOG_ERROR("dump ctrl is not cleared 0x%llx\n", dump_ctrl); +- } +- +- ps3_dump_ctrl_set(instance, PS3_DUMP_CTRL_DUMP_ABORT); ++ ret = ps3_dump_ctrl_get(instance, &dump_ctrl); ++ INJECT_START(PS3_ERR_IJ_DUMP_ABORT_GET_CTRL_FAIL, &ret); ++ if (ret) { ++ if (dump_ctrl) ++ LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); + ++ ps3_dump_ctrl_set(instance, PS3_DUMP_CTRL_DUMP_ABORT); ++ } else { ++ LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", ++ PS3_HOST(instance)); ++ } + ctxt->dump_state = PS3_DUMP_STATE_ABORTED; + l_ret: + return; +@@ -273,13 +281,19 @@ + static inline void ps3_dump_end(struct ps3_instance *instance) + { + U64 dump_ctrl; ++ Bool ret = PS3_TRUE; + +- dump_ctrl = ps3_dump_ctrl_get(instance); +- if (dump_ctrl) { +- LOG_ERROR("dump ctrl is not cleared 0x%llx\n", dump_ctrl); +- } ++ ret = ps3_dump_ctrl_get(instance, &dump_ctrl); ++ INJECT_START(PS3_ERR_IJ_DUMP_END_GET_CTRL_FAIL, &ret); ++ if (ret) { ++ if (dump_ctrl) ++ LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); + +- ps3_dump_ctrl_set(instance, PS3_DUMP_CTRL_DUMP_END); ++ ps3_dump_ctrl_set(instance, PS3_DUMP_CTRL_DUMP_END); ++ } else { ++ LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", ++ PS3_HOST(instance)); ++ } + + return; + } +@@ -290,6 +304,7 @@ + U64 dump_ctrl; + U64 ctrl_val = 0; + S32 ret = PS3_SUCCESS; ++ Bool reg_ret = PS3_TRUE; + + switch (dump_type) { + case PS3_DUMP_TYPE_CRASH: +@@ -306,14 +321,20 @@ + goto l_ret; + } + +- dump_ctrl = ps3_dump_ctrl_get(instance); +- if (dump_ctrl) { +- LOG_ERROR("dump ctrl is not cleared 0x%llx\n", dump_ctrl); +- ret = -PS3_FAILED; ++ reg_ret = ps3_dump_ctrl_get(instance, &dump_ctrl); ++ INJECT_START(PS3_ERR_IJ_DUMP_TRIGGER_GET_CTRL_FAIL, ®_ret); ++ if (reg_ret) { ++ if (dump_ctrl) { ++ LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); ++ ret = -PS3_FAILED; ++ } else { ++ ps3_dump_ctrl_set(instance, ctrl_val); ++ } + } else { +- ps3_dump_ctrl_set(instance, ctrl_val); ++ LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", ++ PS3_HOST(instance)); ++ ret = -PS3_FAILED; + } +- + l_ret: + return ret; + } +@@ -324,9 +345,9 @@ + Bool ret = PS3_TRUE; + + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpStatus, *dump_status); +- ++ INJECT_START(PS3_ERR_IJ_DUMP_STATUS_ERR, dump_status); + if (*dump_status == U64_MAX) { +- LOG_INFO("hno:%u read reg ps3DumpStatus failed!\n", ++ LOG_INFO("hno:%u read reg ps3DumpStatus NOK!\n", + PS3_HOST(instance)); + *dump_status = 0; + ret = PS3_FALSE; +@@ -342,7 +363,6 @@ + static inline void ps3_dump_status_set(struct ps3_instance *instance, + U64 value) + { +- + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpStatus, value); + } + +@@ -352,8 +372,9 @@ + Bool ret = PS3_TRUE; + + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpDataSize, *data_size); ++ INJECT_START(PS3_ERR_IJ_DUMP_DATA_SIZE_FAIL, data_size); + if (*data_size == U64_MAX) { +- LOG_INFO("hno:%u read reg ps3DumpDataSize failed!\n", ++ LOG_INFO("hno:%u read reg ps3DumpDataSize NOK!\n", + PS3_HOST(instance)); + *data_size = 0; + ret = PS3_FALSE; +@@ -395,7 +416,8 @@ + { + U64 dma_size = 0; + U64 dump_ctrl; +- S32 ret = 0; ++ S32 ret = PS3_SUCCESS; ++ Bool reg_ret = PS3_TRUE; + + if (!ps3_dump_data_size_get_clear(ctxt->instance, &dma_size)) { + ret = -PS3_FAILED; +@@ -410,8 +432,9 @@ + ctxt->dump_data_size += dma_size; + + ret = ps3_dump_file_write(&ctxt->dump_out_file, ctxt->dump_dma_buf, dma_size); ++ INJECT_START(PS3_ERR_IJ_DUMP_WRITE_FAIL, &ret); + if (ret < 0 || ret != (S32)dma_size) { +- LOG_ERROR("error: write data failure ret %d, dma_size %llu\n", ret, dma_size); ++ LOG_WARN("error: write data failure ret %d, dma_size %llu\n", ret, dma_size); + ret = -PS3_FAILED; + goto l_out; + } +@@ -420,14 +443,19 @@ + PS3_REG_CLR(status, PS3_DUMP_STATUS_REG_DMA_FINISH_MASK); + ps3_dump_status_set(ctxt->instance, status); + +- dump_ctrl = ps3_dump_ctrl_get(ctxt->instance); +- if (dump_ctrl) { +- LOG_ERROR("dump ctrl is not cleared 0x%llx\n", dump_ctrl); +- } +- +- ps3_dump_ctrl_set(ctxt->instance, PS3_DUMP_CTRL_COPY_FINISH); ++ reg_ret = ps3_dump_ctrl_get(ctxt->instance, &dump_ctrl); ++ INJECT_START(PS3_ERR_IJ_DUMP_DATA_COPY_GET_CTRL_FAIL, ®_ret); ++ if (reg_ret) { ++ if (dump_ctrl) ++ LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); + +- ret = PS3_SUCCESS; ++ ps3_dump_ctrl_set(ctxt->instance, PS3_DUMP_CTRL_COPY_FINISH); ++ ret = PS3_SUCCESS; ++ } else { ++ LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", ++ PS3_HOST(ctxt->instance)); ++ ret = -PS3_FAILED; ++ } + + l_out: + return ret; +@@ -452,11 +480,14 @@ + ps3_container_of(work, struct ps3_dump_context, dump_work.work); + U64 status = 0, delay_ms = 0; + S32 cur_state = 0; ++ Bool ret = PS3_TRUE; + + ctxt->dump_work_status = PS3_DUMP_WORK_RUNNING; +- if (!ps3_dump_status_get(ctxt->instance, &status)) { ++ ret = ps3_dump_status_get(ctxt->instance, &status); ++ INJECT_START(PS3_ERR_IJ_DUMP_DUMP_STATE_GET_FAIL, &ret); ++ if (!ret) { + delay_ms = PS3_REG_READ_INTERVAL_MS; +- LOG_ERROR("ps3_dump_status_get error ,delay %llums try again\n", ++ LOG_INFO("ps3_dump_status_get error, delay %llums try again\n", + delay_ms); + queue_delayed_work(ctxt->dump_work_queue, &ctxt->dump_work, + msecs_to_jiffies(delay_ms)); +@@ -473,6 +504,7 @@ + + switch(ctxt->dump_state) { + case PS3_DUMP_STATE_START: ++ INJECT_START(PS3_ERR_IJ_DUMP_DUMP_STATE_INVALID, &status); + if ((status & PS3_DUMP_STATUS_REG_INVALID_BITS_MASK) == 0 || + (status & PS3_DUMP_STATUS_REG_ABORT_MASK) != 0) { + LOG_INFO("abort dump in START STATE, status: 0x%llx\n", status); +@@ -537,14 +569,14 @@ + work_wait_times = 0; + goto l_out; + default: +- LOG_WARN("warn: dump work state %d\n", ctxt->dump_state); ++ LOG_INFO("warn: dump work state %d\n", ctxt->dump_state); + ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; + continue; + } + if (delay_ms) { + if (work_wait_times >= + max((U32)WAIT_DUMP_TIMES_MIN, (U32)ctxt->dump_dma_wait_times)) { +- LOG_ERROR("error: wait too many times %d for dump %s, abort it\n", ++ LOG_INFO("error: wait too many times %d for dump %s, abort it\n", + work_wait_times,ps3_dump_type_to_name(ctxt->dump_type)); + ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; + work_wait_times = 0; +@@ -573,7 +605,7 @@ + &ctxt->dump_dma_addr); + INJECT_START(PS3_ERR_IJ_FORCE_ALLOC_DMA_BUF_FAILED, &ctxt->dump_dma_buf) + if (ctxt->dump_dma_buf == NULL) { +- LOG_ERROR("host_no[%d], dump dma alloc failed!\n", PS3_HOST(instance)); ++ LOG_ERROR("host_no[%d], dump dma alloc NOK!\n", PS3_HOST(instance)); + ret = -PS3_FAILED; + } + +@@ -585,7 +617,6 @@ + struct ps3_dump_context *ctxt = &instance->dump_context; + + if (ctxt->dump_dma_buf != NULL) { +- LOG_INFO("free dump_dma_buf = %p\n", ctxt->dump_dma_buf); + ps3_dma_free_coherent(instance, + PS3_DUMP_DMA_BUF_SIZE, ctxt->dump_dma_buf, + ctxt->dump_dma_addr); +@@ -608,18 +639,21 @@ + S32 cur_state = PS3_INSTANCE_STATE_INIT; + LOG_INFO("dump type set: type %d\n", type); + ++ INJECT_START(PS3_ERR_IJ_DUMP_TYPE_ILLEGAL, &type); + if ( (type < PS3_DUMP_TYPE_CRASH)|| (type > PS3_DUMP_TYPE_BAR_DATA)) { + ret = -PS3_FAILED; + goto l_ret; + } + ++ INJECT_START(PS3_ERR_IJ_DUMP_WORK_QUEUE_NULL, &ctxt->dump_work_queue); + if (ctxt->dump_work_queue == NULL) { +- LOG_ERROR("dump type set: no work to do, type %d\n", type); ++ LOG_WARN("dump type set: no work to do, type %d\n", type); + ret = -PS3_FAILED; + goto l_ret; + } + + ps3_mutex_lock(&ctxt->dump_lock); ++ INJECT_START(PS3_ERR_IJ_DUMP_STATE_ILLEGAL, &ctxt->dump_state); + if (ctxt->dump_state != PS3_DUMP_STATE_INVALID) { + LOG_FILE_ERROR("dump type set: work is busy, current state: %d, type %d\n", ctxt->dump_state, type); + ret = -PS3_FAILED; +@@ -656,6 +690,7 @@ + INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID, ctxt->instance); + + ret = ps3_dump_trigger (ctxt->instance, type); ++ INJECT_START(PS3_ERR_IJ_DUMP_TRIGGER_FAIL, &ret); + if (ret != PS3_SUCCESS) { + ps3_dump_reset(ctxt); + goto l_unlock; +@@ -714,7 +749,7 @@ + S32 ret = PS3_SUCCESS; + S32 dump_type = 0; + U64 status = 0; +- HilReg0Ps3RegisterFPs3DumpStatus_u dump_status = {0}; ++ union HilReg0Ps3RegisterFPs3DumpStatus dump_status = {0}; + U8 is_trigger_log; + + if (!ps3_dump_status_get(instance, &status)) { +@@ -723,7 +758,7 @@ + dump_status.val = status; + + dump_type = dump_status.reg.hasAutoDump; +- ++ INJECT_START(PS3_ERR_IJ_DUMP_TYPE_INVALID, &dump_type); + if (dump_type == 0) { + goto l_out; + } +@@ -755,7 +790,6 @@ + return; + } + +-#ifndef _WINDOWS + static void ps3_dump_irq_handler_work(struct work_struct *work) + { + struct ps3_dump_context * ctxt = +@@ -773,7 +807,7 @@ + { + struct ps3_instance *pInstance = (struct ps3_instance *)dev_id; + struct ps3_dump_context *p_dump_ctx = &pInstance->dump_context; +- ULong flags; ++ ULong flags = 0; + + spin_lock_irqsave(&p_dump_ctx->dump_irq_handler_lock, flags); + if (p_dump_ctx->dump_enabled) { +@@ -790,7 +824,6 @@ + + return IRQ_HANDLED; + } +-#endif + + static void ps3_dump_dir_init(char *dump_dir) + { +@@ -821,8 +854,13 @@ + S32 ret = PS3_SUCCESS; + struct ps3_dump_context *ctxt = &instance->dump_context; + ++ if (reset_devices) { ++ LOG_INFO("resetting device in progress, Do not initialize dump\n"); ++ goto l_ret; ++ } ++ + if (ctxt->dump_dma_buf != NULL) { +- LOG_WARN("hno:%u init already\n", PS3_HOST(instance)); ++ LOG_INFO("hno:%u init already\n", PS3_HOST(instance)); + goto l_ret; + } + memset((void*)ctxt, 0, sizeof(struct ps3_dump_context )); +@@ -831,8 +869,6 @@ + goto l_ret; + } + +- ps3_mutex_init(&ctxt->dump_lock); +- + ps3_dump_dir_init((char *)ctxt->dump_dir); + + ctxt->instance = instance; +@@ -846,8 +882,9 @@ + + INIT_DELAYED_WORK(&ctxt->dump_work, ps3_dump_work); + ctxt->dump_work_queue = create_singlethread_workqueue((char*)"ps3_dump_work_queue"); ++ INJECT_START(PS3_ERR_IJ_DUMP_WORK_FAILED, &ctxt->dump_work_queue); + if (ctxt->dump_work_queue == NULL) { +- LOG_ERROR("dump work queue create failed\n"); ++ LOG_ERROR("dump work queue create NOK\n"); + ret = -PS3_FAILED; + goto l_failed; + } +@@ -855,11 +892,13 @@ + INIT_WORK(&ctxt->dump_irq_handler_work, ps3_dump_irq_handler_work); + ctxt->dump_irq_handler_work_queue = create_singlethread_workqueue( + (char*)"ps3_dump_irq_handler_work_queue"); ++ INJECT_START(PS3_ERR_DUMP_ALLOC_FAILED, &ctxt->dump_irq_handler_work_queue); + if (ctxt->dump_irq_handler_work_queue == NULL) { +- LOG_ERROR("dump irq handler work queue create failed\n"); ++ LOG_ERROR("dump irq handler work queue create NOK\n"); + ret = -PS3_FAILED; + goto l_failed; + } ++ ps3_mutex_init(&ctxt->dump_lock); + + spin_lock_init(&ctxt->dump_irq_handler_lock); + ctxt->dump_enabled = 1; +@@ -873,17 +912,13 @@ + void ps3_dump_exit(struct ps3_instance *instance) + { + struct ps3_dump_context *ctxt = &instance->dump_context; +- ULong flags; ++ ULong flags = 0; + + if (ctxt->dump_dma_buf == NULL) { + return; + } + + spin_lock_irqsave(&ctxt->dump_irq_handler_lock, flags); +- if (ctxt->dump_enabled == 0) { +- spin_unlock_irqrestore(&ctxt->dump_irq_handler_lock, flags); +- return; +- } + ctxt->dump_enabled = 0; + spin_unlock_irqrestore(&ctxt->dump_irq_handler_lock, flags); + +@@ -912,7 +947,7 @@ + ps3_dump_file_close(&ctxt->dump_out_file); + + ps3_mutex_destroy(&ctxt->dump_lock); +- LOG_WARN("hno:%u dump destory work and stop service\n", ++ LOG_INFO("hno:%u dump destroy work and stop service\n", + PS3_HOST(instance)); + } + +@@ -948,7 +983,10 @@ + } + void ps3_dump_ctrl_set_int_ready(struct ps3_instance *instance) + { +- ++ if (reset_devices) { ++ LOG_INFO("resetting device in progress, unable to confiure ps3DumpCtrl\n"); ++ return; ++ } + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpCtrl, PS3_DUMP_CTRL_DUMP_INT_READY); + } + +@@ -959,18 +997,29 @@ + Bool is_trigger_log = PS3_FALSE; + S32 cur_state = ps3_atomic_read(&instance->state_machine.state); + Bool is_halt = (is_support_halt && (cur_state == PS3_INSTANCE_STATE_DEAD)); ++ Bool ret = PS3_TRUE; + ++ INJECT_START(PS3_ERR_IJ_DUMP_PCIE_ERR, instance); ++ INJECT_START(PS3_ERR_IJ_DUMP_RECOVERY_ERR, instance); + if (likely(is_halt || + (cur_state == PS3_INSTANCE_STATE_OPERATIONAL && !ps3_pci_err_recovery_get(instance)))) { + is_trigger_log = PS3_TRUE; + } + + if (instance->is_support_dump_ctrl) { +- dump_ctrl = ps3_dump_ctrl_get(instance); +- if(dump_ctrl != 0) { ++ ret = ps3_dump_ctrl_get(instance, &dump_ctrl); ++ INJECT_START(PS3_ERR_IJ_DUMP_IS_TRIGGER_GET_CTRL_FAIL, &ret); ++ if (ret) { ++ if (dump_ctrl != 0) ++ is_trigger_log = PS3_FALSE; ++ ++ } else { ++ LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", ++ PS3_HOST(instance)); + is_trigger_log = PS3_FALSE; + } + } + + return is_trigger_log; + } ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_pcie_err_handle.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_pcie_err_handle.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_pcie_err_handle.c 2025-06-10 20:13:00.201052795 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_pcie_err_handle.c 2025-06-10 20:13:00.454061620 +0800 +@@ -64,7 +64,6 @@ + ps3_irqs_sync(instance); + + ps3_irqpolls_enable(instance); +- + ps3_dump_work_stop(instance); + ps3_pci_init_complete_exit(instance); + } +@@ -80,19 +79,11 @@ + goto l_out; + } + +- LOG_INFO("[%d:%d:%d]:PCIe err detected state:%u\n", ps3_get_pci_bus(pdev), \ ++ LOG_INFO("[%04x:%02x:%02x:%x]:PCIe err detected state:%u\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), state); + dev_info(&pdev->dev, "[PS3]%s():%d;PCIe err detected state:%u\n", + __FUNCTION__, __LINE__, state); +- +- ps3_atomic_inc(&instance->pcie_err_handle_ref); +- INJECT_START(PS3_ERR_IJ_FORCE_PCIE_ERR_RES_ONLINE_FAILED, instance) +- if (!instance->state_machine.is_res_online) { +- ps3_atomic_dec(&instance->pcie_err_handle_ref); +- ret = PCI_ERS_RESULT_DISCONNECT; +- goto l_out; +- } +- ++ instance->is_pcie_err_detected = PS3_TRUE; + switch (state) { + case pci_channel_io_normal: + ret = PCI_ERS_RESULT_CAN_RECOVER; +@@ -104,6 +95,7 @@ + if (ps3_recovery_cancel_work_sync(instance) != PS3_SUCCESS) { + LOG_ERROR("hno:%u work sync failed, state: %u\n", PS3_HOST(instance), state); + } ++ instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_CLEAN; + ps3_base_free_resources(instance); + ret = PCI_ERS_RESULT_NEED_RESET; + break; +@@ -113,8 +105,7 @@ + if (ps3_recovery_cancel_work_sync(instance) != PS3_SUCCESS) { + LOG_ERROR("hno:%u work sync failed, state: %u\n", PS3_HOST(instance), state); + } +- ps3_scsi_cmd_force_stop(instance); +- ps3_mgr_cmd_force_stop(instance); ++ ps3_cmd_force_stop(instance); + ps3_pci_err_recovery_set(instance, PS3_FALSE); + ps3_instance_state_transfer_to_dead(instance); + ret = PCI_ERS_RESULT_DISCONNECT; +@@ -123,11 +114,12 @@ + ret = PCI_ERS_RESULT_RECOVERED; + break; + } +- ps3_atomic_dec(&instance->pcie_err_handle_ref); + ++ instance->is_pcie_err_detected = PS3_FALSE; + l_out: +- LOG_INFO("[%d:%d:%d]:PCIe err detect state:%u ret:%u\n", ps3_get_pci_bus(pdev), \ +- ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), state, ret); ++ LOG_INFO("[%04x:%02x:%02x:%x]:PCIe err detect state:%u ret:%u\n", ps3_get_pci_domain(pdev), ++ ps3_get_pci_bus(pdev), ps3_get_pci_slot(pdev), ++ ps3_get_pci_function(pdev), state, ret); + dev_info(&pdev->dev, "[PS3]%s():%d;PCIe err detect state:%u ret:%u\n", + __FUNCTION__, __LINE__, state, ret); + return ret; +@@ -137,7 +129,7 @@ + { + pci_ers_result_t ret = PCI_ERS_RESULT_RECOVERED; + +- LOG_INFO("[%d:%d:%d]: PCIe err mmio enabled\n", ps3_get_pci_bus(pdev), \ ++ LOG_INFO("[%04x:%02x:%02x:%x]: PCIe err mmio enabled\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + dev_info(&pdev->dev, "[PS3]%s():%d; PCIe err mmio enabled\n", + __FUNCTION__, __LINE__); +@@ -149,7 +141,6 @@ + { + int ret; + struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); +- ps3_atomic_inc(&instance->pcie_err_handle_ref); + + LOG_INFO("hno:%u PCIe err slot reset begin.\n", PS3_HOST(instance)); + dev_info(&pdev->dev, "[PS3]%s():%d;hno:%u PCIe err slot reset begin.\n", +@@ -158,6 +149,8 @@ + instance->pdev = pdev; + pci_restore_state(pdev); + ++ ps3_irq_context_exit(instance); ++ + ret = ps3_base_init_resources(instance); + if (ret) { + LOG_ERROR("hno:%u base init resources failed, ret: %d\n", PS3_HOST(instance), ret); +@@ -169,14 +162,14 @@ + dev_info(&pdev->dev, "[PS3]%s():%d;hno:%u PCIe err slot reset succeed.\n", + __FUNCTION__, __LINE__, PS3_HOST(instance)); + ps3_pci_err_recovery_set(instance, PS3_FALSE); +- ps3_atomic_dec(&instance->pcie_err_handle_ref); ++ instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_INIT; + return PCI_ERS_RESULT_RECOVERED; + l_out: + if (instance) { + ps3_instance_state_transfer_to_dead(instance); + } + ps3_pci_err_recovery_set(instance, PS3_FALSE); +- ps3_atomic_dec(&instance->pcie_err_handle_ref); ++ instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_INIT; + + return PCI_ERS_RESULT_DISCONNECT; + } +@@ -186,7 +179,6 @@ + S32 ret = PS3_SUCCESS; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); +- ps3_atomic_inc(&instance->pcie_err_handle_ref); + + LOG_INFO("hno:%u PCIe err resume\n", PS3_HOST(instance)); + dev_info(&pdev->dev, "[PS3]%s():%d;hno:%u PCIe err resume\n", +@@ -200,7 +192,7 @@ + goto l_norecovery; + } + INJECT_START(PS3_ERR_IJ_PCI_FORCE_HARD_RECOVERY_REQ_FAILED, instance) +- ret = ps3_hard_recovery_request(instance); ++ ret = ps3_hard_recovery_request_with_retry(instance); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u hard reset NOK, ret: %d\n", PS3_HOST(instance), ret); + dev_info(&pdev->dev, "[PS3]hno:%u hard reset NOK, ret: %d\n", PS3_HOST(instance), ret); +@@ -225,7 +217,7 @@ + #endif + ps3_watchdog_start(instance); + scsi_unblock_requests(instance->host); +- ps3_atomic_dec(&instance->pcie_err_handle_ref); ++ instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; + return; + l_failed: + #if ((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)) || \ +@@ -239,15 +231,7 @@ + if (instance) { + ps3_instance_state_transfer_to_dead(instance); + } +- ps3_atomic_dec(&instance->pcie_err_handle_ref); ++ instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; + return; + } + +-void ps3_check_and_wait_pci_err_handle(struct ps3_instance *instance) +-{ +- while(ps3_atomic_read(&instance->pcie_err_handle_ref) != 0){ +- ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); +- } +- +- return; +-} +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_pcie_err_handle.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_pcie_err_handle.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/linux/ps3_pcie_err_handle.h 2025-06-10 20:13:00.201052795 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/linux/ps3_pcie_err_handle.h 2025-06-10 20:13:00.455061655 +0800 +@@ -15,7 +15,6 @@ + int ps3_base_init_resources(struct ps3_instance *instance); + + void ps3_base_free_resources(struct ps3_instance *instance); +-void ps3_check_and_wait_pci_err_handle(struct ps3_instance *instance); + + #ifdef __cplusplus + } +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/Makefile ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/Makefile +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/Makefile 2025-06-10 20:13:00.201052795 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/Makefile 2025-06-10 20:13:00.470062179 +0800 +@@ -2,17 +2,30 @@ + EXTRA_CFLAGS += -DPS3_CFG_RELEASE + EXTRA_CFLAGS += -DPS3_HARDWARE_ASIC + EXTRA_CFLAGS += -DPS3_MODEL_V200 ++ ++ifneq ($(KERNELRELEASE),) + CONFIG_MODULE_SIG=n ++obj-m += ps3stor.o + +-#当前目录下的Makefile路径 +-MAKEPATH := $(abspath $(lastword $(MAKEFILE_LIST))) ++ps3stor-objs := $(patsubst %.c, %.o, $(notdir $(wildcard $(src)/*.c))) ++ps3stor-objs += $(patsubst %.c, linux/%.o, $(notdir $(wildcard $(src)/linux/*.c))) + +-#当前路径 +-CURDIR :=$(shell dirname $(MAKEPATH)) ++ccflags-y += -Werror -frecord-gcc-switches ++ccflags-y += $(call cc-option, -Wmaybe-uninitialized) ++ccflags-y += -I$(src) -I$(src)/linux -I$(src)/include/htp_v200 -I$(src)/include/ ++else ++ KDIR ?= /lib/modules/`uname -r`/build + +-ccflags-y += -Werror -Wmaybe-uninitialized -frecord-gcc-switches +-ccflags-y += -I$(CURDIR) -I$(CURDIR)/linux -I$(CURDIR)/include/htp_v200 -I$(CURDIR)/include/ ++all: ++ @echo "ARCH=$(ARCH)" ++ @echo "KDIR=$(KDIR)" ++ @echo "OS=$(OS_SYSTEM)" ++ @echo "EXTRA_CFLAGS=$(EXTRA_CFLAGS)" ++ @$(MAKE) -C $(KDIR) M=$(PWD) INCDIR=$(PWD)/linux modules ++clean: ++ @rm -rf *.o *.d *.ko Module.* modules.* *.mod.* .*.d .*.cmd .tmp_versions *.o.ur-safe ++ @rm -rf ./linux/*.o ++ @rm -rf ./tags ++ @rm -rf ./output.log ++endif + +-obj-$(CONFIG_PS3STOR) += ps3stor.o +-ps3stor-objs := $(patsubst %.c, %.o, $(notdir $(wildcard $(CURDIR)/*.c))) +-ps3stor-objs += $(patsubst %.c, linux/%.o, $(notdir $(wildcard $(CURDIR)/linux/*.c))) +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_channel.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_channel.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_channel.c 2025-06-10 20:13:00.209053074 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_channel.c 2025-06-10 20:13:00.471062213 +0800 +@@ -25,14 +25,7 @@ + #include "ps3_module_para.h" + #include "ps3_scsih.h" + #include "ps3_ioc_state.h" +- +-enum { +- DMA_ALIGN_BYTES_256 = 256, +- DMA_ALIGN_BYTES_128 = 128, +- DMA_ALIGN_BYTES_64 = 64, +- DMA_ALIGN_BYTES_16 = 16, +- DMA_ALIGN_BYTES_4 = 4, +-}; ++#include "ps3_mgr_cmd.h" + + static S32 ps3_req_frame_alloc(struct ps3_instance *instance); + static void ps3_req_frame_free(struct ps3_instance *instance); +@@ -145,23 +138,21 @@ + + static S32 ps3_req_frame_alloc(struct ps3_instance *instance) + { +-#ifndef _WINDOWS + U32 size = 0; + struct ps3_cmd_context *context = &instance->cmd_context; + +- PS3_BUG_ON(context->req_frame_dma_pool != NULL); +- + size = PS3_DEFAULT_REQ_FRAME_SIZE * context->max_cmd_count; + + context->req_frame_dma_pool = (struct dma_pool *) ps3_dma_pool_create( + "PS3 req frame pool",&instance->pdev->dev, size, +- DMA_ALIGN_BYTES_16, 0); ++ DMA_ALIGN_BYTES_256, 0); ++ INJECT_START(PS3_ERR_IJ_PS3_REQ_FRAME_BUF_ALLOC, &context->req_frame_dma_pool); + if (!context->req_frame_dma_pool) { + LOG_ERROR("Failed to setup frame pool\n"); + goto l_create_dma_pool_failed; + } + +- context->req_frame_buf = (U8*)ps3_dma_pool_alloc( ++ context->req_frame_buf = (U8 *)ps3_dma_pool_alloc(instance, + context->req_frame_dma_pool, + GFP_KERNEL, &context->req_frame_buf_phys); + if (!context->req_frame_buf) { +@@ -178,21 +169,6 @@ + } + l_create_dma_pool_failed: + return -PS3_FAILED; +-#else +- struct ps3_cmd_context *context = &instance->cmd_context; +- context->req_frame_buf_size = sizeof(struct ps3_cmd) * context->max_cmd_count; +- +- context->req_frame_buf = (U8*)ps3_dma_alloc_coherent(instance, +- context->req_frame_buf_size, &context->req_frame_buf_phys); +- if (context->req_frame_buf == NULL) { +- LOG_ERROR("Failed to alloc frame dma memory\n"); +- goto l_failed; +- } +- +- return PS3_SUCCESS; +-l_failed: +- return -PS3_FAILED; +-#endif + } + + static void ps3_req_frame_free(struct ps3_instance *instance) +@@ -223,28 +199,27 @@ + + static S32 ps3_cmd_resp_frame_alloc(struct ps3_instance *instance) + { +-#ifndef _WINDOWS + U32 sense_size = 0; + struct ps3_cmd_context *context = &instance->cmd_context; + +- PS3_BUG_ON(context->response_frame_dma_pool != NULL); +- + sense_size = PS3_RESP_FRAME_LENGH * context->max_cmd_count; + + context->response_frame_dma_pool = (struct dma_pool *)ps3_dma_pool_create("PS3 respSense pool", + &instance->pdev->dev, sense_size, +- DMA_ALIGN_BYTES_64, 0); ++ DMA_ALIGN_BYTES_4K, 0); ++ + if (!context->response_frame_dma_pool) { + LOG_ERROR("Failed to setup sense pool\n"); + goto l_failed_alloc; + } +- context->response_frame_buf = (U8*)ps3_dma_pool_alloc(context->response_frame_dma_pool, ++ context->response_frame_buf = (U8 *)ps3_dma_pool_alloc(instance, context->response_frame_dma_pool, + GFP_KERNEL, &context->response_frame_buf_phys); ++ INJECT_START(PS3_ERR_IJ_PS3_RESP_FRAME_BUF_ALLOC, &context->response_frame_buf); + if (!context->response_frame_buf) { + LOG_ERROR("Failed to alloc sense dma memory\n"); + goto l_free_mem; + } +- ++ ps3_get_so_addr_ranger(instance, context->response_frame_buf_phys, sense_size); + return PS3_SUCCESS; + + l_free_mem: +@@ -255,20 +230,6 @@ + + l_failed_alloc: + return -PS3_FAILED; +-#else +- struct ps3_cmd_context *context = &instance->cmd_context; +- context->response_frame_buf_size = PS3_RESP_FRAME_LENGH * context->max_cmd_count; +- context->response_frame_buf = (U8*)ps3_dma_alloc_coherent(instance, +- context->response_frame_buf_size, &context->response_frame_buf_phys); +- if (context->response_frame_buf == NULL) { +- LOG_ERROR("Failed to alloc response frame dma memory\n"); +- goto l_failed; +- } +- +- return PS3_SUCCESS; +-l_failed: +- return -PS3_FAILED; +-#endif + } + + static void ps3_cmd_resp_frame_free(struct ps3_instance *instance) +@@ -328,6 +289,7 @@ + + cmd->transient = (struct ps3_ioctl_transient *) + ps3_kzalloc(instance, sizeof(struct ps3_ioctl_transient)); ++ INJECT_START(PS3_ERR_IJ_PS3_IOCTL_TRANSIENT_ALLOC, &cmd->transient); + if (cmd->transient == NULL) { + LOG_ERROR("Failed to alloc sge dma memory\n"); + goto l_free; +@@ -360,8 +322,9 @@ + + for (i = 0; i < context->max_scsi_cmd_count; i++) { + cmd = context->cmd_buf[i]; +- cmd->ext_buf = ps3_dma_pool_zalloc(context->ext_buf_dma_pool, ++ cmd->ext_buf = ps3_dma_pool_zalloc(instance, context->ext_buf_dma_pool, + GFP_KERNEL, &cmd->ext_buf_phys); ++ INJECT_START(PS3_ERR_IJ_PS3_EXT_BUF_ALLOC, &cmd->ext_buf); + if (!cmd->ext_buf) { + LOG_ERROR("Failed to alloc scsi ext buf memory\n"); + goto l_free_sge; +@@ -379,8 +342,9 @@ + + for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { + cmd = context->cmd_buf[i]; +- cmd->ext_buf = ps3_dma_pool_zalloc(context->mgr_ext_buf_dma_pool, ++ cmd->ext_buf = ps3_dma_pool_zalloc(instance, context->mgr_ext_buf_dma_pool, + GFP_KERNEL, &cmd->ext_buf_phys); ++ INJECT_START(PS3_ERR_IJ_PS3_MGR_EXT_BUF_ALLOC, &cmd->ext_buf); + if (!cmd->ext_buf) { + LOG_ERROR("Failed to alloc mgr ext buf memory\n"); + goto l_free_sge; +@@ -496,6 +460,7 @@ + cmd = context->cmd_buf[i]; + cmd->szblock_cnt = 0; + cmd->node_buff = ps3_kzalloc(instance, node_buff_size); ++ INJECT_START(PS3_ERR_IJ_PS3_R1XLOCK_BUF_ALLOC, &cmd->node_buff); + if (!cmd->node_buff) { + LOG_ERROR("Failed to alloc r1x write lock range node buf memory\n"); + goto l_free_node; +@@ -540,6 +505,7 @@ + + context->cmd_buf = (struct ps3_cmd**)ps3_kcalloc(instance, context->max_cmd_count, + sizeof(struct ps3_cmd*)); ++ INJECT_START(PS3_ERR_IJ_PS3_CMD_BUF_ALLOC, &context->cmd_buf); + if (context->cmd_buf == NULL) { + LOG_ERROR("Failed to kcalloc memory for cmd_buf\n"); + goto l_failed; +@@ -549,6 +515,7 @@ + for (i = 0; i < context->max_cmd_count; i++) { + context->cmd_buf[i] = (struct ps3_cmd*)ps3_kzalloc(instance, + sizeof(struct ps3_cmd)); ++ INJECT_START(PS3_ERR_IJ_PS3_PS3_CMD_ALLOC, &context->cmd_buf[i]); + if (context->cmd_buf[i] == NULL) { + LOG_ERROR("Failed to malloc memory for ps3_cmd\n"); + goto l_failed; +@@ -617,7 +584,6 @@ + cmd->resp_frame = (PS3RespFrame_u *) + (context->response_frame_buf + offset); + cmd->resp_frame_phys = context->response_frame_buf_phys + offset; +- + cmd->index = i; + cmd->is_aborting = 0; + #ifndef _WINDOWS +@@ -702,6 +668,7 @@ + context->max_r1x_cmd_count = (context->max_scsi_cmd_count / 2); + } + ps3_r1x_mode_set(instance); ++ + LOG_DEBUG("host_no:%u max_r1x_cmd_final count:%u\n", + PS3_HOST(instance), context->max_r1x_cmd_count); + +@@ -718,10 +685,6 @@ + context->max_prp_count = PS3_FRAME_REQ_PRP_NUM_FE + + (instance->cmd_attr.nvme_page_size / sizeof(U64)); + +- if (!ps3_ioc_sgl_mode_support(instance, +- &context->sgl_mode_support)) { +- goto l_failed; +- } + ps3_host_max_sge_count(context); + + if (context->max_cmd_count <= instance->max_mgr_cmd_total_count) { +@@ -766,6 +729,7 @@ + } + + instance->scsi_cmd_deliver = alloc_percpu(S64); ++ INJECT_START(PS3_ERR_IJ_PS3_PERCPU_ALLOC, &instance->scsi_cmd_deliver); + if (!instance->scsi_cmd_deliver) { + LOG_ERROR("alloc per_cpu scsi_cmd_deliver failed. hno:%u\n", + PS3_HOST(instance)); +@@ -843,14 +807,73 @@ + + memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); + +- INIT_LIST_HEAD(&cmd->qos_list); +- memset(&cmd->target_pd, 0, sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); +- cmd->target_pd_count = 0; +- cmd->first_over_quota_pd_idx = 0; +- cmd->qos_waitq_flag = 0; ++ INIT_LIST_HEAD(&cmd->qos_list); ++ memset(&cmd->target_pd, 0, sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); ++ cmd->target_pd_count = 0; ++ cmd->first_over_quota_pd_idx = 0; ++ cmd->qos_waitq_flag = 0; ++ memset(&cmd->cmdq_info, 0, sizeof(struct ps3_qos_cmdq_info) * PS3_QOS_MAX_CMDQ_ONE_CMD); ++ cmd->cmdq_count = 0; ++} ++ ++static void ps3_scsi_cmd_content_init(struct ps3_cmd *cmd) ++{ ++ cmd->cmd_word_value = 0; ++#ifndef _WINDOWS ++ cmd->scmd = NULL; ++#else ++ cmd->srb = NULL; ++ memset(&cmd->scmd_imp, 0, sizeof(cmd->scmd_imp)); ++ cmd->scmd = &cmd->scmd_imp; ++#endif ++ cmd->trace_id = 0; ++ cmd->no_reply_word = 0; ++ cmd->os_sge_map_count = 0; ++ INIT_LIST_HEAD(&cmd->cmd_list); ++ cmd->cmd_receive_cb = NULL; ++ cmd->cmd_send_cb = NULL; ++ ++ cmd->cmd_state.state = PS3_CMD_STATE_INIT; ++ cmd->cmd_state.reset_flag = 0; ++ cmd->qos_processing = PS3_FALSE; ++ cmd->time_out = 0; ++ cmd->is_interrupt = PS3_DRV_FALSE; ++ cmd->retry_cnt = 0; ++ cmd->is_force_polling = 0; ++ cmd->is_inserted_c_q = 0; ++ cmd->is_got_r1x = 0; ++ cmd->is_r1x_aborting = 0; ++ cmd->r1x_peer_cmd = NULL; ++ cmd->r1x_reply_flag = 0; ++ cmd->is_r1x_scsi_complete = PS3_FALSE; ++ cmd->flighting = PS3_FALSE; ++ cmd->r1x_read_pd = 0; ++ ++ if (cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].length != 0) ++ memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); ++ ++ if (!ps3_scsih_is_rw_type(cmd->io_attr.rw_flag) && ++ (cmd->transient == NULL || cmd->transient->sge_num == 0)) { ++ memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); ++ } ++ ++ if (cmd->resp_frame->normalRespFrame.respStatus != 0xFF) ++ cmd->resp_frame->normalRespFrame.respStatus = 0xFF; ++ ++ if (cmd->resp_frame->sasRespFrame.status != 0xFF) ++ cmd->resp_frame->sasRespFrame.status = 0xFF; ++ ++ memset((void *)&cmd->sync_done, 0, sizeof(cmd->sync_done)); ++ memset(&cmd->io_attr, 0, sizeof(struct ps3_scsi_io_attr)); ++ INIT_LIST_HEAD(&cmd->qos_list); ++ memset(&cmd->target_pd, 0, sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); ++ cmd->target_pd_count = 0; ++ cmd->first_over_quota_pd_idx = 0; ++ cmd->qos_waitq_flag = 0; + memset(&cmd->cmdq_info, 0, sizeof(struct ps3_qos_cmdq_info) * PS3_QOS_MAX_CMDQ_ONE_CMD); + cmd->cmdq_count = 0; + } ++ + #ifndef _WINDOWS + struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, U32 tag) + { +@@ -871,7 +894,7 @@ + S32 ret = -PS3_FAILED; + + if (cmd->index < (U32)cmd->instance->cmd_attr.cur_can_que) { +- ps3_cmd_content_init(cmd); ++ ps3_scsi_cmd_content_init(cmd); + ret = PS3_SUCCESS; + } + return ret; +@@ -979,7 +1002,7 @@ + goto l_out; + } + +- ps3_cmd_content_init(cmd); ++ ps3_scsi_cmd_content_init(cmd); + if (instance->r1x_mode == PS3_R1X_MODE_NORMAL) { + cmd_pool_free(&context->r1x_scsi_cmd_pool, + &context->r1x_scsi_pool_lock, cmd); +@@ -1004,6 +1027,7 @@ + } + + ps3_cmd_content_init(cmd); ++ INJECT_START(PS3_ERR_FORCE_SET_CMD_INDEX_NOT_MGR, &cmd->index); + if (is_task_cmd(instance, cmd->index)) { + cmd_pool_free(&context->task_cmd_pool, + &context->task_pool_lock, cmd); +@@ -1011,7 +1035,10 @@ + cmd_pool_free(&context->mgr_cmd_pool, + &context->mgr_pool_lock, cmd); + } else { ++ LOG_INFO_IN_IRQ(instance, "host_no:%u CFID:%u not mgr cmd!\n", ++ PS3_HOST(instance), cmd->index); + PS3_BUG(); ++ ret = -PS3_FAILED; + } + l_out: + return ret; +@@ -1034,7 +1061,7 @@ + INJECT_START(PS3_ERR_IJ_FORCE_EVENT_CMD_FAIL_DEAD, &cur_state) + } + if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { +- if (instance->is_probe_finish == PS3_TRUE) { ++ if (instance->is_probe_finish && !instance->is_resume) { + LOG_FILE_ERROR("host_no:%u cannot send async cmd due to %s, return fail\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); + ret = -PS3_FAILED; +@@ -1163,7 +1190,28 @@ + put_cpu_ptr(cmd_deliver); + } + +-S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd) ++void ps3_wait_mgr_cmd_done(struct ps3_instance *instance, Bool time_out) ++{ ++ U16 try_cnt = 0; ++ ++ while (ps3_atomic_read(&instance->cmd_statistics.cmd_delivering) != 0) { ++ INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_2, instance); ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); ++ if (time_out) { ++ try_cnt++; ++ if (try_cnt > PS3_WAIT_SCSI_CMD_DONE_COUNT) { ++ LOG_WARN("hno:%u wait mgr cmd done NOK\n", ++ PS3_HOST(instance)); ++ break; ++ } ++ } ++ } ++ ++ LOG_INFO("wait mgr cmd done end. hno:%u try_cnt[%u]\n", ++ PS3_HOST(instance), try_cnt); ++} ++ ++S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, Bool need_prk_err) + { + S32 ret = PS3_SUCCESS; + struct ps3_cmd *peer_cmd = NULL; +@@ -1178,24 +1226,27 @@ + INJECT_START(PS3_ERR_IJ_FORCE_TASK_MGR_BUSY, instance); + if (unlikely(instance->task_manager_host_busy)) { + INJECT_START(PS3_ERR_IJ_SEND_CMD_TASK_MGR_BUSY, instance); +- LOG_INFO_LIM("host_no:%u cannot send block cmd due to task_manager_host_busy\n", ++ LOG_INFO_LIM_WITH_CHECK(instance, need_prk_err, ++ "host_no:%u cannot send block cmd due to task_manager_host_busy\n", + PS3_HOST(instance)); ++ + ret = -PS3_RETRY; + goto l_out; + } + + INJECT_START(PS3_ERR_IJ_CMD_SEND_FORCE_INS_UNLOAD, instance) + if (!instance->state_machine.is_load) { +- LOG_WARN_LIM("host_no:%u instance state not is_load\n", PS3_HOST(instance)); ++ LOG_WARN_LIM_WITH_CHECK(instance, need_prk_err, ++ "host_no:%u instance state not is_load\n", PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_out; + } + INJECT_START(PS3_ERR_IJ_CMD_SEND_BLOCK, instance); +- INJECT_START(PS3_ERR_IJ_CMD_SEND_FORCE_UNORMAL, instance) ++ INJECT_START(PS3_ERR_IJ_CMD_SEND_FORCE_UNORMAL, instance); + + PS3_IJ_SLEEP(10000, PS3_ERR_IJ_SCSI_DELIVER_DELAY_2); + +- if (!ps3_is_instance_state_normal(instance)) { ++ if (!ps3_is_instance_state_normal(instance, need_prk_err)) { + ret = -PS3_RECOVERED; + goto l_out; + } +@@ -1209,12 +1260,10 @@ + cmd->flighting = PS3_FALSE; + wmb(); + ++ INJECT_START(PS3_ERR_IJ_CMD_BLOCK_BEFORE_SEND_TO_IOC, instance); + ps3_ioc_scsi_cmd_send(instance, &cmd->cmd_word); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_DONE, instance); + if (peer_cmd != NULL) { +- if (ps3_r1x_interval_delay_get() != 0) { +- msleep(ps3_r1x_interval_delay_get()); +- } + PS3_IO_DRV2IOC_START_INC(instance, peer_cmd); + ps3_ioc_scsi_cmd_send(instance, &peer_cmd->cmd_word); + } +@@ -1246,7 +1295,7 @@ + return cmd; + } + +-S32 ps3_cmd_dispatch(struct ps3_instance *instance ,U16 cmd_frame_id, struct PS3ReplyWord *reply_word) ++S32 ps3_cmd_dispatch(struct ps3_instance *instance, U16 cmd_frame_id, struct PS3ReplyWord *reply_word) + { + S32 ret = -PS3_FAILED; + struct ps3_cmd *cmd = NULL; +@@ -1282,6 +1331,8 @@ + cur_state = ps3_atomic_read(&instance->state_machine.state); + INJECT_START(PS3_ERR_IJ_INS_STATE_UNNORMAL, &cur_state) + INJECT_START(PS3_ERR_IJ_INS_STATE_DEAD, &cur_state) ++ INJECT_START(PS3_ERR_IJ_V2_FORCE_INS_STATE_UNNORMAL, instance); ++ INJECT_START(PS3_ERR_IJ_V2_FORCE_INS_DEAD, instance); + if (cur_state == PS3_INSTANCE_STATE_DEAD && + (PS3_IOC_STATE_HALT_SUPPORT(instance) == PS3_TRUE) && + PS3_HALT_CLI_SUPPORT(instance)){ +@@ -1319,3 +1370,259 @@ + l_out: + return ret; + } ++ ++S32 ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, Bool no_check) ++{ ++ S32 ret = PS3_SUCCESS; ++ ++ INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE, instance); ++ if (!no_check && !instance->state_machine.is_load) { ++ LOG_WARN_LIM("hno[%u] instance state not is_load\n", ++ PS3_HOST(instance)); ++ ret = -PS3_IN_UNLOAD; ++ goto l_out; ++ } ++ INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_UNORMAL, instance); ++ if (!ps3_is_instance_state_allow_cmd_execute(instance)) { ++ ret = -PS3_RECOVERED; ++ goto l_out; ++ } ++ INJECT_START(PS3_ERR_IJ_V2_PCIE_ERR, instance); ++ if (ps3_pci_err_recovery_get(instance)) { ++ LOG_WARN_LIM("hno[%u] host in pci err recovery\n", ++ PS3_HOST(instance)); ++ ret = -PS3_IN_PCIE_ERR; ++ goto l_out; ++ } ++l_out: ++ return ret; ++} ++ ++S32 ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd) ++{ ++ S32 ret = PS3_SUCCESS; ++ S32 cur_state = ps3_atomic_read(&instance->state_machine.state); ++ ++ INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE, instance); ++ if (!instance->state_machine.is_load) { ++ if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT) { ++ ret = -PS3_IN_UNLOAD; ++ goto l_failed; ++ } ++ } ++ INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_UNORMAL, instance); ++ INJECT_START(PS3_ERR_IJ_V2_FORCE_INS_DEAD1, instance); ++ if (!ps3_is_instance_state_allow_cmd_execute(instance)) { ++ ret = -PS3_RECOVERED; ++ if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) { ++ cur_state = ps3_atomic_read(&instance->state_machine.state); ++ if (cur_state == PS3_INSTANCE_STATE_QUIT || ++ cur_state == PS3_INSTANCE_STATE_DEAD) { ++ goto l_failed; ++ } ++ cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; ++ ret = -PS3_RESP_ERR; ++ } ++ goto l_failed; ++ } ++ INJECT_START(PS3_ERR_IJ_V2_PCIE_ERR, instance); ++ if (ps3_pci_err_recovery_get(instance)) { ++ ret = -PS3_IN_PCIE_ERR; ++ goto l_failed; ++ } ++ goto l_out; ++ ++l_failed: ++ LOG_WARN_LIM("hno:%u, tid:0x%llx CFID:%u type:%d state:%d send check ret:%d\n", ++ PS3_HOST(instance), cmd->trace_id, cmd->index, PS3_MGR_CMD_TYPE(cmd), cur_state, ret); ++l_out: ++ return ret; ++} ++ ++void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, U8 bit_pos) ++{ ++ U32 i = 0; ++ struct ps3_irq_context *irq_context = &instance->irq_context; ++ struct ps3_cmd_context *cmd_context = &instance->cmd_context; ++ struct ps3_debug_context *debug_context = &instance->debug_context; ++ struct ps3_dump_context *dump_context = &instance->dump_context; ++ struct ps3_dev_context *dev_context = &instance->dev_context; ++ struct ps3_sas_dev_context *ps3_sas_ctx = &instance->sas_dev_context; ++ struct ps3_cmd *cmd = NULL; ++ ++ irq_context->reply_fifo_desc_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ++ irq_context->reply_fifo_desc_buf_phys); ++ irq_context->reply_fifo_desc_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ irq_context->reply_fifo_desc_buf_phys); ++ for (; i < irq_context->valid_msix_vector_count; i++) { ++ irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ++ irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr); ++ irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr); ++ irq_context->reply_fifo_phys_base_addr_buf[i] = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ++ irq_context->reply_fifo_phys_base_addr_buf[i]); ++ irq_context->reply_fifo_phys_base_addr_buf[i] = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ irq_context->reply_fifo_phys_base_addr_buf[i]); ++ } ++ cmd_context->init_frame_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->init_frame_buf_phys); ++ cmd_context->init_frame_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ cmd_context->init_frame_buf_phys); ++ cmd_context->init_filter_table_phy_addr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->init_filter_table_phy_addr); ++ cmd_context->init_filter_table_phy_addr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ cmd_context->init_filter_table_phy_addr); ++ if (cmd_context->init_frame_sys_info_buf != NULL) { ++ cmd_context->init_frame_sys_info_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->init_frame_sys_info_phys); ++ cmd_context->init_frame_sys_info_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ cmd_context->init_frame_sys_info_phys); ++ } ++ instance->ctrl_info_buf_h = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->ctrl_info_buf_h); ++ instance->ctrl_info_buf_h = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->ctrl_info_buf_h); ++ cmd_context->req_frame_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->req_frame_buf_phys); ++ cmd_context->req_frame_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, cmd_context->req_frame_buf_phys); ++ cmd_context->response_frame_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->response_frame_buf_phys); ++ cmd_context->response_frame_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ cmd_context->response_frame_buf_phys); ++ for (i = 0; i < cmd_context->max_cmd_count; i++) { ++ cmd = cmd_context->cmd_buf[i]; ++ if (cmd->ext_buf != NULL) { ++ cmd->ext_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd->ext_buf_phys); ++ cmd->ext_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ cmd->ext_buf_phys); ++ } ++ } ++ if (debug_context->debug_mem_buf != NULL) { ++ debug_context->debug_mem_buf_phy = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, debug_context->debug_mem_buf_phy); ++ debug_context->debug_mem_buf_phy = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ debug_context->debug_mem_buf_phy); ++ for (i = 0; i < debug_context->debug_mem_array_num; i++) { ++ debug_context->debug_mem_buf[i].debugMemAddr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ++ debug_context->debug_mem_buf[i].debugMemAddr); ++ debug_context->debug_mem_buf[i].debugMemAddr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ debug_context->debug_mem_buf[i].debugMemAddr); ++ } ++ } ++ if (dump_context->dump_dma_buf != NULL) { ++ dump_context->dump_dma_addr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dump_context->dump_dma_addr); ++ dump_context->dump_dma_addr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ dump_context->dump_dma_addr); ++ } ++ instance->drv_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->drv_info_buf_phys); ++ instance->drv_info_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->drv_info_buf_phys); ++ instance->host_mem_info_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->host_mem_info_buf_phys); ++ instance->host_mem_info_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ instance->host_mem_info_buf_phys); ++ if (dev_context->pd_list_buf != NULL) { ++ dev_context->pd_list_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->pd_list_buf_phys); ++ dev_context->pd_list_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ dev_context->pd_list_buf_phys); ++ } ++ if (dev_context->pd_info_buf != NULL) { ++ dev_context->pd_info_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->pd_info_buf_phys); ++ dev_context->pd_info_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ dev_context->pd_info_buf_phys); ++ } ++ if (dev_context->vd_list_buf != NULL) { ++ dev_context->vd_list_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->vd_list_buf_phys); ++ dev_context->vd_list_buf_phys = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ dev_context->vd_list_buf_phys); ++ } ++ if (dev_context->vd_info_buf_sync != NULL) { ++ dev_context->vd_info_buf_phys_sync = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->vd_info_buf_phys_sync); ++ dev_context->vd_info_buf_phys_sync = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ dev_context->vd_info_buf_phys_sync); ++ } ++ if (dev_context->vd_info_buf_async != NULL) { ++ dev_context->vd_info_buf_phys_async = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->vd_info_buf_phys_async); ++ dev_context->vd_info_buf_phys_async = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ dev_context->vd_info_buf_phys_async); ++ } ++ if (ps3_sas_ctx->ps3_sas_buff != NULL) { ++ ps3_sas_ctx->ps3_sas_buff_dma_addr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ps3_sas_ctx->ps3_sas_buff_dma_addr); ++ ps3_sas_ctx->ps3_sas_buff_dma_addr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ ps3_sas_ctx->ps3_sas_buff_dma_addr); ++ } ++ if (ps3_sas_ctx->ps3_sas_phy_buff != NULL) { ++ ps3_sas_ctx->ps3_sas_phy_buff_dma_addr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); ++ ps3_sas_ctx->ps3_sas_phy_buff_dma_addr = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); ++ } ++ instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->so_start_addr); ++ instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ instance->so_start_addr); ++ instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->so_end_addr); ++ instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->so_end_addr); ++} ++ ++Bool ps3_bit_pos_update(struct ps3_instance *instance) ++{ ++ U8 old_bit_pos = instance->dma_addr_bit_pos; ++ U8 bit_pos = 0; ++ Bool ret = PS3_FALSE; ++ ++ if (!ps3_ioc_atu_support_retry_read(instance, &bit_pos)) ++ goto l_out; ++ switch (bit_pos) { ++ case PS3_BIT_POS_DEFAULT: ++ case PS3_BIT_POS_44: ++ instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS; ++ break; ++ case PS3_BIT_POS_53: ++ instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F1; ++ break; ++ case PS3_BIT_POS_54: ++ instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F0; ++ break; ++ default: ++ LOG_WARN("hno:%u bit pos value is unexpect %u\n", ++ PS3_HOST(instance), bit_pos); ++ goto l_out; ++ } ++ mb(); /* in order to force CPU ordering */ ++ if (instance->dma_addr_bit_pos == old_bit_pos) { ++ ret = PS3_TRUE; ++ goto l_out; ++ } ++ ps3_dma_addr_bit_pos_update(instance, old_bit_pos); ++ LOG_WARN("hno:%u bit pos %u change to %u\n", ++ PS3_HOST(instance), old_bit_pos, instance->dma_addr_bit_pos); ++ ret = PS3_TRUE; ++l_out: ++ return ret; ++} ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_channel.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_channel.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_channel.h 2025-06-10 20:13:00.209053074 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_channel.h 2025-06-10 20:13:00.471062213 +0800 +@@ -17,7 +17,19 @@ + + #define PS3_DEFAULT_REQ_FRAME_SIZE (256) + +-#define PS3_WAIT_SCSI_CMD_DONE_COUNT 300 ++#define PS3_WAIT_SCSI_CMD_DONE_COUNT (1200) ++ ++enum { ++ DMA_ALIGN_BYTES_4K = 4096, ++ DMA_ALIGN_BYTES_2K = 2048, ++ DMA_ALIGN_BYTES_1K = 1024, ++ DMA_ALIGN_BYTES_512 = 512, ++ DMA_ALIGN_BYTES_256 = 256, ++ DMA_ALIGN_BYTES_128 = 128, ++ DMA_ALIGN_BYTES_64 = 64, ++ DMA_ALIGN_BYTES_16 = 16, ++ DMA_ALIGN_BYTES_4 = 4, ++}; + + enum { + PS3_CMD_STATE_INIT = 0, +@@ -117,7 +129,7 @@ + void *transient_buff[PS3_MAX_IOCTL_SGE_NUM]; + }; + +-#define PS3_QOS_MAX_PD_IN_VD 16 ++#define PS3_QOS_MAX_PD_IN_VD (17) + struct ps3_qos_member_pd_info { + U16 flat_disk_id; + U16 strip_count; +@@ -166,11 +178,7 @@ + U8 is_aborting; + U8 r1x_reply_flag; + U8 qos_processing; +-#ifndef _WINDOWS + U32 os_sge_map_count; +-#else +- U16 os_sge_map_count; +-#endif + struct ps3_cmd_state_t cmd_state; + U16 time_out; + Bool is_interrupt; +@@ -286,7 +294,7 @@ + S32 ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd); + + #ifndef _WINDOWS +-S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd); ++S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, Bool need_prk_err); + #endif + + struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, U16 cmd_frame_id); +@@ -323,4 +331,14 @@ + + void ps3_scsi_cmd_deliver_put(struct ps3_instance *instance); + ++void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, U8 bit_pos); ++ ++Bool ps3_bit_pos_update(struct ps3_instance *instance); ++ ++void ps3_wait_mgr_cmd_done(struct ps3_instance *instance, Bool time_out); ++ ++S32 ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, Bool no_check); ++ ++S32 ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd); ++ + #endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_complete.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_complete.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_complete.c 2025-06-10 20:13:00.210053108 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_complete.c 2025-06-10 20:13:00.471062213 +0800 +@@ -347,6 +347,8 @@ + void ps3_all_reply_fifo_complete(struct ps3_instance *instance) + { + U32 i = 0; ++ if (instance->irq_context.irqs == NULL) ++ return; + for (; i < instance->irq_context.valid_msix_vector_count; ++i) { + (void)ps3_cmd_complete(instance->irq_context.irqs + i); + } +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_stat_def.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_stat_def.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_stat_def.h 2025-06-10 20:13:00.210053108 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_stat_def.h 2025-06-10 20:13:00.472062248 +0800 +@@ -92,8 +92,8 @@ + [PS3_QOS_MGR_PRO] = "qos_mgr_pro", + [PS3_QOS_CMD_PRO] = "qos_cmd_pro", + [PS3_QOS_PD_QUEUE] = "qos_pd_queue", +- [PS3_QOS_VD_QUEUE] = "qos_vd_queue", +- [PS3_QOS_TAG_QUEUE] = "qos_tag_queue", ++ [PS3_QOS_VD_QUEUE] = "qos_vd_queue", ++ [PS3_QOS_TAG_QUEUE] = "qos_tag_queue", + [PS3_QOS_MGR_QUEUE] = "qos_mgr_queue", + [PS3_QOS_CMD_QUEUE] = "qos_cmd_queue", + [PS3_CMD_STAT_COUNT] = "type_unknown", +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_statistics.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_statistics.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_statistics.c 2025-06-10 20:13:00.210053108 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_statistics.c 2025-06-10 20:13:00.471062213 +0800 +@@ -248,9 +248,14 @@ + void ps3_io_statis_clear(struct scsi_device *sdev) + { + struct ps3_scsi_priv_data *data = NULL; +- data = PS3_SDEV_PRI_DATA(sdev); ++ struct ps3_instance *instance = ++ (struct ps3_instance *)sdev->host->hostdata; + +- ps3_dev_io_statis_init(&data->statis); ++ ps3_mutex_lock(&instance->dev_context.dev_priv_lock); ++ data = PS3_SDEV_PRI_DATA(sdev); ++ if (data != NULL) ++ ps3_dev_io_statis_init(&data->statis); ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + } + + void ps3_dev_io_start_inc(struct ps3_instance *instance, +@@ -501,6 +506,7 @@ + ctx->stat_entry_max_count = instance->cmd_context.max_cmd_count; + ctx->cmd_stat_buf = (struct ps3_single_cmd_stat**)ps3_kzalloc(instance, + ctx->stat_entry_max_count * sizeof(struct ps3_single_cmd_stat*)); ++ INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC1, &ctx->cmd_stat_buf); + if (ctx->cmd_stat_buf == NULL) { + LOG_ERROR("failed to kcalloc for cmd_stat_buf\n"); + ret = -PS3_FAILED; +@@ -510,6 +516,7 @@ + for (; i < ctx->stat_entry_max_count; ++i) { + ctx->cmd_stat_buf[i] = (struct ps3_single_cmd_stat*)ps3_kzalloc(instance, + sizeof(struct ps3_single_cmd_stat)); ++ INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC2, &ctx->cmd_stat_buf[i]); + if (ctx->cmd_stat_buf[i] == NULL) { + LOG_ERROR("Failed to alloc mem for ps3_single_cmd_stat\n"); + ret = -PS3_FAILED; +@@ -558,6 +565,7 @@ + ctx->stat_entry_max_count = instance->cmd_context.max_cmd_count; + ctx->last_stat_buf = (struct ps3_single_cmd_stat**)ps3_kzalloc(instance, + ctx->stat_entry_max_count * sizeof(struct ps3_single_cmd_stat*)); ++ INJECT_START(PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC1, &ctx->last_stat_buf); + if (ctx->last_stat_buf == NULL) { + LOG_ERROR("failed to kzalloc for last_stat_buf\n"); + ret = -PS3_FAILED; +@@ -567,6 +575,7 @@ + for (; i < ctx->stat_entry_max_count; ++i) { + ctx->last_stat_buf[i] = (struct ps3_single_cmd_stat*)ps3_kzalloc(instance, + sizeof(struct ps3_single_cmd_stat)); ++ INJECT_START(PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC2, &ctx->last_stat_buf[i]); + if (ctx->last_stat_buf[i] == NULL) { + LOG_ERROR("Failed to alloc mem for ps3_single_cmd_stat\n"); + ret = -PS3_FAILED; +@@ -634,6 +643,7 @@ + ctx->stat_entry_max_count = instance->cmd_context.max_cmd_count; + ctx->cmd_stat_backup_buf = (struct ps3_single_cmd_stat**)ps3_kzalloc(instance, + ctx->stat_entry_max_count * sizeof(struct ps3_single_cmd_stat*)); ++ INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC1, &ctx->cmd_stat_backup_buf); + if (ctx->cmd_stat_backup_buf == NULL) { + LOG_ERROR("failed to kzalloc for cmd_stat_backup_buf\n"); + ret = -PS3_FAILED; +@@ -643,6 +653,7 @@ + for (; i < ctx->stat_entry_max_count; ++i) { + ctx->cmd_stat_backup_buf[i] = (struct ps3_single_cmd_stat*)ps3_kzalloc(instance, + sizeof(struct ps3_single_cmd_stat)); ++ INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC2, &ctx->cmd_stat_backup_buf[i]); + if (ctx->cmd_stat_backup_buf[i] == NULL) { + LOG_ERROR("Failed to alloc mem for ps3_single_cmd_stat\n"); + ret = -PS3_FAILED; +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_statistics.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_statistics.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_cmd_statistics.h 2025-06-10 20:13:00.210053108 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_cmd_statistics.h 2025-06-10 20:13:00.472062248 +0800 +@@ -169,8 +169,13 @@ + + atomic_inc(&device_priv_data->sdev_priv_busy); + #else ++#ifdef PS3_UT ++ atomic_inc(&scmd->device->device_busy); ++#else + (void) scmd; + #endif ++#endif ++ + return; + } + +@@ -184,8 +189,12 @@ + + atomic_dec(&device_priv_data->sdev_priv_busy); + #else ++#ifdef PS3_UT ++ atomic_dec(&scmd->device->device_busy); ++#else + (void) scmd; + #endif ++#endif + return; + } + +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_debug.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_debug.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_debug.c 2025-06-10 20:13:00.210053108 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_debug.c 2025-06-10 20:13:00.472062248 +0800 +@@ -40,8 +40,6 @@ + S8 name[32]; + }; + +-static U32 g_ps3_r1x_intrval_delay = 0; +- + static struct ps3_reg_name g_ps3_reg_name_table[] = { + {0, 0, 8, "reserved0"}, + {0, 0, 1, "ps3Doorbell"}, +@@ -170,24 +168,27 @@ + }; + static inline U64 ps3_util_now_timestamp_ms_get(void) + { +- U64 timenow = 0; ++ U64 timenow = 0; + #ifndef _WINDOWS + + #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +- struct timespec now; +- now = current_kernel_time(); ++ struct timespec now; ++ ++ now = current_kernel_time(); + #else +- struct timespec64 now; +- ktime_get_coarse_real_ts64(&now); ++ struct timespec64 now; ++ ++ ktime_get_coarse_real_ts64(&now); + #endif +- timenow = now.tv_sec * 1000 + now.tv_nsec / 1000000; ++ timenow = now.tv_sec * 1000 + now.tv_nsec / 1000000; + #else +- LARGE_INTEGER now; +- StorPortQuerySystemTime(&now); ++ LARGE_INTEGER now; + +- timenow = (U64)(now.QuadPart / 10000); ++ StorPortQuerySystemTime(&now); ++ ++ timenow = (U64)(now.QuadPart / 10000); + #endif +- return timenow; ++ return timenow; + + } + +@@ -304,6 +305,7 @@ + ctx->debug_mem_vaddr[i].debugMemAddr = + (U64)ps3_dma_alloc_coherent(instance, alloc_size, + &entry[i].debugMemAddr); ++ INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_ADDR_ALLOC, &ctx->debug_mem_vaddr[i].debugMemAddr); + if (ctx->debug_mem_vaddr[i].debugMemAddr == 0) { + LOG_ERROR("hno:%u alloc debug_mem[%u] end failed\n", + PS3_HOST(instance), i); +@@ -323,6 +325,7 @@ + ctx->debug_mem_vaddr[i].debugMemAddr = + (U64)ps3_dma_alloc_coherent(instance, alloc_size, + &entry[i].debugMemAddr); ++ INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_ADDR_ALLOC, &ctx->debug_mem_vaddr[i].debugMemAddr); + if (ctx->debug_mem_vaddr[i].debugMemAddr == 0) { + LOG_ERROR("hno:%u alloc debug_mem index[%u] failed\n", + PS3_HOST(instance), i); +@@ -355,12 +358,14 @@ + } + + if (debug_mem_size > PS3_MAX_DEBUG_MEM_SIZE_PARA) { ++ LOG_WARN("hno:%u debug mem size is greater than the maximum value\n", PS3_HOST(instance)); + ret = -PS3_ENOMEM; + goto l_out; + } + + instance->debug_context.debug_mem_buf = (Ps3DebugMemEntry_s*)ps3_dma_alloc_coherent(instance, + buf_size, &instance->debug_context.debug_mem_buf_phy); ++ INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_BUF_ALLOC, &instance->debug_context.debug_mem_buf); + if (instance->debug_context.debug_mem_buf == NULL) { + LOG_ERROR("hno:%u alloc debug_mem_buf failed\n", PS3_HOST(instance)); + ret = -PS3_ENOMEM; +@@ -426,7 +431,7 @@ + + void ps3_debug_context_init(struct ps3_instance *instance) + { +- memset(&instance->debug_context, 0 , sizeof(struct ps3_debug_context)); ++ memset(&instance->debug_context, 0, sizeof(struct ps3_debug_context)); + instance->debug_context.io_trace_switch = PS3_FALSE; + + ps3_reg_dump_attr_init(instance); +@@ -583,16 +588,6 @@ + return len; + } + +-void ps3_r1x_interval_delay_set(u32 r1x_interval_delay) +-{ +- g_ps3_r1x_intrval_delay = r1x_interval_delay; +-} +- +-U32 ps3_r1x_interval_delay_get(void) +-{ +- return g_ps3_r1x_intrval_delay; +-} +- + ssize_t ps3_event_subscribe_info_get(struct ps3_instance *instance, + char *buf, ssize_t total_len) + { +@@ -1032,7 +1027,7 @@ + LOG_WARN("hno:%u can not start hard reset\n", + PS3_HOST(instance)); + } else { +- ps3_hard_recovery_request(instance); ++ ps3_hard_recovery_request_with_retry(instance); + } + + return count; +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_debug.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_debug.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_debug.h 2025-06-10 20:13:00.210053108 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_debug.h 2025-06-10 20:13:00.472062248 +0800 +@@ -69,10 +69,6 @@ + ssize_t ps3_halt_support_cli_store(struct device *cdev,struct device_attribute *attr, + const char *buf, size_t count); + +-void ps3_r1x_interval_delay_set(u32 r1x_interval_delay); +- +-U32 ps3_r1x_interval_delay_get(void); +- + #if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_device_manager.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_device_manager.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_device_manager.c 2025-06-10 20:13:00.217053353 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_device_manager.c 2025-06-10 20:13:00.478062458 +0800 +@@ -113,6 +113,11 @@ + p_dev_ctx->pd_pool.devs_buffer = NULL; + } + ++ if (p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array != NULL) { ++ ps3_vfree(instance, p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array); ++ p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array = NULL; ++ } ++ + if (p_dev_ctx->vd_pool.devs_buffer != NULL) { + ps3_kfree(instance, p_dev_ctx->vd_pool.devs_buffer); + p_dev_ctx->vd_pool.devs_buffer = NULL; +@@ -162,8 +167,9 @@ + for (i = 0; i < PS3_VD_TABLE_NUM; i++) { + p_vd_table[i].vd_idxs_array = (U16*)ps3_kzalloc(instance, sizeof(U16) * + p_dev_ctx->total_vd_count); ++ INJECT_START(PS3_ERR_IJ_PS3_VD_IDX_ARRAY_ALLOC, &p_vd_table[i].vd_idxs_array); + if (p_vd_table[i].vd_idxs_array == NULL) { +- LOG_ERROR("hno:%u , Failed to allocate VD table %d buffer\n", ++ LOG_ERROR("hno:%u, Failed to allocate VD table %d buffer\n", + PS3_HOST(instance), i); + goto free_dev_buff; + } +@@ -171,8 +177,9 @@ + p_dev_ctx->vd_entries_array[i] = (struct PS3VDEntry*) + ps3_kzalloc(instance, sizeof(struct PS3VDEntry) * + (PS3_MAX_VD_COUNT(instance) + 1)); ++ INJECT_START(PS3_ERR_IJ_PS3_VD_ENTRIES_ARRAY_ALLOC, &p_dev_ctx->vd_entries_array[i]); + if (p_dev_ctx->vd_entries_array[i] == NULL) { +- LOG_ERROR("hno:%u , Failed to allocate VD entry buffer\n", ++ LOG_ERROR("hno:%u, Failed to allocate VD entry buffer\n", + PS3_HOST(instance)); + goto free_dev_buff; + } +@@ -180,6 +187,7 @@ + + vd_pool->devs_buffer = (union PS3Device*)ps3_kzalloc(instance, + sizeof(union PS3Device) * p_dev_ctx->total_vd_count); ++ INJECT_START(PS3_ERR_IJ_PS3_VD_DEVS_BUF_ALLOC, &vd_pool->devs_buffer); + if (vd_pool->devs_buffer == NULL) { + LOG_ERROR("hno:%u Failed to allocate VD pool buffer\n", + PS3_HOST(instance)); +@@ -191,8 +199,9 @@ + p_vd_pri_data_table->vd_pri_data_idxs_array = + (struct ps3_scsi_priv_data**)ps3_vzalloc(instance, + sizeof(struct ps3_scsi_priv_data*) * p_dev_ctx->total_vd_count); ++ INJECT_START(PS3_ERR_IJ_PS3_VD_PRI_DATA_IDXS_ARRAY_ALLOC, &p_vd_pri_data_table->vd_pri_data_idxs_array); + if (p_vd_pri_data_table->vd_pri_data_idxs_array == NULL) { +- LOG_ERROR("hno:%u , Failed to allocate VD R1X table %d buffer\n", ++ LOG_ERROR("hno:%u, Failed to allocate VD R1X table %d buffer\n", + PS3_HOST(instance), i); + goto free_dev_buff; + } +@@ -241,24 +250,27 @@ + p_dev_ctx->pd_entries_array = (struct ps3_pd_entry*) + ps3_kzalloc(instance, sizeof(struct ps3_pd_entry) * + (PS3_MAX_PD_COUNT(instance) + 1)); ++ INJECT_START(PS3_ERR_IJ_PS3_PD_ENTRIES_ARRAY_ALLOC, &p_dev_ctx->pd_entries_array); + if (p_dev_ctx->pd_entries_array == NULL) { +- LOG_ERROR("hno:%u , Failed to allocate PD entry buffer\n", ++ LOG_ERROR("hno:%u, Failed to allocate PD entry buffer\n", + PS3_HOST(instance)); + goto free_dev_pool; + } + + pd_table->pd_idxs_array = (U16*)ps3_kzalloc(instance, sizeof(U16) * + p_dev_ctx->total_pd_count); ++ INJECT_START(PS3_ERR_IJ_PS3_PD_IDX_ARRAY_ALLOC, &pd_table->pd_idxs_array); + if (pd_table->pd_idxs_array == NULL) { +- LOG_ERROR("hno:%u , Failed to allocate PD table buffer\n", ++ LOG_ERROR("hno:%u, Failed to allocate PD table buffer\n", + PS3_HOST(instance)); + goto free_dev_pool; + } + + pd_pool->devs_buffer = (union PS3Device*)ps3_kzalloc(instance, + sizeof(union PS3Device) * p_dev_ctx->total_pd_count); ++ INJECT_START(PS3_ERR_IJ_PS3_PD_DEVS_BUF_ALLOC, &pd_pool->devs_buffer); + if (pd_pool->devs_buffer == NULL) { +- LOG_ERROR("hno:%u , Failed to allocate PD pool buffer\n", ++ LOG_ERROR("hno:%u, Failed to allocate PD pool buffer\n", + PS3_HOST(instance)); + goto free_dev_pool; + } +@@ -405,8 +417,8 @@ + "task_abort_timeout[%u], task_reset_timeout[%u], " + "max_io_size[%u], dev_queue_depth[%u], " + "sector_size[%u], encl_id[%u], pd phy_id[%u], " +- "dma_addr_alignment[%u], dma_len_alignment[%u]" +- "normal_quota[%u] direct_quota[%u]\n" ++ "dma_addr_alignment[%u], dma_len_alignment[%u], " ++ "normal_quota[%u] direct_quota[%u] is_direct_disable[%u]\n" + , PS3_HOST(instance), + PS3_CHANNEL(&pd_entry->disk_pos), + PS3_TARGET(&pd_entry->disk_pos), +@@ -421,7 +433,7 @@ + pd_entry->sector_size, pd_entry->encl_id, + pd_entry->phy_id, pd_entry->dma_addr_alignment, + pd_entry->dma_len_alignment, +- pd_entry->normal_quota, pd_entry->direct_quota ++ pd_entry->normal_quota, pd_entry->direct_quota, pd_entry->is_direct_disable + ); + } + +@@ -439,6 +451,7 @@ + local_entry->max_io_size = pd_info->maxIOSize; + local_entry->dev_queue_depth = pd_info->devQueDepth; + local_entry->sector_size = pd_info->sectorSize; ++ local_entry->is_direct_disable = pd_info->isDirectDisable; + local_entry->encl_id = pd_info->enclId; + local_entry->phy_id = pd_info->phyId; + local_entry->dma_addr_alignment = ps3_pd_dma_alignment_calc(pd_info->dmaAddrAlignShift); +@@ -462,21 +475,21 @@ + struct PS3PDInfo *pd_info = NULL; + struct ps3_dev_context *dev_ctx = &instance->dev_context; + +- LOG_DEBUG("hno:%u , get PD info [%u:%u:%u] start\n", ++ LOG_DEBUG("hno:%u, get PD info [%u:%u:%u] start\n", + PS3_HOST(instance), channel, target_id, pd_id); + + ret = ps3_pd_info_get(instance, channel, target_id, pd_id); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL6, &ret); + if (ret != PS3_SUCCESS) { +- LOG_ERROR("hno:%u , get single PD info [%u:%u:%u] NOK\n", ++ LOG_ERROR("hno:%u, get single PD info [%u:%u:%u] NOK\n", + PS3_HOST(instance), channel, target_id, pd_id); + goto l_out; + } + + pd_info = dev_ctx->pd_info_buf; + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS1, &pd_info->diskPos.diskDev.diskID); +- if (PS3_DEV_INVALID(pd_info->diskPos)) { +- LOG_WARN("hno:%u , cannot found PD info [%u:%u:%u]\n", ++ if (PS3_PDID_INVALID(&pd_info->diskPos)) { ++ LOG_WARN("hno:%u, cannot found PD info [%u:%u:%u]\n", + PS3_HOST(instance), channel, target_id, pd_id); + ret = -PS3_FAILED; + goto l_out; +@@ -549,14 +562,13 @@ + for (i = 0; i < p_dev_ctx->pd_channel_count; i++) { + chan_id = pd_chan[i].channel; + for (j = 0; j < pd_chan[i].max_dev_num; j++) { +- if (PS3_DEV_INVALID(p_pd_pool->devs[chan_id][j].pd.diskPos)) { ++ if (PS3_PDID_INVALID(&p_pd_pool->devs[chan_id][j].pd.diskPos)) + continue; +- } + + ret = ps3_dev_mgr_pd_info_get(instance, chan_id, j, + PS3_PDID(&p_pd_pool->devs[chan_id][j].pd.diskPos)); + if (ret != PS3_SUCCESS) { +- LOG_ERROR("hno:%u , get PD[%u:%u] info NOK\n", ++ LOG_ERROR("hno:%u, get PD[%u:%u] info NOK\n", + PS3_HOST(instance), chan_id, j); + } + } +@@ -603,7 +615,7 @@ + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); +- LOG_ERROR("hno:%u who steal free this cmd,CFID:%d\n", ++ LOG_WARN("hno:%u who steal free this cmd,CFID:%d\n", + PS3_HOST(instance), cmd->index); + instance->dev_context.vd_pending_cmd = NULL; + goto l_out; +@@ -637,6 +649,7 @@ + } + + ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_VDPENDING_CMD); ++ INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_VD_PENDING_FAILED, &ret) + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u unsubscribe vd pending, cancel cmd NOK\n", + PS3_HOST(instance)); +@@ -678,7 +691,7 @@ + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); +- LOG_ERROR("hno:%u free vdpending cmd,CFID:%d\n", ++ LOG_WARN("hno:%u free vdpending cmd,CFID:%d\n", + PS3_HOST(instance), cmd->index); + instance->dev_context.vd_pending_cmd = NULL; + goto l_out; +@@ -845,7 +858,7 @@ + + ret = ps3_vd_info_sync_get(instance, 0, PS3_MAX_VD_COUNT(instance)); + if (ret != PS3_SUCCESS) { +- LOG_ERROR("hno:%u , sync get VD info NOK\n", ++ LOG_ERROR("hno:%u, sync get VD info NOK\n", + PS3_HOST(instance)); + goto l_out; + } +@@ -857,8 +870,8 @@ + PS3_HOST(instance),p_dev_ctx->vd_info_buf_sync->count); + + for (i = 0; i < p_dev_ctx->vd_info_buf_sync->count; i++) { +- if (PS3_DEV_INVALID(p_vd_entry[i].diskPos)) { +- LOG_WARN("hno:%u , init %d of %d vd info NOK, disk_id is 0\n", ++ if (PS3_VDID_INVALID(&p_vd_entry[i].diskPos)) { ++ LOG_WARN("hno:%u, init %d of %d vd info NOK, vdid is 0\n", + PS3_HOST(instance), i, + p_dev_ctx->vd_info_buf_sync->count); + continue; +@@ -996,7 +1009,7 @@ + + ret = ps3_pd_list_get(instance); + if (ret != PS3_SUCCESS) { +- LOG_ERROR("hno:%u , dev mgr get pd list NOK\n", ++ LOG_ERROR("hno:%u, dev mgr get pd list NOK\n", + PS3_HOST(instance)); + goto l_out; + } +@@ -1010,8 +1023,8 @@ + for (i = 0; i < p_pd_list->count; i++) { + p_dev = PS3_DEV(&p_pd_list->devs[i].pd.diskPos); + +- if (PS3_DEV_INVALID(p_pd_list->devs[i].pd.diskPos)) { +- LOG_WARN("hno:%u , get pd list %d dev disk_id is 0\n", ++ if (PS3_PDID_INVALID(&p_pd_list->devs[i].pd.diskPos)) { ++ LOG_WARN("hno:%u, get pd list %d dev pdid is 0\n", + PS3_HOST(instance), i); + continue; + } +@@ -1022,7 +1035,7 @@ + continue; + } + +- LOG_INFO("hno:%u , pd list %d dev[%u:%u:%u], magic[%#x], state[%s]\n", ++ LOG_INFO("hno:%u, pd list %d dev[%u:%u:%u], magic[%#x], state[%s]\n", + PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, + p_dev->phyDiskID, + p_pd_list->devs[i].pd.diskPos.diskMagicNum, +@@ -1046,7 +1059,7 @@ + + ret = ps3_vd_list_get(instance); + if (ret != PS3_SUCCESS) { +- LOG_ERROR("hno:%u , dev mgr get vd list NOK\n", ++ LOG_ERROR("hno:%u, dev mgr get vd list NOK\n", + PS3_HOST(instance)); + goto l_out; + } +@@ -1060,8 +1073,8 @@ + for (i = 0; i < p_vd_list->count; i++) { + p_dev = PS3_DEV(&p_vd_list->devs[i].vd.diskPos); + +- if (PS3_DEV_INVALID(p_vd_list->devs[i].vd.diskPos)) { +- LOG_WARN("hno:%u , get vd list %d dev disk_id is 0\n", ++ if (PS3_VDID_INVALID(&p_vd_list->devs[i].vd.diskPos)) { ++ LOG_WARN("hno:%u, get vd list %d vdid is 0\n", + PS3_HOST(instance), i); + continue; + } +@@ -1072,7 +1085,7 @@ + continue; + } + +- LOG_INFO("hno:%u , vd list %d dev[%u:%u:%u], magic[%#x]\n", ++ LOG_INFO("hno:%u, vd list %d dev[%u:%u:%u], magic[%#x]\n", + PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, + p_dev->virtDiskID, + p_vd_list->devs[i].vd.diskPos.diskMagicNum); +@@ -1153,7 +1166,7 @@ + goto l_out; + } + +- LOG_DEBUG("hno:%u , vd[%u:%u] raid level is:%d\n", ++ LOG_DEBUG("hno:%u, vd[%u:%u] raid level is:%d\n", + PS3_HOST(instance), channel, target_id, p_entry->raidLevel); + + ret = p_entry->raidLevel; +@@ -1178,6 +1191,13 @@ + return ret; + } + ++static inline Bool ps3_dev_is_valid(struct PS3DiskDevPos *diskPos, U8 channel, U16 target_id) ++{ ++ if (PS3_DEV_INVALID(*diskPos) || PS3_CHANNEL(diskPos) != channel || PS3_TARGET(diskPos) != target_id) ++ return PS3_FALSE; ++ return PS3_TRUE; ++} ++ + struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info( + struct ps3_instance *instance, U8 channel, U16 target_id) + { +@@ -1204,7 +1224,7 @@ + p_entry = &p_vd_array[virtDiskIdx]; + + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS, &p_entry->diskPos.diskDev.diskID); +- if (PS3_DEV_INVALID(p_entry->diskPos)) { ++ if (ps3_dev_is_valid(&p_entry->diskPos, channel, target_id) != PS3_TRUE) { + p_entry = NULL; + goto l_out; + } +@@ -1229,7 +1249,7 @@ + p_entry = &p_dev_ctx->pd_entries_array[disk_idx]; + + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS, &p_entry->disk_pos.diskDev.diskID); +- if (PS3_DEV_INVALID(p_entry->disk_pos)) { ++ if (ps3_dev_is_valid(&p_entry->disk_pos, channel, target_id) != PS3_TRUE) { + p_entry = NULL; + goto l_out; + } +@@ -1253,7 +1273,7 @@ + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_id); + + if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(instance))) { +- LOG_ERROR_LIM("hno:%u , dev mgr lookup vd info disk id > max count:%d>%d\n", ++ LOG_ERROR_IN_IRQ(instance, "hno:%u , dev mgr lookup vd info disk id > max count:%d>%d\n", + PS3_HOST(instance), disk_id, + PS3_MAX_VD_COUNT(instance)); + +@@ -1264,7 +1284,7 @@ + p_entry = &p_vd_array[virtDiskIdx]; + + if (PS3_DEV_INVALID(p_entry->diskPos)) { +- LOG_INFO_LIM("hno:%u idx[%d], virDisk[%d] dev id is invalid\n", ++ LOG_INFO_IN_IRQ(instance, "hno:%u idx[%d], virDisk[%d] dev id is invalid\n", + PS3_HOST(instance), p_dev_ctx->vd_table_idx, disk_id); + p_entry = NULL; + goto l_out; +@@ -1280,7 +1300,7 @@ + struct ps3_pd_entry *p_entry = NULL; + + if (unlikely(disk_id > PS3_MAX_PD_COUNT(instance))) { +- LOG_ERROR_LIM("hno:%u , dev mgr lookup pd info disk id > max count:%d>%d\n", ++ LOG_ERROR_IN_IRQ(instance, "hno:%u, dev mgr lookup pd info disk id > max count:%d>%d\n", + PS3_HOST(instance), disk_id, + PS3_MAX_PD_COUNT(instance)); + PS3_BUG(); +@@ -1291,7 +1311,7 @@ + + if (PS3_DEV_INVALID(p_entry->disk_pos) || + p_entry->config_flag == MIC_PD_STATE_UNKNOWN) { +- LOG_INFO_LIM("hno:%u pdid[%d] dev[%x] id is invalid, config_flag[%d]\n", ++ LOG_INFO_IN_IRQ(instance, "hno:%u pdid[%d] dev[%x] id is invalid, config_flag[%d]\n", + PS3_HOST(instance), disk_id, + PS3_DISKID(&p_entry->disk_pos), + p_entry->config_flag); +@@ -1434,10 +1454,6 @@ + if (queue_depth > sdev->host->can_queue) { + queue_depth = sdev->host->can_queue; + } +- if (PS3_IS_VD_CHANNEL(instance, sdev->channel) && +- reason != SCSI_QDEPTH_DEFAULT) { +- goto l_out; +- } + if (reason == SCSI_QDEPTH_DEFAULT || reason == SCSI_QDEPTH_RAMP_UP) { + ret = ps3_adjust_device_queue_depth(sdev, instance, queue_depth); + } else if (reason == SCSI_QDEPTH_QFULL) { +@@ -1498,6 +1514,7 @@ + S32 ret = PS3_SUCCESS; + struct ps3_scsi_priv_data *p_priv_data = NULL; + struct ps3_pd_entry *p_pd_entry = NULL; ++ struct ps3_qos_pd_mgr *p_qos_pd_mgr = NULL; + struct ps3_instance *instance = + (struct ps3_instance*)sdev->host->hostdata; + +@@ -1551,7 +1568,9 @@ + ps3_atomic_set(&p_priv_data->wr_io_outstand, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_total_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_res_cnt, PS3_CMD_STAT_INIT_VALUE); +- ps3_qos_pd_mgr_init(instance, p_pd_entry); ++ p_qos_pd_mgr = ps3_qos_pd_mgr_init(instance, p_pd_entry); ++ if (p_qos_pd_mgr != NULL && p_qos_pd_mgr->dev_type != p_pd_entry->dev_type) ++ ps3_qos_pd_rsc_init(p_qos_pd_mgr, p_pd_entry); + p_priv_data->dev_deling = PS3_FALSE; + p_priv_data->swap_flag = PS3_FALSE; + sdev->hostdata = p_priv_data; +@@ -1611,8 +1630,6 @@ + goto l_out; + } + +- sdev->hostdata = p_priv_data; +- + p_priv_data->disk_pos = p_vd_entry->diskPos; + p_priv_data->dev_type = PS3_DEV_TYPE_VD; + p_priv_data->is_taskmgmt_enable = p_vd_entry->isTaskMgmtEnable; +@@ -1637,19 +1654,23 @@ + ret = -ENOMEM; + goto l_err; + } ++ ps3_mutex_lock(&instance->dev_context.dev_priv_lock); ++ sdev->hostdata = p_priv_data; + + ret = ps3_r1x_lock_prepare_for_vd(instance, sdev, + p_vd_entry->raidLevel); + if(unlikely(PS3_SUCCESS != ret)){ ++ ps3_kfree(instance, p_priv_data->r1x_rb_info); ++ p_priv_data->r1x_rb_info = NULL; ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + LOG_ERROR("hno:%u vd[%u:%u:%u] Failed" + " to allocate raid1x write lock mgr\n", + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_VDID(&p_vd_entry->diskPos)); +- ps3_kfree(instance, p_priv_data->r1x_rb_info); +- p_priv_data->r1x_rb_info = NULL; + ret = -ENOMEM; + goto l_err; + } ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + + p_vd_pri_data_table->vd_pri_data_idxs[PS3_SDEV_CHANNEL(sdev)] + [PS3_SDEV_TARGET(sdev)] = p_priv_data; +@@ -1658,10 +1679,12 @@ + + goto l_out; + l_err: ++ ps3_mutex_lock(&instance->dev_context.dev_priv_lock); + if (p_priv_data != NULL) { + ps3_kfree(instance, p_priv_data); + sdev->hostdata = NULL; + } ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + + l_out: + return ret; +@@ -1697,16 +1720,16 @@ + } + + sdev->hostdata = NULL; ++ INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_FORCE_WAIT, sdev); + + ret = -ENXIO; +- + if (PS3_IS_VD_CHANNEL(instance, sdev->channel)) { + dev_type = PS3_DISK_TYPE_VD; + p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, sdev->channel, + sdev->id); + INJECT_START(PS3_ERR_IJ_FORCE_VD_ENTRY_NULL, &p_vd_entry); + if (p_vd_entry == NULL) { +- LOG_ERROR("hno:%u , cannot found VD[%u:%u] device info\n", ++ LOG_ERROR("hno:%u, cannot found VD[%u:%u] device info\n", + PS3_HOST(instance), sdev->channel, sdev->id); + + goto l_out; +@@ -1720,7 +1743,7 @@ + sdev->id); + INJECT_START(PS3_ERR_IJ_FORCE_PD_ENTRY_NULL, &p_pd_entry); + if (p_pd_entry == NULL) { +- LOG_ERROR("hno:%u , cannot found PD[%u:%u] device info\n", ++ LOG_ERROR("hno:%u, cannot found PD[%u:%u] device info\n", + PS3_HOST(instance), sdev->channel, sdev->id); + + goto l_out; +@@ -1744,6 +1767,9 @@ + } + + p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; ++ ++ INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_FORCE_WAIT, NULL); ++ INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, NULL); + ret = ps3_scsi_add_device_ack(instance, p_diskPos, + dev_type); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL3, &ret); +@@ -1797,6 +1823,7 @@ + goto l_out; + l_dev_ack_failed: + ps3_scsi_slave_destroy(sdev); ++ INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_FORCE_WAIT, sdev); + l_dev_done: + ps3_scsi_remove_device_done(instance, p_diskPos, dev_type); + l_out: +@@ -1827,6 +1854,7 @@ + LOG_INFO("hno[%u], vd[%u:%u] r1x conflict destory\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); ++ INJECT_AT_TIMES(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); + ps3_mutex_lock(&instance->dev_context.dev_priv_lock); + ps3_r1x_lock_destory_for_vd(instance, &p_priv_data->lock_mgr); + ps3_qos_vd_reset(instance, PS3_VDID(&p_priv_data->disk_pos)); +@@ -1909,7 +1937,6 @@ + blk_queue_flag_set(QUEUE_FLAG_NOMERGES, sdev->request_queue); + #endif + blk_queue_virt_boundary(sdev->request_queue, align_mask); +- blk_queue_dma_alignment(sdev->request_queue, (S32)align_mask); + } + + static inline void ps3_nvme_pd_attr_set(struct scsi_device *sdev, +@@ -1947,19 +1974,20 @@ + { + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR >= 8) && (RHEL_MINOR >= 6))) ++ (void)instance; + blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, + sdev->request_queue); + #else + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) + sdev->request_queue->backing_dev_info.capabilities + |= BDI_CAP_STABLE_WRITES; +- LOG_INFO("hno:%u , dev type[%u:%u] capabilities[0x%x]\n", ++ LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(instance), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info.capabilities); + #else + sdev->request_queue->backing_dev_info->capabilities + |= BDI_CAP_STABLE_WRITES; +- LOG_INFO("hno:%u , dev type[%u:%u] capabilities[0x%x]\n", ++ LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(instance), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info->capabilities); + #endif +@@ -1972,10 +2000,10 @@ + return blk_queue_stable_writes(sdev->request_queue); + #else + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) +- return ((sdev->request_queue->backing_dev_info.capabilities & \ ++ return ((sdev->request_queue->backing_dev_info.capabilities & + BDI_CAP_STABLE_WRITES) == BDI_CAP_STABLE_WRITES); + #else +- return ((sdev->request_queue->backing_dev_info->capabilities & \ ++ return ((sdev->request_queue->backing_dev_info->capabilities & + BDI_CAP_STABLE_WRITES) == BDI_CAP_STABLE_WRITES); + #endif + #endif +@@ -1985,19 +2013,20 @@ + { + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR >= 8) && (RHEL_MINOR >= 6))) ++ (void)instance; + blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, + sdev->request_queue); + #else + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) + sdev->request_queue->backing_dev_info.capabilities + &= ~BDI_CAP_STABLE_WRITES;; +- LOG_INFO("hno:%u , dev type[%u:%u] capabilities[0x%x]\n", ++ LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(instance), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info.capabilities); + #else + sdev->request_queue->backing_dev_info->capabilities + &= ~BDI_CAP_STABLE_WRITES;; +- LOG_INFO("hno:%u , dev type[%u:%u] capabilities[0x%x]\n", ++ LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(instance), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info->capabilities); + #endif +@@ -2029,7 +2058,7 @@ + p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; + INJECT_START(PS3_ERR_IJ_FORCE_PRIV_DATA_NULL1, &p_priv_data); + if (unlikely(p_priv_data == NULL)) { +- LOG_ERROR("hno:%u , slave configure have no private data, [%u:%u]\n", ++ LOG_ERROR("hno:%u, slave configure have no private data, [%u:%u]\n", + PS3_HOST(instance), sdev->channel, sdev->id); + PS3_BUG(); + ret = -ENXIO; +@@ -2037,7 +2066,7 @@ + } + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DEV_TYPE, &p_priv_data->dev_type); + if (unlikely(p_priv_data->dev_type == PS3_DEV_TYPE_UNKNOWN)) { +- LOG_ERROR("hno:%u , dev type[%u:%u] is PS3_DEV_TYPE_UNKNOWN\n", ++ LOG_ERROR("hno:%u, dev type[%u:%u] is PS3_DEV_TYPE_UNKNOWN\n", + PS3_HOST(instance), sdev->channel, sdev->id); + ret = -ENXIO; + goto l_out; +@@ -2048,7 +2077,7 @@ + sdev->id); + INJECT_START(PS3_ERR_IJ_FORCE_VD_ENTRY_NULL2, &p_vd_entry); + if (p_vd_entry == NULL) { +- LOG_ERROR("hno:%u , cannot found VD[%u:%u] device info\n", ++ LOG_ERROR("hno:%u, cannot found VD[%u:%u] device info\n", + PS3_HOST(instance), sdev->channel, sdev->id); + ret = -ENXIO; + goto l_out; +@@ -2064,7 +2093,7 @@ + sdev->id); + INJECT_START(PS3_ERR_IJ_FORCE_PD_ENTRY_NULL2, &p_pd_entry); + if (p_pd_entry == NULL) { +- LOG_ERROR("hno:%u , cannot found PD[%u:%u] device info\n", ++ LOG_ERROR("hno:%u, cannot found PD[%u:%u] device info\n", + PS3_HOST(instance), sdev->channel, sdev->id); + ret = -ENXIO; + goto l_out; +@@ -2095,7 +2124,7 @@ + + LOG_INFO("slave_configure, dma_addr_alignment[%d], " + "dma_len_alignment[%d], io_timeout[%u], queue_depth[%u]\n", +- dma_addr_alignment ,dma_len_alignment, io_tmo, queue_depth); ++ dma_addr_alignment, dma_len_alignment, io_tmo, queue_depth); + + blk_queue_rq_timeout(sdev->request_queue, io_tmo * HZ); + +@@ -2136,7 +2165,7 @@ + + if (ps3_sas_is_support_smp(instance) && p_pd_entry != NULL) { + if (ps3_check_pd_is_vd_member(p_pd_entry->config_flag)) { +- LOG_DEBUG("hno:%u , PD[%u:%u] is belong to vd device\n", ++ LOG_DEBUG("hno:%u, PD[%u:%u] is belong to vd device\n", + PS3_HOST(instance), sdev->channel, sdev->id); + sdev->no_uld_attach = 1; + } +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_device_manager.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_device_manager.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_device_manager.h 2025-06-10 20:13:00.217053353 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_device_manager.h 2025-06-10 20:13:00.478062458 +0800 +@@ -59,6 +59,10 @@ + + #define PS3_DEV_INVALID(pos) \ + ((pos).diskDev.diskID == PS3_INVALID_DEV_ID) ++#define PS3_PDID_INVALID(pos) \ ++ (PS3_PDID(pos) == PS3_INVALID_DEV_ID) ++#define PS3_VDID_INVALID(pos) \ ++ (PS3_VDID(pos) == PS3_INVALID_DEV_ID) + #define PS3_IS_VD_CHANNEL(ins, chan) \ + ((ins->dev_context.vd_table[0].vd_idxs[chan] != NULL) ? \ + PS3_DRV_TRUE : PS3_DRV_FALSE) +@@ -233,8 +237,8 @@ + + }; + +-#ifndef _WINDOWS +-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)) ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) || \ ++ (defined(KYLIN_MAJOR) && defined(CONFIG_X86) && (KYLIN_MAJOR == 10 && KYLIN_MINOR == 4))) + #define DRIVER_SUPPORT_PRIV_BUSY + #endif + +@@ -264,22 +268,9 @@ + ULong ata_cmd_busy; + Bool dev_deling; + Bool swap_flag; ++ U16 qmask_count; ++ U8 reserved2[6]; + }; +-#else +-struct ps3_scsi_priv_data { +- struct PS3DiskDevPos disk_pos; +- struct ps3_dev_io_statis statis; +- struct ps3_vd_stream_detect vd_sd[2]; +- struct ps3_r1x_lock_mgr lock_mgr; +- U8 is_taskmgmt_enable : 1; +- U8 task_manager_busy : 1; +- U8 reserved1 : 6; +- U8 dev_type; +- U8 task_abort_timeout; +- U8 task_reset_timeout; +- ULong ata_cmd_busy; +-}; +-#endif + + #ifdef _WINDOWS + +@@ -336,7 +327,8 @@ + struct { + U8 support_ncq:1; + U8 protect:1; +- U8 reserved:6; ++ U8 is_direct_disable:1; ++ U8 reserved:5; + }; + U8 pd_flags; + }; +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_device_manager_sas.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_device_manager_sas.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_device_manager_sas.c 2025-06-10 20:13:00.219053423 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_device_manager_sas.c 2025-06-10 20:13:00.482062597 +0800 +@@ -25,6 +25,12 @@ + return instance->sas_dev_context.is_support_smp; + } + ++static inline Bool ps3_is_sata_end_device(struct ps3_pd_entry *pd_entry) ++{ ++ return (pd_entry->dev_type == PS3_DEV_TYPE_SATA_HDD || ++ pd_entry->dev_type == PS3_DEV_TYPE_SATA_SSD); ++} ++ + S32 ps3_sas_rphy_slot_get(struct ps3_instance *instance, U64 sas_addr, U32 *slot_id) + { + S32 ret = -PS3_FAILED; +@@ -172,6 +178,7 @@ + + INIT_LIST_HEAD(&ps3_phy->port_siblings); + sas_phy = sas_phy_alloc(sas_node->dev, phy_info->phyId); ++ INJECT_START(PS3_ERR_IJ_SAS_ALLOC_PHY_NULL1, &sas_phy); + if (sas_phy == NULL) { + LOG_ERROR("hno:%u alloc node[%d] phys[%d] buffer failed !\n", + PS3_HOST(instance), sas_node->encl_id, +@@ -207,6 +214,7 @@ + sas_phy->maximum_linkrate, sas_phy->maximum_linkrate_hw); + + ret = sas_phy_add(sas_phy); ++ INJECT_START(PS3_ERR_IJ_SAS_PHY_ADD_FAILED1, &ret); + if (ret != 0) { + LOG_ERROR("hno:%u add node[%d]-phys[%d] failed ret[%d] !\n", + PS3_HOST(instance), sas_node->encl_id, +@@ -223,7 +231,7 @@ + void ps3_sas_node_phy_update(struct ps3_instance *instance, struct ps3_sas_phy *ps3_phy, + struct PS3PhyInfo *phy_info) + { +- instance = instance; ++ (void)instance; + ps3_phy->identify.initiator_port_protocols = + phy_info->initiatorPortProtocol; + ps3_phy->identify.target_port_protocols = +@@ -352,6 +360,7 @@ + struct ps3_sas_phy *ps3_phy = NULL; + + sas_port = sas_port_alloc_num(parent_node->dev); ++ INJECT_START(PS3_ERR_IJ_SAS_ALLOC_NUM_NULL, &sas_port); + if (sas_port == NULL) { + LOG_ERROR("hno:%u alloc sas_port on node[%d] failed !\n", + PS3_HOST(instance), parent_node->encl_id); +@@ -359,6 +368,7 @@ + } + + ret = sas_port_add(sas_port); ++ INJECT_START(PS3_ERR_IJ_SAS_PORT_ADD_FAILED, &ret); + if (ret != 0) { + LOG_ERROR("hno:%u add sas_port on node[%d] failed !\n", + PS3_HOST(instance), parent_node->encl_id); +@@ -394,6 +404,7 @@ + sas_rphy->identify = ps3_sas_port->remote_identify; + ret = ps3_scsi_add_device_ack(instance, &pd_entry->disk_pos, + PS3_DISK_TYPE_PD); ++ INJECT_START(PS3_ERR_IJ_SAS_ADD_ACK_FAILED, &ret); + if (unlikely(ret != PS3_SUCCESS)) { + LOG_ERROR("hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] " + "magic[%#x] add scsi device ack NOK, ret %d\n", +@@ -436,7 +447,7 @@ + sas_rphy = sas_expander_alloc(ps3_sas_port->port, + (enum sas_device_type)ps3_sas_port->remote_identify.device_type); + } +- ++ INJECT_START(PS3_ERR_IJ_SAS_ALLOC_PHY_NULL, &sas_rphy); + if (unlikely(sas_rphy == NULL)) { + LOG_ERROR("hno:%u alloc SAS rphy for sas_addr[%016llx] failed !\n", + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); +@@ -457,6 +468,7 @@ + } + + ret = sas_rphy_add(sas_rphy); ++ INJECT_START(PS3_ERR_IJ_SAS_PHY_ADD_FAILED, &ret); + if (unlikely(ret != 0)) { + LOG_ERROR("hno:%u add SAS rphy for sas_addr[%016llx] failed !\n", + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); +@@ -551,6 +563,7 @@ + LOG_ERROR("hno:%u cannot find node sas_addr[%016llx] !\n", + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); + PS3_BUG(); ++ continue; + } + + ps3_sas_expander_node_del(instance, exp_node); +@@ -588,6 +601,7 @@ + + ps3_sas_port->port = ps3_sas_sas_port_create(instance, sas_node, + &ps3_sas_port->phy_list); ++ INJECT_START(PS3_ERR_IJ_SAS_PORT_CREATE_FAIL, ps3_sas_port); + if (unlikely(ps3_sas_port->port == NULL)) { + LOG_ERROR("hno:%u cannot add port on parent[%d] !\n", + PS3_HOST(instance), sas_node->encl_id); +@@ -677,14 +691,25 @@ + LOG_DEBUG("hno:%u find exist port[%016llx] on node[%d]\n", + PS3_HOST(instance), ps3_phy->remote_identify.sas_address, + sas_node->encl_id); +- ps3_sas_port_phy_add(instance, ps3_sas_port, ps3_phy); +- goto l_out; ++ if (ps3_is_sata_end_device(pd_entry) && ++ ps3_sas_port->pd_flat_id != PS3_PDID(&pd_entry->disk_pos)) { ++ LOG_INFO("hno:%u sata end device [%u:%u] not exist but in port\n", ++ PS3_HOST(instance), PS3_CHANNEL(&pd_entry->disk_pos), ++ PS3_TARGET(&pd_entry->disk_pos)); ++ ps3_sas_port_del(instance, ps3_sas_port); ++ ps3_sas_port = NULL; ++ } else { ++ ps3_sas_port_phy_add(instance, ps3_sas_port, ps3_phy); ++ goto l_out; ++ } + } + + ps3_sas_port = (struct ps3_sas_port *)ps3_kzalloc(instance, sizeof(struct ps3_sas_port)); ++ INJECT_START(PS3_ERR_IJ_SAS_PORT_ALLOC_NULL, &ps3_sas_port); + if (ps3_sas_port == NULL) { + LOG_ERROR("hno:%u alloc PS3 port on node[%d] failed !\n", + PS3_HOST(instance), sas_node->encl_id); ++ ret = -PS3_FAILED; + goto l_out; + } + +@@ -693,7 +718,6 @@ + list_add_tail(&ps3_phy->port_siblings, &ps3_sas_port->phy_list); + ps3_phy->attach_port = ps3_sas_port; + ps3_sas_port->phy_count++; +- + ps3_sas_port->pd_flat_id = pd_entry->disk_pos.diskDev.ps3Dev.phyDiskID; + ret = ps3_sas_port_create(instance, sas_node, ps3_sas_port); + if (ret != PS3_SUCCESS) { +@@ -705,6 +729,8 @@ + + goto l_out; + l_failed: ++ list_del(&ps3_phy->port_siblings); ++ ps3_phy->attach_port = NULL; + kfree(ps3_sas_port); + + l_out: +@@ -731,6 +757,7 @@ + + memset(phy_info, 0, PS3_SAS_REQ_BUFF_LEN); + ret = ps3_sas_phy_get(instance, &sas_req_param); ++ INJECT_START(PS3_ERR_IJ_SAS_PHY_GET_ERR1, &ret); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u get encl[%d] all phys info NOK\n", + PS3_HOST(instance), sas_req_param.enclID); +@@ -847,6 +874,8 @@ + U8 i = 0; + ULong flags = 0; + Bool is_exist_port = PS3_TRUE; ++ struct ps3_sas_phy *sas_phy = NULL; ++ struct ps3_sas_phy *sas_phy_next = NULL; + + parent_node = ps3_sas_find_node_by_id(instance, + exp_node->parent_encl_id); +@@ -859,6 +888,7 @@ + ps3_sas_port = ps3_sas_port_find(instance, parent_node, exp_node->sas_address); + if (ps3_sas_port == NULL) { + ps3_sas_port = (struct ps3_sas_port*)ps3_kzalloc(instance, sizeof(struct ps3_sas_port)); ++ INJECT_START(PS3_ERR_IJ_SAS_PORT_ALLOC_NULL1, &ps3_sas_port); + if (ps3_sas_port == NULL) { + LOG_ERROR("hno:%u alloc PS3 port on node[%d] failed !\n", + PS3_HOST(instance), parent_node->encl_id); +@@ -910,6 +940,11 @@ + return ps3_sas_port; + + l_failed: ++ list_for_each_entry_safe(sas_phy, sas_phy_next, ++ &ps3_sas_port->phy_list, port_siblings) { ++ sas_phy->attach_port = NULL; ++ list_del(&sas_phy->port_siblings); ++ } + kfree(ps3_sas_port); + + return NULL; +@@ -944,6 +979,7 @@ + + if (exp_node == NULL) { + exp_node = (struct ps3_sas_node*)ps3_kzalloc(instance, sizeof(struct ps3_sas_node)); ++ INJECT_START(PS3_ERR_IJ_ALLOC_EXP_NODE_NULL, &exp_node); + if (exp_node == NULL) { + LOG_ERROR("hno:%u alloc node[%d] failed !\n", + PS3_HOST(instance), exp_info->enclID); +@@ -959,6 +995,7 @@ + + exp_node->phys = (struct ps3_sas_phy*)ps3_kcalloc(instance, exp_node->phy_count, + sizeof(struct ps3_sas_phy)); ++ INJECT_START(PS3_ERR_IJ_ALLOC_EXP_PHYS_NULL, &exp_node->phys); + if (exp_node->phys == NULL) { + LOG_ERROR("hno:%u alloc exp[%d] phys buffer failed !\n", + PS3_HOST(instance), exp_node->encl_id); +@@ -1171,10 +1208,12 @@ + LOG_INFO("hno:%u get expander list count[%d]\n", + PS3_HOST(instance), p_expanders->count); + ++ INJECT_START(PS3_ERR_HBA_PHY_COUNT_ZERO, &p_expanders->count); + if (p_expanders->count == 0) { + LOG_ERROR("hno:%u expander init info count = 0\n", + PS3_HOST(instance)); +- BUG(); ++ ret = -PS3_FAILED; ++ goto l_out; + } + + ret = ps3_sas_hba_node_init(instance, exp_info, p_expanders->hbaSasAddr); +@@ -1185,11 +1224,9 @@ + } + + for (i = 1; i < p_expanders->count; i++) { +- ret = ps3_sas_expander_node_add(instance, &exp_info[i]); +- if (ret != PS3_SUCCESS) { +- LOG_ERROR("hno:%u init add expander[%d] info NOK\n", ++ if (ps3_sas_expander_node_add(instance, &exp_info[i]) != PS3_SUCCESS) { ++ LOG_WARN("hno:%u init add expander[%d] info NOK\n", + PS3_HOST(instance), exp_info[i].enclID); +- goto l_out; + } + } + +@@ -1223,7 +1260,7 @@ + ps3_sas_ctx->ps3_sas_buff = ps3_dma_alloc_coherent(instance, + PS3_SAS_REQ_BUFF_LEN, + &ps3_sas_ctx->ps3_sas_buff_dma_addr); +- ++ INJECT_START(PS3_ERR_IJ_PS3_SAS_BUF_ALLOC, &ps3_sas_ctx->ps3_sas_buff); + if (ps3_sas_ctx->ps3_sas_buff == NULL) { + LOG_ERROR("hno:%u alloc SAS req buffer failed !\n", + PS3_HOST(instance)); +@@ -1255,7 +1292,7 @@ + (struct PS3PhyInfo *)ps3_dma_alloc_coherent(instance, + PS3_SAS_REQ_BUFF_LEN, + &ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); +- ++ INJECT_START(PS3_ERR_IJ_PS3_SAS_PHY_BUF_ALLOC, &ps3_sas_ctx->ps3_sas_phy_buff); + if (ps3_sas_ctx->ps3_sas_phy_buff == NULL) { + LOG_ERROR("hno:%u alloc SAS req buffer failed !\n", + PS3_HOST(instance)); +@@ -1664,6 +1701,7 @@ + + memset(phy_info, 0, PS3_SAS_REQ_BUFF_LEN); + ret = ps3_sas_phy_get(instance, &sas_req_param); ++ INJECT_START(PS3_ERR_IJ_SAS_PHY_GET_ERR, &ret); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u init get expander NOK\n", + PS3_HOST(instance)); +@@ -1687,7 +1725,7 @@ + (struct PS3ExpanderInfo *)instance->sas_dev_context.ps3_sas_buff; + struct PS3SasMgr sas_req_param; + +- memset(&sas_req_param, 0 , sizeof(sas_req_param)); ++ memset(&sas_req_param, 0, sizeof(sas_req_param)); + sas_req_param.enclID = encl_id; + + LOG_WARN("hno:%u enter sas expander add encl_id[%d] !\n", +@@ -1706,11 +1744,13 @@ + ret = -PS3_FAILED; + goto l_out; + } +- ++ INJECT_START(PS3_ERR_EXP_ID_ERR, &encl_id); + if (exp_info->enclID != encl_id) { + LOG_ERROR("hno:%u got expander[%d] is not [%d]\n", + PS3_HOST(instance), exp_info->enclID, encl_id); +- BUG(); ++ PS3_BUG(); ++ ret = -PS3_FAILED; ++ goto l_out; + } + + ret = ps3_sas_expander_event_update(instance, exp_info->parentId); +@@ -1786,11 +1826,11 @@ + S32 ret_map = PS3_SUCCESS; + U32 i = 0; + +- LOG_DEBUG("hno:%u ,event detail count[%d]\n", ++ LOG_DEBUG("hno:%u, event detail count[%d]\n", + PS3_HOST(instance), event_cnt); + + for (i = 0; i < event_cnt; i++) { +- LOG_INFO("hno:%u ,event detail %d eventCode is [%s], encl_Id[%d]\n", ++ LOG_INFO("hno:%u, event detail %d eventCode is [%s], encl_Id[%d]\n", + PS3_HOST(instance), i, mgrEvtCodeTrans(event_detail[i].eventCode), + event_detail[i].EnclId); + +@@ -1840,8 +1880,7 @@ + pd_entry->encl_id); + goto l_out; + } +- +- if (pd_entry->phy_id > parent_node->phy_count) { ++ if (pd_entry->phy_id >= parent_node->phy_count) { + LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] exceed node phy_count[%u] !\n", + PS3_HOST(instance), softChan, devID, phyDiskID, + pd_entry->phy_id, parent_node->phy_count); +@@ -1900,12 +1939,12 @@ + parent_node = ps3_sas_find_node_by_id(instance, encl_id); + if (parent_node == NULL) { + LOG_ERROR("hno:%u add end device channel[%u:%u:%u] cannot found node[%u] !\n", +- PS3_HOST(instance),softChan, devID, phyDiskID, ++ PS3_HOST(instance), softChan, devID, phyDiskID, + encl_id); + goto l_out; + } + +- if (phy_id > parent_node->phy_count) { ++ if (phy_id >= parent_node->phy_count) { + LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] exceed node phy_count[%u] !\n", + PS3_HOST(instance), softChan, devID, phyDiskID, + phy_id, parent_node->phy_count); +@@ -1958,8 +1997,9 @@ + + instance = (struct ps3_instance *)shost_priv(host); + channel_info = &instance->ctrl_info.channelInfo; +- ++ INJECT_START(PS3_ERR_IJ_PD_ATTR, NULL); + ps3_mutex_lock(&instance->dev_context.dev_scan_lock); ++ INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_PD_ATTR_WAIT_PD_ATTR, PS3_ERR_IJ_PD_ATTR, NULL); + for (i = 0; i < channel_info->channelNum; i++) { + if ((channel_info->channels[i].channelType == PS3_CHAN_TYPE_PD) && + (channel == SCAN_WILD_CARD || channel == i)) { +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_device_update.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_device_update.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_device_update.c 2025-06-10 20:13:00.220053457 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_device_update.c 2025-06-10 20:13:00.483062632 +0800 +@@ -43,7 +43,10 @@ + U32 ps3_scsi_dev_magic(struct ps3_instance *instance, struct scsi_device *sdev) + { + U32 dev_magic_num = 0; +- struct ps3_scsi_priv_data *p_priv_data = PS3_SDEV_PRI_DATA(sdev); ++ struct ps3_scsi_priv_data *p_priv_data = NULL; ++ ++ ps3_mutex_lock(&instance->dev_context.dev_priv_lock); ++ p_priv_data = PS3_SDEV_PRI_DATA(sdev); + if (p_priv_data != NULL) { + if (PS3_IS_VD_CHANNEL(instance, PS3_SDEV_CHANNEL(sdev)) || + ps3_sas_is_support_smp(instance)) { +@@ -52,6 +55,7 @@ + dev_magic_num = p_priv_data->disk_pos.checkSum; + } + } ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + + return dev_magic_num; + } +@@ -83,7 +87,7 @@ + #if (LINUX_VERSION_CODE > KERNEL_VERSION(4,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) + if (!instance->is_support_jbod && + ps3_check_pd_is_vd_member(config_flag)) { +- LOG_DEBUG("hno:%u PD[%u:%u:%u] is vd componet, config_flag[%s] \n", ++ LOG_DEBUG("hno:%u PD[%u:%u:%u] is vd component, config_flag[%s]\n", + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_PDID(disk_pos), + getPdStateName((MicPdState_e)config_flag, instance->is_raid)); +@@ -173,7 +177,7 @@ + ret = ps3_scsi_add_device_ack(instance, disk_pos, dev_type); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL2, &ret); + if (ret != PS3_SUCCESS) { +- LOG_ERROR("hno:%u dev[%u:%u] magic[%#x] add scsi device ack NOK, ret %d\n", ++ LOG_WARN("hno:%u dev[%u:%u] magic[%#x] add scsi device ack NOK, ret %d\n", + PS3_HOST(instance), channel, id, + disk_pos->diskMagicNum, ret); + } else { +@@ -321,12 +325,14 @@ + struct scsi_device *sdev) + { + S32 ret = PS3_SUCCESS; +-#ifndef _WINDOWS + struct ps3_scsi_priv_data *p_priv_data = NULL; +-#endif ++ + U8 dev_type = PS3_DISK_TYPE_UNKNOWN; + U8 channel = PS3_SDEV_CHANNEL(sdev); + U16 target_id = PS3_SDEV_TARGET(sdev); ++ struct PS3DiskDevPos disk_pos; ++ U8 encl_id = 0; ++ U8 phy_id = 0; + + if (PS3_IS_PD_CHANNEL(instance, channel)) { + dev_type = PS3_DISK_TYPE_PD; +@@ -340,33 +346,42 @@ + goto l_out; + } + +-#ifndef _WINDOWS ++ ps3_mutex_lock(&instance->dev_context.dev_priv_lock); + p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; +- ps3_qos_disk_del(instance, p_priv_data); +- if (ps3_sas_is_support_smp(instance) && dev_type == PS3_DISK_TYPE_PD && +- p_priv_data->dev_type != PS3_DEV_TYPE_NVME_SSD && +- p_priv_data->dev_type != PS3_DEV_TYPE_VEP) { +- ps3_sas_remove_device(instance, &p_priv_data->disk_pos, +- p_priv_data->encl_id, p_priv_data->phy_id); +- } else { +-#endif +- LOG_WARN("remove device channel[%u], id[%u] begin\n", channel, target_id); +- if (p_priv_data->dev_type == PS3_DEV_TYPE_VD && +- p_priv_data->lock_mgr.hash_mgr != NULL) { +- LOG_INFO("clean r1x conflict queue of dev[%u:%u], begin\n", +- channel, target_id); +- p_priv_data->lock_mgr.dev_deling = PS3_TRUE; +- ps3_r1x_conflict_queue_clean(p_priv_data, +- PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT)); +- LOG_INFO("clean r1x conflict queue of dev[%u:%u], end\n", +- channel, target_id); ++ if (p_priv_data != NULL) { ++ INJECT_AT_TIMES(PS3_ERR_IJ_FORCE_WAIT, sdev); ++ ++ INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_DEL_DEV_WAIT_OS_PRIV_DATA, ++ PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); ++ ++ ps3_qos_disk_del(instance, p_priv_data); ++ if (ps3_sas_is_support_smp(instance) && dev_type == PS3_DISK_TYPE_PD && ++ p_priv_data->dev_type != PS3_DEV_TYPE_NVME_SSD && ++ p_priv_data->dev_type != PS3_DEV_TYPE_VEP) { ++ memset(&disk_pos, 0, sizeof(struct PS3DiskDevPos)); ++ memcpy(&disk_pos, &p_priv_data->disk_pos, sizeof(struct PS3DiskDevPos)); ++ encl_id = p_priv_data->encl_id; ++ phy_id = p_priv_data->phy_id; ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ++ ps3_sas_remove_device(instance, &disk_pos, encl_id, phy_id); ++ } else { ++ if (p_priv_data->dev_type == PS3_DEV_TYPE_VD && ++ p_priv_data->lock_mgr.hash_mgr != NULL) { ++ p_priv_data->lock_mgr.dev_deling = PS3_TRUE; ++ ps3_r1x_conflict_queue_clean(p_priv_data, ++ PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT)); ++ } ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ++ LOG_WARN("remove device channel[%u], id[%u] begin\n", channel, target_id); ++ ps3_scsi_remove_device(instance, sdev); ++ LOG_WARN("remove device channel[%u], id[%u] end\n", channel, target_id); + } ++ } else { + +- ps3_scsi_remove_device(instance, sdev); +- LOG_WARN("remove device channel[%u], id[%u] end\n", channel, target_id); +-#ifndef _WINDOWS ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ++ LOG_DEBUG("hno:%u del disk, priv data NULL, [%u:%u],\n", ++ PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), PS3_SDEV_TARGET(sdev)); + } +-#endif + l_out: + return ret; + } +@@ -397,6 +412,7 @@ + goto l_out; + } + #endif ++ INJECT_AT_TIMES(PS3_ERR_IJ_FORCE_WAIT, sdev); + ret = _ps3_del_disk(instance, sdev); + ps3_scsi_device_put(instance, sdev); + l_out: +@@ -414,7 +430,7 @@ + S32 ret = -PS3_FAILED; + PS3DiskDev_u vd_id = {0}; + struct PS3VDEntry *p_vd_entry = NULL; +- ++ U16 virtDiskIdx = PS3_INVALID_DEV_ID; + vd_id.ps3Dev.virtDiskID = dev->virtDiskID; + vd_id.ps3Dev.softChan = dev->softChan; + vd_id.ps3Dev.devID = dev->devID; +@@ -422,18 +438,31 @@ + ret = ps3_vd_info_sync_get(instance, vd_id.diskID, 1); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL1, &ret); + if (ret != PS3_SUCCESS) { +- LOG_ERROR("hno:%u , sync get VD info NOK\n", ++ LOG_ERROR("hno:%u, sync get VD info NOK\n", + PS3_HOST(instance)); + goto l_out; + } + INJECT_START(PS3_ERR_IJ_FORCE_VD_COUNT_ERR, &instance->dev_context.vd_info_buf_sync->count); + if (instance->dev_context.vd_info_buf_sync->count != 1) { +- LOG_ERROR("hno:%u , single add VD, has no info\n", ++ LOG_ERROR("hno:%u, single add VD, has no info\n", + PS3_HOST(instance)); + goto l_out; + } + + p_vd_entry = instance->dev_context.vd_info_buf_sync->vds; ++ if (PS3_VDID_INVALID(&p_vd_entry->diskPos)) { ++ LOG_WARN("hno:%u, init single vd info NOK, vdid is 0\n", ++ PS3_HOST(instance)); ++ p_vd_entry = NULL; ++ goto l_out; ++ } ++ virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), PS3_VDID(&p_vd_entry->diskPos)); ++ if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(instance))) { ++ LOG_WARN("hno:%u, init single vd info NOK, vir_id[%d] > max[%d]\n", ++ PS3_HOST(instance), virtDiskIdx, PS3_MAX_VD_COUNT(instance)); ++ p_vd_entry = NULL; ++ goto l_out; ++ } + INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN, dev); + if (PS3_CHANNEL(&p_vd_entry->diskPos) != dev->softChan || + PS3_TARGET(&p_vd_entry->diskPos) != dev->devID) { +@@ -491,7 +520,7 @@ + + ps3_vd_info_show(instance, &p_vd_array[virtDiskIdx]); + +- LOG_DEBUG("hno:%u ,idx[%d], VD[%u:%u] single add, got vd info\n", ++ LOG_DEBUG("hno:%u, idx[%d], VD[%u:%u] single add, got vd info\n", + PS3_HOST(instance), p_dev_ctx->vd_table_idx, dev->softChan, + dev->devID); + l_out: +@@ -554,27 +583,41 @@ + #if (LINUX_VERSION_CODE > KERNEL_VERSION(4,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) + (void)sdev; + if (ps3_check_pd_is_vd_member(local_entry->config_flag)) { +- LOG_WARN("hno:%u change ready to componet, remove device channel[%u], id[%u], begin\n", ++ LOG_WARN("hno:%u change ready to component, remove device channel[%u], id[%u], begin\n", + PS3_HOST(instance), + PS3_CHANNEL(&local_entry->disk_pos), + PS3_TARGET(&local_entry->disk_pos)); +- ps3_pd_del(instance, &local_entry->disk_pos, MIC_PD_STATE_UNKNOWN); +- LOG_WARN("hno:%u change ready to componet, remove device channel[%u], id[%u] end\n", ++ ps3_pd_del(instance, &local_entry->disk_pos, local_entry->config_flag); ++ LOG_WARN("hno:%u change ready to component, remove device channel[%u], id[%u] end\n", + PS3_HOST(instance), + PS3_CHANNEL(&local_entry->disk_pos), + PS3_TARGET(&local_entry->disk_pos)); + } else { +- LOG_WARN("hno:%u change componet to ready, add device channel[%u], id[%u], begin\n", ++ ps3_mutex_lock(&instance->dev_context.dev_scan_lock); ++ sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(&local_entry->disk_pos), ++ PS3_TARGET(&local_entry->disk_pos), 0); ++ if (sdev) { ++ ps3_scsi_device_put(instance, sdev); ++ ps3_mutex_unlock(&instance->dev_context.dev_scan_lock); ++ } else { ++ ps3_mutex_unlock(&instance->dev_context.dev_scan_lock); ++ ps3_linx80_vd_member_change(instance, local_entry); ++ } ++ LOG_WARN("hno:%u change component to ready, add device channel[%u], id[%u], begin\n", + PS3_HOST(instance), + PS3_CHANNEL(&local_entry->disk_pos), + PS3_TARGET(&local_entry->disk_pos)); + ps3_pd_add(instance, &local_entry->disk_pos); +- LOG_WARN("hno:%u change componet to ready, add device channel[%u], id[%u], end\n", ++ LOG_WARN("hno:%u change component to ready, add device channel[%u], id[%u], end\n", + PS3_HOST(instance), + PS3_CHANNEL(&local_entry->disk_pos), + PS3_TARGET(&local_entry->disk_pos)); + } + #else ++ ++ INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_PD_ATTR_WAIT_OS_SCAN, PS3_ERR_IJ_OS_SCAN, NULL); ++ INJECT_START(PS3_ERR_IJ_OS_SCAN, NULL); ++ ps3_mutex_lock(&instance->dev_context.dev_scan_lock); + sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(&local_entry->disk_pos), + PS3_TARGET(&local_entry->disk_pos), 0); + if (sdev) { +@@ -582,25 +625,26 @@ + if (sdev->no_uld_attach != 1) { + sdev->no_uld_attach = 1; + ps3_qos_vd_member_change(instance, local_entry, sdev, PS3_TRUE); +- LOG_WARN("hno:%u pd[%u:%u] change ready to componet start\n", ++ LOG_WARN("hno:%u pd[%u:%u] change ready to component start\n", + PS3_HOST(instance), sdev->channel, sdev->id); + PS3_WARN_ON(scsi_device_reprobe(sdev)); +- LOG_WARN("hno:%u pd[%u:%u] change ready to componet end\n", ++ LOG_WARN("hno:%u pd[%u:%u] change ready to component end\n", + PS3_HOST(instance), sdev->channel, sdev->id); + } + } else { + if (sdev->no_uld_attach != 0) { + sdev->no_uld_attach = 0; + ps3_qos_vd_member_change(instance, local_entry, sdev, PS3_FALSE); +- LOG_WARN("hno:%u pd[%u:%u] change componet to ready start\n", ++ LOG_WARN("hno:%u pd[%u:%u] change component to ready start\n", + PS3_HOST(instance), sdev->channel, sdev->id); + PS3_WARN_ON(scsi_device_reprobe(sdev)); +- LOG_WARN("hno:%u pd[%u:%u] change componet to ready end\n", ++ LOG_WARN("hno:%u pd[%u:%u] change component to ready end\n", + PS3_HOST(instance), sdev->channel, sdev->id); + } + } + ps3_scsi_device_put(instance, sdev); + } ++ ps3_mutex_unlock(&instance->dev_context.dev_scan_lock); + #endif + l_out: + return; +@@ -663,10 +707,14 @@ + goto l_out; + } + ++ INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, ++ PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); + if (!_ps3_add_disk_prepare(instance, dev_pos_newes)) { + goto l_out; + } + ++ INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, ++ PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); + ret = _ps3_add_disk(instance, PS3_CHANNEL(dev_pos_newes), + PS3_TARGET(dev_pos_newes), disk_type); + if (ret != PS3_SUCCESS) { +@@ -932,9 +980,10 @@ + struct PS3DiskDevPos *dev_pos, union PS3Device *list_item) + { + S32 ret = PS3_SUCCESS; ++ U8 channel = dev_pos->diskDev.ps3Dev.softChan; + struct ps3_pd_entry *p_pd_entry = NULL; +- +- if (unlikely(!PS3_IS_PD_CHANNEL(instance, PS3_CHANNEL(dev_pos)))) { ++ INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN1, &channel); ++ if (unlikely(!PS3_IS_PD_CHANNEL(instance, channel))) { + LOG_ERROR("hno:%u , PD[%u:%u] info update, but channel is not pd\n", + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); +@@ -959,7 +1008,7 @@ + ret = ps3_dev_mgr_pd_info_get(instance, PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos), PS3_PDID(dev_pos)); + if (ret != PS3_SUCCESS) { +- LOG_ERROR("hno:%u , single add get PD[%u:%u] info NOK\n", ++ LOG_ERROR("hno:%u, single add get PD[%u:%u] info NOK\n", + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); + goto l_out; +@@ -1066,26 +1115,21 @@ + struct ps3_scsi_priv_data *scsi_priv = NULL; + Bool ret = PS3_TRUE; + +- if (disk_Pos == NULL) { +- LOG_DEBUG("host[%u], get sdev pose inout NULL\n", +- PS3_HOST(instance)); +- PS3_BUG(); +- } +- +-#ifdef _WINDOWS +- sdev = ps3_scsi_device_lookup_win(instance, channel, target_id); +- if (unlikely(sdev == NULL || sdev->add_ack != 1)) { +- ret = PS3_FALSE; +- } +-#else + sdev = ps3_scsi_device_lookup(instance, channel, target_id, 0); + if(unlikely(sdev == NULL)) { + ret = PS3_FALSE; + } +-#endif + if (ret) { ++ ps3_mutex_lock(&instance->dev_context.dev_priv_lock); + scsi_priv = PS3_SDEV_PRI_DATA(sdev); +- *disk_Pos = scsi_priv->disk_pos; ++ if (scsi_priv != NULL) { ++ *disk_Pos = scsi_priv->disk_pos; ++ } else { ++ ret = PS3_FALSE; ++ LOG_DEBUG("hno:%u get sdev pos, priv data NULL, [%u:%u],\n", ++ PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), PS3_SDEV_TARGET(sdev)); ++ } ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + ps3_scsi_device_put(instance, sdev); + } + +@@ -1151,7 +1195,7 @@ + struct ps3_channel *pd_chan = instance->dev_context.channel_pd; + struct ps3_dev_context *p_dev_ctx = &instance->dev_context; + +- LOG_DEBUG("hno:%u ,ready to update full pd count\n", ++ LOG_DEBUG("hno:%u, ready to update full pd count\n", + PS3_HOST(instance)); + + ret = ps3_dev_mgr_pd_list_get(instance); +@@ -1172,7 +1216,7 @@ + } + + l_out: +- LOG_DEBUG("hno:%u ,update full pd count end\n", ++ LOG_DEBUG("hno:%u, update full pd count end\n", + PS3_HOST(instance)); + + return ret; +@@ -1239,7 +1283,7 @@ + + ret = ps3_pd_list_get(instance); + if (ret != PS3_SUCCESS) { +- LOG_ERROR("hno:%u , dev mgr get pd list NOK\n", ++ LOG_ERROR("hno:%u, dev mgr get pd list NOK\n", + PS3_HOST(instance)); + goto l_out; + } +@@ -1250,8 +1294,8 @@ + for (i = 0; i < p_pd_list->count; i++) { + p_dev = PS3_DEV(&p_pd_list->devs[i].pd.diskPos); + +- if (PS3_DEV_INVALID(p_pd_list->devs[i].pd.diskPos)) { +- LOG_WARN("hno:%u check pd list %d dev disk_id is 0\n", ++ if (PS3_PDID_INVALID(&p_pd_list->devs[i].pd.diskPos)) { ++ LOG_WARN("hno:%u check pd list %d dev pdid is 0\n", + PS3_HOST(instance), i); + continue; + } +@@ -1358,7 +1402,7 @@ + S32 ret_map = PS3_SUCCESS; + U32 i = 0; + +- LOG_INFO("hno:%u ,event detail count[%d]\n", ++ LOG_INFO("hno:%u, event detail count[%d]\n", + PS3_HOST(instance), event_cnt); + + ps3_dev_update_pre_check(event_detail, event_cnt); +@@ -1458,18 +1502,25 @@ + struct ps3_vd_table *p_old_vd_tb = &p_dev_ctx->vd_table[old_vd_table_idx]; + struct PS3VDEntry *p_old_vd_array = p_dev_ctx->vd_entries_array[old_vd_table_idx]; + struct PS3VDEntry *p_vd_entry = p_dev_ctx->vd_info_buf_async->vds; ++ struct PS3VDEntry *vd_entry_old = NULL; + struct PS3Dev *p_dev = NULL; + U16 virtDiskIdx = PS3_INVALID_DEV_ID; + struct scsi_device *sdev = NULL; + + memcpy(p_new_vd_tb->vd_idxs_array, p_old_vd_tb->vd_idxs_array, + p_dev_ctx->total_vd_count * sizeof(U16)); +- memcpy(p_new_vd_array, p_old_vd_array, PS3_MAX_VD_COUNT(cmd->instance) * ++ memcpy(p_new_vd_array, p_old_vd_array, (PS3_MAX_VD_COUNT(cmd->instance) + 1) * + sizeof(struct PS3VDEntry)); + + for (i = 0; i < p_dev_ctx->vd_info_buf_async->count; i++) { ++ if (PS3_VDID_INVALID(&p_vd_entry[i].diskPos)) { ++ LOG_WARN_IN_IRQ(cmd->instance, ++ "hno:%u, init %d of %d vd info NOK, vdid is 0\n", ++ PS3_HOST(cmd->instance), i, ++ p_dev_ctx->vd_info_buf_sync->count); ++ continue; ++ } + p_dev = PS3_DEV(&p_vd_entry[i].diskPos); +- + if (!ps3_dev_id_valid_check(cmd->instance, (U8)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_VD)) { + LOG_ERROR_IN_IRQ(cmd->instance, +@@ -1481,16 +1532,23 @@ + PS3_BUG_NO_SYNC(); + continue; + } +- ++ virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(cmd->instance), p_dev->virtDiskID); ++ if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(cmd->instance))) { ++ LOG_WARN_IN_IRQ(cmd->instance, "hno:%u, init %d of %d vd info NOK, vir_id[%d] > max[%d]\n", ++ PS3_HOST(cmd->instance), i, ++ p_dev_ctx->vd_info_buf_sync->count, ++ virtDiskIdx, PS3_MAX_VD_COUNT(cmd->instance)); ++ continue; ++ } + LOG_INFO_IN_IRQ(cmd->instance, + "hno:%u update vd[%u:%u] info\n", + PS3_HOST(cmd->instance), p_dev->softChan, p_dev->devID); + + ps3_qos_vd_init(cmd->instance, &p_vd_entry[i]); +- ++ vd_entry_old = ps3_dev_mgr_lookup_vd_info_by_id(cmd->instance, p_dev->virtDiskID); ++ ps3_qos_vd_attr_change(cmd->instance, vd_entry_old, &p_vd_entry[i]); + p_new_vd_tb->vd_idxs[p_dev->softChan][p_dev->devID] = + p_dev->virtDiskID; +- virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(cmd->instance), p_dev->virtDiskID); + memcpy(&p_new_vd_array[virtDiskIdx], &p_vd_entry[i], + sizeof(struct PS3VDEntry)); + +@@ -1606,7 +1664,7 @@ + ps3_mgr_cmd_free(instance, cmd); + ret = ps3_dev_mgr_vd_info_subscribe(instance); + if (ret != PS3_SUCCESS) { +- LOG_INFO("hno:%u subscribe failed!\n", ++ LOG_INFO_IN_IRQ(instance, "hno:%u subscribe failed!\n", + PS3_HOST(instance)); + } + +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_drv_readme.sh ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_drv_readme.sh +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_drv_readme.sh 2025-06-10 20:13:00.220053457 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_drv_readme.sh 1970-01-01 08:00:00.000000000 +0800 +@@ -1,51 +0,0 @@ +-#!/bin/bash +-# +-# 检查参数 +-num=0 +-while getopts :i:o:h opt +-do +- case "$opt" in +- "o") VERSION_FILE=$OPTARG +- num=$(($num+1)) +- ;; +- "i") TOOLCHAIN_ID=$OPTARG +- num=$(($num+1)) +- ;; +- "h") echo "Usage: ps3_drv_readme.sh -o [-i ]" +- ;; +- *) echo "Unknown option: $opt. Usage: ps3_drv_readme.sh -o [-i ]" +- ;; +- esac +-done +- +-if [ $num -ne 1 ]&&[ $num -ne 2 ]; then +- echo "Invalid command. Usage: ps3_drv_readme.sh -o [-i ]" +- exit 1 +-fi +- +-# 将toolchain id 写入版本信息头文件 +-if [ "$TOOLCHAIN_ID" == "no" ]; then +- TOOLCHAIN_ID='' +-fi +- +-DRV_TOOLCHAIN="#define PS3_DRV_TOOLCHAIN_ID \"${TOOLCHAIN_ID}\"" +-sed -i "/PS3_DRV_TOOLCHAIN_ID/c ${DRV_TOOLCHAIN}" $VERSION_FILE +- +-# 从已生成的版本信息头文件中获取版本信息 +-CUR_DIR=$(dirname $0) +-README_FILE=${CUR_DIR}/ps3_drv_readme.txt +- +-VERSION=$(grep PS3_DRV_VERSION ${VERSION_FILE} | cut -d '"' -f 2- |cut -d '"' -f 1) +-COMMIT_ID=$(grep PS3_DRV_COMMIT_ID ${VERSION_FILE} | cut -d '"' -f 2- |cut -d '"' -f 1) +-BRANCH=$(grep PS3_DRV_BRANCH ${VERSION_FILE} | cut -d '"' -f 2- |cut -d '"' -f 1) +-BUILD_TIME=$(grep PS3_DRV_BUILD_TIME ${VERSION_FILE} | cut -d '"' -f 2- |cut -d '"' -f 1) +-ARCH=$(grep PS3_DRV_ARCH ${VERSION_FILE} | cut -d '"' -f 2- |cut -d '"' -f 1) +-PRODUCT_SUPPORT=$(grep PS3_DRV_PRODUCT_SUPPORT ${VERSION_FILE} | cut -d '"' -f 2- |cut -d '"' -f 1) +- +-# 将版本信息写入 readme.txt +-echo "version : " ${VERSION} > ${README_FILE} #第一行,覆盖写 +-echo "commit_id : " ${COMMIT_ID} >> ${README_FILE} #第二行开始,用追加写 +-echo "toolchain_id : " ${TOOLCHAIN_ID} >> ${README_FILE} #第二行开始,用追加写 +-echo "build_time : " ${BUILD_TIME} >> ${README_FILE} #第二行开始,用追加写 +-echo "arch : " ${ARCH} >> ${README_FILE} #第二行开始,用追加写 +-echo "product_support : " ${PRODUCT_SUPPORT} >> ${README_FILE} #第二行开始,用追加写 +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_drv_readme.txt ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_drv_readme.txt +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_drv_readme.txt 2025-06-10 20:13:00.220053457 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_drv_readme.txt 2025-06-10 20:13:00.483062632 +0800 +@@ -1,6 +1,5 @@ +-version : 2.3.0.3 +-commit_id : d7f4761 42be4ef ++version : 2.5.0.30 ++commit_id : e2b0a93 3b1194f + toolchain_id : +-build_time : Apr 20 2024 18:17:29 +-arch : x86_64 ++build_time : Dec 20 2024 17:18:28 + product_support : RAID/HBA +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_drv_ver.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_drv_ver.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_drv_ver.h 2025-06-10 20:13:00.220053457 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_drv_ver.h 2025-06-10 20:13:00.483062632 +0800 +@@ -2,14 +2,13 @@ + #define _PS3_DRV_VER_H_ + + #define PS3_PRIVATE_VERSION "00.000.00.01" +-#define PS3_DRV_VERSION "2.3.0.3" +-#define PS3_DRV_COMMIT_ID "d7f4761 42be4ef" +-#define PS3_DRV_BUILD_TIME "Apr 20 2024 18:17:29" +-#define PS3_DRV_ARCH "x86_64" ++#define PS3_DRV_VERSION "2.5.0.30" ++#define PS3_DRV_COMMIT_ID "e2b0a93 3b1194f" ++#define PS3_DRV_BUILD_TIME "Dec 20 2024 17:18:28" + #define PS3_DRV_TOOLCHAIN_ID "" + + #define PS3_DRV_PRODUCT_SUPPORT "RAID/HBA" +-#define PS3_DRV_LICENSE "GPL" ++#define PS3_DRV_LICENSE "GPL" + #define PS3_DRV_AUTHOR "ps3stor" + #define PS3_DRV_DESCRIPTION "ps3stor driver" + +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_err_inject.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_err_inject.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_err_inject.c 2025-06-10 20:13:00.221053492 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_err_inject.c 2025-06-10 20:13:00.470062179 +0800 +@@ -19,8 +19,29 @@ + #ifdef PS3_SUPPORT_INJECT + + struct ps3_rec_work_context g_work_que_recovery; ++struct ps3_rec_work_context g_work_que_probe; ++ + static Ps3Injection_t g_ps3_err_scene[PS3_ERR_SCENE_NUM]; + static Bool is_inject_init = PS3_FALSE; ++static U64 sgl_addr; ++ ++static inline U32 ps3_prandom_u32_max(U32 ep_ro) ++{ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 34) ++ return prandom_u32_max(ep_ro); ++#else ++ return get_random_u32_below(ep_ro); ++#endif ++} ++ ++static inline U32 ps3_prandom_u32(void) ++{ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 34) ++ return prandom_u32(); ++#else ++ return get_random_u32(); ++#endif ++} + + void ps3_err_inject_sleep(U32 ms, U16 err_type) + { +@@ -37,7 +58,7 @@ + if ((err_type < PS3_ERR_SCENE_NUM && + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) && + g_ps3_err_scene[err_type - 1].active) { +- slepp_ms = min + prandom_u32_max(max - min); ++ slepp_ms = min + ps3_prandom_u32_max(max - min); + ps3_msleep(slepp_ms); + } + } +@@ -68,6 +89,22 @@ + return PS3_FALSE; + } + ++void ps3_err_inject_wait_pre(U16 err_type_wait) ++{ ++ while (g_ps3_err_scene[err_type_wait-1].active && ++ !g_ps3_err_scene[err_type_wait-1].is_hit_pre) { ++ msleep(5); ++ } ++} ++ ++void ps3_err_inject_wait_post(U16 err_type_wait) ++{ ++ while (g_ps3_err_scene[err_type_wait-1].active && ++ !g_ps3_err_scene[err_type_wait-1].is_hit_pre) { ++ msleep(5); ++ } ++} ++ + void inject_register(U16 err_type, injectCallback callback) + { + if (err_type < PS3_ERR_SCENE_NUM && +@@ -84,19 +121,24 @@ + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + g_ps3_err_scene[err_type - 1].active = PS3_TRUE; + g_ps3_err_scene[err_type - 1].count = count; ++ g_ps3_err_scene[err_type - 1].is_hit_pre = PS3_FALSE; ++ g_ps3_err_scene[err_type - 1].is_hit_post = PS3_FALSE; + } + + return ; + } + void inject_execute_callback(U16 err_type, void * data) + { +- S32 ret; ++ S32 ret = PS3_SUCCESS; ++ + if (err_type < PS3_ERR_SCENE_NUM && + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + if (g_ps3_err_scene[err_type-1].active == PS3_TRUE && +- g_ps3_err_scene[err_type-1].callback != NULL && + g_ps3_err_scene[err_type-1].count != 0) { +- ret = g_ps3_err_scene[err_type-1].callback(data); ++ g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; ++ if (g_ps3_err_scene[err_type-1].callback != NULL) ++ ret = g_ps3_err_scene[err_type-1].callback(data); ++ g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; + if(g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS){ + g_ps3_err_scene[err_type-1].count--; + } +@@ -108,17 +150,125 @@ + + void inject_execute_callback_at_time(U16 err_type, void * data) + { +- S32 ret; ++ S32 ret = PS3_SUCCESS; ++ ++ if (err_type < PS3_ERR_SCENE_NUM && ++ err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { ++ ++ if (g_ps3_err_scene[err_type-1].active == PS3_TRUE) { ++ if (g_ps3_err_scene[err_type-1].count > 1) { ++ g_ps3_err_scene[err_type-1].count--; ++ } else if (g_ps3_err_scene[err_type-1].count == 1) { ++ g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; ++ if (g_ps3_err_scene[err_type-1].callback != NULL) ++ ret = g_ps3_err_scene[err_type-1].callback(data); ++ g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; ++ if (g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS) ++ g_ps3_err_scene[err_type-1].count--; ++ } ++ } ++ } ++} ++ ++void inject_execute_callback_relevance_wait_pre(U16 err_type, U16 err_type_wait, void *data) ++{ ++ S32 ret = PS3_SUCCESS; ++ + if (err_type < PS3_ERR_SCENE_NUM && + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { ++ if (g_ps3_err_scene[err_type-1].active == PS3_TRUE && ++ g_ps3_err_scene[err_type_wait-1].active == PS3_TRUE && ++ g_ps3_err_scene[err_type-1].count != 0) { ++ g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; ++ while (g_ps3_err_scene[err_type_wait-1].active && ++ !g_ps3_err_scene[err_type_wait-1].is_hit_pre) { ++ msleep(5); ++ } ++ if (g_ps3_err_scene[err_type-1].callback != NULL) ++ ret = g_ps3_err_scene[err_type-1].callback(data); ++ g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; ++ if (g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS) ++ g_ps3_err_scene[err_type-1].count--; ++ } ++ } ++} ++ ++void inject_execute_callback_relevance_wait_post(U16 err_type, U16 err_type_wait, void *data) ++{ ++ S32 ret = PS3_SUCCESS; + ++ if (err_type < PS3_ERR_SCENE_NUM && ++ err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + if (g_ps3_err_scene[err_type-1].active == PS3_TRUE && +- g_ps3_err_scene[err_type-1].callback != NULL) { ++ g_ps3_err_scene[err_type_wait-1].active == PS3_TRUE && ++ g_ps3_err_scene[err_type-1].count != 0) { ++ g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; ++ while (g_ps3_err_scene[err_type_wait-1].active && ++ !g_ps3_err_scene[err_type_wait-1].is_hit_post) { ++ msleep(5); ++ } ++ if (g_ps3_err_scene[err_type-1].callback != NULL) ++ ret = g_ps3_err_scene[err_type-1].callback(data); ++ g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; ++ if (g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS) ++ g_ps3_err_scene[err_type-1].count--; ++ } ++ } ++} + ++void inject_execute_callback_at_time_relevance_wait_pre(U16 err_type, ++ U16 err_type_wait, void *data) ++{ ++ S32 ret = PS3_SUCCESS; ++ ++ if (err_type < PS3_ERR_SCENE_NUM && ++ err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { ++ ++ if (g_ps3_err_scene[err_type-1].active == PS3_TRUE) { + if (g_ps3_err_scene[err_type-1].count > 1) { + g_ps3_err_scene[err_type-1].count--; + } else if (g_ps3_err_scene[err_type-1].count == 1) { +- ret = g_ps3_err_scene[err_type-1].callback(data); ++ g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; ++ ++ while (g_ps3_err_scene[err_type_wait-1].active && ++ !g_ps3_err_scene[err_type_wait-1].is_hit_pre) { ++ msleep(5); ++ } ++ ++ if (g_ps3_err_scene[err_type-1].callback != NULL) ++ ret = g_ps3_err_scene[err_type-1].callback(data); ++ ++ g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; ++ if (g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS) ++ g_ps3_err_scene[err_type-1].count--; ++ } ++ } ++ } ++} ++ ++void inject_execute_callback_at_time_relevance_wait_post(U16 err_type, ++ U16 err_type_wait, void *data) ++{ ++ S32 ret = PS3_SUCCESS; ++ ++ if (err_type < PS3_ERR_SCENE_NUM && ++ err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { ++ ++ if (g_ps3_err_scene[err_type-1].active == PS3_TRUE) { ++ if (g_ps3_err_scene[err_type-1].count > 1) { ++ g_ps3_err_scene[err_type-1].count--; ++ } else if (g_ps3_err_scene[err_type-1].count == 1) { ++ g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; ++ ++ while (g_ps3_err_scene[err_type_wait-1].active && ++ !g_ps3_err_scene[err_type_wait-1].is_hit_post) { ++ msleep(5); ++ } ++ ++ if (g_ps3_err_scene[err_type-1].callback != NULL) ++ ret = g_ps3_err_scene[err_type-1].callback(data); ++ ++ g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; + if(g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS){ + g_ps3_err_scene[err_type-1].count--; + } +@@ -164,6 +314,12 @@ + *(S32 *)ptr = -PS3_TIMEOUT; + return PS3_SUCCESS; + } ++S32 force_mgr_cmd_no_resp(void *ptr) ++{ ++ *(S32 *)ptr = -PS3_TIMEOUT; ++ return PS3_SUCCESS; ++} ++ + S32 force_return_fail(void * ptr) + { + *(S32 *)ptr = -PS3_FAILED; +@@ -266,6 +422,14 @@ + return PS3_SUCCESS; + } + ++S32 force_instance_state_normal(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_OPERATIONAL); ++ return PS3_SUCCESS; ++} ++ + S32 wait_instance_unnormal(void * ptr) + { + struct ps3_instance *instance = (struct ps3_instance *)ptr; +@@ -276,6 +440,22 @@ + return PS3_SUCCESS; + } + ++S32 wait_instance_unnormal_and_set_flag(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ Bool flag = PS3_FALSE; ++ ++ while (ps3_atomic_read(&instance->state_machine.state) == PS3_INSTANCE_STATE_OPERATIONAL) { ++ if (!flag) { ++ instance->reserved[0] = 0x11; ++ flag = PS3_TRUE; ++ } ++ msleep(5); ++ } ++ msleep(1000); ++ return PS3_SUCCESS; ++} ++ + S32 wait_ioc_ready(void * ptr) + { + struct ps3_instance *instance = (struct ps3_instance *)ptr; +@@ -367,6 +547,58 @@ + *ret = -PS3_FAILED; + return PS3_SUCCESS; + } ++ ++S32 force_reg_fail(void *ptr) ++{ ++ U64 *ret = (U64 *)ptr; ++ *ret = U64_MAX; ++ return PS3_SUCCESS; ++} ++ ++S32 force_ready_failed(void *ptr) ++{ ++ U32 *fw_cur_state = (U32 *)ptr; ++ *fw_cur_state = PS3_FW_STATE_START; ++ return PS3_SUCCESS; ++} ++ ++S32 force_ioc_critical(void *ptr) ++{ ++ U32 *fw_cur_state = (U32 *)ptr; ++ *fw_cur_state = PS3_FW_STATE_CRITICAL; ++ return PS3_SUCCESS; ++} ++ ++S32 force_change_sgl_addr_to_page_mode_5(void *ptr) ++{ ++ U64 *addr = (U64 *)ptr; ++ ++ sgl_addr = *addr; ++ *addr = 0xfffffc5600000; ++ return PS3_SUCCESS; ++} ++ ++S32 force_sgl_addr_restore(void *ptr) ++{ ++ U64 *addr = (U64 *)ptr; ++ *addr = sgl_addr; ++ return PS3_SUCCESS; ++} ++ ++S32 force_atu_support_failed(void *ptr) ++{ ++ U8 *bit_pos = (U8 *)ptr; ++ *bit_pos = 0xe0; ++ return PS3_SUCCESS; ++} ++ ++S32 force_reg_zero(void *ptr) ++{ ++ U64 *reg = (U64 *)ptr; ++ *reg = 0x0; ++ return PS3_SUCCESS; ++} ++ + S32 force_scan_host_delay(void * ptr) + { + U32 times = *(U32 *)ptr; +@@ -629,18 +861,6 @@ + + return PS3_SUCCESS; + } +-S32 wait_recovery_req_func1_probe(void * ptr) +-{ +- struct ps3_instance *instance = (struct ps3_instance *)ptr; +- instance->reserve[0] = 0xa1; +- +- while (instance->reserve[0] == 0xa1) { +- msleep(10); +- } +- LOG_INFO("wait_recovery_func1_probe success \n"); +- +- return PS3_SUCCESS; +-} + + S32 wait_recovery_func1_remove(void * ptr) + { +@@ -810,6 +1030,20 @@ + LOG_WARN("ioc state [%llu]\n", state); + return PS3_SUCCESS; + } ++S32 force_set_ioc_halt(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ U64 state; ++ ++ if (instance->reg_set != NULL) { ++ instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = ++ PS3_FW_STATE_HALT; ++ } ++ state = instance->ioc_adpter->ioc_state_get(instance); ++ ++ LOG_WARN("ioc state [%llu]\n", state); ++ return PS3_SUCCESS; ++} + + S32 force_set_f0_ioc_critical(void * ptr) + { +@@ -950,7 +1184,10 @@ + S32 force_return_true(void * ptr) + { + Bool *ret = (Bool *)ptr; ++ LOG_WARN("force_return_true in\n"); + *ret = PS3_TRUE; ++ LOG_WARN("force_return_true in\n"); ++ + return PS3_SUCCESS; + } + +@@ -1076,6 +1313,18 @@ + return PS3_SUCCESS; + } + ++S32 force_pdlist_cmd_retry(void *ptr) ++{ ++ struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; ++ struct ps3_instance *instance = cmd->instance; ++ ++ cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; ++ LOG_WARN("hno:%u force complete task mgr CFID:%d\n", ++ PS3_HOST(instance), cmd->index); ++ ++ return PS3_SUCCESS; ++} ++ + S32 force_get_linkerrors_cmd_error(void * ptr) + { + struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; +@@ -1154,6 +1403,7 @@ + + return PS3_SUCCESS; + } ++ + S32 force_cmd_polling(void ** ptr) + { + struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; +@@ -1174,6 +1424,35 @@ + return PS3_SUCCESS; + } + ++S32 cli_wait_recovery(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ Bool flag = PS3_FALSE; ++ ++ while (ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_READY) { ++ if (!flag) { ++ instance->reserve[0] = 1; ++ flag = PS3_TRUE; ++ } ++ msleep(10); ++ } ++ instance->reserve[1] = 1; ++ while (ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_OPERATIONAL) { ++ msleep(10); ++ } ++ return PS3_SUCCESS; ++} ++ ++S32 recovery_wait_cli(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ while (instance->reserve[1] != 1) ++ msleep(10); ++ instance->reserve[1] = 0; ++ return PS3_SUCCESS; ++} ++ + S32 force_blk_rq_bytes_invalid(void * ptr) + { + struct request *req = (struct request *)ptr; +@@ -1197,6 +1476,7 @@ + { + struct ps3_instance *instance = (struct ps3_instance *)ptr; + while(instance->reserved[0] == 0) { ++ instance->reserved[1] = 0xcd; + msleep(10); + } + return PS3_SUCCESS; +@@ -1339,6 +1619,12 @@ + return PS3_SUCCESS; + } + ++S32 force_u64_zero(void *ptr) ++{ ++ *(U64 *)ptr = 0; ++ return PS3_SUCCESS; ++} ++ + S32 force_fifo_depth_zero(void *ptr) + { + *(U64 *)ptr = 0; +@@ -1396,10 +1682,6 @@ + + LOG_INFO("hno:%u wait dead or pre_operational begin\n", PS3_HOST(instance)); + for (idx = 0; idx < wait_cnt; idx++) { +- if (ps3_no_need_recovery(instance)) { +- break; +- } +- + cur_state = ps3_atomic_read(&instance->state_machine.state); + if ((cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || + (cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || +@@ -1486,6 +1768,17 @@ + return PS3_SUCCESS; + } + ++S32 err_abort_block(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ while (instance->reserved2[0] == 0) { ++ instance->reserved2[1] = 0xcd; ++ msleep(10); ++ } ++ return PS3_SUCCESS; ++} ++ + static void ps3_test_recovery_call(struct work_struct* work) + { + struct ps3_instance *instance = NULL; +@@ -1514,24 +1807,175 @@ + g_work_que_recovery.state = 0; + + queue_delayed_work(g_work_que_recovery._queue, &g_work_que_recovery._work, +- msecs_to_jiffies(prandom_u32() % 800)); ++ msecs_to_jiffies(ps3_prandom_u32() % 800)); + } ++ ++static void ps3_test_probe_call(struct work_struct *work) ++{ ++ struct ps3_instance *instance = NULL; ++ U32 idx = 0; ++ (void)work; ++ instance = g_work_que_probe.instance; ++ ++ LOG_WARN("%s enter\n", __func__); ++ ++ if (instance->peer_instance == NULL) ++ return; ++ instance->peer_instance->is_probe_finish = false; ++ g_work_que_probe.state = 1; ++ while (idx++ < 10000) ++ msleep(10); ++ ++ instance->peer_instance->is_probe_finish = true; ++ LOG_WARN("%s quit\n", __func__); ++} ++void ps3_start_probe_rand_thread(struct ps3_instance *instance) ++{ ++ char _queue_name[32] = {"test_probe"}; ++ ++ INIT_DELAYED_WORK(&g_work_que_probe._work, ps3_test_probe_call); ++ ++ g_work_que_probe._queue = create_singlethread_workqueue(_queue_name); ++ if (g_work_que_probe._queue == NULL) ++ return; ++ ++ g_work_que_probe.instance = instance; ++ g_work_que_probe.state = 0; ++ ++ queue_delayed_work(g_work_que_probe._queue, &g_work_que_probe._work, ++ msecs_to_jiffies(ps3_prandom_u32() % 800)); ++} ++S32 wait_recovery_req_func1_probe(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ ps3_start_probe_rand_thread(instance); ++ while (g_work_que_probe.state != 1) ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); ++ ++ LOG_INFO("wait_recovery_func1_probe success\n"); ++ ++ return PS3_SUCCESS; ++} ++void ps3_wait_probe_rand_finish(void) ++{ ++ LOG_WARN("enter %s\n", __func__); ++ while (g_work_que_probe.state != 1) ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); ++ ++ if (g_work_que_probe._queue != NULL) { ++ if (!cancel_delayed_work_sync(&g_work_que_probe._work)) ++ flush_workqueue(g_work_que_probe._queue); ++ ++ destroy_workqueue(g_work_que_probe._queue); ++ g_work_que_probe._queue = NULL; ++ } ++ LOG_WARN("quit %s\n", __func__); ++} ++ + S32 force_hard_reset_request(void *ptr) + { + struct ps3_instance *instance = (struct ps3_instance *)ptr; + if (instance->peer_instance != NULL) { + ps3_start_recovery_rand_thread(instance->peer_instance); ++ while (ps3_atomic_read(&instance->recovery_context->hardreset_ref) == 0) ++ msleep(5); + } else { + ps3_hard_recovery_request(instance); + } + +- return PS3_SUCCESS; ++ return PS3_SUCCESS; ++} ++ ++S32 force_hard_reset_request_1(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ LOG_WARN("enter %s\n", __func__); ++ if (instance->reserve[0] == 0) ++ ps3_hard_recovery_request(instance); ++ else ++ ps3_hard_recovery_request(instance->peer_instance); ++ cancel_work_sync(&instance->recovery_context->recovery_work); ++ LOG_WARN("enter %s end\n", __func__); ++ ++ return PS3_SUCCESS; ++} ++ ++S32 force_instance_null(void *ptr) ++{ ++ struct ps3_instance **instance = (struct ps3_instance **)ptr; ++ ++ LOG_WARN("enter %s\n", __func__); ++ *instance = NULL; ++ LOG_WARN("%s end\n", __func__); ++ return PS3_SUCCESS; ++} ++ ++S32 force_half_reset(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ LOG_WARN("enter %s\n", __func__); ++ instance->is_half_hard_reset = PS3_DRV_TRUE; ++ LOG_WARN("%s end\n", __func__); ++ return PS3_SUCCESS; ++} ++ ++S32 force_half_reset_false(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ LOG_WARN("enter %s\n", __func__); ++ instance->is_half_hard_reset = PS3_DRV_FALSE; ++ LOG_WARN("%s end\n", __func__); ++ return PS3_SUCCESS; ++} ++ ++S32 force_web_subscribe_failed(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ LOG_WARN("enter %s\n", __func__); ++ ps3_atomic_set(&instance->webSubscribe_context.is_subscribe, 1); ++ ps3_atomic_set(&instance->cmd_statistics.cmd_delivering, 1); ++ LOG_WARN("%s end\n", __func__); ++ return PS3_SUCCESS; ++} ++ ++S32 force_cmd_delivering_zero(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ LOG_WARN("enter %s\n", __func__); ++ ps3_atomic_set(&instance->cmd_statistics.cmd_delivering, 0); ++ LOG_WARN("%s end\n", __func__); ++ return PS3_SUCCESS; ++} ++ ++S32 force_async_hard_reset_request(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ ps3_start_recovery_rand_thread(instance); ++ return PS3_SUCCESS; ++} ++ ++S32 change_fw_state_to_halt_in_recover_prepare(void *ptr) ++{ ++ U32 *p_ioc_state = (U32 *)ptr; ++ *p_ioc_state = PS3_FW_STATE_HALT; ++ ++ return PS3_SUCCESS; + } + + S32 wait_scsi_cmd_done_fail(void *ptr) + { + struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserved[0] = 0xab; ++ while (*instance->scsi_cmd_deliver != 0) ++ ps3_msleep(10); ++ + return PS3_SUCCESS; + } + void ps3_wait_recovery_rand_finish(void) +@@ -1554,12 +1998,7 @@ + } + LOG_WARN("quit ps3_wait_reco_rand_finish\n"); + } +-S32 force_res_online_fail(void *ptr) +-{ +- struct ps3_instance *instance = (struct ps3_instance *)ptr; +- instance->state_machine.is_res_online = PS3_FALSE; +- return PS3_SUCCESS; +-} ++ + S32 force_hard_recovery_request_nosupport_fail(void *ptr) + { + struct ps3_instance *instance = (struct ps3_instance *)ptr; +@@ -1579,6 +2018,7 @@ + { + struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; + while (cmd->r1x_peer_cmd != NULL) { ++ cmd->instance->reserved2[0] = 0xcd; + ps3_msleep(20); + } + return PS3_SUCCESS; +@@ -1668,6 +2108,28 @@ + return PS3_SUCCESS; + } + ++S32 force_ret_recovery(void *ptr) ++{ ++ S32 *ret = (S32 *)ptr; ++ ++ if (ret) ++ *ret = -PS3_RECOVERED; ++ ++ return PS3_SUCCESS; ++} ++ ++S32 force_return_zero(void *ptr) ++{ ++ *(S32 *)ptr = 0; ++ return PS3_SUCCESS; ++} ++ ++S32 force_return_invalid(void *ptr) ++{ ++ *(S32 *)ptr = 0x80; ++ return PS3_SUCCESS; ++} ++ + S32 force_ret_failed(void * ptr) + { + S32 *ret = (S32 *)ptr; +@@ -1678,6 +2140,20 @@ + return PS3_SUCCESS; + } + ++S32 force_cmd_not_mgr_cmd(void *ptr) ++{ ++ U16 *index = (U16 *)ptr; ++ *index = 0; ++ return PS3_SUCCESS; ++} ++ ++S32 force_phy_count_zero(void *ptr) ++{ ++ U8 *phy_count = (U8 *)ptr; ++ *phy_count = 0; ++ return PS3_SUCCESS; ++} ++ + S32 force_doorbell_failed(void * ptr) + { + U32 *fw_cur_state = (U32 *)ptr; +@@ -1738,6 +2214,24 @@ + + return PS3_SUCCESS; + } ++S32 force_s32_zero(void *ptr) ++{ ++ S32 *ret = (S32 *)ptr; ++ ++ if (ret) ++ *ret = 0; ++ ++ return PS3_SUCCESS; ++} ++S32 force_s32_letter_zero(void *ptr) ++{ ++ S32 *ret = (S32 *)ptr; ++ ++ if (ret) ++ *ret = 0; ++ ++ return PS3_SUCCESS; ++} + + S32 force_align_err(void * ptr) + { +@@ -1813,6 +2307,246 @@ + } + return PS3_SUCCESS; + } ++S32 force_pcie_frozen(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ instance->reg_set = NULL; ++ return PS3_SUCCESS; ++} ++ ++S32 for_mod_so_addr(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET(0x5000); ++ instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET(0x10000); ++ return PS3_SUCCESS; ++} ++S32 force_pci_ioremap_fail(void **ptr) ++{ ++ iounmap(*ptr); ++ *ptr = NULL; ++ ++ return PS3_SUCCESS; ++} ++S32 wait_recovery_req_coming(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ U32 count = 0; ++ ++ LOG_INFO("wait_recovery_req in\n"); ++ while (1) { ++ if (ps3_atomic_read(&instance->recovery_context->hardreset_ref) != 0) ++ break; ++ if (count == 10000) ++ break; ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); ++ count++; ++ } ++ ++ LOG_INFO("wait_recovery_req success\n"); ++ ++ return PS3_SUCCESS; ++} ++S32 wait_hard_recovery_req(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ U32 count = 0; ++ ++ LOG_INFO("%s in\n", __func__); ++ while (1) { ++ if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || ++ instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { ++ break; ++ } ++ if (count == 10000) ++ break; ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); ++ count++; ++ } ++ ++ LOG_INFO("%s success\n", __func__); ++ ++ return PS3_SUCCESS; ++} ++ ++S32 force_u8_1(void *ptr) ++{ ++ U8 *ret = (U8 *)ptr; ++ ++ if (ret) ++ *ret = 1; ++ ++ return PS3_SUCCESS; ++} ++S32 force_multi_hard_req(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_SHALLOW; ++ ++ return PS3_SUCCESS; ++} ++S32 force_multi_hard_req_pending(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) ++ instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_CONTINUE; ++ ++ return PS3_SUCCESS; ++} ++S32 force_recovery_wq_null(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ instance->recovery_context->recovery_wq = NULL; ++ return PS3_SUCCESS; ++} ++S32 force_recovery_state_dead(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ ps3_atomic_set(&instance->state_machine.state, ++ PS3_INSTANCE_STATE_DEAD); ++ return PS3_SUCCESS; ++} ++S32 force_recovery_support_false(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ instance->is_hard_recovery_support = false; ++ return PS3_SUCCESS; ++} ++S32 force_memory_alloc_failed(void **ptr) ++{ ++ kfree(*ptr); ++ ++ *ptr = NULL; ++ return PS3_SUCCESS; ++} ++S32 force_web_subcribe(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ ps3_atomic_set(&instance->webSubscribe_context.is_subscribe, 1); ++ ++ return PS3_SUCCESS; ++} ++S32 force_instance_probe_failed(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ instance->state_machine.is_load = PS3_FALSE; ++ ++ return PS3_SUCCESS; ++} ++ ++S32 force_func_id_invalid(void **ptr) ++{ ++ (void)ptr; ++ ++ ps3_available_func_id_modify(PS3_FUNC_ID_1); ++ return PS3_SUCCESS; ++} ++ ++S32 wait_recovery_request(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ while (instance->recovery_context->recovery_state != PS3_HARD_RECOVERY_DECIDE && ++ instance->recovery_context->recovery_state != PS3_HARD_RECOVERY_SHALLOW) { ++ msleep(10); ++ } ++ return PS3_SUCCESS; ++} ++ ++S32 recovery_wait_conditional(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ instance->reserved[0] = 0xab; ++ while (instance->reserved[0] == 0xab) ++ msleep(10); ++ return PS3_SUCCESS; ++} ++ ++S32 wait_recovery_request_2(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ ps3_hard_recovery_request(instance); ++ return PS3_SUCCESS; ++} ++ ++S32 wait_f0_watchdog(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ LOG_WARN("%s in\n", __func__); ++ if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1) ++ goto l_out; ++ while (instance->recovery_context->recovery_state < PS3_HARD_RECOVERY_DECIDE) ++ ps3_msleep(10); ++ ++l_out: ++ LOG_WARN("%s out\n", __func__); ++ return PS3_SUCCESS; ++} ++ ++S32 wait_f0_watchdog_2(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ LOG_WARN("%s in\n", __func__); ++ while (instance->ioc_adpter->ioc_heartbeat_detect(instance) == 0) ++ ps3_msleep(10); ++ ++ LOG_WARN("%s out\n", __func__); ++ return PS3_SUCCESS; ++} ++ ++S32 wait_recovery_end(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ instance->reserved[0] = 0xff; ++ cancel_work_sync(&instance->recovery_context->recovery_work); ++ return PS3_SUCCESS; ++} ++ ++S32 force_sas_port_create_fail(void *ptr) ++{ ++ struct ps3_sas_port *sas_port = (struct ps3_sas_port *)ptr; ++ ++ if (sas_port->port != NULL) { ++ sas_port_delete(sas_port->port); ++ sas_port->port = NULL; ++ } ++ return PS3_SUCCESS; ++} ++ ++S32 force_pcie_remove_break(void *ptr) ++{ ++ struct ps3_cmd_context *cmd_context = (struct ps3_cmd_context *)ptr; ++ ++ LOG_WARN("%s in\n", __func__); ++ cmd_context->reserved0[0] = 1; ++ LOG_WARN("%s out\n", __func__); ++ return PS3_SUCCESS; ++} ++ ++S32 check_pcie_remove_state(void *ptr) ++{ ++ struct ps3_instance *instance = (struct ps3_instance *)ptr; ++ ++ LOG_WARN("%s in\n", __func__); ++ while (instance->cmd_context.reserved0[0] != 1) ++ ps3_msleep(10000); ++ LOG_WARN("%s out\n", __func__); ++ return PS3_SUCCESS; ++} + + void active_err_inject(void) + { +@@ -1901,7 +2635,7 @@ + INJECT_REG(PS3_ERR_IJ_FWSTATE_REMOVE, wait_remove_is_load_flag) + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_RETRY_DONE, ioctl_cmd_retry_done) + INJECT_REG(PS3_ERR_IJ_QOS_SET_SHARE_COUNT, set_qos_share_cnt) +- INJECT_REG(PS3_ERR_IJ_IOCTL_WAIT_UNNORMAL, wait_instance_unnormal) ++ INJECT_REG(PS3_ERR_IJ_IOCTL_WAIT_UNNORMAL, wait_instance_unnormal_and_set_flag) + INJECT_REG(PS3_ERR_IJ_FORCE_EVENT_CMD_FAIL_DEAD, force_event_cmd_dead) + INJECT_REG(PS3_ERR_IJ_IOCTL_WAIT_IRQ_DISABLE, wait_irq_disable) + INJECT_REG(PS3_ERR_IJ_WAIT_IOCTL_IN_RECOVERY, wait_ioctl_detect_irq_disable) +@@ -1950,7 +2684,7 @@ + INJECT_REG(PS3_ERR_IJ_QOS_PD_RESEND_NOT_EXPIRED, force_return_false) + INJECT_REG(PS3_ERR_IJ_IOC_NOT_RUNNING, force_ioc_not_running) + INJECT_REG(PS3_ERR_IJ_IOC_IS_NOT_NORMAL_IN_UNLOAD, force_ioc_not_running) +- INJECT_REG(PS3_ERR_IJ_HALF_HARD_RESET, force_return_false) ++ INJECT_REG(PS3_ERR_IJ_HALF_HARD_RESET, force_return_true) + INJECT_REG(PS3_ERR_IJ_ROMOVE_UNLOAD_FAIL, force_mgr_cmd_alloc_null) + INJECT_REG(PS3_ERR_IJ_WAIT_TASK_MGR_BUSY, wait_task_mgr_busy) + INJECT_REG(PS3_ERR_IJ_RESET_TARGET_PAUSE, reset_target_pause) +@@ -1993,8 +2727,8 @@ + INJECT_REG(PS3_ERR_IJ_CMD_SEND_FORCE_UNORMAL, force_instance_state_unnormal) + INJECT_REG(PS3_ERR_IJ_CMD_SEND_FORCE_PCI_ERR, force_instance_state_pci_err) + INJECT_REG(PS3_ERR_IJ_QOS_FORCE_VD_SEQ_CHANGE, force_cmd_vd_seq_change) +- INJECT_REG(PS3_ERR_IJ_QOS_FORCE_MGRQ_ZERO_DEPTH, force_fifo_depth_zero) +- INJECT_REG(PS3_ERR_IJ_QOS_FORCE_CMDQ_ZERO_DEPTH, force_fifo_depth_zero) ++ INJECT_REG(PS3_ERR_IJ_QOS_FORCE_MGRQ_ZERO_DEPTH, force_u64_zero) ++ INJECT_REG(PS3_ERR_IJ_QOS_FORCE_CMDQ_ZERO_DEPTH, force_u64_zero) + INJECT_REG(PS3_ERR_IJ_QOS_MGRQ_INIT_FAIL_1, create_mgr_waitq_fail) + INJECT_REG(PS3_ERR_IJ_QOS_MGRQ_INIT_FAIL_2, create_mgr_worker_fail) + INJECT_REG(PS3_ERR_IJ_QOS_CMDQ_INIT_FAIL_1, create_cmd_waitq_fail) +@@ -2077,7 +2811,6 @@ + INJECT_REG(PS3_ERR_IJ_FORCE_ALLOC_DMA_BUF_FAILED, force_ptr_null) + INJECT_REG(PS3_ERR_IJ_FORCE_PCIE_ERR_PCI_INIT_FAILED, force_ret_fail) + INJECT_REG(PS3_ERR_IJ_FORCE_PCIE_ERR_PCI_INIT_COMP_FAILED, force_ret_fail) +- INJECT_REG(PS3_ERR_IJ_FORCE_PCIE_ERR_RES_ONLINE_FAILED, force_res_online_fail) + INJECT_REG(PS3_ERR_IJ_PCI_FORCE_HARD_RECOVERY_REQ_FAILED, force_hard_recovery_request_nosupport_fail) + INJECT_REG(PS3_ERR_IJ_PCI_FORCE_WAIT_OPERARIONAL_FAILED, force_ret_fail) + INJECT_REG(PS3_ERR_IJ_FORCE_PCIE_ERR_IOC_RUNNING_INIT_FAILED, force_ioc_not_running) +@@ -2157,6 +2890,209 @@ + INJECT_REG(PS3_ERR_IJ_SET_HIGH_IOPS_CHANNEL_IN_QOS, set_iops_channel) + INJECT_REG(PS3_ERR_IJ_FORCE_F0_WATCHDOG_START_HARD, force_set_f0_ioc_critical) + INJECT_REG(PS3_ERR_IJ_ADD_DISK_HOST_RESET, force_stop_aborted_cmd_done) ++ INJECT_REG(PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY_1, force_stop_aborted_cmd_done) ++ INJECT_REG(PS3_ERR_IJ_PCIE_FROZEN, force_pcie_frozen) ++ INJECT_REG(PS3_ERR_IJ_PEER_PCIE_FROZEN, force_pcie_frozen) ++ INJECT_REG(PS3_ERR_IJ_ASYNC_HARDRESET_PROBE, force_async_hard_reset_request) ++ INJECT_REG(PS3_ERR_IJ_ASYNC_HARDRESET_REMOVE, force_async_hard_reset_request) ++ INJECT_REG(PS3_ERR_IJ_MOD_SO_ADDR, for_mod_so_addr) ++ INJECT_REG(PS3_ERR_IJ_SHUTDOWN_HARDRESET, force_hard_reset_request) ++ INJECT_REG(PS3_ERR_IJ_CANCEL_WEB_CMD_ALLOC_NULL, force_return_fail) ++ INJECT_REG(PS3_ERR_IJ_GET_REPLYQ_COUNT_INVALID, force_fw_state_ff) ++ INJECT_REG(PS3_ERR_IJ_GET_MSIX_VEC_COUNT_INVALID, force_s32_zero) ++ INJECT_REG(PS3_ERR_IJ_GET_MSI_VEC_COUNT_INVALID, force_s32_letter_zero) ++ INJECT_REG(PS3_ERR_IJ_GET_MAX_CMD_COUNT_INVALID, force_fw_state_ff) ++ INJECT_REG(PS3_ERR_IJ_ALLOC_LEGACY_VECTOR_FAILED, force_s32_zero) ++ INJECT_REG(PS3_ERR_IJ_CPU_MSIX_TABLE_ALLOC_FAILED, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_POOL_ALLOC_FAILED, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_ALLOC_FAILED, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_REPLY_FIFO_POOL_ALLOC_FAILED, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_REPLY_VIRT_BASE_ALLOC_FAILED, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_IRQS_ALLOC_FAILED, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_REPLY_REQ_IRQS_FAILED, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_DUMP_REQ_IRQS_FAILED, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_IRQ_VECTORS_ALLOC_FAILED, force_s32_zero) ++ INJECT_REG(PS3_ERR_IJ_SAS_PHY_GET_ERR, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_SAS_PORT_ALLOC_NULL, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_SAS_ALLOC_NUM_NULL, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_SAS_PORT_ADD_FAILED, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_SAS_ALLOC_PHY_NULL, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_SAS_PHY_ADD_FAILED, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_SAS_ADD_ACK_FAILED, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_CHANGE_FW_TO_HALT_IN_PREPARE, change_fw_state_to_halt_in_recover_prepare) ++ INJECT_REG(PS3_ERR_IJ_ALLOC_EXP_NODE_NULL, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_ALLOC_EXP_PHYS_NULL, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_SAS_PORT_ALLOC_NULL1, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_SAS_PHY_GET_ERR1, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_SAS_ALLOC_PHY_NULL1, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_SAS_PHY_ADD_FAILED1, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_READ_ATU_REG_FAILED, force_reg_fail) ++ INJECT_REG(PS3_ERR_IJ_IOC_TO_READY_FAILED, force_ready_failed) ++ INJECT_REG(PS3_ERR_IJ_BIT_POS_ERR, force_atu_support_failed) ++ INJECT_REG(PS3_ERR_IJ_FORCE_ALLOC_CANCEL_CMD_FAILED, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_FORCE_CANCEL_CMD_RET_RECOVERY, force_ret_recovery) ++ INJECT_REG(PS3_ERR_IJ_FORCE_CANCEL_CMD_PCIE_ERR, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_WAIT_RESUME_WAIT_RECOVERY, force_hard_reset_request_1) ++ INJECT_REG(PS3_ERR_IJ_FORCE_STREAM_DETECT_FALSE, force_return_false) ++ INJECT_REG(PS3_ERR_IJ_PS3_INIT_FRAME_SYS_INFO_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_CMD_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_PS3_CMD_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_REQ_FRAME_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_RESP_FRAME_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_EXT_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_MGR_EXT_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_R1XLOCK_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_IOCTL_TRANSIENT_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_PERCPU_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_DELAY_WORK_POOL_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC1, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC2, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC1, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC2, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC1, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC2, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_DEBUG_MEM_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_DEBUG_MEM_ADDR_ALLOC, force_u64_zero) ++ INJECT_REG(PS3_ERR_IJ_PS3_DRV_INFO_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_HOST_MEM_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_PD_LIST_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_PD_INFO_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_VD_LIST_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_VD_INFO_BUF_SYNC_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_VD_INFO_BUF_ASYNC_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_VD_IDX_ARRAY_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_VD_ENTRIES_ARRAY_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_VD_DEVS_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_VD_PRI_DATA_IDXS_ARRAY_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_PD_ENTRIES_ARRAY_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_PD_IDX_ARRAY_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_PD_DEVS_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_SAS_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_SAS_PHY_BUF_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_PS3_VD_PENDING_CMD_ALLOC, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_FORCE_PCI_EN_MEM_FAILED, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_FORCE_PCI_RES_FLAGS_FAILED, force_s32_zero) ++ INJECT_REG(PS3_ERR_IJ_FORCE_PCI_REQ_REGION_FAILED, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_FORCE_PCI_IOREMAP_FAILED, force_pci_ioremap_fail) ++ INJECT_REG(PS3_ERR_IJ_ADD_INSTANCE_WAIT, wait_recovery_req_coming) ++ INJECT_REG(PS3_ERR_IJ_REMOVE_INSTANCE_WAIT, wait_recovery_req_coming) ++ INJECT_REG(PS3_ERR_IJ_ADD_INSTANCE, force_u8_1) ++ INJECT_REG(PS3_ERR_IJ_REMOVE_INSTANCE, force_u8_1) ++ INJECT_REG(PS3_ERR_IJ_FORCE_DUL_RECOVERY, force_multi_hard_req) ++ INJECT_REG(PS3_ERR_IJ_FORCE_START_DUL_RECOVERY, force_multi_hard_req) ++ INJECT_REG(PS3_ERR_IJ_WAIT_HARDRESET, wait_hard_recovery_req) ++ INJECT_REG(PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, force_multi_hard_req_pending) ++ INJECT_REG(PS3_ERR_IJ_FORCE_DESTROY_RECOVERY, force_recovery_wq_null) ++ INJECT_REG(PS3_ERR_IJ_FORCE_START_DESTROY_RECOVERY, force_recovery_wq_null) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, force_recovery_state_dead) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_PEER_STATE_DEAD, force_recovery_state_dead) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_NOT_SUPPORT, force_recovery_support_false) ++ INJECT_REG(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL, force_recovery_state_dead) ++ INJECT_REG(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_PEER_DEAD_FAIL, force_recovery_state_dead) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_REG_FAILED, force_ioc_not_running) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_PEER_COMPLETE_FAILED, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, force_mgr_cmd_alloc_null) ++ INJECT_REG(PS3_ERR_IJ_PD_LIST_WAIT_IRQ_DISABLE, wait_irq_disable) ++ INJECT_REG(PS3_ERR_IJ_PD_LIST_CMD_NO_RESP, force_mgr_cmd_no_resp) ++ INJECT_REG(PS3_ERR_IJ_PD_LIST_RESP_RETRY, force_pdlist_cmd_retry) ++ INJECT_REG(PS3_ERR_IJ_FORCE_ENTRY_NULL, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL1, force_recovery_state_dead) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_ALLOC_FAIL, force_memory_alloc_failed) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_DECIDE_PEER_INSTANCE_FAIL, force_instance_state_to_unnormal) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PCIE_ERR, force_pcie_err) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_PCIE_ERR, force_pcie_err) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_IOC_HALT, force_set_ioc_halt) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_IOC_HALT, force_set_ioc_halt) ++ INJECT_REG(PS3_ERR_IJ_FORCE_IOC_RUNNING_PCI_ERR, force_pcie_err) ++ INJECT_REG(PS3_ERR_IJ_FORCE_VDINFO_SUB_FAIL, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_FORCE_WEB_SUB_FAIL, force_ret_failed) ++ INJECT_REG(PS3_ERR_IJ_WAIT_RUNNING_FAIL, force_ioc_not_running) ++ INJECT_REG(PS3_ERR_IJ_WAIT_RUNNING_FAIL1, force_ioc_not_running) ++ INJECT_REG(PS3_ERR_IJ_WEB_SUBSCRIBE, force_web_subcribe) ++ INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_FINISH_STATE_NOOPERATIONAL, force_instance_state_to_unnormal) ++ INJECT_REG(PS3_ERR_IJ_FORCE_HARD_INIT_RUNNING_UNNORMAL, force_instance_probe_failed) ++ INJECT_REG(PS3_ERR_IJ_FORCE_HARD_READY_PCIE_ERRL, force_pcie_err) ++ INJECT_REG(PS3_ERR_IJ_WAIT_PM_INSTANCE_NULL, force_instance_null) ++ INJECT_REG(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET, force_half_reset) ++ INJECT_REG(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_1, force_half_reset_false) ++ INJECT_REG(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED, force_web_subscribe_failed) ++ INJECT_REG(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_1, force_return_fail) ++ INJECT_REG(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_2, force_cmd_delivering_zero) ++ INJECT_REG(PS3_ERR_IJ_WAIT_SUSPEND_VD_PENDING_FAILED, force_return_fail) ++ INJECT_REG(PS3_ERR_IJ_WAIT_RESUME_EVENT_FAILED, force_return_fail) ++ INJECT_REG(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_2, force_half_reset) ++ INJECT_REG(PS3_ERR_IJ_WAIT_RESUME_FUNCID_INVALID, force_func_id_invalid) ++ INJECT_REG(PS3_ERR_IJ_DUMP_WORK_FAILED, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_FEATURE_SUPPORT_ERR, force_reg_fail) ++ INJECT_REG(PS3_ERR_IJ_DUMP_STATUS_ERR, force_reg_fail) ++ INJECT_REG(PS3_ERR_IJ_DUMP_TYPE_INVALID, force_return_zero) ++ INJECT_REG(PS3_ERR_IJ_DUMP_PCIE_ERR, force_pcie_err) ++ INJECT_REG(PS3_ERR_IJ_DUMP_RECOVERY_ERR, force_instance_state_unnormal) ++ INJECT_REG(PS3_ERR_IJ_DUMP_TYPE_ILLEGAL, force_return_zero) ++ INJECT_REG(PS3_ERR_IJ_DUMP_WORK_QUEUE_NULL, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_DUMP_STATE_ILLEGAL, force_return_true) ++ INJECT_REG(PS3_ERR_IJ_DUMP_TRIGGER_FAIL, force_return_fail) ++ INJECT_REG(PS3_ERR_IJ_DUMP_DUMP_STATE_GET_FAIL, force_return_false) ++ INJECT_REG(PS3_ERR_IJ_DUMP_DUMP_STATE_INVALID, force_return_invalid) ++ INJECT_REG(PS3_ERR_IJ_DUMP_FILE_OPEN_FAIL, force_ptr_null) ++ INJECT_REG(PS3_ERR_IJ_DUMP_DATA_SIZE_FAIL, force_reg_fail) ++ INJECT_REG(PS3_ERR_IJ_DUMP_WRITE_FAIL, force_return_fail) ++ INJECT_REG(PS3_ERR_IJ_DUMP_ABORT_GET_CTRL_FAIL, force_return_false) ++ INJECT_REG(PS3_ERR_IJ_DUMP_END_GET_CTRL_FAIL, force_return_false) ++ INJECT_REG(PS3_ERR_IJ_DUMP_TRIGGER_GET_CTRL_FAIL, force_return_false) ++ INJECT_REG(PS3_ERR_IJ_DUMP_DATA_COPY_GET_CTRL_FAIL, force_return_false) ++ INJECT_REG(PS3_ERR_IJ_DUMP_IS_TRIGGER_GET_CTRL_FAIL, force_return_false) ++ INJECT_REG(PS3_ERR_IJ_DUMP_CTRL_ERR, force_reg_fail) ++ INJECT_REG(PS3_ERR_DUMP_ALLOC_FAILED, force_ptr_null) ++ INJECT_REG(PS3_ERR_RECOVERY_CONTEXT_ALLOC_FAILED, force_ptr_null) ++ INJECT_REG(PS3_ERR_FORCE_SET_CMD_INDEX_NOT_MGR, force_cmd_not_mgr_cmd) ++ INJECT_REG(PS3_ERR_EXP_ID_ERR, force_chan_err) ++ INJECT_REG(PS3_ERR_HBA_PHY_COUNT_ZERO, force_phy_count_zero) ++ INJECT_REG(PS3_ERR_IJ_CHANGE_FW_TO_HALT_IN_PREPARE, change_fw_state_to_halt_in_recover_prepare) ++ INJECT_REG(PS3_ERR_IJ_IOC_TO_READY_FAILED1, force_ready_failed) ++ INJECT_REG(PS3_ERR_IJ_REG_READ_ERR, force_reg_fail) ++ INJECT_REG(PS3_ERR_IJ_REG_READ_ZERO, force_reg_zero) ++ INJECT_REG(PS3_ERR_IJ_QOS_FORCE_TFIFO_ZERO_DEPTH, force_fifo_depth_zero) ++ INJECT_REG(PS3_ERR_IJ_FEATURE_REG_READ_ERR, force_reg_fail) ++ INJECT_REG(PS3_ERR_IJ_IOC_TO_CRITICAL, force_ioc_critical) ++ INJECT_REG(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL) ++ INJECT_REG(PS3_ERR_IJ_DEL_DEV_WAIT_OS_PRIV_DATA, NULL) ++ INJECT_REG(PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, NULL) ++ INJECT_REG(PS3_ERR_IJ_SGL_ADDR_PAGE_MODE_5, force_change_sgl_addr_to_page_mode_5) ++ INJECT_REG(PS3_ERR_IJ_SGL_ADDR_RESTORE, force_sgl_addr_restore) ++ INJECT_REG(PS3_ERR_IJ_FORCE_WAIT, NULL) ++ INJECT_REG(PS3_ERR_IJ_PD_ATTR_WAIT_OS_SCAN, NULL) ++ INJECT_REG(PS3_ERR_IJ_OS_SCAN, NULL) ++ INJECT_REG(PS3_ERR_IJ_PD_ATTR_WAIT_PD_ATTR, NULL) ++ INJECT_REG(PS3_ERR_IJ_PD_ATTR, NULL) ++ INJECT_REG(PS3_ERR_IJ_CMD_BLOCK_BEFORE_SEND_TO_IOC, wait_cmd_send_block) ++ INJECT_REG(PS3_ERR_IJ_FORCE_IOCTL_WAIT_RECOVERY, cli_wait_recovery) ++ INJECT_REG(PS3_ERR_IJ_FORCE_WAIT_CLI_CMD, recovery_wait_cli) ++ INJECT_REG(PS3_ERR_IJ_WDT_WAIT_REC_REQ, wait_recovery_request) ++ INJECT_REG(PS3_ERR_IJ_WDT_WAIT_REC_REQ_2, wait_recovery_request_2) ++ INJECT_REG(PS3_ERR_IJ_RECOVERY_BLOCK_BEFORE_RUNNING, recovery_wait_conditional) ++ INJECT_REG(PS3_ERR_IJ_CMD_SEND_INSTANCE_RECOVERY, force_instance_state_unnormal) ++ INJECT_REG(PS3_ERR_IJ_CMD_BLOCK_BEFORE_DELIVER_CNT, wait_cmd_send_block) ++ INJECT_REG(PS3_ERR_IJ_WDT_WAIT_REC_REQ_3, wait_f0_watchdog) ++ INJECT_REG(PS3_ERR_IJ_WDT_WAIT_REC_REQ_4, wait_f0_watchdog_2) ++ INJECT_REG(PS3_ERR_IJ_V2_IS_LOAD_FALSE, force_instance_unload) ++ INJECT_REG(PS3_ERR_IJ_V2_PCIE_ERR, force_instance_state_pci_err) ++ INJECT_REG(PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_UNORMAL, wait_instance_unnormal_and_set_flag) ++ INJECT_REG(PS3_ERR_IJ_V2_WAKE_RECOVERY_WAIT, set_send_cmd_task_mgr_busy_flag) ++ INJECT_REG(PS3_ERR_IJ_V2_RECOVERY_WAIT_NOTIFY, reset_target_pause) ++ INJECT_REG(PS3_ERR_IJ_V2_FORCE_INSTANCE_STATE_NORMAL, force_instance_state_normal) ++ INJECT_REG(PS3_ERR_IJ_V2_FORCE_INS_STATE_UNNORMAL, force_instance_state_unnormal) ++ INJECT_REG(PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_NORMAL, wait_instance_normal) ++ INJECT_REG(PS3_ERR_IJ_V2_FORCE_INS_DEAD, force_recovery_state_dead) ++ INJECT_REG(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, force_instance_unload) ++ INJECT_REG(PS3_ERR_IJ_V2_FORCE_INS_DEAD1, force_recovery_state_dead) ++ INJECT_REG(PS3_ERR_IJ_ABORT_BLOCK1, err_abort_block) ++ INJECT_REG(PS3_ERR_IJ_ABORT_BLOCK2, wait_cmd_send_block) ++ INJECT_REG(PS3_ERR_IJ_SAS_PORT_CREATE_FAIL, force_sas_port_create_fail) ++ INJECT_REG(PS3_ERR_IJ_DETECTED_REMOVE_BREAK, force_return_true) ++ INJECT_REG(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_2, force_pcie_remove_break) ++ INJECT_REG(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, check_pcie_remove_state) + + LOG_INFO("inject_init success\n"); + ps3_inject_init(); +@@ -2173,3 +3109,4 @@ + is_inject_init = PS3_FALSE; + } + #endif ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_err_inject.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_err_inject.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_err_inject.h 2025-06-10 20:13:00.221053492 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_err_inject.h 2025-06-10 20:13:00.492062946 +0800 +@@ -319,6 +319,209 @@ + PS3_ERR_IJ_SET_HIGH_IOPS_CHANNEL_IN_QOS, + PS3_ERR_IJ_FORCE_F0_WATCHDOG_START_HARD, + PS3_ERR_IJ_ADD_DISK_HOST_RESET, ++ PS3_ERR_IJ_PCIE_FROZEN, ++ PS3_ERR_IJ_PEER_PCIE_FROZEN, ++ PS3_ERR_IJ_ASYNC_HARDRESET_PROBE, ++ PS3_ERR_IJ_ASYNC_HARDRESET_REMOVE, ++ PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY, ++ PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY_1, ++ PS3_ERR_IJ_MOD_SO_ADDR, ++ PS3_ERR_IJ_SHUTDOWN_HARDRESET, ++ PS3_ERR_IJ_CANCEL_WEB_CMD_ALLOC_NULL, ++ PS3_ERR_IJ_GET_REPLYQ_COUNT_INVALID, ++ PS3_ERR_IJ_GET_MSIX_VEC_COUNT_INVALID, ++ PS3_ERR_IJ_GET_MSI_VEC_COUNT_INVALID, ++ PS3_ERR_IJ_GET_MAX_CMD_COUNT_INVALID, ++ PS3_ERR_IJ_ALLOC_LEGACY_VECTOR_FAILED, ++ PS3_ERR_IJ_CPU_MSIX_TABLE_ALLOC_FAILED, ++ PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_POOL_ALLOC_FAILED, ++ PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_ALLOC_FAILED, ++ PS3_ERR_IJ_REPLY_FIFO_POOL_ALLOC_FAILED, ++ PS3_ERR_IJ_REPLY_VIRT_BASE_ALLOC_FAILED, ++ PS3_ERR_IJ_IRQS_ALLOC_FAILED, ++ PS3_ERR_IJ_REPLY_REQ_IRQS_FAILED, ++ PS3_ERR_IJ_DUMP_REQ_IRQS_FAILED, ++ PS3_ERR_IJ_IRQ_VECTORS_ALLOC_FAILED, ++ PS3_ERR_IJ_SAS_PHY_GET_ERR, ++ PS3_ERR_IJ_SAS_PORT_ALLOC_NULL, ++ PS3_ERR_IJ_SAS_ALLOC_NUM_NULL, ++ PS3_ERR_IJ_SAS_PORT_ADD_FAILED, ++ PS3_ERR_IJ_SAS_ALLOC_PHY_NULL, ++ PS3_ERR_IJ_SAS_PHY_ADD_FAILED, ++ PS3_ERR_IJ_SAS_ADD_ACK_FAILED, ++ PS3_ERR_IJ_ALLOC_EXP_NODE_NULL, ++ PS3_ERR_IJ_ALLOC_EXP_PHYS_NULL, ++ PS3_ERR_IJ_SAS_PORT_ALLOC_NULL1, ++ PS3_ERR_IJ_SAS_PHY_GET_ERR1, ++ PS3_ERR_IJ_SAS_ALLOC_PHY_NULL1, ++ PS3_ERR_IJ_SAS_PHY_ADD_FAILED1, ++ PS3_ERR_IJ_READ_ATU_REG_FAILED, ++ PS3_ERR_IJ_IOC_TO_READY_FAILED, ++ PS3_ERR_IJ_BIT_POS_ERR, ++ PS3_ERR_RECOVERY_CONTEXT_ALLOC_FAILED, ++ PS3_ERR_IJ_FORCE_ALLOC_CANCEL_CMD_FAILED, ++ PS3_ERR_IJ_FORCE_CANCEL_CMD_RET_RECOVERY, ++ PS3_ERR_IJ_FORCE_CANCEL_CMD_PCIE_ERR, ++ PS3_ERR_IJ_WAIT_RESUME_WAIT_RECOVERY, ++ PS3_ERR_IJ_FORCE_STREAM_DETECT_FALSE, ++ PS3_ERR_IJ_PS3_INIT_FRAME_SYS_INFO_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_CMD_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_PS3_CMD_ALLOC, ++ PS3_ERR_IJ_PS3_REQ_FRAME_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_RESP_FRAME_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_EXT_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_MGR_EXT_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_R1XLOCK_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_IOCTL_TRANSIENT_ALLOC, ++ PS3_ERR_IJ_PS3_PERCPU_ALLOC, ++ PS3_ERR_IJ_PS3_DELAY_WORK_POOL_ALLOC, ++ PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC1, ++ PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC2, ++ PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC1, ++ PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC2, ++ PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC1, ++ PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC2, ++ PS3_ERR_IJ_PS3_DEBUG_MEM_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_DEBUG_MEM_ADDR_ALLOC, ++ PS3_ERR_IJ_PS3_DRV_INFO_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_HOST_MEM_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_PD_LIST_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_PD_INFO_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_VD_LIST_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_VD_INFO_BUF_SYNC_ALLOC, ++ PS3_ERR_IJ_PS3_VD_INFO_BUF_ASYNC_ALLOC, ++ PS3_ERR_IJ_PS3_VD_IDX_ARRAY_ALLOC, ++ PS3_ERR_IJ_PS3_VD_ENTRIES_ARRAY_ALLOC, ++ PS3_ERR_IJ_PS3_VD_DEVS_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_VD_PRI_DATA_IDXS_ARRAY_ALLOC, ++ PS3_ERR_IJ_PS3_PD_ENTRIES_ARRAY_ALLOC, ++ PS3_ERR_IJ_PS3_PD_IDX_ARRAY_ALLOC, ++ PS3_ERR_IJ_PS3_PD_DEVS_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_SAS_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_SAS_PHY_BUF_ALLOC, ++ PS3_ERR_IJ_PS3_VD_PENDING_CMD_ALLOC, ++ PS3_ERR_IJ_FORCE_PCI_EN_MEM_FAILED, ++ PS3_ERR_IJ_FORCE_PCI_RES_FLAGS_FAILED, ++ PS3_ERR_IJ_FORCE_PCI_REQ_REGION_FAILED, ++ PS3_ERR_IJ_FORCE_PCI_IOREMAP_FAILED, ++ PS3_ERR_IJ_ADD_INSTANCE_WAIT, ++ PS3_ERR_IJ_REMOVE_INSTANCE_WAIT, ++ PS3_ERR_IJ_ADD_INSTANCE, ++ PS3_ERR_IJ_REMOVE_INSTANCE, ++ PS3_ERR_IJ_FORCE_DUL_RECOVERY, ++ PS3_ERR_IJ_FORCE_START_DUL_RECOVERY, ++ PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, ++ PS3_ERR_IJ_FORCE_DESTROY_RECOVERY, ++ PS3_ERR_IJ_FORCE_START_DESTROY_RECOVERY, ++ PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, ++ PS3_ERR_IJ_FORCE_RECOVERY_PEER_STATE_DEAD, ++ PS3_ERR_IJ_FORCE_RECOVERY_NOT_SUPPORT, ++ PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL, ++ PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_PEER_DEAD_FAIL, ++ PS3_ERR_IJ_FORCE_RECOVERY_REG_FAILED, ++ PS3_ERR_IJ_FORCE_RECOVERY_PEER_COMPLETE_FAILED, ++ PS3_ERR_IJ_WAIT_HARDRESET, ++ PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, ++ PS3_ERR_IJ_PD_LIST_WAIT_IRQ_DISABLE, ++ PS3_ERR_IJ_PD_LIST_CMD_NO_RESP, ++ PS3_ERR_IJ_PD_LIST_RESP_RETRY, ++ PS3_ERR_IJ_FORCE_ENTRY_NULL, ++ PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL1, ++ PS3_ERR_IJ_FORCE_RECOVERY_ALLOC_FAIL, ++ PS3_ERR_IJ_FORCE_RECOVERY_DECIDE_PEER_INSTANCE_FAIL, ++ PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PCIE_ERR, ++ PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_PCIE_ERR, ++ PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_IOC_HALT, ++ PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_IOC_HALT, ++ PS3_ERR_IJ_FORCE_IOC_RUNNING_PCI_ERR, ++ PS3_ERR_IJ_FORCE_VDINFO_SUB_FAIL, ++ PS3_ERR_IJ_FORCE_WEB_SUB_FAIL, ++ PS3_ERR_IJ_WAIT_RUNNING_FAIL, ++ PS3_ERR_IJ_WEB_SUBSCRIBE, ++ PS3_ERR_IJ_FORCE_RECOVERY_FINISH_STATE_NOOPERATIONAL, ++ PS3_ERR_IJ_FORCE_HARD_INIT_RUNNING_UNNORMAL, ++ PS3_ERR_IJ_FORCE_HARD_READY_PCIE_ERRL, ++ PS3_ERR_IJ_WAIT_RUNNING_FAIL1, ++ PS3_ERR_DUMP_ALLOC_FAILED, ++ PS3_ERR_IJ_DUMP_WORK_FAILED, ++ PS3_ERR_IJ_FEATURE_SUPPORT_ERR, ++ PS3_ERR_IJ_DUMP_STATUS_ERR, ++ PS3_ERR_IJ_DUMP_TYPE_INVALID, ++ PS3_ERR_IJ_DUMP_PCIE_ERR, ++ PS3_ERR_IJ_DUMP_RECOVERY_ERR, ++ PS3_ERR_IJ_DUMP_TYPE_ILLEGAL, ++ PS3_ERR_IJ_DUMP_WORK_QUEUE_NULL, ++ PS3_ERR_IJ_DUMP_STATE_ILLEGAL, ++ PS3_ERR_IJ_DUMP_TRIGGER_FAIL, ++ PS3_ERR_IJ_DUMP_DUMP_STATE_GET_FAIL, ++ PS3_ERR_IJ_DUMP_DUMP_STATE_INVALID, ++ PS3_ERR_IJ_DUMP_FILE_OPEN_FAIL, ++ PS3_ERR_IJ_DUMP_DATA_SIZE_FAIL, ++ PS3_ERR_IJ_DUMP_WRITE_FAIL, ++ PS3_ERR_IJ_DUMP_ABORT_GET_CTRL_FAIL, ++ PS3_ERR_IJ_DUMP_END_GET_CTRL_FAIL, ++ PS3_ERR_IJ_DUMP_TRIGGER_GET_CTRL_FAIL, ++ PS3_ERR_IJ_DUMP_DATA_COPY_GET_CTRL_FAIL, ++ PS3_ERR_IJ_DUMP_IS_TRIGGER_GET_CTRL_FAIL, ++ PS3_ERR_IJ_DUMP_CTRL_ERR, ++ PS3_ERR_IJ_WAIT_PM_INSTANCE_NULL, ++ PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET, ++ PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_1, ++ PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED, ++ PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_1, ++ PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_2, ++ PS3_ERR_IJ_WAIT_SUSPEND_VD_PENDING_FAILED, ++ PS3_ERR_IJ_WAIT_RESUME_EVENT_FAILED, ++ PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_2, ++ PS3_ERR_IJ_WAIT_RESUME_FUNCID_INVALID, ++ PS3_ERR_FORCE_SET_CMD_INDEX_NOT_MGR, ++ PS3_ERR_EXP_ID_ERR, ++ PS3_ERR_HBA_PHY_COUNT_ZERO, ++ PS3_ERR_IJ_IOC_TO_READY_FAILED1, ++ PS3_ERR_IJ_REG_READ_ZERO, ++ PS3_ERR_IJ_REG_READ_ERR, ++ PS3_ERR_IJ_QOS_FORCE_TFIFO_ZERO_DEPTH, ++ PS3_ERR_IJ_FEATURE_REG_READ_ERR, ++ PS3_ERR_IJ_IOC_TO_CRITICAL, ++ PS3_ERR_IJ_CHANGE_FW_TO_HALT_IN_PREPARE, ++ PS3_ERR_IJ_GET_PRIV_DATA_DELAY, ++ PS3_ERR_IJ_DEL_DEV_WAIT_OS_PRIV_DATA, ++ PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, ++ PS3_ERR_IJ_FORCE_WAIT, ++ PS3_ERR_IJ_PD_ATTR_WAIT_OS_SCAN, ++ PS3_ERR_IJ_OS_SCAN, ++ PS3_ERR_IJ_PD_ATTR_WAIT_PD_ATTR, ++ PS3_ERR_IJ_PD_ATTR, ++ PS3_ERR_IJ_CMD_BLOCK_BEFORE_SEND_TO_IOC, ++ PS3_ERR_IJ_SGL_ADDR_PAGE_MODE_5, ++ PS3_ERR_IJ_SGL_ADDR_RESTORE, ++ PS3_ERR_IJ_FORCE_IOCTL_WAIT_RECOVERY, ++ PS3_ERR_IJ_FORCE_WAIT_CLI_CMD, ++ PS3_ERR_IJ_WDT_WAIT_REC_REQ, ++ PS3_ERR_IJ_WDT_WAIT_REC_REQ_2, ++ PS3_ERR_IJ_WDT_WAIT_REC_REQ_3, ++ PS3_ERR_IJ_WDT_WAIT_REC_REQ_4, ++ PS3_ERR_IJ_RECOVERY_BLOCK_BEFORE_RUNNING, ++ PS3_ERR_IJ_CMD_SEND_WAIT_RECOVERY_END, ++ PS3_ERR_IJ_CMD_SEND_INSTANCE_RECOVERY, ++ PS3_ERR_IJ_CMD_BLOCK_BEFORE_DELIVER_CNT, ++ PS3_ERR_IJ_V2_IS_LOAD_FALSE, ++ PS3_ERR_IJ_V2_PCIE_ERR, ++ PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_UNORMAL, ++ PS3_ERR_IJ_V2_WAKE_RECOVERY_WAIT, ++ PS3_ERR_IJ_V2_RECOVERY_WAIT_NOTIFY, ++ PS3_ERR_IJ_V2_FORCE_INSTANCE_STATE_NORMAL, ++ PS3_ERR_IJ_V2_FORCE_INS_STATE_UNNORMAL, ++ PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_NORMAL, ++ PS3_ERR_IJ_V2_FORCE_INS_DEAD, ++ PS3_ERR_IJ_V2_IS_LOAD_FALSE1, ++ PS3_ERR_IJ_V2_FORCE_INS_DEAD1, ++ PS3_ERR_IJ_ABORT_BLOCK1, ++ PS3_ERR_IJ_ABORT_BLOCK2, ++ PS3_ERR_IJ_SAS_PORT_CREATE_FAIL, ++ PS3_ERR_IJ_DETECTED_REMOVE_BREAK, ++ PS3_ERR_IJ_DETECTED_REMOVE_BREAK_2, ++ PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, + PS3_ERR_IJ_MAX_COUNT, + }InjectType_E; + struct ps3_rec_work_context { +@@ -340,17 +543,34 @@ + injectCallback callback; + Bool active; + U16 count; ++ U8 is_hit_pre:1; ++ U8 is_hit_post:1; ++ U8 reserved:6; + }Ps3Injection_t; + + void inject_register(U16 err_type, injectCallback callback); + void inject_active_intf(U16 err_type, U16 count); + void inject_execute_callback(U16 err_type, void * data); + void inject_execute_callback_at_time(U16 err_type, void * data); ++void inject_execute_callback_relevance_wait_pre(U16 err_type, U16 err_type_wait, void *data); ++void inject_execute_callback_relevance_wait_post(U16 err_type, U16 err_type_wait, void *data); ++void inject_execute_callback_at_time_relevance_wait_pre(U16 err_type, ++ U16 err_type_wait, void *data); ++void inject_execute_callback_at_time_relevance_wait_post(U16 err_type, ++ U16 err_type_wait, void *data); + + #define INJECT_REG(type, callback) inject_register(type, (injectCallback)callback); +-#define INJECT_ACTIVE(type, count) inject_active_intf(type, count); ++#define INJECT_ACTIVE(type, count) do { inject_active_intf(type, count); } while (0) + #define INJECT_START(type, data) inject_execute_callback(type, data); + #define INJECT_AT_TIMES(type, data) inject_execute_callback_at_time(type, data); ++#define INJECT_START_WAIT_REV_PRE(type, type_wait, data) \ ++ do { inject_execute_callback_relevance_wait_pre(type, type_wait, data); } while (0) ++#define INJECT_START_WAIT_REV_POST(type, type_wait, data) \ ++ do { inject_execute_callback_relevance_wait_post(type, type_wait, data); } while (0) ++#define INJECT_START_AT_TIME_WAIT_REV_PRE(type, type_wait, data) \ ++ do { inject_execute_callback_at_time_relevance_wait_pre(type, type_wait, data); } while (0) ++#define INJECT_START_AT_TIME_WAIT_REV_POST(type, type_wait, data) \ ++ do { inject_execute_callback_at_time_relevance_wait_post(type, type_wait, data); } while (0) + + + +@@ -369,6 +589,9 @@ + void active_err_inject(void); + void ps3_wait_recovery_rand_finish(void); + ++void ps3_err_inject_wait_pre(U16 err_type_wait); ++void ps3_err_inject_wait_post(U16 err_type_wait); ++ + #define INJECT_PROBE_ACTIVE() active_err_inject(); + void inject_init(void); + void inject_exit(void); +@@ -384,6 +607,11 @@ + #define INJECT_ACTIVE(type, count) + #define INJECT_START(type, data) + #define INJECT_AT_TIMES(type, data) ++#define INJECT_START_WAIT_REV_PRE(type, type_wait, data) ++#define INJECT_START_WAIT_REV_POST(type, type_wait, data) ++#define INJECT_START_AT_TIME_WAIT_REV_PRE(type, type_wait, data) ++#define INJECT_START_AT_TIME_WAIT_REV_POST(type, type_wait, data) ++ + #define INJECT_INIT() + #define INJECT_EXIT() + #define INJECT_PROBE_ACTIVE() +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_event.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_event.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_event.c 2025-06-10 20:13:00.221053492 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_event.c 2025-06-10 20:13:00.501063260 +0800 +@@ -204,6 +204,7 @@ + ULong flags = 0; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + struct PS3MgrEvent *event_req_info = NULL; ++ INJECT_START(PS3_ERR_IJ_INS_STATE_UNNORMAL, &instance->state_machine.is_load) + + if (!instance->state_machine.is_load) { + LOG_WARN_IN_IRQ(instance, +@@ -385,18 +386,17 @@ + cmd->trace_id, PS3_HOST(instance), delay_work->event_delay); + } + +-static void ps3_event_handle(struct ps3_event_delay_work* ps3_delay_work) ++void ps3_event_handle(struct ps3_event_delay_work *ps3_delay_work) + { + struct ps3_cmd *cmd = ps3_delay_work->cmd; + struct ps3_instance *instance = cmd->instance; + struct PS3EventInfo* event_info = instance->event_context.event_info; + U32 event_proc_result_bitmap = PS3_EVT_ILLEGAL_TYPE; + struct ps3_event_delay_work* ps3_new_delay_work = NULL; +- + ULong flags = 0; +- S32 ret; ++ S32 ret; + +- INJECT_START(PS3_ERR_IJ_EVENT_CMD_NULL, instance) ++ INJECT_START(PS3_ERR_IJ_EVENT_CMD_NULL, instance); + if (instance->event_context.event_cmd == NULL) { + LOG_WARN("trace_id[0x%llx], hno:%u Event is unsubscribed\n", + cmd->trace_id, PS3_HOST(instance)); +@@ -457,8 +457,8 @@ + "trace_id[0x%llx], hno:%u Event proc free cmd:%d, abort_eventcmd %d!\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, + instance->event_context.abort_eventcmd); +- instance->event_context.event_cmd = NULL; +- ps3_mgr_cmd_free(instance, cmd); ++ instance->event_context.event_cmd = NULL; ++ ps3_mgr_cmd_free(instance, cmd); + ps3_new_delay_work = + (ps3_delay_work == &instance->event_context.delay_work_pool[PS3_EVENT_WORKER_POOL_SIZE - 1])? + (&instance->event_context.delay_work_pool[0]):(ps3_delay_work + 1); +@@ -528,6 +528,7 @@ + #ifndef _WINDOWS + delay_work_pool = (struct ps3_event_delay_work *)ps3_kzalloc(instance, + sizeof(struct ps3_event_delay_work) * PS3_EVENT_WORKER_POOL_SIZE); ++ INJECT_START(PS3_ERR_IJ_PS3_DELAY_WORK_POOL_ALLOC, &delay_work_pool); + if (delay_work_pool == NULL) { + LOG_ERROR("hno:%u delay work kzalloc failed!\n", + PS3_HOST(instance)); +@@ -535,8 +536,8 @@ + } + event_ctx->delay_work_pool = delay_work_pool; + for(idx = 0; idx < PS3_EVENT_WORKER_POOL_SIZE; idx++){ +- delay_work = &delay_work_pool[idx]; +- INIT_DELAYED_WORK(&delay_work->event_work, ps3_event_polling); ++ delay_work = &delay_work_pool[idx]; ++ INIT_DELAYED_WORK(&delay_work->event_work, ps3_event_polling); + } + event_ctx->delay_work = &delay_work_pool[0]; + event_ctx->event_cmd = NULL; +@@ -606,6 +607,7 @@ + } + + ret = ps3_event_register(instance, event_req_info); ++ INJECT_START(PS3_ERR_IJ_WAIT_RESUME_EVENT_FAILED, &ret) + if (ret != PS3_SUCCESS) { + LOG_WARN_IN_IRQ(instance, "hno:%u Failed to register event cmd, ret: %d\n", + PS3_HOST(instance), ret); +@@ -651,7 +653,7 @@ + INJECT_START(PS3_ERR_IJ_SUBC_EVENT_CMD_INIT, instance) + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); +- LOG_ERROR("hno:%u had been free,CFID:%d\n", ++ LOG_WARN("hno:%u had been free,CFID:%d\n", + PS3_HOST(instance), cmd->index); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + event_ctx->event_cmd = NULL; +@@ -744,7 +746,7 @@ + INJECT_START(PS3_ERR_IJ_RESUBC_EVENT_CMD_INIT, instance) + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); +- LOG_ERROR("hno:%u had been free,CFID:%d\n", ++ LOG_WARN("hno:%u had been free,CFID:%d\n", + PS3_HOST(instance), cmd->index); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + event_ctx->event_cmd = NULL; +@@ -935,8 +937,8 @@ + cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + +- if (ps3_async_cmd_send(cmd->instance, cmd) != PS3_SUCCESS) { +- LOG_ERROR("trace_id[0x%llx],CFID[%d],hno:%u resend web cmd NOK\n", ++ if (ps3_async_cmd_send(cmd->instance, cmd) != PS3_SUCCESS) { ++ LOG_ERROR_IN_IRQ(instance, "trace_id[0x%llx],CFID[%d],hno:%u resend web cmd NOK\n", + cmd->trace_id,cmd->index, PS3_HOST(cmd->instance)); + + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); +@@ -1008,7 +1010,7 @@ + ret = ps3_web_subscribe(instance); + if (ret != PS3_SUCCESS) { + LOG_ERROR_IN_IRQ(instance, +- "hno:%u web subscribe failed!\n", ++ "hno:%u web subscribe failed!\n", + PS3_HOST(instance)); + } + instance->webSubscribe_context.abort_webcmd = 0; +@@ -1021,7 +1023,7 @@ + cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + LOG_INFO_IN_IRQ(instance, +- "trace_id[0x%llx],CFID[%d], hno:%u failed!\n", ++ "trace_id[0x%llx],CFID[%d], hno:%u failed!\n", + cmd->trace_id, cmd->index, PS3_HOST(instance)); + l_out: + return ret; +@@ -1072,7 +1074,7 @@ + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); +- LOG_ERROR("hno:%u had been free,CFID:%d\n", ++ LOG_WARN("hno:%u had been free,CFID:%d\n", + PS3_HOST(instance), cmd->index); + web_context->webSubscribe_cmd = NULL; + ret = PS3_SUCCESS; +@@ -1087,6 +1089,7 @@ + } + + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_WEB_CMD); ++ INJECT_START(PS3_ERR_IJ_CANCEL_WEB_CMD_ALLOC_NULL, &ret) + if(ret == -PS3_ENOMEM){ + LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); + ret = -PS3_FAILED; +@@ -1105,6 +1108,7 @@ + goto l_out; + } + ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_WEB_CMD); ++ INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_1, &ret) + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u event cancel cmd NOK, ret:%d\n", + PS3_HOST(instance), ret); +@@ -1147,7 +1151,7 @@ + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); +- LOG_ERROR("hno:%u had been free,CFID:%d\n", ++ LOG_WARN("hno:%u had been free,CFID:%d\n", + PS3_HOST(instance), cmd->index); + web_context->webSubscribe_cmd = NULL; + ret = PS3_SUCCESS; +@@ -1170,7 +1174,7 @@ + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } else if (ret != PS3_SUCCESS) { +- ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); ++ ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", + PS3_HOST(instance), ps3_cmd_frame_id(instance->webSubscribe_context.web_abort_cmd), cmd->index); + abort_cmd = instance->webSubscribe_context.web_abort_cmd; +@@ -1234,7 +1238,7 @@ + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); +- LOG_ERROR("hno:%u free this cmd,CFID:%d\n", ++ LOG_WARN("hno:%u free this cmd,CFID:%d\n", + PS3_HOST(instance), cmd->index); + instance->webSubscribe_context.webSubscribe_cmd = NULL; + goto l_out; +@@ -1250,3 +1254,4 @@ + l_out: + return; + } ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_event.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_event.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_event.h 2025-06-10 20:13:00.221053492 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_event.h 2025-06-10 20:13:00.502063295 +0800 +@@ -12,6 +12,7 @@ + S32 ps3_event_subscribe(struct ps3_instance *instance); + S32 ps3_event_unsubscribe(struct ps3_instance *instance); + S32 ps3_soft_reset_event_resubscribe(struct ps3_instance *instance); ++void ps3_event_handle(struct ps3_event_delay_work *ps3_delay_work); + + S32 ps3_event_service(struct ps3_cmd *cmd, U16 reply_flags); + S32 ps3_event_delay_set(struct ps3_instance *instance, U32 delay); +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_inject.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_inject.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_inject.c 2025-06-10 20:13:00.221053492 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_inject.c 2025-06-10 20:13:00.502063295 +0800 +@@ -446,7 +446,7 @@ + ps3_r1x_write_unlock(&data->lock_mgr, cmd); + } + } else { +- LOG_ERROR("hno:%u force stop scsi has Null pointer CFID[%u]\n", ++ LOG_WARN("hno:%u force stop scsi has Null pointer CFID[%u]\n", + PS3_HOST(cmd->instance), cmd->index); + } + if (cmd->r1x_peer_cmd != NULL) { +@@ -705,7 +705,7 @@ + ps3_mutex_lock(&g_inject_list.lock); + if (list_empty(&g_hit_cmd_list.mgr_list)) { + LOG_DEBUG("[inject] task inject list is empty!\n"); +- goto l_out; ++ goto l_unlock; + } + + list_for_each_entry_safe(p_cmd, p_cmd_next, &g_hit_cmd_list.mgr_list, list) { +@@ -719,7 +719,7 @@ + } + + if (!is_find){ +- goto l_out; ++ goto l_unlock; + } + + if (p_cmd->pitem->item.mgr_cmd.dealType == PS3_MGR_CMD_TIMEOUT) { +@@ -739,9 +739,9 @@ + if(pitem->item.mgr_cmd.inject_count == 0) { + ps3_delete_mgr_inject(pitem); + } +- +-l_out: ++l_unlock: + ps3_mutex_unlock(&g_inject_list.lock); ++l_out: + return iRet; + } + +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_inner_data.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_inner_data.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_inner_data.h 2025-06-10 20:13:00.222053527 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_inner_data.h 2025-06-10 20:13:00.502063295 +0800 +@@ -16,10 +16,10 @@ + #include "ps3_htp_event.h" + #include "ps3_htp_dev.h" + #include "ps3_htp_pci.h" +-#include "hwapi/include_cs100/s1861_regs/s1861_global_baseaddr.h" +-#include "hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h" +-#include "hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h" +-#include "hwapi/include_cs100/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h" ++#include "hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h" ++#include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h" ++#include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h" ++#include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h" + + #include "ps3_device_manager.h" + #include "ps3_register_fifo.h" +@@ -44,12 +44,16 @@ + #define PS3_MAX_REPLY_QUE_COUNT (128) + #define PS3_RAIDHBA_NUM_ADJUST_VALUE (1) + ++#define PS3_DEVICE_IO_BUSY_THRESHOLD (8) ++ + #if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 4)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 1)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0))) + #include ++#ifndef PS3_TAGSET_SUPPORT + #define PS3_TAGSET_SUPPORT + #endif ++#endif + + #if ((LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9 && RHEL_MINOR >= 2)) || \ +@@ -146,7 +150,7 @@ + }; + + enum { +- PS3_REG_OFFSET_REQUEST_QUE = \ ++ PS3_REG_OFFSET_REQUEST_QUE = + (HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DOORBELL = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +@@ -156,7 +160,7 @@ + (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_IRQ_CONTROL = \ + (HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_SOFTRESET_KEY = \ ++ PS3_REG_OFFSET_SOFTRESET_KEY = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_STATE = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +@@ -174,11 +178,11 @@ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_TIME_OUT_CNT = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_HARDRESET_KEY = \ ++ PS3_REG_OFFSET_HARDRESET_KEY = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_HARDRESET_STATE = \ ++ PS3_REG_OFFSET_HARDRESET_STATE = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_HARDRESET = \ ++ PS3_REG_OFFSET_HARDRESET = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_LOW = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +@@ -232,25 +236,25 @@ + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_IRQ_STATUS_RPT = \ + (HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_DUMP_CTRL = \ ++ PS3_REG_OFFSET_DUMP_CTRL = + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_CTRl_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_CTRl_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_DUMP_STATUS = \ ++ PS3_REG_OFFSET_DUMP_STATUS = + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_DUMP_DATA_SIZE = \ ++ PS3_REG_OFFSET_DUMP_DATA_SIZE = + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_CMD_TRIGGER = \ ++ PS3_REG_OFFSET_CMD_TRIGGER = + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_CMD_TRIGGER_IRQ_CLEAR = \ ++ PS3_REG_OFFSET_CMD_TRIGGER_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_CMD_TRIGGER_IRQ_MASK = \ ++ PS3_REG_OFFSET_CMD_TRIGGER_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_REG_CMD_STATE = \ ++ PS3_REG_OFFSET_REG_CMD_STATE = + (HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +- PS3_REG_OFFSET_SOFTRESET_COUNTER = \ ++ PS3_REG_OFFSET_SOFTRESET_COUNTER = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG0 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_instance_manager.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_instance_manager.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_instance_manager.c 2025-06-10 20:13:00.222053527 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_instance_manager.c 2025-06-10 20:13:00.509063539 +0800 +@@ -5,6 +5,8 @@ + + #ifndef _WINDOWS + #include "ps3_debug.h" ++#include ++#include + #endif + #include "ps3_cli_debug.h" + +@@ -19,6 +21,8 @@ + #define PS3_INSTANCE_STATE_CHECK_INTERVAL_MS (1000) + #endif + ++struct ps3_host_info g_ps3_host_info; ++ + #ifndef _WINDOWS + struct ps3_mgmt_info *ps3_mgmt_info_get(void) + { +@@ -51,7 +55,7 @@ + return ret; + } + +- spin_lock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { + if (pitem == &instance->list_item) { + pitem = NULL; +@@ -61,22 +65,32 @@ + + list_for_each_entry(peer_instance, &ps3_mgmt_info_get()->instance_list_head, list_item) { + if (peer_instance != NULL && ++ ps3_get_pci_domain(peer_instance->pdev) == ps3_get_pci_domain(instance->pdev) && + peer_instance->pdev->bus->number == instance->pdev->bus->number && + PCI_SLOT(peer_instance->pdev->devfn) == PCI_SLOT(instance->pdev->devfn)) { ++ INJECT_START(PS3_ERR_IJ_ASYNC_HARDRESET_PROBE, peer_instance) ++ peer_instance->recovery_context->instance_change = 1; ++ INJECT_START(PS3_ERR_IJ_ADD_INSTANCE_WAIT, peer_instance) ++ mb(); /* in order to force CPU ordering */ ++ ps3_recovery_cancel_work_sync(peer_instance); + instance->peer_instance = peer_instance; + peer_instance->peer_instance = instance; ++ mb(); /* in order to force CPU ordering */ ++ peer_instance->recovery_context->instance_change = 0; + } + } + + list_add(&instance->list_item, &ps3_mgmt_info_get()->instance_list_head); + mutex_init(&instance->state_machine.lock); ++ ps3_mutex_init(&instance->task_mgr_reset_lock); ++ ps3_mutex_init(&instance->task_abort_lock); + atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_INIT); + instance->state_machine.is_load = PS3_FALSE; + instance->state_machine.is_pci_err_recovery = PS3_FALSE; + + ret = PS3_SUCCESS; + l_repeat_add: +- spin_unlock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + if (pitem == NULL) { + LOG_WARN("hno:%u repeat add instance!\n", + PS3_HOST(instance)); +@@ -92,33 +106,47 @@ + return -PS3_FAILED; + } + +- spin_lock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + list_del(&instance->list_item); + instance->peer_instance = NULL; + list_for_each_entry(peer_instance, &ps3_mgmt_info_get()->instance_list_head, list_item) { + if (peer_instance != NULL && ++ ps3_get_pci_domain(peer_instance->pdev) == ps3_get_pci_domain(instance->pdev) && + peer_instance->pdev->bus->number == instance->pdev->bus->number && + PCI_SLOT(peer_instance->pdev->devfn) == PCI_SLOT(instance->pdev->devfn)) { ++ INJECT_START(PS3_ERR_IJ_ASYNC_HARDRESET_REMOVE, peer_instance) ++ INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE_WAIT, peer_instance) ++ peer_instance->recovery_context->instance_change = 1; ++ mb(); /* in order to force CPU ordering */ ++ ps3_recovery_cancel_work_sync(peer_instance); + peer_instance->peer_instance = NULL; ++ mb(); /* in order to force CPU ordering */ ++ peer_instance->recovery_context->instance_change = 0; + } + } + mutex_destroy(&instance->state_machine.lock); + ps3_mutex_destroy(&instance->task_mgr_reset_lock); + ps3_mutex_destroy(&instance->task_abort_lock); +- spin_unlock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + + return PS3_SUCCESS; + } + + void ps3_mgmt_info_init(void) + { +- ps3_spin_lock_init(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_init(&ps3_mgmt_info_get()->ps3_mgmt_lock); + INIT_LIST_HEAD(&ps3_mgmt_info_get()->instance_list_head); + + ps3_cli_debug_init(); + + return; + } ++ ++void ps3_mgmt_exit(void) ++{ ++ ps3_mutex_destroy(&ps3_mgmt_info_get()->ps3_mgmt_lock); ++} ++ + #endif + void ps3_instance_init(struct ps3_instance *instance) + { +@@ -241,7 +269,7 @@ + l_success: + ps3_atomic_set(&instance->state_machine.state, dest_state); + ps3_mutex_unlock(&instance->state_machine.lock); +- LOG_WARN("hno:%u state transfer from %s to %s!\n", ++ LOG_INFO("hno:%u state transfer from %s to %s!\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state), + namePS3InstanceState(dest_state)); +@@ -351,13 +379,18 @@ + return -PS3_FAILED; + l_success: + ps3_atomic_set(&instance->state_machine.state, dest_state); +- LOG_WARN("hno:%u state transfer from %s to %s!\n", ++ LOG_INFO("hno:%u state transfer from %s to %s!\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state), + namePS3InstanceState(dest_state)); + return PS3_SUCCESS; + } + ++void ps3_instance_state_transfer_to_dead_nolock(struct ps3_instance *instance) ++{ ++ ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_DEAD); ++} ++ + void ps3_instance_state_transfer_to_dead(struct ps3_instance *instance) + { + ps3_mutex_lock(&instance->state_machine.lock); +@@ -485,7 +518,7 @@ + + for (idx = 0; idx < wait_cnt; idx++) { + if (!instance->state_machine.is_load) { +- LOG_ERROR("hno:%u instance state not is_load\n", PS3_HOST(instance)); ++ LOG_INFO("hno:%u instance state not is_load\n", PS3_HOST(instance)); + break; + } + +@@ -531,13 +564,15 @@ + Bool is_pci_err_recovery = PS3_FALSE; + + for (idx = 0; idx < wait_cnt; idx++) { ++ INJECT_START(PS3_ERR_IJ_V2_WAKE_RECOVERY_WAIT, instance); ++ INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_NORMAL, instance); + is_pci_err_recovery = ps3_pci_err_recovery_get(instance); + cur_state = ps3_atomic_read(&instance->state_machine.state); + if (cur_state == PS3_INSTANCE_STATE_DEAD && + PS3_IOC_STATE_HALT_SUPPORT(instance) && + PS3_HALT_CLI_SUPPORT(instance)) { + goto l_out; +- } ++ } + + if (ps3_state_is_normal(cur_state) || + cur_state == PS3_INSTANCE_STATE_QUIT || +@@ -617,3 +652,47 @@ + } + return ret; + } ++ ++void ps3_host_info_get(void) ++{ ++#if defined(CONFIG_X86) || defined(CONFIG_X86_64) ++ struct cpuinfo_x86 *cpu = NULL; ++ ++ memset(&g_ps3_host_info, 0, sizeof(struct ps3_host_info)); ++ cpu = &cpu_data(0); ++ g_ps3_host_info.machine = PS3_HOST_MACHINE_X86; ++ if (strstr(cpu->x86_vendor_id, "Intel")) ++ g_ps3_host_info.vendor = PS3_HOST_VENDOR_INTEL; ++ else if (strstr(cpu->x86_vendor_id, "Hygon")) ++ g_ps3_host_info.vendor = PS3_HOST_VENDOR_HYGON; ++ else if (strstr(cpu->x86_vendor_id, "AMD")) ++ g_ps3_host_info.vendor = PS3_HOST_VENDOR_AMD; ++ ++ g_ps3_host_info.processor_cnt = num_online_cpus(); ++#else ++ memset(&g_ps3_host_info, 0, sizeof(struct ps3_host_info)); ++#endif ++ ++ memset(g_ps3_host_info.release, 0, SYS_INFO_LEN + 1); ++ snprintf(g_ps3_host_info.release, SYS_INFO_LEN, "%s", utsname()->release); ++ ++ LOG_DEBUG("host info: machine=%u,vendor=%u,processor_cnt=%u release=%s\n", ++ g_ps3_host_info.machine, g_ps3_host_info.vendor, ++ g_ps3_host_info.processor_cnt, g_ps3_host_info.release); ++} ++ ++U16 ps3_host_vendor_get(void) ++{ ++ return g_ps3_host_info.vendor; ++} ++ ++char *ps3_host_release_get(void) ++{ ++ return g_ps3_host_info.release; ++} ++ ++U8 ps3_is_last_func(struct ps3_instance *instance) ++{ ++ return (!ps3_ioc_multi_func_support(instance) || ++ (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1)); ++} +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_instance_manager.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_instance_manager.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_instance_manager.h 2025-06-10 20:13:00.222053527 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_instance_manager.h 2025-06-10 20:13:00.534064411 +0800 +@@ -45,6 +45,11 @@ + PS3_INSTANCE_STATE_PCIE_RECOVERY = 9, + PS3_INSTANCE_STATE_COUNT = 10 + }; ++enum PS3_DEVICE_ERR_HANDLE_STATE_TYPE { ++ PS3_DEVICE_ERR_STATE_NORMAL = 0, ++ PS3_DEVICE_ERR_STATE_CLEAN = 1, ++ PS3_DEVICE_ERR_STATE_INIT = 2, ++}; + + struct ps3_instance_state_machine { + ps3_mutex lock; +@@ -54,7 +59,6 @@ + Bool is_poweroff; + Bool is_pci_err_recovery; + Bool can_hostreset; +- Bool is_res_online; + }; + + static inline const S8 *namePS3InstanceState(S32 s) +@@ -104,7 +108,6 @@ + #endif + Ps3Fifo_s __iomem *reg_set; + ps3_atomic32 watchdog_reg_read_fail_count; +- ps3_atomic32 pcie_err_handle_ref; + + struct ps3_cmd_context cmd_context; + struct ps3_irq_context irq_context; +@@ -178,11 +181,14 @@ + Bool is_irq_prk_support; + Bool is_support_irq; + Bool is_raid; ++ Bool smp_affinity_enable; ++ Bool msix_combined; + U8 reserved[2]; + U16 unload_timeout; + U16 wait_ready_timeout; + U16 dev_id; +- U8 reserved1[2]; ++ U8 dma_addr_bit_pos; ++ U8 pci_err_handle_state; + const char *product_model; + S64 __percpu *scsi_cmd_deliver; + +@@ -191,6 +197,8 @@ + #ifdef _WINDOWS + STOR_DPC device_reset_dpc; + #endif ++ Bool page_mode_change; ++ U64 page_mode_addr_mask; + ps3_atomic32 is_err_scsi_processing; + ps3_atomic32 reg_op_count; + ps3_atomic32 host_reset_processing; +@@ -212,14 +220,45 @@ + U8 r1x_mode; + U64 start_pfn; + U64 end_pfn; ++ U64 so_start_addr; ++ U64 so_end_addr; ++ S32 device_busy_threshold; ++ U8 is_pcie_err_detected; ++ U8 reserved3; + }; + + #ifndef _WINDOWS + struct ps3_mgmt_info { +- ps3_spinlock spin_lock_obj; ++ ps3_mutex ps3_mgmt_lock; + ps3_list_head instance_list_head; + }; + ++enum { ++ PS3_HOST_MACHINE_DEFAULT, ++ PS3_HOST_MACHINE_X86 = 0, ++ PS3_HOST_MACHINE_ARM, ++ PS3_HOST_MACHINE_MIPS, ++ PS3_HOST_MACHINE_COUNT, ++}; ++ ++enum { ++ PS3_HOST_VENDOR_DEFAULT, ++ PS3_HOST_VENDOR_INTEL = 0, ++ PS3_HOST_VENDOR_HYGON, ++ PS3_HOST_VENDOR_AMD, ++ PS3_HOST_VENDOR_COUNT, ++}; ++ ++#define SYS_INFO_LEN (64) ++struct ps3_host_info { ++ U8 machine; ++ U8 vendor; ++ U16 cpu_cnt; ++ U16 core_cnt; ++ U16 processor_cnt; ++ char release[SYS_INFO_LEN + 1]; ++}; ++ + struct ps3_mgmt_info* ps3_mgmt_info_get(void); + + struct ps3_instance *ps3_instance_lookup(U16 host_no); +@@ -230,6 +269,8 @@ + + void ps3_mgmt_info_init(void); + ++void ps3_mgmt_exit(void); ++ + #endif + + void ps3_instance_init(struct ps3_instance *instance); +@@ -239,6 +280,8 @@ + S32 ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, + U32 dest_state); + ++void ps3_instance_state_transfer_to_dead_nolock(struct ps3_instance *instance); ++ + void ps3_instance_state_transfer_to_dead(struct ps3_instance *instance); + + void ps3_instance_state_transfer_to_pcie_recovery(struct ps3_instance *instance); +@@ -254,15 +297,16 @@ + + S32 ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance); + +-static inline Bool ps3_is_instance_state_normal(struct ps3_instance *instance) ++static inline Bool ps3_is_instance_state_normal(struct ps3_instance *instance, Bool need_prk_err) + { + S32 cur_state = ps3_atomic_read(&instance->state_machine.state); + INJECT_START(PS3_ERR_IJ_SAS_REQ_PRE_CHECK, &cur_state) + if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && + cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && + cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { +- LOG_WARN_LIM("hno:%u instance exception state %s\n", ++ LOG_WARN_LIM_WITH_CHECK(instance, need_prk_err, "hno:%u instance exception state %s\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); ++ + return PS3_FALSE; + } + +@@ -374,6 +418,7 @@ + void (*io_cmd_rebuild)(struct ps3_cmd *cmd); + Bool (*rw_cmd_is_need_split)(struct ps3_cmd *cmd); + Bool (*write_direct_enable)(struct ps3_cmd *cmd); ++ Bool (*ssd_vd_qmask_calculate)(struct ps3_cmd *cmd); + }; + #define PS3_DEVICE_IS_SWITCH(id) ((id == PCI_DEVICE_ID_PS3_SWITCH || \ + id == PCI_DEVICE_ID_PS3_SWITCH_FPGA)) +@@ -402,6 +447,11 @@ + return (pci->bus->number); + } + ++static inline S32 ps3_get_pci_domain(struct pci_dev *pci) ++{ ++ return pci_domain_nr(pci->bus); ++} ++ + static inline bool ps3_is_latest_func(struct ps3_instance *instance) + { + bool ret = PS3_TRUE; +@@ -409,6 +459,7 @@ + + list_for_each_entry(peer_instance, &ps3_mgmt_info_get()->instance_list_head, list_item) { + if ((peer_instance != NULL) && ++ (ps3_get_pci_domain(peer_instance->pdev) == ps3_get_pci_domain(instance->pdev)) && + (PCI_BUS_NUM(peer_instance->pdev->devfn) == PCI_BUS_NUM(instance->pdev->devfn)) && + (PCI_SLOT(peer_instance->pdev->devfn) == PCI_SLOT(instance->pdev->devfn)) && + (PCI_FUNC(peer_instance->pdev->devfn) != PCI_FUNC(instance->pdev->devfn))) { +@@ -419,4 +470,27 @@ + return ret; + } + ++static inline void ps3_get_so_addr_ranger(struct ps3_instance *instance, ++ U64 addr, U32 offset) ++{ ++ U64 so_end_addr = (addr + offset) - 1; ++ ++ if (instance->so_start_addr == 0 && instance->so_end_addr == 0) { ++ instance->so_start_addr = addr; ++ instance->so_end_addr = so_end_addr; ++ goto l_out; ++ } ++ instance->so_start_addr = ((addr < instance->so_start_addr) ? addr : instance->so_start_addr); ++ instance->so_end_addr = ((so_end_addr > instance->so_end_addr) ? so_end_addr : instance->so_end_addr); ++l_out: ++ return; ++} ++ ++void ps3_host_info_get(void); ++ ++U16 ps3_host_vendor_get(void); ++ ++char *ps3_host_release_get(void); ++ ++U8 ps3_is_last_func(struct ps3_instance *instance); + #endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioc_adp.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioc_adp.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioc_adp.c 2025-06-10 20:13:00.222053527 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioc_adp.c 2025-06-10 20:13:00.510063574 +0800 +@@ -74,6 +74,10 @@ + instance->task_manager_host_busy = PS3_FALSE; + instance->is_print_special_log = PS3_FALSE; + instance->r1x_mode = PS3_R1X_MODE_NORMAL; ++ instance->smp_affinity_enable = ps3_smp_affinity_query(); ++ instance->page_mode_change = ++ ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : PS3_TRUE; ++ instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_3_ADDR_MASK; + ps3_mutex_init(&instance->task_mgr_reset_lock); + ps3_mutex_init(&instance->task_abort_lock); + } +@@ -128,6 +132,10 @@ + instance->is_print_special_log = PS3_FALSE; + instance->r1x_mode = PS3_R1X_MODE_NORMAL; + instance->task_manager_host_busy = PS3_FALSE; ++ instance->smp_affinity_enable = ps3_smp_affinity_query(); ++ instance->page_mode_change = ++ ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : PS3_TRUE; ++ instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_3_ADDR_MASK; + ps3_mutex_init(&instance->task_mgr_reset_lock); + ps3_mutex_init(&instance->task_abort_lock); + ps3_raid_qos_prepare(instance); +@@ -181,9 +189,13 @@ + instance->is_raid = PS3_FALSE; + instance->hard_dog_mask = PS3_HARD_DOG_MASK; + instance->is_print_special_log = PS3_FALSE; ++ instance->smp_affinity_enable = ps3_smp_affinity_query(); + ps3_atomic_set(&instance->host_reset_processing, 0); + instance->task_manager_host_busy = PS3_FALSE; + instance->r1x_mode = PS3_R1X_MODE_NORMAL; ++ instance->page_mode_change = ++ ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : PS3_TRUE; ++ instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_3_ADDR_MASK; + ps3_mutex_init(&instance->task_mgr_reset_lock); + ps3_mutex_init(&instance->task_abort_lock); + ps3_hba_qos_prepare(instance); +@@ -293,7 +305,8 @@ + .ioc_security_check = NULL, + .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, + .rw_cmd_is_need_split = NULL, +- .write_direct_enable = NULL, ++ .write_direct_enable = NULL, ++ .ssd_vd_qmask_calculate = NULL, + }; + + struct ps3_ioc_adp_template g_ps3_template_hba = { +@@ -336,7 +349,8 @@ + .ioc_security_check = NULL, + .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, + .rw_cmd_is_need_split = ps3_scsih_rw_cmd_is_need_split_hba, +- .write_direct_enable = NULL, ++ .write_direct_enable = NULL, ++ .ssd_vd_qmask_calculate = ps3_ssd_vd_qmask_calculate_hba, + }; + + struct ps3_ioc_adp_template g_ps3_template_raid = { +@@ -379,6 +393,7 @@ + .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, + .rw_cmd_is_need_split = ps3_scsih_rw_cmd_is_need_split_raid, + .write_direct_enable = ps3_write_direct_enable, ++ .ssd_vd_qmask_calculate = NULL, + }; + + static struct ps3_ioc_adp_temp_entry ps3_ioc_adp_template_map[] = { +@@ -389,6 +404,7 @@ + {PCI_DEVICE_ID_STARS_IOC_2020_18i, &g_ps3_template_hba}, + {PCI_DEVICE_ID_STARS_ROC_2020_10i, &g_ps3_template_raid}, + {PCI_DEVICE_ID_PS3_RAID_FPGA, &g_ps3_template_raid}, ++ {PCI_DEVICE_ID_STARS_IOC_2213_16i, &g_ps3_template_hba}, + }; + + #ifndef _WINDOWS +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioc_manager.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioc_manager.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioc_manager.c 2025-06-10 20:13:00.223053562 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioc_manager.c 2025-06-10 20:13:00.590066365 +0800 +@@ -86,7 +86,7 @@ + } + + ret = PS3_SUCCESS; +- LOG_INFO("hno:%u init cmd response successfully\n", ++ LOG_WARN("hno:%u init cmd response successfully\n", + PS3_HOST(instance)); + + l_out: +@@ -163,7 +163,7 @@ + (U8*)ps3_dma_alloc_coherent(instance, + sizeof(struct PS3DrvSysInfo), + &cmd_context->init_frame_sys_info_phys); +- ++ INJECT_START(PS3_ERR_IJ_PS3_INIT_FRAME_SYS_INFO_BUF_ALLOC, &cmd_context->init_frame_sys_info_buf); + if (!cmd_context->init_frame_sys_info_buf) { + LOG_ERROR("hno:%u Failed to alloc sysinfo dma buffer\n", + PS3_HOST(instance)); +@@ -260,7 +260,7 @@ + (U8*)ps3_dma_alloc_coherent(instance, + sizeof(struct PS3DrvInfo), + &instance->drv_info_buf_phys); +- ++ INJECT_START(PS3_ERR_IJ_PS3_DRV_INFO_BUF_ALLOC, &instance->drv_info_buf); + if (instance->drv_info_buf == NULL) { + LOG_ERROR("hno:%u Failed to alloc drv info dma buffer\n", + PS3_HOST(instance)); +@@ -288,7 +288,7 @@ + (U8*)ps3_dma_alloc_coherent(instance, + (sizeof(struct PS3HostMemInfo) * PS3_HOST_MEM_INFO_NUM), + &instance->host_mem_info_buf_phys); +- ++ INJECT_START(PS3_ERR_IJ_PS3_HOST_MEM_BUF_ALLOC, &instance->host_mem_info_buf); + if (instance->host_mem_info_buf == NULL) { + LOG_ERROR("hno:%u Failed to alloc host mem info dma buffer\n", + PS3_HOST(instance)); +@@ -391,8 +391,8 @@ + S32 ret = PS3_SUCCESS; + Bool is_unload_valid = PS3_FALSE; + +- INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING, instance); +- INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING_RESUME_RECOVERY, instance); ++ INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING, instance); ++ INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING_RESUME_RECOVERY, instance); + ret = ps3_ioc_state_transfer_to_ready(instance); + INJECT_START(PS3_ERR_IJ_FW_STATE_RUNNING, &ret) + if (ret == PS3_SUCCESS) { +@@ -432,15 +432,99 @@ + + snprintf(drv_info->drvName, PS3_DRV_NAME_MAX_LEN, PS3_DRV_AUTHOR); + snprintf(drv_info->drvVersion, PS3_DRV_VERSION_MAX_LEN, PS3_DRV_VERSION); ++ drv_info->domain_support = PS3_TRUE; ++ drv_info->domain = (U32)ps3_get_pci_domain(instance->pdev); + drv_info->bus = ps3_get_pci_bus(instance->pdev); + drv_info->dev = PCI_SLOT(instance->pdev->devfn); + drv_info->func = PCI_FUNC(instance->pdev->devfn); + drv_info->compatVer = PS3_COMPAT_VER_1; + LOG_DEBUG("hno:%u driver information dump:\n" + "\t drvName = %s, drvVersion = %s\n" +- "\t bus = %llx, dev = %x, func = %x\n", ++ "\t domain = %x bus = %llx, dev = %x, func = %x\n", + PS3_HOST(instance), drv_info->drvName, drv_info->drvVersion, +- drv_info->bus, drv_info->dev, drv_info->func); ++ drv_info->domain, drv_info->bus, drv_info->dev, drv_info->func); ++} ++ ++static inline bool ps3_pgdat_is_empty(pg_data_t *pgdat) ++{ ++ return !pgdat->node_start_pfn && !pgdat->node_spanned_pages; ++} ++ ++struct pglist_data *first_online_pgdat(void) ++{ ++ return NODE_DATA(first_online_node); ++} ++ ++struct pglist_data *next_online_pgdat(struct pglist_data *pgdat) ++{ ++ int nid = next_online_node(pgdat->node_id); ++ ++ if (nid == MAX_NUMNODES) ++ return NULL; ++ return NODE_DATA(nid); ++} ++ ++static Bool ps3_get_numa_mem_addr(struct ps3_instance *instance) ++{ ++ Bool ret = PS3_FALSE; ++ S32 node = -1; ++ struct pglist_data *pgdata = NULL; ++ ++ node = dev_to_node(&instance->pdev->dev); ++ if (node < 0) ++ goto l_out; ++ pgdata = NODE_DATA(node); ++ if (pgdata == NULL || ps3_pgdat_is_empty(pgdata)) ++ goto l_out; ++ ++ instance->start_pfn = pgdata->node_start_pfn << PAGE_SHIFT; ++ instance->end_pfn = ((pgdat_end_pfn(pgdata) << PAGE_SHIFT) - 1); ++ ++ LOG_INFO("host_no:%u numa:%d, addr range:[0x%llx - 0x%llx], so addr range:[0x%llx - 0x%llx]\n", ++ PS3_HOST(instance), node, instance->start_pfn, instance->end_pfn, ++ instance->so_start_addr, instance->so_end_addr); ++ ret = PS3_TRUE; ++l_out: ++ return ret; ++} ++ ++static void ps3_get_all_numa_mem_addr(struct ps3_instance *instance) ++{ ++ struct pglist_data *pgdata = NULL; ++ S32 node = -1; ++ Bool is_in_range = PS3_FALSE; ++ U64 start_pfn = 0; ++ U64 end_pfn = 0; ++ ++ if (ps3_get_numa_mem_addr(instance)) ++ goto l_out; ++ for_each_online_pgdat(pgdata) { ++ if (ps3_pgdat_is_empty(pgdata)) ++ continue; ++ start_pfn = pgdata->node_start_pfn << PAGE_SHIFT; ++ end_pfn = ((pgdat_end_pfn(pgdata) << PAGE_SHIFT) - 1); ++ INJECT_START(PS3_ERR_IJ_MOD_SO_ADDR, instance); ++ if (PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(instance->dma_addr_bit_pos, ++ instance->so_start_addr) >= start_pfn && ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(instance->dma_addr_bit_pos, instance->so_end_addr) <= ++ end_pfn) { ++ node = pgdata->node_id; ++ is_in_range = PS3_TRUE; ++ break; ++ } ++ } ++ if (is_in_range) { ++ instance->start_pfn = start_pfn; ++ instance->end_pfn = end_pfn; ++ } else { ++ instance->start_pfn = 0; ++ instance->end_pfn = 0; ++ } ++ LOG_INFO("host_no:%u numa:%d, addr range:[0x%llx - 0x%llx], so addr range:[0x%llx - 0x%llx]\n", ++ PS3_HOST(instance), node, instance->start_pfn, instance->end_pfn, ++ instance->so_start_addr, instance->so_end_addr); ++l_out: ++ return; + } + + static void ps3_host_mem_info_prepare(struct ps3_instance *instance) +@@ -507,10 +591,11 @@ + init_frame_msg->systemInfoBufAddr = + cmd_context->init_frame_sys_info_phys; + #endif +- +- init_frame_msg->dumpDmaBufAddr = cpu_to_le64(dump_context->dump_dma_addr); +- init_frame_msg->dumpDmaBufLen = cpu_to_le64(PS3_DUMP_DMA_BUF_SIZE); +- init_frame_msg->dumpIsrSN = cpu_to_le32(irq_context->dump_isrSN); ++ if (!reset_devices) { ++ init_frame_msg->dumpDmaBufAddr = cpu_to_le64(dump_context->dump_dma_addr); ++ init_frame_msg->dumpDmaBufLen = cpu_to_le64(PS3_DUMP_DMA_BUF_SIZE); ++ init_frame_msg->dumpIsrSN = cpu_to_le32(irq_context->dump_isrSN); ++ } + #ifndef _WINDOWS + init_frame_msg->debugMemArrayNum = + cpu_to_le32(instance->debug_context.debug_mem_array_num); +@@ -527,10 +612,14 @@ + ps3_drv_info_prepare(instance); + init_frame_msg->drvInfoBufAddr = cpu_to_le64(instance->drv_info_buf_phys); + init_frame_msg->drvInfoBufLen = cpu_to_le16(sizeof(struct PS3DrvInfo)); ++ ps3_get_all_numa_mem_addr(instance); + if (instance->end_pfn != 0) { + ps3_host_mem_info_prepare(instance); + init_frame_msg->hostMemInfoBaseAddr = cpu_to_le64(instance->host_mem_info_buf_phys); + init_frame_msg->hostMemInfoNum = cpu_to_le32(PS3_HOST_MEM_INFO_NUM); ++ } else { ++ init_frame_msg->hostMemInfoBaseAddr = 0; ++ init_frame_msg->hostMemInfoNum = 0; + } + LOG_DEBUG("hno:%u init frame information dump:\n" + "\t initFramePhysicAddr = 0x%llx, initFrameLen = %d, version = %d\n" +@@ -568,7 +657,7 @@ + init_frame_msg->respStatus = U32_MAX; + + ps3_all_reply_fifo_init(instance); +- LOG_INFO("hno:%u start to send init cmd![init:0x%llx, respstats:0x%llx]\n", PS3_HOST(instance), ++ LOG_WARN("hno:%u start to send init cmd![init:0x%llx, respstats:0x%llx]\n", PS3_HOST(instance), + cmd_context->init_frame_buf_phys, + (U64)cmd_context->init_frame_buf_phys + offsetof(struct PS3InitReqFrame, respStatus)); + +@@ -580,6 +669,7 @@ + S32 state = PS3_FW_STATE_UNDEFINED; + S32 retry = 0; + ++ ps3_ioc_can_hardreset_set(instance, PS3_IOC_CANNOT_HARDRESET); + while (retry < PS3_IOC_INIT_PROC_FAIL_RETRY_COUNT) { + ret = ps3_ioc_init_cmd_proc(instance); + INJECT_START(PS3_ERR_IJ_INIT_CMD_PROC_FAIL, &ret) +@@ -607,7 +697,7 @@ + if(state == PS3_FW_STATE_WAIT || + state == PS3_FW_STATE_RUNNING){ + if (ps3_soc_unload(instance, PS3_TRUE, PS3_UNLOAD_SUB_TYPE_REMOVE, PS3_SUSPEND_TYPE_NONE) == PS3_SUCCESS) { +- LOG_ERROR("device[%d] unload success,exit init proc.\n", instance->pdev->dev.id); ++ LOG_INFO("device[%d] unload success,exit init proc.\n", instance->pdev->dev.id); + retry++; + continue; + } +@@ -844,7 +934,7 @@ + LOG_DEBUG("hno:%u init command: cmd.words = 0x%llx, " + "session_reg_offset = %#lx\n", PS3_HOST(instance), + cmd_word_default->words, +- offsetof(HilReg0Ps3RegisterF_s, ps3SessioncmdAddr)); ++ offsetof(struct HilReg0Ps3RegisterF, ps3SessioncmdAddr)); + } + #ifndef _WINDOWS + U64 ps3_switch_ioc_reg_read(struct ps3_instance *instance, void __iomem *reg) +@@ -906,7 +996,7 @@ + LOG_ERROR("hno:%u no register read\n", PS3_HOST(instance)); + } + +- ps3_reg_dump(instance, reg, value, PS3_TRUE); ++ + return value; + } + inline U64 ps3_ioc_reg_read_with_check(struct ps3_instance *instance, +@@ -924,3 +1014,95 @@ + + return reg_value; + } ++ ++static U64 ps3_ioc_reg_safe_read(struct ps3_instance *instance, ++ void __iomem *reg) ++{ ++ U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; ++ U32 count = 0; ++ U32 retry_cnt = 0; ++ U64 tmp_value = U64_MAX; ++ U64 value = U64_MAX; ++ Bool is_first = PS3_TRUE; ++ ++ for (; retry_cnt < PS3_REG_READ_SAFE_RETRY_NUM; retry_cnt++) { ++ tmp_value = ps3_ioc_reg_read_with_check(instance, reg); ++ INJECT_START(PS3_ERR_IJ_REG_READ_ERR, &tmp_value); ++ if (tmp_value == U64_MAX) { ++ value = U64_MAX; ++ goto l_out; ++ } ++ fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); ++ INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED1, &fw_cur_state); ++ INJECT_START(PS3_ERR_IJ_IOC_TO_CRITICAL, &fw_cur_state); ++ if (!ps3_ioc_state_valid_check(fw_cur_state)) { ++ for (; count < PS3_REG_READ_RETRY_NUM; count++) { ++ fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); ++ INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED1, &fw_cur_state); ++ INJECT_START(PS3_ERR_IJ_IOC_TO_CRITICAL, &fw_cur_state); ++ if (ps3_ioc_state_valid_check(fw_cur_state)) { ++ value = ps3_ioc_reg_read_with_check(instance, reg); ++ goto l_out; ++ } ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); ++ } ++ value = U64_MAX; ++ LOG_WARN_LIM("hno:%u wait ioc to valid state NOK\n", PS3_HOST(instance)); ++ goto l_out; ++ } ++ if (is_first) { ++ value = tmp_value; ++ is_first = PS3_FALSE; ++ continue; ++ } ++ INJECT_START(PS3_ERR_IJ_REG_READ_ZERO, &tmp_value); ++ if (value != tmp_value) { ++ LOG_WARN_LIM("hno:%u reg value not equal old-new[%llu, %llu]\n", ++ PS3_HOST(instance), value, tmp_value); ++ value = U64_MAX; ++ goto l_out; ++ } ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_50MS); ++ } ++l_out: ++ return value; ++} ++ ++U64 ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, void __iomem *reg) ++{ ++ U32 retry_cnt = PS3_REG_READ_SAFE_RETRY_NUM; ++ U64 reg_value = 0; ++ ++ while (retry_cnt--) { ++ reg_value = ps3_ioc_reg_safe_read(instance, reg); ++ if (reg_value != U64_MAX) ++ break; ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); ++ } ++ return reg_value; ++} ++ ++Bool ps3_feature_support_reg_get(struct ps3_instance *instance) ++{ ++ Bool ret = PS3_FALSE; ++ union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; ++ U64 value = 0; ++ ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); ++ INJECT_START(PS3_ERR_IJ_FEATURE_REG_READ_ERR, &value); ++ if (value == U64_MAX) { ++ LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", ++ PS3_HOST(instance)); ++ goto l_out; ++ } ++ ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; ++ instance->is_ioc_halt_support = (ps3_feature_support->reg.fwHaltSupport == 1); ++ instance->is_shallow_soft_recovery_support = (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); ++ instance->is_deep_soft_recovery_support = (ps3_feature_support->reg.deepSoftRecoverySupport == 1); ++ instance->is_hard_recovery_support = (ps3_feature_support->reg.hardRecoverySupport == 1); ++ instance->cmd_context.sgl_mode_support = (ps3_feature_support->reg.sglModeSupport == 1); ++ ret = PS3_TRUE; ++l_out: ++ return ret; ++} ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioc_manager.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioc_manager.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioc_manager.h 2025-06-10 20:13:00.223053562 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioc_manager.h 2025-06-10 20:13:00.564065458 +0800 +@@ -5,6 +5,7 @@ + #include "ps3_instance_manager.h" + #include "ps3_inner_data.h" + #include "ps3_module_para.h" ++#include "ps3_ioc_state.h" + #ifndef _WINDOWS + #define PS3_REG_SESSION_ADDR_WRITE(instance, val, reg) \ + do { \ +@@ -19,6 +20,7 @@ + } while(0) + #endif + ++#define PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES (100) + #define PS3_REG_READ_INTERVAL_MS (10) + #if (defined PS3_HARDWARE_FPGA && defined PS3_MODEL_V200) + #define PS3_REG_WRITE_RETRY_NUM (60) +@@ -26,7 +28,9 @@ + #define PS3_REG_WRITE_RETRY_NUM (10) + #endif + #define PS3_REG_WRITE_INTERVAL_MS (10) +- ++#define PS3_REG_READ_RETRY_NUM (5000) ++#define PS3_ATU_SUPPORT_READ_RETRY_NUM (3) ++#define PS3_REG_READ_SAFE_RETRY_NUM (3) + #define PS3_HOST_MEM_INFO_NUM (1) + #define PS3_IOC_STATE_HALT_SUPPORT(ins) \ + (ins->is_ioc_halt_support) +@@ -58,6 +62,20 @@ + ps3_atomic_dec(&(instance)->reg_op_count); \ + } while(0); + ++#define PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_type, reg_name, read_value) do {\ ++ ps3_atomic_inc(&(instance)->reg_op_count); \ ++ mb(); /* in order to force CPU ordering */ \ ++ if ((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ ++ read_value = ps3_ioc_reg_retry_safe_read(instance, &(instance)->reg_set->reg_type.reg_name); \ ++ } else { \ ++ LOG_FILE_ERROR("hno:%u register %p,read blocked by hardreset(%d) or pci err(%d)\n", \ ++ PS3_HOST(instance), &(instance)->reg_set->reg_type.reg_name, \ ++ (instance)->is_hard_reset, (instance)->is_pci_reset); \ ++ read_value = U64_MAX; \ ++ } \ ++ ps3_atomic_dec(&(instance)->reg_op_count); \ ++} while (0) ++ + #define PS3_IOC_REG_READ_OFFSET(instance, offset, read_value) do {\ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); \ +@@ -178,6 +196,13 @@ + U64 ps3_ioc_reg_read_with_check(struct ps3_instance *instance, + void __iomem *reg); + ++static inline Bool ps3_ioc_state_valid_check(U32 fw_cur_state) ++{ ++ return ((fw_cur_state > PS3_FW_STATE_START) && (fw_cur_state != PS3_FW_STATE_MASK)); ++} ++ ++U64 ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, void __iomem *reg); ++ + static inline void ps3_ioc_reg_write_with_check(struct ps3_instance *instance, + U64 val, void __iomem *reg) + { +@@ -214,11 +239,11 @@ + U32 *max_cmd_count) + { + Bool ret = PS3_TRUE; +- HilReg0Ps3RegisterFPs3MaxFwCmd_u *reg_max_fw_cmd = NULL; ++ union HilReg0Ps3RegisterFPs3MaxFwCmd *reg_max_fw_cmd = NULL; + U64 value = 0; + +- +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MaxFwCmd, value); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxFwCmd, value); ++ INJECT_START(PS3_ERR_IJ_GET_REPLYQ_COUNT_INVALID, &value) + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3MaxFwCmd NOK!\n", + PS3_HOST(instance)); +@@ -227,15 +252,17 @@ + goto l_out; + } + +- reg_max_fw_cmd = (HilReg0Ps3RegisterFPs3MaxFwCmd_u *)&value; ++ reg_max_fw_cmd = (union HilReg0Ps3RegisterFPs3MaxFwCmd *)&value; + *max_cmd_count = (U32)reg_max_fw_cmd->reg.ps3MaxFwCmd; + + if(instance->is_adjust_register_count) { + *max_cmd_count += 1; + } ++ if (reset_devices && *max_cmd_count > PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES) ++ *max_cmd_count = PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES; ++ + l_out: + return ret; +- + } + + static inline U32 +@@ -250,10 +277,10 @@ + struct ps3_instance *instance, U32 *max_chain_size) + { + Bool ret = PS3_TRUE; +- HilReg0Ps3RegisterFPs3MaxChainSize_u *max_chain_size_u = NULL; ++ union HilReg0Ps3RegisterFPs3MaxChainSize *max_chain_size_u = NULL; + U64 value = 0; + +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MaxChainSize, value); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxChainSize, value); + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3MaxChainSize NOK!\n", + PS3_HOST(instance)); +@@ -262,7 +289,7 @@ + goto l_out; + } + +- max_chain_size_u = (HilReg0Ps3RegisterFPs3MaxChainSize_u *)&value; ++ max_chain_size_u = (union HilReg0Ps3RegisterFPs3MaxChainSize *)&value; + *max_chain_size = (U32)max_chain_size_u->reg.ps3MaxChainSize; + l_out: + return ret; +@@ -272,7 +299,7 @@ + struct ps3_instance *instance, U32 *vd_info_size) + { + Bool ret = PS3_TRUE; +- HilReg0Ps3RegisterFPs3MaxVdInfoSize_u *vd_info_size_u = NULL; ++ union HilReg0Ps3RegisterFPs3MaxVdInfoSize *vd_info_size_u = NULL; + U64 value = 0; + + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MaxVdInfoSize, value); +@@ -283,7 +310,7 @@ + ret = PS3_FALSE; + goto l_out; + } +- vd_info_size_u = (HilReg0Ps3RegisterFPs3MaxVdInfoSize_u *)&value; ++ vd_info_size_u = (union HilReg0Ps3RegisterFPs3MaxVdInfoSize *)&value; + + *vd_info_size = (U32)vd_info_size_u->reg.ps3MaxVdInfoSize; + l_out: +@@ -294,11 +321,10 @@ + struct ps3_instance *instance, U32 *max_nvme_page_size) + { + Bool ret = PS3_TRUE; +- HilReg0Ps3RegisterFPs3MaxNvmePageSize_u *max_nvme_page_size_u = NULL; ++ union HilReg0Ps3RegisterFPs3MaxNvmePageSize *max_nvme_page_size_u = NULL; + U64 value = 0; + +- +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MaxNvmePageSize, value); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxNvmePageSize, value); + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3MaxNvmePageSize NOK!\n", + PS3_HOST(instance)); +@@ -307,7 +333,7 @@ + goto l_out; + } + +- max_nvme_page_size_u = (HilReg0Ps3RegisterFPs3MaxNvmePageSize_u *)&value; ++ max_nvme_page_size_u = (union HilReg0Ps3RegisterFPs3MaxNvmePageSize *)&value; + *max_nvme_page_size = (U32)max_nvme_page_size_u->reg.ps3MaxNvmePageSize; + l_out: + return ret; +@@ -317,11 +343,10 @@ + Bool *is_dma64_support) + { + Bool ret = PS3_TRUE; +- HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; ++ union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + U64 value = 0; + +- +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", + PS3_HOST(instance)); +@@ -330,7 +355,7 @@ + goto l_out; + } + +- ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; ++ ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + *is_dma64_support = (ps3_feature_support->reg.dmaBit64Support != 0); + l_out: + return ret; +@@ -342,7 +367,8 @@ + Bool ret = PS3_TRUE; + U64 value = 0; + +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MaxReplyque, value); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxReplyque, value); ++ INJECT_START(PS3_ERR_IJ_GET_REPLYQ_COUNT_INVALID, &value) + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3MaxReplyque NOK!\n", + PS3_HOST(instance)); +@@ -359,12 +385,11 @@ + static inline Bool ps3_ioc_fw_version_get(struct ps3_instance *instance) + { + Bool ret = PS3_TRUE; +- HilReg0Ps3RegisterFPs3FirmwareVersion_u *pver = NULL; ++ union HilReg0Ps3RegisterFPs3FirmwareVersion *pver = NULL; + U64 fw_version_last = instance->ioc_fw_version; + U64 ver = 0; + +- +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FirmwareVersion, ver); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FirmwareVersion, ver); + if (ver == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3FirmwareVersion NOK!\n", + PS3_HOST(instance)); +@@ -373,7 +398,7 @@ + goto l_out; + } + +- pver = (HilReg0Ps3RegisterFPs3FirmwareVersion_u *)&ver; ++ pver = (union HilReg0Ps3RegisterFPs3FirmwareVersion *)&ver; + instance->ioc_fw_version = (U64)pver->reg.ps3FmVer; + l_out: + return ret; +@@ -383,11 +408,10 @@ + Bool *is_sgl_mode_support) + { + Bool ret = PS3_TRUE; +- HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; ++ union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + U64 value = 0; + +- +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", + PS3_HOST(instance)); +@@ -396,7 +420,7 @@ + goto l_out; + } + +- ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; ++ ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + *is_sgl_mode_support = (ps3_feature_support->reg.sglModeSupport == 1); + l_out: + return ret; +@@ -406,11 +430,11 @@ + { + Bool ret = PS3_TRUE; + Bool last_dump_support = instance->dump_context.is_dump_support; +- HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; ++ union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + U64 value = 0; + +- + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); ++ INJECT_START(PS3_ERR_IJ_FEATURE_SUPPORT_ERR, &value); + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", + PS3_HOST(instance)); +@@ -419,7 +443,7 @@ + goto l_out; + } + +- ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; ++ ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + instance->dump_context.is_dump_support = + (ps3_feature_support->reg.dumpCrashSupport == 1); + l_out: +@@ -430,10 +454,9 @@ + { + Bool ret = PS3_TRUE; + Bool last_halt_support = instance->is_ioc_halt_support; +- HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; ++ union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + U64 value = 0; + +- + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", +@@ -443,7 +466,7 @@ + goto l_out; + } + +- ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; ++ ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + instance->is_ioc_halt_support = (ps3_feature_support->reg.fwHaltSupport == 1); + l_out: + return ret; +@@ -540,10 +563,10 @@ + U16 *max_r1x_cmds) + { + Bool ret = PS3_TRUE; +- HilReg0Ps3RegisterFPs3MaxSecR1xCmds_u *ps3_max_sec_r1x_cmds = NULL; ++ union HilReg0Ps3RegisterFPs3MaxSecR1xCmds *ps3_max_sec_r1x_cmds = NULL; + U64 value = 0; + +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MaxSecR1xCmds, value); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxSecR1xCmds, value); + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3Debug6 NOK!\n", + PS3_HOST(instance)); +@@ -552,7 +575,7 @@ + goto l_out; + } + +- ps3_max_sec_r1x_cmds = (HilReg0Ps3RegisterFPs3MaxSecR1xCmds_u *)&value; ++ ps3_max_sec_r1x_cmds = (union HilReg0Ps3RegisterFPs3MaxSecR1xCmds *)&value; + *max_r1x_cmds = ps3_max_sec_r1x_cmds->reg.ps3MaxSecR1xCmds; + l_out: + return ret; +@@ -615,10 +638,9 @@ + instance->is_deep_soft_recovery_support; + Bool last_hard_recovery_support = + instance->is_hard_recovery_support; +- HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; ++ union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + U64 value = 0; + +- + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", +@@ -633,7 +655,7 @@ + goto l_out; + } + +- ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; ++ ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + instance->is_shallow_soft_recovery_support = + (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); + instance->is_deep_soft_recovery_support = +@@ -644,12 +666,32 @@ + return ret; + } + ++static inline Bool ps3_ioc_multi_func_support(struct ps3_instance *instance) ++{ ++ Bool ret = PS3_TRUE; ++ union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; ++ U64 value = 0; ++ ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); ++ if (value == U64_MAX) { ++ LOG_ERROR("hno:%u read reg ps3FeatureSupport failed!\n", ++ PS3_HOST(instance)); ++ ret = PS3_FALSE; ++ goto l_out; ++ } ++ ++ ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; ++ ret = (ps3_feature_support->reg.multiDevfnSupport == 1); ++l_out: ++ return ret; ++} ++ + static inline Bool ps3_ioc_security_state_check(struct ps3_instance *instance) + { + U64 value = 0; + Bool ret = PS3_FALSE; + +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3Debug7, value); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3Debug7, value); + if (value == U64_MAX || (value & 0x1)) { + ret = PS3_TRUE; + LOG_ERROR("hno:%u read register NOK or ioc is security [%llu]\n", +@@ -663,7 +705,103 @@ + return ret; + } + ++static inline Bool ps3_ioc_atu_support_get(struct ps3_instance *instance, U8 *bit_pos) ++{ ++ Bool ret = PS3_TRUE; ++ union HilRegPs3RegisterFPs3AtuSupport *ps3_atu_support = NULL; ++ U64 value = PS3_BIT_POS_DEFAULT; ++ ++ PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3Debug8, value); ++ INJECT_START(PS3_ERR_IJ_READ_ATU_REG_FAILED, &value); ++ if (value == U64_MAX) { ++ LOG_ERROR("hno:%u read reg ps3AtuSupport NOK!\n", ++ PS3_HOST(instance)); ++ *bit_pos = PS3_BIT_POS_DEFAULT; ++ ret = PS3_FALSE; ++ goto l_out; ++ } ++ ps3_atu_support = (union HilRegPs3RegisterFPs3AtuSupport *)&value; ++ *bit_pos = ps3_atu_support->reg.bitPos; ++l_out: ++ return ret; ++} ++ ++static inline Bool ps3_ioc_atu_support_safe_get(struct ps3_instance *instance, U8 *bit_pos) ++{ ++ Bool ret = PS3_FALSE; ++ U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; ++ U32 count = 0; ++ U32 retry_cnt = 0; ++ U8 tmp_bit_pos = 0; ++ Bool is_first = PS3_TRUE; ++ ++ for (; retry_cnt < PS3_ATU_SUPPORT_READ_RETRY_NUM; retry_cnt++) { ++ if (!ps3_ioc_atu_support_get(instance, &tmp_bit_pos)) ++ goto l_out; ++ fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); ++ INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED, &fw_cur_state); ++ if (!ps3_ioc_state_valid_check(fw_cur_state)) { ++ for (; count < PS3_REG_READ_RETRY_NUM; count++) { ++ fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); ++ INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED, &fw_cur_state); ++ if (ps3_ioc_state_valid_check(fw_cur_state)) { ++ if (!ps3_ioc_atu_support_get(instance, &tmp_bit_pos)) ++ goto l_out; ++ *bit_pos = tmp_bit_pos; ++ ret = PS3_TRUE; ++ goto l_out; ++ } ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); ++ } ++ goto l_out; ++ } ++ if (is_first) { ++ *bit_pos = tmp_bit_pos; ++ is_first = PS3_FALSE; ++ continue; ++ } ++ INJECT_START(PS3_ERR_IJ_BIT_POS_ERR, &tmp_bit_pos); ++ if (*bit_pos != tmp_bit_pos) ++ goto l_out; ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_50MS); ++ } ++ ret = PS3_TRUE; ++l_out: ++ return ret; ++} ++ ++static inline Bool ps3_ioc_atu_support_retry_read(struct ps3_instance *instance, U8 *bit_pos) ++{ ++ U32 retry_cnt = PS3_ATU_SUPPORT_READ_RETRY_NUM; ++ Bool ret = PS3_FALSE; ++ ++ while (retry_cnt--) { ++ if (ps3_ioc_atu_support_safe_get(instance, bit_pos)) { ++ ret = PS3_TRUE; ++ break; ++ } ++ ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); ++ } ++ return ret; ++} ++ ++static inline void ps3_ioc_can_hardreset_set(struct ps3_instance *instance, U8 enable) ++{ ++ U64 can_hardreset = 0; ++ union HilRegPs3RegisterFPs3CanHardReset *ps3_can_hardreset = NULL; ++ ++ ps3_can_hardreset = (union HilRegPs3RegisterFPs3CanHardReset *)&can_hardreset; ++ ps3_can_hardreset->reg.canHardReset = enable; ++ PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3Debug9, ps3_can_hardreset->val); ++} ++ ++Bool ps3_feature_support_reg_get(struct ps3_instance *instance); ++ + void ps3_ioc_scsi_cmd_send(struct ps3_instance *instance, + struct PS3CmdWord *cmd_word); + ++struct pglist_data *first_online_pgdat(void); ++ ++struct pglist_data *next_online_pgdat(struct pglist_data *pgdat); ++ + #endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioc_state.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioc_state.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioc_state.c 2025-06-10 20:13:00.223053562 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioc_state.c 2025-06-10 20:13:00.555065144 +0800 +@@ -50,27 +50,27 @@ + + static struct ps3_reset_key_map g_reset_key_table[] = { + [PS3_FW_HARD_RESET] = { +- offsetof(HilReg0Ps3RegisterF_s, ps3HardresetKey), +- offsetof(HilReg0Ps3RegisterF_s, ps3HardresetState), +- offsetof(HilReg0Ps3RegisterF_s, ps3Hardreset), ++ offsetof(struct HilReg0Ps3RegisterF, ps3HardresetKey), ++ offsetof(struct HilReg0Ps3RegisterF, ps3HardresetState), ++ offsetof(struct HilReg0Ps3RegisterF, ps3Hardreset), + PS3_FW_HARD_RESET_ACT, +- offsetof(HilReg0Ps3RegisterF_s, ps3Hardreset), ++ offsetof(struct HilReg0Ps3RegisterF, ps3Hardreset), + PS3_HARDRESET_MASK + }, + [PS3_FW_SHALLOW_SOFT_RESET] = { +- offsetof(HilReg0Ps3RegisterF_s, ps3SoftresetKey), +- offsetof(HilReg0Ps3RegisterF_s, ps3SoftresetState), +- offsetof(HilReg0Ps3RegisterF_s, ps3Softreset), ++ offsetof(struct HilReg0Ps3RegisterF, ps3SoftresetKey), ++ offsetof(struct HilReg0Ps3RegisterF, ps3SoftresetState), ++ offsetof(struct HilReg0Ps3RegisterF, ps3Softreset), + PS3_FW_STATE_ACT_SHALLOW_SOFT_RESET, +- offsetof(HilReg0Ps3RegisterF_s, ps3Softreset), ++ offsetof(struct HilReg0Ps3RegisterF, ps3Softreset), + PS3_SOFTRESET_MASK + }, + [PS3_FW_DEEP_SOFT_RESET] = { +- offsetof(HilReg0Ps3RegisterF_s, ps3SoftresetKey), +- offsetof(HilReg0Ps3RegisterF_s, ps3SoftresetState), +- offsetof(HilReg0Ps3RegisterF_s, ps3Softreset), ++ offsetof(struct HilReg0Ps3RegisterF, ps3SoftresetKey), ++ offsetof(struct HilReg0Ps3RegisterF, ps3SoftresetState), ++ offsetof(struct HilReg0Ps3RegisterF, ps3Softreset), + PS3_FW_STATE_ACT_DEEP_SOFT_RESET, +- offsetof(HilReg0Ps3RegisterF_s, ps3Softreset), ++ offsetof(struct HilReg0Ps3RegisterF, ps3Softreset), + PS3_SOFTRESET_MASK + }, + }; +@@ -109,7 +109,7 @@ + } + } + static void ps3_hardreset_key_write(struct ps3_instance *instance, +- U8 *reset_key_vir_addr) ++ U8 *reset_key_vir_addr, U64 *timeval) + { + static U32 reset_key_array[] = { + PS3_FW_DIAG_1ST_KEY, +@@ -123,11 +123,12 @@ + PS3_FW_DIAG_9TH_KEY + }; + U32 idx = 0; +- ++ timeval[PS3_START_WRITE_KEY_REG] = ps3_1970_now_ms_get(); + for(idx = 0;idx < ARRAY_SIZE(reset_key_array);idx++) { + ps3_ioc_hardreset_reg_write(instance, +- (U64)reset_key_array[idx], reset_key_vir_addr, idx==0); ++ (U64)reset_key_array[idx], reset_key_vir_addr, 0); + } ++ timeval[PS3_END_WRITE_KEY_REG] = ps3_1970_now_ms_get(); + } + static S32 ps3_reset_key_state_check(struct ps3_instance *instance, + U32 offset) +@@ -166,23 +167,22 @@ + return ret; + } + static S32 ps3_hardreset_key_state_check(struct ps3_instance *instance, +- U8 *reset_key_state_vir_addr) ++ U8 *reset_key_state_vir_addr, U64 *timeval) + { + U32 reset_key_state = 0; + U32 read_count = 0; +- const U32 retry_max = 180; ++ const U32 retry_max = 900; + S32 ret = PS3_SUCCESS; + ++ timeval[PS3_START_WAIT_KEY_READY_REG] = ps3_1970_now_ms_get(); + do { + if (read_count >= retry_max) { +- LOG_ERROR("hno:%u PS3 reset key state is still " +- "disabled after 0.9 sec \n", PS3_HOST(instance)); + ret = -PS3_FAILED; + break; + } + + if (read_count != 0) { +- ps3_mdelay(5); ++ ps3_mdelay(PS3_LOOP_TIME_INTERVAL_1MS); + } + + reset_key_state = (U32)ps3_ioc_hardreset_reg_read(instance, +@@ -191,12 +191,7 @@ + read_count++; + } while (!(reset_key_state & PS3_FW_DIAG_ENABLE) || + ((U32_MAX & reset_key_state) == U32_MAX)); +- +- if (ret == PS3_SUCCESS) { +- LOG_INFO("hno:%u PS3 reset key state is enabled after %d msecs\n", +- PS3_HOST(instance), +- (read_count - 1) * PS3_LOOP_TIME_INTERVAL_100MS); +- } ++ timeval[PS3_END_WAIT_KEY_READY_REG] = ps3_1970_now_ms_get(); + + return ret; + } +@@ -242,7 +237,7 @@ + } + + if ( ret != PS3_SUCCESS ) { +- LOG_ERROR("hno:%u PS3 IOC state is not valid 180 secs after IOC reset , fw state is %s\n", ++ LOG_ERROR("hno:%u PS3 IOC state is not valid 180 secs after IOC reset, fw state is %s\n", + PS3_HOST(instance),ps3_ioc_state_print(fw_state)); + } + +@@ -372,6 +367,7 @@ + break; + } + #else ++ INJECT_START(PS3_ERR_IJ_FORCE_HARD_READY_PCIE_ERRL, instance) + if (ps3_pci_err_recovery_get(instance)) { + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + ret = -PS3_IN_PCIE_ERR; +@@ -430,19 +426,19 @@ + case PS3_FW_STATE_START: + case PS3_FW_STATE_FLUSHING: + ret = ps3_ioc_state_ready_wait(instance); +- if (ret != PS3_SUCCESS) { +- if (ret != -PS3_IN_PCIE_ERR) { ++ if (ret != PS3_SUCCESS) { ++ if (ret != -PS3_IN_PCIE_ERR) + ret = -PS3_NO_RECOVERED; +- } +- LOG_ERROR("hno:%u fw state to ready NOK \n", +- PS3_HOST(instance)); +- } ++ ++ LOG_ERROR("hno:%u fw state to ready NOK\n", ++ PS3_HOST(instance)); ++ } + break; + case PS3_FW_STATE_READY: + break; + case PS3_FW_STATE_WAIT: + case PS3_FW_STATE_RUNNING: +- LOG_ERROR("hno:%u fw state is wait/running, to ready NOK \n", ++ LOG_WARN("hno:%u fw state is wait/running\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; + break; +@@ -469,6 +465,7 @@ + U32 count = 0; + + fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); ++ INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_FAIL, &fw_cur_state) + LOG_INFO("hno:%u fw state is %s(0x%x)\n", + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state), fw_cur_state); +@@ -480,10 +477,11 @@ + || (fw_cur_state == PS3_FW_STATE_CRITICAL)){ + break; + } +- ++ INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING_PCI_ERR, instance) + if (ps3_pci_err_recovery_get(instance)) { + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); +- break; ++ ret = -PS3_IN_PCIE_ERR; ++ goto l_out; + } + + ps3_mutex_lock(&instance->state_machine.lock); +@@ -500,7 +498,7 @@ + fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); + count++; + } +- ++ INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_FAIL1, &fw_cur_state) + if (fw_cur_state != PS3_FW_STATE_RUNNING) { + LOG_ERROR("hno:%u fw state transition NOK, state is %s\n", + PS3_HOST(instance), +@@ -515,7 +513,7 @@ + + LOG_INFO("hno:%u fw state transit to %s\n", + PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state)); +- ++l_out: + return ret; + } + +@@ -585,6 +583,8 @@ + U8 *reg_start = (U8*)instance->reg_set; + U32 read_count = 0; + const U32 retry_max = 180; ++ ULong flags = 0; ++ U64 timeval[PS3_RESET_MAX_COUNT] = {0}; + + reset_key_addr = reg_start + + g_reset_key_table[reset_type].reset_key_offset; +@@ -620,6 +620,14 @@ + goto l_out; + } + } ++ INJECT_START(PS3_ERR_IJ_V2_RECOVERY_WAIT_NOTIFY, instance); ++ ps3_wait_scsi_cmd_done(instance, PS3_TRUE); ++ ps3_wait_mgr_cmd_done(instance, PS3_TRUE); ++ if (instance->peer_instance != NULL) { ++ ps3_wait_scsi_cmd_done(instance->peer_instance, PS3_TRUE); ++ ps3_wait_mgr_cmd_done(instance->peer_instance, PS3_TRUE); ++ } ++ + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_4, instance) + if (ps3_pci_err_recovery_get(instance)) { + LOG_INFO("hno:%u pcie recovery proceess\n", +@@ -627,29 +635,42 @@ + ret = -PS3_IN_PCIE_ERR; + goto l_out; + } +- preempt_disable(); +- ps3_hardreset_key_write(instance, reset_key_addr); +- preempt_enable(); ++ spin_lock_irqsave(&instance->recovery_context->ps3_hardreset_lock, flags); ++ ps3_hardreset_key_write(instance, reset_key_addr, timeval); + +- ret = ps3_hardreset_key_state_check(instance, reset_state_addr); ++ ret = ps3_hardreset_key_state_check(instance, reset_state_addr, timeval); + if(ret != PS3_SUCCESS){ ++ spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, flags); + LOG_INFO("hno:%u %s, key check failed, ret:%d\n", + PS3_HOST(instance), namePS3ResetType(reset_type),ret); + goto l_out; + } +- LOG_INFO("hno:%u %s, key_offset: key state success," +- "then write hardreset ioc_reset_type:%u, reset_addr:%p\n", +- PS3_HOST(instance), namePS3ResetType(reset_type), ioc_reset_type, reset_addr); ++ + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_5, instance) + if (ps3_pci_err_recovery_get(instance)) { ++ spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, flags); + LOG_WARN("hno:%u pcie recovery proceess\n", + PS3_HOST(instance)); + ret = -PS3_IN_PCIE_ERR; + goto l_out; + } ++ ++ timeval[PS3_START_WRITE_HARDRESET_REG] = ps3_1970_now_ms_get(); + ps3_ioc_hardreset_reg_write(instance, (U64)ioc_reset_type, reset_addr, PS3_TRUE); ++ timeval[PS3_END_WRITE_HARDRESET_REG] = ps3_1970_now_ms_get(); ++ spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, flags); ++ LOG_INFO("hno:%u %s, key_offset: key state success, " ++ "then write hardreset ioc_reset_type:%u, reset_addr:%p\n", ++ PS3_HOST(instance), namePS3ResetType(reset_type), ioc_reset_type, reset_addr); ++ LOG_INFO("hno:%u time:%lld-%lld-%lld-%lld-%lld-%lld\n", ++ PS3_HOST(instance), timeval[PS3_START_WRITE_KEY_REG], timeval[PS3_END_WRITE_KEY_REG], ++ timeval[PS3_START_WAIT_KEY_READY_REG], timeval[PS3_END_WAIT_KEY_READY_REG], ++ timeval[PS3_START_WRITE_HARDRESET_REG], timeval[PS3_END_WRITE_HARDRESET_REG]); ++ + instance->recovery_context->hardreset_count++; +- ps3_msleep(ps3_hard_reset_waiting_query()); ++ if (ps3_hard_reset_waiting_query()) ++ ps3_msleep(ps3_hard_reset_waiting_query()); ++ + LOG_INFO("hno:%u %s, after sleep:%d ms\n", + PS3_HOST(instance), namePS3ResetType(reset_type),ps3_hard_reset_waiting_query()); + +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioc_state.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioc_state.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioc_state.h 2025-06-10 20:13:00.223053562 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioc_state.h 2025-06-10 20:13:00.510063574 +0800 +@@ -15,7 +15,9 @@ + PS3_FW_STATE_TO_HALT_TMO_LOOP_COUNT = 9000, + PS3_FW_STATE_TO_UNLOAD_TMO_LOOP_COUNT = 500, + PS3_WAIT_EVENT_CMD_LOOP_COUNT = 100, ++ PS3_LOOP_TIME_INTERVAL_1MS = 1, + PS3_LOOP_TIME_INTERVAL_20MS = 20, ++ PS3_LOOP_TIME_INTERVAL_50MS = 50, + PS3_LOOP_TIME_INTERVAL_100MS = 100, + PS3_LOOP_TIME_INTERVAL_3000MS = 3000, + PS3_WRITE_HARD_RESET_WAIT_TIME_500MS = 500, +@@ -24,6 +26,15 @@ + PS3_PS3_LOOP_TIME_INTERVAL_1000MS = 1000, + PS3_TRANS_DEAD_IOC_FAILED_MAX_COUNT = 10, + }; ++enum ps3_reset_time_type { ++ PS3_START_WRITE_KEY_REG = 0, ++ PS3_END_WRITE_KEY_REG = 1, ++ PS3_START_WAIT_KEY_READY_REG = 2, ++ PS3_END_WAIT_KEY_READY_REG = 3, ++ PS3_START_WRITE_HARDRESET_REG = 4, ++ PS3_END_WRITE_HARDRESET_REG = 5, ++ PS3_RESET_MAX_COUNT = 6, ++}; + + #define PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED (PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT * \ + PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS / HZ + \ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioctl.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioctl.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioctl.c 2025-06-10 20:13:00.222053527 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioctl.c 2025-06-10 20:13:00.510063574 +0800 +@@ -62,6 +62,37 @@ + return ret; + } + ++void ps3_ioctl_buff_bit_pos_update(struct ps3_cmd *cmd) ++{ ++ U8 i = 0; ++ struct PS3Sge *pSge = (struct PS3Sge *)cmd->req_frame->mgrReq.sgl; ++ struct ps3_instance *instance = cmd->instance; ++ U8 bit_pos = 0; ++ ++ if (cmd->transient == NULL) ++ goto l_out; ++ ++ if (cmd->transient->sge_num == 0) ++ goto l_out; ++ ++ for (i = 0; i < cmd->transient->sge_num; i++) { ++ if (cmd->transient->transient_buff[i] != NULL) { ++ if (pSge->ext == 1) ++ pSge = (struct PS3Sge *)cmd->ext_buf; ++ bit_pos = ps3_dma_addr_bit_pos_check((dma_addr_t)le64_to_cpu(pSge->addr)); ++ if (bit_pos != instance->dma_addr_bit_pos) { ++ pSge->addr = cpu_to_le64(PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ++ le64_to_cpu(pSge->addr))); ++ pSge->addr = cpu_to_le64(PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ++ le64_to_cpu(pSge->addr))); ++ } ++ } ++ pSge++; ++ } ++l_out: ++ return; ++} ++ + void ps3_ioctl_buff_release(struct ps3_cmd *cmd) + { + U8 i = 0; +@@ -122,7 +153,7 @@ + #else + (void)base_addr; + if (copy_from_user(*transient_buff, (void __user*)psrc_sge->addr, psrc_sge->length)) { +- LOG_ERROR("hno:%u , copy from user err\n", ++ LOG_ERROR("hno:%u, copy from user err\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_out; +@@ -257,26 +288,42 @@ + return ret; + } + +-#ifdef _WINDOWS +-static S32 ps3_ioctl_mgr_handle(struct ps3_instance *instance, +- struct PS3IoctlSyncCmd* ioc, PSCSI_REQUEST_BLOCK Srb) +-#else + static S32 ps3_ioctl_mgr_handle(struct ps3_instance *instance, + struct PS3IoctlSyncCmd* ioc) +-#endif + + { + S32 ret = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; +-#ifndef _WINDOWS + S32 send_result = PS3_SUCCESS; +-#endif ++ U8 retry_count = 0; ++ ++ while (retry_count < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ ret = ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE); ++ if (ret != PS3_SUCCESS) { ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (ret == -PS3_RECOVERED) { ++ if (++retry_count < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { ++ INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_STATE_NORMAL, instance); ++ ret = ps3_instance_wait_for_normal(instance); ++ } ++ } ++ if (ret != PS3_SUCCESS) { ++ LOG_WARN_LIM("tid[0x%llx], hno:%u ioctl cmd pre check NOK ret:%d!\n", ++ ioc->traceId, PS3_HOST(instance), ret); ++ goto l_no_free_cmd; ++ } ++ continue; ++ } ++ break; ++ } + cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_FORCE_IOCTL_ALLOC_CMD_FAILED, &cmd) + if (cmd == NULL) { + LOG_WARN("hno:%u ioctl req, not get a cmd packet\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + goto l_no_free_cmd; + } + LOG_DEBUG("trace_id[0x%llx], hno:%u CFID [%u], get mgr cmd succeed\n", +@@ -296,21 +343,19 @@ + memset(cmd->transient->transient_buff, 0, sizeof(void*) * PS3_MAX_IOCTL_SGE_NUM); + ret = ps3_ioctl_sgl_fill(instance, cmd, ioc); + if (ret != PS3_SUCCESS) { ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + goto l_out; + } +- ++ INJECT_START(PS3_ERR_IJ_FORCE_IOCTL_WAIT_RECOVERY, instance); + ps3_ioctl_req_frame_build(cmd); + ps3_mgr_cmd_word_build(cmd); + +-#ifdef _WINDOWS +- ps3_cmd_bind_srb_extension(cmd, Srb); +- cmd->cmd_receive_cb = ps3_ioctl_callback_proc; +- cmd->cmd_word.noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; +- goto l_no_free_cmd; +-#else +- INJECT_START(PS3_ERR_IJ_IOCTL_WAIT_IRQ_DISABLE, cmd) ++ INJECT_START(PS3_ERR_IJ_IOCTL_WAIT_IRQ_DISABLE, cmd); + send_result = ps3_cmd_send_sync(instance, cmd); +- INJECT_START(PS3_ERR_IJ_IOCTL_CMD_NO_RESP, &send_result) ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ INJECT_START(PS3_ERR_IJ_IOCTL_CMD_NO_RESP, &send_result); + ret = ps3_mgr_complete_proc(instance, cmd, send_result); + if (ret == -PS3_CMD_NO_RESP) { + LOG_ERROR("trace_id[0x%llx], hno:%u ioctl request no response!\n", +@@ -329,7 +374,6 @@ + LOG_INFO("trace_id[0x%llx], hno:%u CFID [%u], ioctl cmd_type[%d], sub_type[%d] end\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, + ioc->msg.header.cmdType, ioc->msg.header.cmdSubType); +-#endif + + l_out: + ps3_ioctl_buff_release(cmd); +@@ -569,17 +613,17 @@ + ioc->traceId, ioc->hostId, ioc->msg.header.cmdType, + ioc->sglOffset, ioc->sgeCount, ioc->resultCode); + +- spin_lock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + instance = ps3_instance_lookup(ioc->hostId); + if (instance == NULL) { +- spin_unlock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + LOG_WARN("can found instance, host no is %d\n", ioc->hostId); + ret = -ENODEV; + goto l_out_free_ioc; + } + + if (!instance->state_machine.is_load) { +- spin_unlock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + LOG_WARN("trace_id[0x%llx], hno:%u instance state [%d]\n", + ioc->traceId, PS3_HOST(instance), + instance->state_machine.is_load); +@@ -589,7 +633,7 @@ + + INJECT_START(PS3_ERR_IJ_SCSI_SCAN_HOST_NOT_FINISH, instance) + if (!instance->is_scan_host_finish) { +- spin_unlock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + LOG_WARN("trace_id[0x%llx], hno:%u instance scan host not finish\n", + ioc->traceId, PS3_HOST(instance)); + ret = -EAGAIN; +@@ -597,7 +641,7 @@ + } + + ps3_atomic_inc(&instance->cmd_statistics.cli_cnt); +- spin_unlock(&ps3_mgmt_info_get()->spin_lock_obj); ++ ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + + LOG_FILE_INFO("hno:%u ioctl ready get sem\n", + PS3_HOST(instance)); +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioctl.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioctl.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_ioctl.h 2025-06-10 20:13:00.222053527 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_ioctl.h 2025-06-10 20:13:00.510063574 +0800 +@@ -55,4 +55,7 @@ + + void ps3_ioctl_clean(struct ps3_instance *instance); + ++void ps3_ioctl_buff_bit_pos_update(struct ps3_cmd *cmd); ++ + #endif ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_io_trace.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_io_trace.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_io_trace.c 2025-06-10 20:13:00.223053562 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_io_trace.c 2025-06-10 20:13:00.511063609 +0800 +@@ -51,10 +51,10 @@ + goto l_out; + } + +- sge_count = scsi_sg_count(s_cmnd); ++ sge_count = cmd->os_sge_map_count; + scsi_for_each_sg(s_cmnd, os_sgl, sge_count, i) { + pdata = (S8 *)sg_virt(os_sgl); +- crc = crc32(seed, pdata, os_sgl->length); ++ crc = crc32(seed, pdata, sg_dma_len(os_sgl)); + + memset(buf, '\0', sizeof(buf)); + buf_len = snprintf(buf, PS3_IO_TRACE_BUF_LEN, +@@ -63,10 +63,12 @@ + "D[%llx:%llx] CRC[0x%x] \n", + PS3_HOST(instance), s_cmnd->device->channel, s_cmnd->device->id, + cmd->trace_id, +- i + 1, sge_count, os_sgl->dma_address, +- os_sgl->length, *(U64*)pdata, *((U64 *)(pdata + 8)), crc); +- PS3_BUG_ON(buf_len >= PS3_IO_TRACE_BUF_LEN); +- ++ i + 1, sge_count, sg_dma_address(os_sgl), ++ sg_dma_len(os_sgl), *(U64 *)pdata, *((U64 *)(pdata + 8)), crc); ++ if (buf_len >= PS3_IO_TRACE_BUF_LEN) { ++ LOG_ERROR("buf_len > PS3_IO_TRACE_BUF_LEN\n"); ++ goto l_out; ++ } + DATA_DUMP(NULL, 0, buf); + } + +@@ -84,7 +86,6 @@ + LOG_WARN("cmd or scmd is null\n"); + goto l_out; + } +-#ifndef _WINDOWS + if (scsi_sg_count(cmd->scmd) == 0) { + goto l_out; + } +@@ -107,30 +108,19 @@ + } + + ps3_scsih_lba_parse(cmd->scmd->cmnd, &lba); +-#else +- +- if (SrbGetDataBuffer(cmd->srb) == NULL) { +- LOG_WARN("srb data buffer is null\n"); +- goto l_out; +- } +- +- ps3_scsih_lba_parse((U8*)SrbGetCdb(cmd->srb), &lba); +-#endif + memset(buf, '\0', sizeof(buf)); + buf_len = snprintf(buf, PS3_IO_TRACE_BUF_LEN, + "%s, trace_id[0x%llx], hno:%u lba[0x%llx]\n", + ps3_io_trace_direct_name(type), cmd->trace_id, PS3_HOST(cmd->instance), lba); +- PS3_BUG_ON(buf_len >= PS3_IO_TRACE_BUF_LEN); +-#ifndef _WINDOWS ++ if (buf_len >= PS3_IO_TRACE_BUF_LEN) { ++ LOG_ERROR("buf_len > PS3_IO_TRACE_BUF_LEN\n"); ++ goto l_out; ++ } + DATA_DUMP(sg_virt(cmd->scmd->sdb.table.sgl), + min_t(U32, cmd->scmd->sdb.table.sgl[0].length, + PS3_IO_TRACE_PRINT_COUNT), buf); +-#else +- DATA_DUMP(SrbGetDataBuffer(cmd->srb), +- min(SrbGetDataTransferLength(cmd->srb), +- PS3_IO_TRACE_PRINT_COUNT), buf); +-#endif + + l_out: + return; + } ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_irq.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_irq.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_irq.c 2025-06-10 20:13:00.224053597 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_irq.c 2025-06-10 20:13:00.519063888 +0800 +@@ -27,11 +27,12 @@ + const U32 PS3_SSD_IOPS_MSIX_VECTORS = 8; + const U32 PS3_HDD_IOPS_MSIX_VECTORS = 8; + const U32 PS3_IRQ_POLL_SCHED_THRESHOLD = 1024; +-const U32 PS3_DEVICE_IO_BUSY_THRESHOLD = 8; + const U32 PS3_HIGH_IOPS_VECTOR_BATCH_COUNT_SHIFT = 5; + const U32 PS3_BALANCE_MODE_MIN_CPU_NUM = 16; + const S32 PS3_SSD_MAX_BUSY_THRESHOLD = 40; + const U32 PS3_IOPS_MSIX_VECTORS = 12; ++const S32 PS3_HYGON_BUSY_ADJUST_THRESHOLD = 32; ++const U32 PS3_MSIX_COMBINED_MODE_MSIX_VECTORS = 16; + + #define PS3_IRQCTX_HOST(irq_context) \ + ps3_container_of((irq_context), struct ps3_instance, irq_context)->host->host_no +@@ -40,6 +41,7 @@ + #define IS_HIGN_OPS_IRQ(irq_context, irq) \ + (((irq_context)->high_iops_msix_vectors > (irq)->isrSN)) + ++#define PS3_MULTI_DATA_DISK_BUSY_THRESHOLD(var, base) ((var) > (base)) + static void msix_irq_mode_check(struct ps3_irq_context *irq_context, + U32 max_vectors) + { +@@ -48,14 +50,16 @@ + U16 lnksta = 0; + U32 iops_msix_cnt = 0; + +- if (ps3_get_pci_function(irq_context->instance->pdev) == PS3_FUNC_ID_1) { ++ if (!ps3_ioc_multi_func_support(irq_context->instance) || ++ ps3_get_pci_function(irq_context->instance->pdev) == PS3_FUNC_ID_1) { + iops_msix_cnt = PS3_IOPS_MSIX_VECTORS; + } else { +- iops_msix_cnt = PS3_IOPS_MSIX_VECTORS >> 1; ++ iops_msix_cnt = 0; + } ++ + pcie_capability_read_word(irq_context->instance->pdev, PCI_EXP_LNKSTA, &lnksta); + speed = lnksta & PCI_EXP_LNKSTA_CLS; +- if ((online_cpu_num >= PS3_BALANCE_MODE_MIN_CPU_NUM) && ++ if ((iops_msix_cnt > 0) && (online_cpu_num >= PS3_BALANCE_MODE_MIN_CPU_NUM) && + (iops_msix_cnt < max_vectors) && (speed >= 0x4)) { + irq_context->high_iops_msix_vectors = iops_msix_cnt; + irq_context->valid_msix_vector_count = +@@ -73,17 +77,44 @@ + return; + } + ++static inline Bool ps3_is_linx80_os(void) ++{ ++ Bool ret = PS3_FALSE; ++#if (!defined(PS3_OS_MANAGED_IRQ_SUPPORT)) ++ ret = PS3_TRUE; ++#endif ++ ++ return ret; ++} ++ ++static inline Bool ps3_support_irq_affinity(void) ++{ ++ Bool ret = PS3_FALSE; ++ ++#if defined(DRIVER_SUPPORT_KERNEL_IRQ_AFFINITY) ++ ret = PS3_TRUE; ++#endif ++ ++ if (!ret) { ++ if (strstr(ps3_host_release_get(), "an8")) ++ ret = PS3_TRUE; ++ } ++ ++ return ret; ++} ++ + static U32 __ps3_irq_vectors_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) + { + int msix_vectors = 0; + U32 irq_flags = PCI_IRQ_MSIX | PCI_IRQ_MSI; ++ struct ps3_instance *instance = irq_context->instance; ++ U32 ps3_irq_mode = ps3_pci_irq_mode_query(); ++ struct irq_affinity *descp = NULL; + #if defined(PS3_OS_MANAGED_IRQ_SUPPORT) + struct irq_affinity desc = { .pre_vectors = irq_context->high_iops_msix_vectors }; +- struct irq_affinity *descp = &desc; ++ descp = &desc; + #endif +- struct ps3_instance *instance = irq_context->instance; +- U32 ps3_irq_mode = ps3_pci_irq_mode_query(); + + switch (ps3_irq_mode) { + case PS3_PCI_IRQ_MODE_LEGACY: +@@ -99,16 +130,23 @@ + break; + } + +-#if ((defined(DRIVER_SUPPORT_KERNEL_IRQ_AFFINITY)) || (!defined(PS3_OS_MANAGED_IRQ_SUPPORT))) +- irq_flags |= PCI_IRQ_AFFINITY; +-#else +- if (irq_context->is_support_balance == PS3_TRUE && +- irq_context->is_balance_current_perf_mode == PS3_TRUE) { +- descp = NULL; ++ if (ps3_support_irq_affinity() || ps3_is_linx80_os()) { ++ if (irq_context->instance->smp_affinity_enable) ++ irq_flags |= PCI_IRQ_AFFINITY; ++ else ++ descp = NULL; + } else { +- irq_flags |= PCI_IRQ_AFFINITY; ++ if (irq_context->is_support_balance == PS3_TRUE && ++ irq_context->is_balance_current_perf_mode == PS3_TRUE) { ++ descp = NULL; ++ } else { ++ if (irq_context->instance->smp_affinity_enable) { ++ irq_flags |= PCI_IRQ_AFFINITY; ++ } else { ++ descp = NULL; ++ } ++ } + } +-#endif + + LOG_INFO("host_no:%u pci_irq_mode:%d specified, msix_vectors:%d max:%d\n", + PS3_IRQCTX_HOST(irq_context), ps3_irq_mode, +@@ -149,21 +187,22 @@ + static void ps3_iops_vectors_affinity_hint_set(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) + { +-#ifndef DRIVER_SUPPORT_KERNEL_IRQ_AFFINITY +- (void)pdev; +- (void)irq_context; +- goto l_out; +-#else + U32 msix_vector = 0; + U32 os_vector = 0; + S32 node = -1; + const struct cpumask* mask = NULL; + S32 cpu_id = 0; + ++ if (!ps3_support_irq_affinity()) ++ goto l_out; ++ + if (!irq_context->is_support_balance) { + goto l_out; + } + ++ if (!irq_context->instance->smp_affinity_enable) ++ goto l_out; ++ + node = dev_to_node(&pdev->dev); + if (node >= 0) { + mask = cpumask_of_node(node); +@@ -184,7 +223,6 @@ + os_vector = pci_irq_vector(pdev, msix_vector); + irq_set_affinity_hint(os_vector, mask); + } +-#endif + l_out: + return; + } +@@ -194,6 +232,7 @@ + U32 max_vectors) + { + U32 msix_vectors = 0; ++ S32 nr_entries = 0; + msix_irq_mode_check(irq_context, max_vectors); + + msix_vectors = __ps3_irq_vectors_alloc(pdev, irq_context); +@@ -209,7 +248,7 @@ + LOG_DEBUG("host_no:%u alloc resource for normal perf mode! \n", + PS3_IRQCTX_HOST(irq_context)); + } +- ++ INJECT_START(PS3_ERR_IJ_IRQ_VECTORS_ALLOC_FAILED, &msix_vectors) + if (msix_vectors > 0) { + irq_context->valid_msix_vector_count = msix_vectors; + ps3_iops_vectors_affinity_hint_set(pdev, irq_context); +@@ -217,7 +256,9 @@ + irq_context->high_iops_msix_vectors = 0; + irq_context->is_support_balance = PS3_FALSE; + irq_context->is_balance_current_perf_mode = PS3_FALSE; +- if (pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY) != 1) { ++ nr_entries = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY); ++ INJECT_START(PS3_ERR_IJ_ALLOC_LEGACY_VECTOR_FAILED, &nr_entries) ++ if (nr_entries != 1) { + LOG_ERROR("host_no:%u alloc irq fail! \n", + PS3_IRQCTX_HOST(irq_context)); + irq_context->valid_msix_vector_count = 0; +@@ -232,11 +273,13 @@ + } + + static inline Bool ps3_irq_set_affinity_hint(struct pci_dev *pdev, +- U32 msix_vector, const struct cpumask *mask) { ++ U32 msix_vector, const struct cpumask *mask, Bool smp_affinity_enable) { + U32 os_vector = pci_irq_vector(pdev, msix_vector); + Bool ret = PS3_TRUE; +- if (irq_set_affinity_hint(os_vector, mask)) { +- ret = PS3_FALSE; ++ ++ if (smp_affinity_enable) { ++ if (irq_set_affinity_hint(os_vector, mask)) ++ ret = PS3_FALSE; + } + return ret; + } +@@ -247,6 +290,7 @@ + const struct cpumask *mask = NULL; + S32 cpu_id = 0; + U32 normal_msix_index = irq_context->high_iops_msix_vectors; ++ Bool smp_affinify_enable = irq_context->instance->smp_affinity_enable; + + for (; normal_msix_index < irq_context->valid_msix_vector_count; + normal_msix_index++) { +@@ -264,6 +308,7 @@ + PS3_IRQCTX_HOST(irq_context), cpu_id, normal_msix_index); + } + } ++ + return; + + l_get_affinity_failed: +@@ -272,7 +317,8 @@ + for (; normal_msix_index < irq_context->valid_msix_vector_count; + normal_msix_index++) { + mask = get_cpu_mask(cpu_id); +- if (!ps3_irq_set_affinity_hint(pdev, normal_msix_index, mask)) { ++ if (!ps3_irq_set_affinity_hint(pdev, normal_msix_index, ++ mask, smp_affinify_enable)) { + LOG_ERROR("host_no:%u set affinity failed, %d.\n", + PS3_IRQCTX_HOST(irq_context), normal_msix_index); + } else { +@@ -297,6 +343,7 @@ + + irq_context->cpu_msix_table = + (U32*)kcalloc(irq_context->cpu_msix_table_sz, sizeof(S32), GFP_KERNEL); ++ INJECT_START(PS3_ERR_IJ_CPU_MSIX_TABLE_ALLOC_FAILED, &(irq_context->cpu_msix_table)) + if (irq_context->cpu_msix_table == NULL) { + LOG_ERROR("host_no:%u kcalloc fail! \n", + PS3_IRQCTX_HOST(irq_context)); +@@ -317,6 +364,7 @@ + ps3_dma_pool_create("PS3 reply fifo desc pool", + &pdev->dev, reply_fifo_desc_buf_size, + sizeof(struct PS3ReplyFifoDesc), 0); ++ INJECT_START(PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_POOL_ALLOC_FAILED, &(irq_context->reply_fifo_desc_buf_pool)) + if (irq_context->reply_fifo_desc_buf_pool == NULL) { + LOG_ERROR("host_no:%u ps3_dma_pool_create fail! \n", + PS3_IRQCTX_HOST(irq_context)); +@@ -324,9 +372,10 @@ + } + + irq_context->reply_fifo_desc_buf = (struct PS3ReplyFifoDesc*) +- ps3_dma_pool_zalloc(irq_context->reply_fifo_desc_buf_pool, ++ ps3_dma_pool_zalloc(irq_context->instance, irq_context->reply_fifo_desc_buf_pool, + GFP_KERNEL, + &irq_context->reply_fifo_desc_buf_phys); ++ INJECT_START(PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_ALLOC_FAILED, &(irq_context->reply_fifo_desc_buf)) + if (irq_context->reply_fifo_desc_buf == NULL) { + LOG_ERROR("host_no:%u ps3_dma_pool_create fail! \n", + PS3_IRQCTX_HOST(irq_context)); +@@ -345,7 +394,8 @@ + static void ps3_reply_fifo_desc_free(struct ps3_irq_context *irq_context) + { + if (irq_context->reply_fifo_desc_buf != NULL) { +- ps3_dma_pool_free(irq_context->reply_fifo_desc_buf_pool, ++ ps3_dma_pool_free( ++ irq_context->reply_fifo_desc_buf_pool, + irq_context->reply_fifo_desc_buf, + irq_context->reply_fifo_desc_buf_phys); + irq_context->reply_fifo_desc_buf = NULL; +@@ -372,15 +422,17 @@ + + for (; i < irq_context->valid_msix_vector_count; i++) { + virt_base[i] = (struct PS3ReplyWord *) +- ps3_dma_pool_alloc(irq_context->reply_fifo_pool, ++ ps3_dma_pool_alloc(irq_context->instance, irq_context->reply_fifo_pool, + GFP_KERNEL, + &phys_base[i]); ++ INJECT_START(PS3_ERR_IJ_REPLY_VIRT_BASE_ALLOC_FAILED, &(virt_base[i])) + if (virt_base[i] == NULL) { + LOG_ERROR("host_no:%u ps3_dma_pool_zalloc fail! \n", + PS3_IRQCTX_HOST(irq_context)); + goto l_alloc_failed; + } + memset(virt_base[i], 0xff, reply_fifo_size); ++ ps3_get_so_addr_ranger(irq_context->instance, phys_base[i], reply_fifo_size); + LOG_DEBUG("host_no:%u reply_fifo index:%u phy addr:0x%llx! \n", + PS3_IRQCTX_HOST(irq_context), i, phys_base[i]); + } +@@ -389,7 +441,8 @@ + + l_alloc_failed: + for (; i > 0; i--) { +- ps3_dma_pool_free(irq_context->reply_fifo_pool, ++ ps3_dma_pool_free( ++ irq_context->reply_fifo_pool, + virt_base[i-1], phys_base[i-1]); + virt_base[i-1] = NULL; + phys_base[i-1] = 0; +@@ -404,7 +457,8 @@ + irq_context->reply_fifo_depth; + irq_context->reply_fifo_pool = + ps3_dma_pool_create("PS3 reply fifo pool", +- &pdev->dev, reply_fifo_size, PAGE_SIZE, 0); ++ &pdev->dev, reply_fifo_size, DMA_ALIGN_BYTES_4K, 0); ++ INJECT_START(PS3_ERR_IJ_REPLY_FIFO_POOL_ALLOC_FAILED, &(irq_context->reply_fifo_pool)) + if (irq_context->reply_fifo_pool == NULL) { + LOG_ERROR("host_no:%u ps3_dma_pool_create fail! \n", + PS3_IRQCTX_HOST(irq_context)); +@@ -440,7 +494,8 @@ + continue; + } + +- ps3_dma_pool_free(irq_context->reply_fifo_pool, ++ ps3_dma_pool_free( ++ irq_context->reply_fifo_pool, + virt_base[i], phys_base[i]); + virt_base[i] = NULL; + phys_base[i] = 0; +@@ -485,13 +540,7 @@ + struct PS3ReplyFifoDesc *desc_buf = irq_context->reply_fifo_desc_buf; + dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; + U32 i = 0; +- U32 iops_msix_cnt = 0; + +- if (ps3_get_pci_function(irq_context->instance->pdev) == PS3_FUNC_ID_1) { +- iops_msix_cnt = PS3_IOPS_MSIX_VECTORS; +- } else { +- iops_msix_cnt = PS3_IOPS_MSIX_VECTORS >> 1; +- } + for (; i < irq_context->valid_msix_vector_count; i++) { + desc_buf[i].ReplyFifoBaseAddr = cpu_to_le64(phys_base[i]); + desc_buf[i].irqNo = cpu_to_le32(pci_irq_vector(pdev, i)); +@@ -499,9 +548,7 @@ + + if (irq_context->is_support_balance && + i < irq_context->high_iops_msix_vectors) { +- if (i < iops_msix_cnt) { +- desc_buf[i].isrAccMode = PS3_ISR_ACC_MODE_IOPS_VER0; +- } ++ desc_buf[i].isrAccMode = PS3_ISR_ACC_MODE_IOPS_VER0; + } + else { + desc_buf[i].isrAccMode = PS3_ISR_ACC_MODE_LATENCY; +@@ -534,10 +581,11 @@ + struct ps3_irq *irqs = NULL; + U32 i = 0; + U32 dump_irq_index; +- ++ S32 retval; + irq_context->irqs = (struct ps3_irq*) + ps3_kcalloc(instance, irq_context->valid_msix_vector_count, + sizeof(struct ps3_irq)); ++ INJECT_START(PS3_ERR_IJ_IRQS_ALLOC_FAILED, &(irq_context->irqs)) + if (irq_context->irqs == NULL) { + LOG_ERROR("host_no:%u kcalloc fail! \n", + PS3_IRQCTX_HOST(irq_context)); +@@ -558,9 +606,10 @@ + irqs[i].last_reply_idx = 0; + snprintf(irqs[i].name, PS3_IRQ_NAME_LENGTH, "ps3_irq_%d_%d", + instance->host->host_no, i); +- +- if (request_irq(irqs[i].irqNo, instance->ioc_adpter->isr, +- IRQF_SHARED, irqs[i].name, &(irqs[i]))) { ++ retval = request_irq(irqs[i].irqNo, instance->ioc_adpter->isr, ++ IRQF_SHARED, irqs[i].name, &(irqs[i])); ++ INJECT_START(PS3_ERR_IJ_REPLY_REQ_IRQS_FAILED, &retval) ++ if (retval) { + LOG_ERROR("host_no:%u request_irq failed! SN:%d\n", + PS3_HOST(instance), i); + +@@ -572,8 +621,11 @@ + } + + dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); +- if (request_irq(irqs[dump_irq_index].irqNo, ps3_dump_irq_handler, IRQF_SHARED, "ps3_dump_irq", (void *)instance)) { +- LOG_ERROR("host_no:%u request dump irq failed! SN:%d\n", ++ retval = request_irq(irqs[dump_irq_index].irqNo, ps3_dump_irq_handler, ++ IRQF_SHARED, "ps3_dump_irq", (void *)instance); ++ INJECT_START(PS3_ERR_IJ_DUMP_REQ_IRQS_FAILED, &retval) ++ if (retval) { ++ LOG_ERROR("host_no:%u request dump irq failed! SN:%d\n", + PS3_HOST(instance), dump_irq_index); + goto l_failed; + } +@@ -734,21 +786,31 @@ + } + + static Bool ps3_irq_max_vectors_calc(struct ps3_instance *instance, +- U32 *max_vectors) ++ S32 *max_vectors) + { + Bool ret = PS3_TRUE; + U32 max_replyq_count = 0; + + if (!instance->ioc_adpter->max_replyq_count_get(instance, &max_replyq_count)) { ++ LOG_ERROR("host_no:%u get max replyq count NOK\n", PS3_HOST(instance)); + ret = PS3_FALSE; + goto l_out; + } + ++ if (max_replyq_count > PS3_MSIX_COMBINED_MODE_MSIX_VECTORS) ++ instance->msix_combined = PS3_TRUE; ++ + LOG_INFO("reqlyq max_replyq_count:%d\n", max_replyq_count); + + *max_vectors = pci_msix_vec_count(instance->pdev); ++ INJECT_START(PS3_ERR_IJ_GET_MSIX_VEC_COUNT_INVALID, max_vectors) + if (*max_vectors <= 0) { + *max_vectors = pci_msi_vec_count(instance->pdev); ++ INJECT_START(PS3_ERR_IJ_GET_MSIX_VEC_COUNT_INVALID, max_vectors) ++ if (*max_vectors < 0) { ++ *max_vectors = 0; ++ goto l_out; ++ } + } + *max_vectors = min_t(S32, *max_vectors, max_replyq_count); + +@@ -760,7 +822,7 @@ + { + struct ps3_irq_context *irq_context = &instance->irq_context; + struct pci_dev *pdev = instance->pdev; +- U32 max_vectors = 0; ++ S32 max_vectors = 0; + if (!ps3_irq_max_vectors_calc(instance, &max_vectors)) { + goto l_irq_vectors_alloc_failed; + } +@@ -782,6 +844,10 @@ + goto l_irq_vectors_alloc_failed; + } + ++ if (!instance->msix_combined) { ++ instance->smp_affinity_enable = PS3_FALSE; ++ } ++ + if (ps3_irq_vectors_alloc(pdev, irq_context, max_vectors) < + instance->min_intr_count) { + LOG_ERROR("host_no:%u alloc irq NOK![cpunum:%d][irq_type:%d][min_intr:%d] \n", +@@ -825,7 +891,9 @@ + struct ps3_irq_context *irq_context = &instance->irq_context; + struct pci_dev *pdev = instance->pdev; + +- ps3_irq_resource_free(irq_context); ++ if (!instance->is_pcie_err_detected) { ++ ps3_irq_resource_free(irq_context); ++ } + + if (irq_context->cpu_msix_table != NULL) { + kfree(irq_context->cpu_msix_table); +@@ -836,7 +904,9 @@ + pci_free_irq_vectors(pdev); + } + +- memset(irq_context, 0, sizeof(struct ps3_irq_context)); ++ if (!instance->is_pcie_err_detected) ++ memset(irq_context, 0, sizeof(struct ps3_irq_context)); ++ + return PS3_SUCCESS; + } + +@@ -861,7 +931,8 @@ + + static inline Bool ps3_sdev_is_high_load(struct ps3_cmd *cmd, U16 scale) + { +- S32 busy_threshold = PS3_DEVICE_IO_BUSY_THRESHOLD * scale; ++ S32 busy_base = cmd->instance->device_busy_threshold; ++ S32 busy_threshold = busy_base * scale; + S32 device_busy = 0; + #if defined DRIVER_SUPPORT_PRIV_BUSY + struct ps3_scsi_priv_data *device_priv_data = (struct ps3_scsi_priv_data*)cmd->scmd->device->hostdata; +@@ -872,10 +943,16 @@ + #else + device_busy = atomic_read(&cmd->scmd->device->device_busy); + #endif +- if ((busy_threshold > PS3_SSD_MAX_BUSY_THRESHOLD) && +- !ps3_is_hdd_cmd(cmd)) { +- busy_threshold = PS3_SSD_MAX_BUSY_THRESHOLD; ++ ++ if (PS3_MULTI_DATA_DISK_BUSY_THRESHOLD(busy_threshold, busy_base) && !ps3_is_hdd_cmd(cmd)) { ++ if (ps3_host_vendor_get() == PS3_HOST_VENDOR_HYGON && ++ busy_threshold <= PS3_HYGON_BUSY_ADJUST_THRESHOLD) { ++ busy_threshold = busy_base; ++ } else if (busy_threshold > PS3_SSD_MAX_BUSY_THRESHOLD) { ++ busy_threshold = PS3_SSD_MAX_BUSY_THRESHOLD; ++ } + } ++ + if (device_busy > busy_threshold) { + return PS3_TRUE; + } +@@ -915,7 +992,7 @@ + } else if (cmd->instance->host->nr_hw_queues > 1) { + msix_index = blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(SCMD_GET_REQUEST(cmd->scmd))) + + irq_context->high_iops_msix_vectors; +- } else { ++ } else { + processor_id = raw_smp_processor_id(); + msix_index = irq_context->cpu_msix_table[processor_id]; + +@@ -1082,6 +1159,9 @@ + struct ps3_irq_context *irq_context = &instance->irq_context; + struct ps3_irq *irqs = irq_context->irqs; + U32 i = 0; ++ if (irqs == NULL) { ++ return; ++ } + + for (; i < irq_context->valid_msix_vector_count; i++) { + if (irqs[i].is_irq_poll_disabled == PS3_TRUE) { +@@ -1614,8 +1694,11 @@ + instance->irq_context.reply_fifo_depth; + struct ps3_irq *irq = NULL; + U32 i = 0; +- + LOG_DEBUG("host_no:%u start to reply fifo init!\n", PS3_HOST(instance)); ++ if (instance->irq_context.irqs == NULL) { ++ return; ++ } ++ + for (; i < instance->irq_context.valid_msix_vector_count; ++i) { + irq = instance->irq_context.irqs + i; + memset(irq->reply_fifo_virt_base_addr, 0xff, reply_fifo_size); +@@ -1625,3 +1708,4 @@ + + return; + } ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_irq.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_irq.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_irq.h 2025-06-10 20:13:00.224053597 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_irq.h 2025-06-10 20:13:00.528064202 +0800 +@@ -16,6 +16,7 @@ + + #define PS3_IRQ_NAME_LENGTH (32) + #define PS3_SWITCH_IRQ_INDEX (0) ++ + struct ps3_instance; + + #if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 2)) || \ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_mgr_channel.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_mgr_channel.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_mgr_channel.c 2025-06-10 20:13:00.224053597 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_mgr_channel.c 2025-06-10 20:13:00.528064202 +0800 +@@ -53,7 +53,7 @@ + } + return PS3_FALSE; + } +-#ifndef _WINDOWS ++ + void ps3_wait_cmd_for_completion_interrupt(struct ps3_instance *instance, + struct ps3_cmd *cmd) + { +@@ -82,6 +82,7 @@ + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_PENDING, &ret) + if(!ret) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); ++ ps3_msleep(100); + continue; + } + ret = is_interrupt_signal(current); +@@ -107,14 +108,17 @@ + is_send_cancel = PS3_TRUE; + cancel: + ret = ps3_mgr_cmd_cancel(instance, cmd->index); ++ INJECT_START(PS3_ERR_IJ_FORCE_CANCEL_CMD_RET_RECOVERY, &ret); ++ INJECT_START(PS3_ERR_IJ_FORCE_CANCEL_CMD_PCIE_ERR, &ret); + if (ret != PS3_SUCCESS) { + if (ret == -PS3_RECOVERED) { + LOG_INFO_LIM("host_no:%u cancel cmd %u send failed, wait\n", + PS3_HOST(instance), cmd->index); ++ ps3_msleep(100); + continue; + } else if(ret == -PS3_EBUSY) { ++ ps3_msleep(100); + if(retry_count++ < CMD_MAX_RETRY_COUNT) { +- ps3_msleep(100); + goto cancel; + } + continue; +@@ -129,20 +133,19 @@ + break; + } else { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); ++ ps3_msleep(100); + } + } + + return ; + } +-#endif +-static S32 ps3_blocked_cmd_send(struct ps3_instance *instance, ++ ++static S32 ps3_mgr_cmd_send(struct ps3_instance *instance, + struct ps3_cmd *cmd) + { + S32 ret = PS3_SUCCESS; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + +- ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); +- mb(); + if (!instance->state_machine.is_load) { + if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT){ + LOG_WARN("host_no:%u instance state is unloading or suspend\n", +@@ -190,23 +193,7 @@ + ps3_get_pci_function(instance->pdev)); + + instance->ioc_adpter->cmd_send(instance, &cmd->cmd_word); +- ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); +- INJECT_START(PS3_ERR_IJ_ABORT_CMD_ERROR ,cmd) +- INJECT_START(PS3_ERR_IJ_RESET_CMD_ERROR ,cmd) +- INJECT_START(PS3_ERR_IJ_ABORT_CMD_NORMAL ,cmd) +- INJECT_START(PS3_ERR_IJ_RESET_CMD_NORMAL ,cmd) +- INJECT_START(PS3_ERR_IJ_SMP_CMD_ERROR ,cmd) +- INJECT_START(PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR ,cmd) +- INJECT_START(PS3_ERR_IJ_PHY_CTRL_CMD_ERROR ,cmd) +- ret = ps3_block_cmd_wait(instance, cmd, 0); +- +- LOG_FILE_INFO("host_no:%u CFID:%d trace_id:0x%llx recv ret:%d\n", +- PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id, ret); +- return ret; + l_out: +- ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); +- LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx failed:%d\n", +- PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id, ret); + return ret; + } + static S32 ps3_blocked_unload_cmd_send(struct ps3_instance *instance, +@@ -258,10 +245,8 @@ + static S32 ps3_polled_cmd_send(struct ps3_instance *instance, + struct ps3_cmd *cmd) + { +- S32 ret = -PS3_FAILED; ++ S32 ret = PS3_SUCCESS; + +- ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); +- mb(); + if (!instance->state_machine.is_load) { + if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT){ + LOG_WARN("host_no:%u instance state is unloading or suspend\n", +@@ -270,7 +255,7 @@ + goto l_out; + } + } +- ++ INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, instance); + if (!ps3_is_instance_state_allow_cmd_execute(instance)) { + ret = -PS3_RECOVERED; + goto l_out; +@@ -285,21 +270,7 @@ + + PS3_MGR_CMD_STAT_INC(instance, cmd); + instance->ioc_adpter->cmd_send(instance, &cmd->cmd_word); +- ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); +- INJECT_START(PS3_ERR_IJ_ABORT_CMD_ERROR ,cmd) +- INJECT_START(PS3_ERR_IJ_RESET_CMD_ERROR ,cmd) +- INJECT_START(PS3_ERR_IJ_ABORT_CMD_NORMAL ,cmd) +- INJECT_START(PS3_ERR_IJ_RESET_CMD_NORMAL ,cmd) +- +- ret = ps3_cmd_reply_polling(instance, cmd, 0, PS3_FALSE); +- if (ret != -PS3_TIMEOUT) { +- PS3_MGR_CMD_BACK_INC(instance, cmd, (ret == PS3_SUCCESS) ? +- PS3_REPLY_WORD_FLAG_SUCCESS : PS3_REPLY_WORD_FLAG_FAIL); +- } +- return ret; +- + l_out: +- ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + return ret; + } + static S32 ps3_polled_unload_cmd_send(struct ps3_instance *instance, +@@ -336,13 +307,45 @@ + INJECT_START(PS3_ERR_IJ_SEND_IOCTL_BLOCK_MODE_FLAG, cmd); + cmd->cmd_receive_cb = ps3_blocked_cmd_cb; + cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; +- return ps3_blocked_cmd_send(instance, cmd); ++ return ps3_mgr_cmd_send(instance, cmd); + } else { + cmd->cmd_receive_cb = NULL; + cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NO_REPLY_WORD; + return ps3_polled_cmd_send(instance, cmd); + } + } ++ ++S32 ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) ++{ ++ S32 ret = PS3_SUCCESS; ++ ++ if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { ++ INJECT_START(PS3_ERR_IJ_ABORT_CMD_ERROR, cmd); ++ INJECT_START(PS3_ERR_IJ_RESET_CMD_ERROR, cmd); ++ INJECT_START(PS3_ERR_IJ_ABORT_CMD_NORMAL, cmd); ++ INJECT_START(PS3_ERR_IJ_RESET_CMD_NORMAL, cmd); ++ INJECT_START(PS3_ERR_IJ_SMP_CMD_ERROR, cmd); ++ INJECT_START(PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR, cmd); ++ INJECT_START(PS3_ERR_IJ_PHY_CTRL_CMD_ERROR, cmd); ++ INJECT_START(PS3_ERR_IJ_PD_LIST_RESP_RETRY, cmd); ++ ret = ps3_block_cmd_wait(instance, cmd, 0); ++ INJECT_START(PS3_ERR_IJ_PD_LIST_CMD_NO_RESP, &ret); ++ } else { ++ INJECT_START(PS3_ERR_IJ_ABORT_CMD_ERROR, cmd); ++ INJECT_START(PS3_ERR_IJ_RESET_CMD_ERROR, cmd); ++ INJECT_START(PS3_ERR_IJ_ABORT_CMD_NORMAL, cmd); ++ INJECT_START(PS3_ERR_IJ_RESET_CMD_NORMAL, cmd); ++ ret = ps3_cmd_reply_polling(instance, cmd, 0, PS3_FALSE); ++ if (ret != -PS3_TIMEOUT) { ++ PS3_MGR_CMD_BACK_INC(instance, cmd, (ret == PS3_SUCCESS) ? ++ PS3_REPLY_WORD_FLAG_SUCCESS : PS3_REPLY_WORD_FLAG_FAIL); ++ } ++ } ++ LOG_FILE_INFO("host_no:%u CFID:%d trace_id:0x%llx recv ret:%d\n", ++ PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id, ret); ++ return ret; ++} ++ + S32 ps3_unload_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) + { + if (cmd->is_force_polling == 0 && +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_mgr_channel.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_mgr_channel.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_mgr_channel.h 2025-06-10 20:13:00.224053597 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_mgr_channel.h 2025-06-10 20:13:00.528064202 +0800 +@@ -9,6 +9,9 @@ + S32 ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, ULong timeout); + S32 ps3_cmd_send_async(struct ps3_instance *instance, struct ps3_cmd *cmd, + S32 (*cmd_receive_cb)(struct ps3_cmd *, U16)); ++ ++S32 ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); ++ + S32 ps3_cmd_no_block_send(struct ps3_instance *instance, struct ps3_cmd *cmd); + + #ifndef _WINDOWS +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_mgr_cmd.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_mgr_cmd.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_mgr_cmd.c 2025-06-10 20:13:00.225053632 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_mgr_cmd.c 2025-06-10 20:13:00.533064376 +0800 +@@ -25,6 +25,7 @@ + #include "ps3_ioc_manager.h" + #include "ps3_err_inject.h" + #include "ps3_ioc_state.h" ++#include "ps3_ioctl.h" + + static S32 ps3_mgr_cmd_sync_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd, U16 time_out); +@@ -68,7 +69,7 @@ + PS3_MAX_PD_COUNT(instance) * + sizeof(struct PS3PhyDevice) + sizeof(struct PS3DevList), + &dev_context->pd_list_buf_phys); +- ++ INJECT_START(PS3_ERR_IJ_PS3_PD_LIST_BUF_ALLOC, &dev_context->pd_list_buf); + if (dev_context->pd_list_buf == NULL) { + LOG_ERROR("host_no:%u alloc pd list buffer failed !\n", + PS3_HOST(instance)); +@@ -88,7 +89,7 @@ + PS3_MAX_VD_COUNT(instance) * + sizeof(struct PS3VirtDevice) + sizeof(struct PS3DevList), + &dev_context->vd_list_buf_phys); +- ++ INJECT_START(PS3_ERR_IJ_PS3_VD_LIST_BUF_ALLOC, &dev_context->vd_list_buf); + if (dev_context->vd_list_buf == NULL) { + LOG_ERROR("host_no:%u alloc vd list buffer failed !\n", + PS3_HOST(instance)); +@@ -105,7 +106,7 @@ + dev_context->pd_info_buf = (struct PS3PDInfo *) + ps3_dma_alloc_coherent(instance, sizeof(struct PS3PDInfo), + &dev_context->pd_info_buf_phys); +- ++ INJECT_START(PS3_ERR_IJ_PS3_PD_INFO_BUF_ALLOC, &dev_context->pd_info_buf); + if (dev_context->pd_info_buf == NULL) { + LOG_ERROR("host_no:%u alloc pd info buffer failed !\n", + PS3_HOST(instance)); +@@ -191,7 +192,7 @@ + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo), + &dev_context->vd_info_buf_phys_sync); +- ++ INJECT_START(PS3_ERR_IJ_PS3_VD_INFO_BUF_SYNC_ALLOC, &dev_context->vd_info_buf_sync); + if (dev_context->vd_info_buf_sync == NULL) { + LOG_ERROR("host_no:%u alloc vd sync info buffer failed !\n", + PS3_HOST(instance)); +@@ -204,7 +205,7 @@ + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo), + &dev_context->vd_info_buf_phys_async); +- ++ INJECT_START(PS3_ERR_IJ_PS3_VD_INFO_BUF_ASYNC_ALLOC, &dev_context->vd_info_buf_async); + if (dev_context->vd_info_buf_async == NULL) { + LOG_ERROR("host_no:%u alloc vd async info buffer failed !\n", + PS3_HOST(instance)); +@@ -222,9 +223,9 @@ + + S32 ps3_mgr_cmd_init(struct ps3_instance *instance) + { +- LOG_INFO("host_no:%u , Soc VD max is:%d\n", PS3_HOST(instance), ++ LOG_INFO("host_no:%u, Soc VD max is:%d\n", PS3_HOST(instance), + PS3_MAX_VD_COUNT(instance)); +- LOG_INFO("host_no:%u , Soc PD max is:%d\n", PS3_HOST(instance), ++ LOG_INFO("host_no:%u, Soc PD max is:%d\n", PS3_HOST(instance), + PS3_MAX_PD_COUNT(instance)); + + if (PS3_MAX_PD_COUNT(instance) > 0) { +@@ -347,17 +348,27 @@ + S32 ps3_pd_list_get(struct ps3_instance *instance) + { + S32 ret = PS3_SUCCESS; ++ S32 send_result = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U32 pd_list_size = PS3_MAX_PD_COUNT(instance) * + sizeof(struct PS3PhyDevice) + sizeof(struct PS3DevList); + + LOG_INFO("host_no:%u enter !\n", PS3_HOST(instance)); +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u pd list cmd pre check NOK\n", ++ PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_EBUSY; ++ goto l_out; ++ } + cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) + if (cmd == NULL) { + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -PS3_EBUSY; + goto l_out; + } +@@ -376,7 +387,14 @@ + instance->dev_context.pd_list_buf_phys, + pd_list_size); + +- ret = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) { ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ ps3_mgr_print_cmd(cmd, ++ namePS3MgrCmdSubType(PS3_MGR_CMD_GET_PD_LIST), PS3_DRV_FALSE); ++ } ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); + l_out: + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + ps3_mgr_cmd_free(instance, cmd); +@@ -389,17 +407,27 @@ + S32 ps3_vd_list_get(struct ps3_instance *instance) + { + S32 ret = PS3_SUCCESS; ++ S32 send_result = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U32 vd_list_size = PS3_MAX_VD_COUNT(instance) * + sizeof(struct PS3VirtDevice) + sizeof(struct PS3DevList); + + LOG_INFO("host_no:%u enter !\n", PS3_HOST(instance)); +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u vd list cmd pre check NOK\n", ++ PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_EBUSY; ++ goto l_out; ++ } + cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); + if (cmd == NULL) { + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -PS3_EBUSY; + goto l_out; + } +@@ -418,7 +446,14 @@ + instance->dev_context.vd_list_buf_phys, + vd_list_size); + +- ret = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) { ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ ps3_mgr_print_cmd(cmd, ++ namePS3MgrCmdSubType(PS3_MGR_CMD_GET_VD_LIST), PS3_DRV_FALSE); ++ } ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); + l_out: + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + ps3_mgr_cmd_free(instance, cmd); +@@ -430,16 +465,26 @@ + S32 ps3_pd_info_get(struct ps3_instance *instance, U16 channel, U16 target_id, U16 pd_disk_id) + { + S32 ret = PS3_SUCCESS; ++ S32 send_result = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U32 pd_info_size = sizeof(struct PS3PDInfo); + + LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u pd info cmd pre check NOK\n", ++ PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_EBUSY; ++ goto l_out; ++ } + cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); + if (cmd == NULL) { + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -PS3_EBUSY; + goto l_out; + } +@@ -462,11 +507,18 @@ + instance->dev_context.pd_info_buf_phys, + pd_info_size); + +- LOG_INFO("host_no:%u ready send, reqFrameId=%d , [%d:%d:%d]!\n", ++ LOG_INFO("host_no:%u ready send, reqFrameId=%d, [%d:%d:%d]!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), channel, target_id, + pd_disk_id); + +- ret = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) { ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ ps3_mgr_print_cmd(cmd, ++ namePS3MgrCmdSubType(PS3_MGR_CMD_GET_PD_INFO), PS3_DRV_FALSE); ++ } ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); + LOG_INFO("host_no:%u get pd info [%d:%d:%d] finished!:ret = %d\n", + PS3_HOST(instance), channel, target_id, pd_disk_id, ret); + l_out: +@@ -484,6 +536,7 @@ + U16 vd_num) + { + S32 ret = PS3_SUCCESS; ++ S32 send_result = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U32 vd_info_size = PS3_MAX_VD_COUNT(instance) * +@@ -491,11 +544,20 @@ + struct ps3_dev_context *dev_context = &instance->dev_context; + + LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u vd info sync cmd pre check NOK\n", ++ PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_EBUSY; ++ goto l_out; ++ } + cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); + if (cmd == NULL) { + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -PS3_EBUSY; + goto l_out; + } +@@ -517,7 +579,14 @@ + LOG_INFO("host_no:%u ready send, reqFrameId=%d, disk_id=0x%x, num=%d !\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), disk_id, vd_num); + +- ret = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) { ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ ps3_mgr_print_cmd(cmd, ++ namePS3MgrCmdSubType(PS3_MGR_CMD_GET_VD_INFO), PS3_DRV_FALSE); ++ } ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); + LOG_INFO("host_no:%u get vd info, reqFrameId=%d, disk_id=0x%x, num=%d finish!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), disk_id, vd_num); + l_out: +@@ -542,6 +611,7 @@ + cmd = dev_context->vd_pending_cmd; + if (cmd == NULL) { + cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_PS3_VD_PENDING_CMD_ALLOC, &cmd); + if (cmd == NULL) { + LOG_FILE_ERROR("host_no:%u mgr cmd get failed !\n", + PS3_HOST(instance)); +@@ -568,14 +638,15 @@ + dev_context->vd_info_buf_async); + + ps3_mgr_cmd_word_build(cmd); +- LOG_FILE_INFO("host_no:%u ready send, reqFrameId=%d ,t_id:0x%llx!\n", ++ LOG_FILE_INFO("host_no:%u ready send, reqFrameId=%d, t_id:0x%llx!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id); + ps3_mgr_print_cmd(cmd, "vd info async", PS3_DRV_TRUE); + dev_context->vd_pending_cmd = cmd; + ret = ps3_cmd_send_async(instance, cmd, ps3_dev_vd_pending_proc); ++ INJECT_START(PS3_ERR_IJ_FORCE_VDINFO_SUB_FAIL, &ret) + ps3_mgr_print_cmd(cmd, "vd info async", PS3_DRV_FALSE); + if (ret != PS3_SUCCESS) { +- LOG_FILE_ERROR("host_no:%u send error, reqFrameId=%d ,t_id:0x%llx ret:%d!\n", ++ LOG_FILE_ERROR("host_no:%u send error, reqFrameId=%d, t_id:0x%llx ret:%d!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), + cmd->trace_id, ret); + dev_context->vd_pending_cmd = NULL; +@@ -655,15 +726,25 @@ + S32 ps3_ctrl_info_get(struct ps3_instance *instance) + { + S32 ret = PS3_SUCCESS; ++ S32 send_result = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + + LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u ctrl info cmd pre check NOK\n", ++ PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_EBUSY; ++ goto l_out; ++ } + cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); + if (cmd == NULL) { + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -PS3_EBUSY; + goto l_out; + } +@@ -681,10 +762,19 @@ + instance->ctrl_info_buf_h, + sizeof(struct PS3IocCtrlInfo)); + +- ret = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); +- if (ret == PS3_SUCCESS) { +- ps3_ctrl_info_update(instance); ++ send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) { ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ ps3_mgr_print_cmd(cmd, ++ namePS3MgrCmdSubType(PS3_MGR_CMD_GET_CTRL_INFO), PS3_DRV_FALSE); ++ } ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); ++ if (ret != PS3_SUCCESS) { ++ LOG_WARN("host_no:%u get ctrl info NOK!\n", PS3_HOST(instance)); ++ goto l_out; + } ++ ps3_ctrl_info_update(instance); + l_out: + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + ps3_mgr_cmd_free(instance, cmd); +@@ -696,7 +786,6 @@ + S32 ps3_soc_unload(struct ps3_instance *instance, Bool is_polling, U8 type, U8 suspend_type) + { + S32 ret = PS3_SUCCESS; +- U32 i = 0; + struct ps3_cmd *cmd = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + +@@ -708,12 +797,7 @@ + } + + ps3_wait_scsi_cmd_done(instance, PS3_TRUE); +- while ((ps3_atomic_read(&instance->cmd_statistics.cmd_delivering) != 0) && +- ++i < PS3_FW_STATE_TO_UNLOAD_TMO_LOOP_COUNT) { +- LOG_INFO("host_no:%u commands in delivering, wait a while!\n", +- PS3_HOST(instance)); +- ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); +- } ++ ps3_wait_mgr_cmd_done(instance, PS3_TRUE); + + cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_ROMOVE_UNLOAD_FAIL, &cmd) +@@ -737,9 +821,10 @@ + mgr_req_frame->suspend_type = suspend_type; + cmd->is_force_polling = is_polling; + +- LOG_WARN("host_no:%u ready send, reqFrameId=%d suspend_type:%d!\n", ++ LOG_WARN("host_no:%u ready send unload, reqFrameId=%d suspend_type:%d!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), suspend_type); + ret = ps3_mgr_unload_cmd_send(cmd, instance->unload_timeout); ++ INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY, &ret) + LOG_WARN("host_no:%u reqFrameId=%d finished ret:%d!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), ret); + l_out: +@@ -792,15 +877,25 @@ + struct PS3DiskDevPos *disk_pos, U8 dev_type) + { + S32 ret = PS3_SUCCESS; ++ S32 send_result = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + + LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u remove done cmd pre check NOK\n", ++ PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_EBUSY; ++ goto l_out; ++ } + cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); + if (cmd == NULL) { + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -PS3_EBUSY; + goto l_out; + } +@@ -823,7 +918,14 @@ + PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), + PS3_VDID(disk_pos), disk_pos->diskMagicNum); + +- ret = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) { ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ ps3_mgr_print_cmd(cmd, ++ namePS3MgrCmdSubType(PS3_MGR_CMD_DEV_DEL_DONE), PS3_DRV_FALSE); ++ } ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); + if (ret != PS3_SUCCESS) { + LOG_INFO("host_no:%u send [%u:%u:%u:%u][type:%d] del done failed!:ret = %d\n", + PS3_HOST(instance), PS3_CHANNEL(disk_pos), +@@ -850,15 +952,25 @@ + struct PS3DiskDevPos *disk_pos, U8 dev_type) + { + S32 ret = PS3_SUCCESS; ++ S32 send_result = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + + LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u add ack cmd pre check NOK\n", ++ PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_EBUSY; ++ goto l_out; ++ } + cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); + if (cmd == NULL) { + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -PS3_EBUSY; + goto l_out; + } +@@ -880,7 +992,14 @@ + PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), + PS3_VDID(disk_pos), disk_pos->diskMagicNum); + +- ret = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) { ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ ps3_mgr_print_cmd(cmd, ++ namePS3MgrCmdSubType(PS3_MGR_CMD_DEV_ADD_ACK), PS3_DRV_FALSE); ++ } ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); + if (ret != PS3_SUCCESS) { + LOG_ERROR("host_no:%u send [%u:%u:%u:%u][type:%d] add ack NOK!:ret = %d\n", + PS3_HOST(instance), PS3_CHANNEL(disk_pos), +@@ -906,17 +1025,27 @@ + S32 ps3_mgr_cmd_cancel(struct ps3_instance *instance, U16 cancel_cmd_frame_id) + { + S32 ret = PS3_SUCCESS; ++ S32 send_result = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U16 cancel_time_out = PS3_CANCEL_MGR_CMD_TIMEOUT; + + LOG_DEBUG("host_no:%u enter, be cancel CFID:%d !\n", + PS3_HOST(instance), cancel_cmd_frame_id); +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u mgr cancel cmd pre check NOK\n", ++ PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_EBUSY; ++ goto l_out; ++ } + cmd = ps3_task_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_FORCE_ALLOC_CANCEL_CMD_FAILED, &cmd) + if (cmd == NULL) { + LOG_FILE_ERROR("host_no:%u task cmd get failed !\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -PS3_EBUSY; + goto l_out; + } +@@ -939,8 +1068,15 @@ + LOG_FILE_INFO("host_no:%u ready send, reqFrameId=%d cancel_cmd_frame_id:%u !\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), cancel_cmd_frame_id); + +- INJECT_START(PS3_ERR_IJ_IOCTL_CMD_RECOVERY_CANCEL, cmd) +- ret = ps3_mgr_cmd_sync_proc(instance, cmd, cancel_time_out); ++ INJECT_START(PS3_ERR_IJ_IOCTL_CMD_RECOVERY_CANCEL, cmd); ++ send_result = ps3_mgr_cmd_sync_proc(instance, cmd, cancel_time_out); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) { ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ ps3_mgr_print_cmd(cmd, ++ namePS3MgrCmdSubType(PS3_MGR_CMD_CANCEL), PS3_DRV_FALSE); ++ } ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); + LOG_FILE_INFO("host_no:%u reqFrameId=%d cancel_cmd_frame_id:%u finished!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), cancel_cmd_frame_id); + l_out: +@@ -1088,6 +1224,7 @@ + LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); + + cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); + if (cmd == NULL) { + LOG_ERROR_IN_IRQ(instance, "host_no:%u mgr cmd get failed !\n", + PS3_HOST(instance)); +@@ -1140,50 +1277,62 @@ + + S32 ps3_web_register(struct ps3_instance *instance) + { +- S32 ret = PS3_SUCCESS; +- struct ps3_cmd *cmd = NULL; +- PS3MgrReqFrame_s *mgr_req_frame = NULL; +- struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; +- +- cmd = web_context->webSubscribe_cmd; +- +- if (cmd == NULL) { +- cmd = ps3_mgr_cmd_alloc(instance); +- if (cmd == NULL) { ++ S32 ret = PS3_SUCCESS; ++ struct ps3_cmd *cmd = NULL; ++ PS3MgrReqFrame_s *mgr_req_frame = NULL; ++ struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; ++ ++ cmd = web_context->webSubscribe_cmd; ++ ++ if (cmd == NULL) { ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u web cmd pre check NOK\n", ++ PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_FAILED; ++ goto l_out; ++ } ++ cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); ++ if (cmd == NULL) { + LOG_WARN_IN_IRQ(instance, + "host_no:%u ioctl req, Failed to get a cmd packet\n", + PS3_HOST(instance)); +- ret = -PS3_FAILED; +- goto l_out; +- } +- mgr_req_frame = &cmd->req_frame->mgrReq; +- memset(mgr_req_frame, 0, sizeof(struct PS3MgrReqFrame)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_FAILED; ++ goto l_out; ++ } ++ mgr_req_frame = &cmd->req_frame->mgrReq; ++ memset(mgr_req_frame, 0, sizeof(struct PS3MgrReqFrame)); + +- ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_WEBSUBSCRIBE_EVENT); ++ ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_WEBSUBSCRIBE_EVENT); + mgr_req_frame->reqHead.timeout = 0; +- mgr_req_frame->timeout = 0; +- mgr_req_frame->syncFlag = 0; +- mgr_req_frame->pendingFlag = 1; +- ps3_mgr_cmd_word_build(cmd); ++ mgr_req_frame->timeout = 0; ++ mgr_req_frame->syncFlag = 0; ++ mgr_req_frame->pendingFlag = 1; ++ ps3_mgr_cmd_word_build(cmd); + LOG_INFO_IN_IRQ(instance, "host_no:%u ready send, reqFrameId=%d !\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd)); +- ps3_mgr_print_cmd(cmd, "web event register", PS3_DRV_TRUE); ++ ps3_mgr_print_cmd(cmd, "web event register", PS3_DRV_TRUE); + +- web_context->webSubscribe_cmd = cmd; ++ web_context->webSubscribe_cmd = cmd; + +- ret = ps3_cmd_send_async(instance, cmd, ps3_webSubscribe_service); +- if (ret != PS3_SUCCESS) { +- web_context->webSubscribe_cmd = NULL; +- ps3_mgr_cmd_free(instance, cmd); +- goto l_out; +- } +- }else { ++ ret = ps3_cmd_send_async(instance, cmd, ps3_webSubscribe_service); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ INJECT_START(PS3_ERR_IJ_FORCE_WEB_SUB_FAIL, &ret) ++ if (ret != PS3_SUCCESS) { ++ web_context->webSubscribe_cmd = NULL; ++ ps3_mgr_cmd_free(instance, cmd); ++ goto l_out; ++ } ++ } else { + LOG_INFO_IN_IRQ(instance, "host_no:%u web event already subscribed\n", +- PS3_HOST(instance)); +- } ++ PS3_HOST(instance)); ++ } + l_out: +- LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); +- return ret; ++ LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); ++ return ret; + } + + static S32 ps3_scsi_task_abort_sync_proc(struct ps3_instance *instance, +@@ -1191,7 +1340,6 @@ + struct ps3_scsi_priv_data *priv_data) + { + S32 ret = PS3_SUCCESS; +- S32 send_result = PS3_SUCCESS; + + cmd->cmd_word_value = abort_cmd->cmd_word_value; + if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_INIT) { +@@ -1204,25 +1352,12 @@ + cmd->time_out = priv_data->task_abort_timeout; + cmd->is_interrupt = PS3_DRV_FALSE; + +- INJECT_START(PS3_ERR_IJ_ABORT_PRE_SEND_FORCE_ABORTED_CMD_DONE ,abort_cmd->scmd) +- send_result = ps3_cmd_send_sync(instance, cmd); +- ret = ps3_mgr_complete_proc(instance, cmd, send_result); ++ INJECT_START(PS3_ERR_IJ_ABORT_PRE_SEND_FORCE_ABORTED_CMD_DONE, abort_cmd->scmd) ++ ret = ps3_cmd_send_sync(instance, cmd); + end: + return ret; + } + +-static S32 ps3_scsi_task_reset_sync_proc(struct ps3_instance *instance, +- struct ps3_cmd *cmd) +-{ +- S32 ret = PS3_SUCCESS; +- S32 send_result = PS3_SUCCESS; +- +- send_result = ps3_cmd_send_sync(instance, cmd); +- ret = ps3_mgr_complete_proc(instance, cmd, send_result); +- +- return ret; +-} +- + static inline void ps3_mgr_scsi_req_head_init(struct ps3_cmd *cmd, + PS3ReqFrameHead_s *req_header, U8 cmdSubType, U32 disk_id, + struct ps3_scsi_priv_data *priv_data) +@@ -1343,6 +1478,7 @@ + struct ps3_scsi_priv_data *priv_data, U16 aborted_cmd_frame_id, struct scsi_cmnd *scmd) + { + S32 ret = PS3_SUCCESS; ++ S32 send_result = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; + struct ps3_cmd *aborted_cmd = NULL; + PS3MgrTaskReqFrame_s *mgr_task_req_frame = NULL; +@@ -1357,7 +1493,7 @@ + goto l_out; + } + +- INJECT_START(PS3_ERR_IJ_ABORT_PRE_BULID_FORCE_ABORTED_CMD_DONE ,scmd) ++ INJECT_START(PS3_ERR_IJ_ABORT_PRE_BULID_FORCE_ABORTED_CMD_DONE, scmd) + aborted_cmd = ps3_cmd_find(instance, aborted_cmd_frame_id); + if (aborted_cmd == NULL || aborted_cmd->scmd == NULL) { + LOG_ERROR("host_no:%u there is no aborted cmd CFID:%u\n", +@@ -1366,11 +1502,20 @@ + ret = PS3_SUCCESS; + goto l_out; + } +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u aborted cmd pre check NOK CFID:%d\n", ++ PS3_HOST(instance), aborted_cmd_frame_id); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_EBUSY; ++ goto l_out; ++ } + cmd = ps3_task_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); + if (cmd == NULL) { + LOG_ERROR("host_no:%u task cmd get NOK !\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -PS3_EBUSY; + goto l_out; + } +@@ -1402,11 +1547,15 @@ + aborted_cmd->cmd_word.qMask, aborted_cmd->cmd_word.isrSN); + + ps3_scsih_print_req(aborted_cmd, LEVEL_INFO); +- INJECT_START(PS3_ERR_IJ_ABORT_PRE_BULID1_FORCE_ABORTED_CMD_DONE ,scmd) ++ INJECT_START(PS3_ERR_IJ_ABORT_PRE_BULID1_FORCE_ABORTED_CMD_DONE, scmd) + INJECT_START(PS3_ERR_IJ_SET_ABORT_COUNT, scmd); + +- ret = ps3_scsi_task_abort_sync_proc(instance, cmd, aborted_cmd, priv_data); ++ send_result = ps3_scsi_task_abort_sync_proc(instance, cmd, aborted_cmd, priv_data); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) ++ send_result = ps3_cmd_wait_sync(instance, cmd); + ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); + LOG_WARN("host_no:%u abort finish, CFID:%d aborted CFID:%d aborted cmdword[0x%08llx], " + "[%u:%u:%u:%u]!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), aborted_cmd_frame_id, aborted_cmd->cmd_word_value, +@@ -1423,23 +1572,7 @@ + return ret; + } + #endif +-S32 ps3_scsi_task_mgr_reset(struct ps3_instance *instance, +- struct ps3_cmd *cmd) +-{ +- S32 ret = PS3_SUCCESS; +- +- ret = ps3_scsi_task_reset_sync_proc(instance, cmd); +- +- LOG_INFO("host_no:%u reset finish CFID:%u t_id:0x%llx!\n", +- PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id); + +- if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { +- ps3_task_cmd_free(instance, cmd); +- } +- LOG_INFO("host_no:%u exit !\n", PS3_HOST(instance)); +- +- return ret; +-} + #ifndef _WINDOWS + static inline void ps3_sas_info_reqframe_build(struct ps3_cmd *cmd, + enum PS3MgrCmdSubType sub_type, dma_addr_t *sge_addr, struct PS3SasMgr *sas_req) +@@ -1474,12 +1607,23 @@ + enum PS3MgrCmdSubType sub_type, dma_addr_t *sge_addr, struct PS3SasMgr *sas_req) + { + S32 ret = 0; ++ S32 send_result = PS3_SUCCESS; + struct ps3_cmd *cmd = NULL; + ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u sas info cmd pre check NOK\n", ++ PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -PS3_FAILED; ++ goto l_out; ++ } + cmd = ps3_mgr_cmd_alloc(instance); ++ INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); + if (cmd == NULL) { + LOG_WARN("host_no:%u not get a cmd packet\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -PS3_FAILED; + goto l_out; + } +@@ -1491,7 +1635,14 @@ + PS3_HOST(instance), cmd->trace_id, cmd->index, + namePS3MgrCmdSubType((enum PS3MgrCmdSubType)sub_type)); + +- ret = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) { ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ ps3_mgr_print_cmd(cmd, ++ namePS3MgrCmdSubType(sub_type), PS3_DRV_FALSE); ++ } ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); + if (ret != PS3_SUCCESS) { + LOG_ERROR("host_no:%u %d respStatus NOK CFID:%d respStatus:%d\n", + PS3_HOST(cmd->instance), ret, +@@ -1545,8 +1696,6 @@ + static S32 ps3_mgr_cmd_sync_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd, U16 time_out) + { +- S32 ret = PS3_SUCCESS; +- S32 send_result = PS3_SUCCESS; + enum PS3MgrCmdSubType sub_type = (enum PS3MgrCmdSubType)PS3_MGR_CMD_SUBTYPE(cmd); + + cmd->time_out = time_out; +@@ -1556,13 +1705,9 @@ + ps3_mgr_print_cmd(cmd, + namePS3MgrCmdSubType(sub_type), PS3_DRV_TRUE); + +- send_result = ps3_cmd_send_sync(instance, cmd); +- +- ps3_mgr_print_cmd(cmd, +- namePS3MgrCmdSubType(sub_type), PS3_DRV_FALSE); +- ret = ps3_mgr_complete_proc(instance, cmd, send_result); ++ INJECT_START(PS3_ERR_IJ_PD_LIST_WAIT_IRQ_DISABLE, cmd); + +- return ret; ++ return ps3_cmd_send_sync(instance, cmd); + } + + static S32 ps3_no_resp_cmd_dead_proc(struct ps3_instance *instance, +@@ -1583,13 +1728,12 @@ + + cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); +- LOG_INFO("host_no:%u entry reset!\n", +- PS3_HOST(instance)); ++ LOG_WARN("host_no:%u cmd_dead_proc entry reset due to cmd not resp!\n", PS3_HOST(instance)); + +- if (instance->is_probe_finish == PS3_FALSE || ++ if (!instance->is_probe_finish || + !instance->state_machine.is_load) { + ps3_need_wait_hard_reset_request(instance); +- ret = ps3_hard_recovery_request(instance); ++ ret = ps3_hard_recovery_request_with_retry(instance); + if (ret == PS3_SUCCESS) { + ps3_instance_wait_for_dead_or_pre_operational(instance); + } else { +@@ -1599,7 +1743,7 @@ + + } else { + ps3_need_wait_hard_reset_request(instance); +- ps3_recovery_request(instance); ++ ps3_recovery_request_with_retry(instance); + } + + LOG_ERROR("t_id:0x%llx CFID:%d host_no:%u state %u, recovery request\n", +@@ -1630,15 +1774,15 @@ + } + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + } +- LOG_INFO("host_no:%u entry soft reset!\n", +- PS3_HOST(instance)); ++ LOG_WARN("host_no:%u cmd_wait_proc entry reset due to cmd not resp, CFID:%d t_id:0x%llx !\n", ++ PS3_HOST(instance), cmd->index, cmd->trace_id); + + is_probe_finish = instance->is_probe_finish; + ps3_need_wait_hard_reset_request(instance); +- if (is_probe_finish == PS3_FALSE) { +- ret = ps3_hard_recovery_request(instance); ++ if (!is_probe_finish) { ++ ret = ps3_hard_recovery_request_with_retry(instance); + } else { +- ret = ps3_recovery_request(instance); ++ ret = ps3_recovery_request_with_retry(instance); + } + + if (ret == -PS3_FAILED) { +@@ -1649,9 +1793,8 @@ + } + INJECT_START(PS3_ERR_IJ_WAIT_HARD_RESET, instance) + +- if (is_probe_finish == PS3_FALSE) { ++ if (!is_probe_finish) + ps3_instance_wait_for_dead_or_pre_operational(instance); +- } + + LOG_WARN("host_no:%u CFID:%d wait again, retries:%d\n", + PS3_HOST(instance), cmd->index, cmd->retry_cnt); +@@ -1703,7 +1846,9 @@ + } + + ps3_need_wait_hard_reset_request(instance); +- ret = ps3_hard_recovery_request(instance); ++ LOG_WARN("host_no:%u scsi_task_cmd_wait_proc entry reset due to cmd not resp, CFID:%d t_id:0x%llx !\n", ++ PS3_HOST(instance), cmd->index, cmd->trace_id); ++ ret = ps3_hard_recovery_request_with_retry(instance); + if (ret == -PS3_FAILED) { + ret = -PS3_CMD_NO_RESP; + LOG_ERROR("host_no:%u hard recovery request NOK\n", +@@ -1819,20 +1964,29 @@ + break; + } + +- ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); +- cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; +- ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + cmd->retry_cnt++; + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_RETRY_DONE, cmd) + if (cmd->retry_cnt >= PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { + break; + } +- + LOG_INFO("host_no:%u mgr CFID:%d retry:%u\n", + PS3_HOST(instance), cmd->index, cmd->retry_cnt); ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ send_result = ps3_mgr_cmd_send_check(instance, cmd); ++ if (send_result != PS3_SUCCESS) { ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ continue; ++ } + cmd->resp_frame->normalRespFrame.respStatus = 0xff; + init_completion(&cmd->sync_done); ++ ps3_ioctl_buff_bit_pos_update(cmd); ++ ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); ++ cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; ++ ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + send_result = ps3_cmd_send_sync(instance, cmd); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) ++ send_result = ps3_cmd_wait_sync(instance, cmd); + }; + + if (cmd->retry_cnt >= PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_mgr_cmd_err.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_mgr_cmd_err.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_mgr_cmd_err.c 2025-06-10 20:13:00.225053632 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_mgr_cmd_err.c 2025-06-10 20:13:00.533064376 +0800 +@@ -130,6 +130,7 @@ + case PS3_FAULT_STRATEGY_RETRY: + ps3_msleep(PS3_ERR_MGR_CMD_DELAY_TIME_BEFORE_RERTY); + proc_result = -PS3_RETRY; ++ break; + default: + break; + } +@@ -203,13 +204,13 @@ + proc_result = -PS3_FAILED; + } + } else if(ps3_cmd_resp_status(cmd) == PS3_DRV_MGR_RESTART_COMMAND_RSP){ +- LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx cli cx restart return success\n", ++ LOG_WARN("host_no:%u CFID:%d trace_id:0x%llx cli cx restart return success\n", + PS3_HOST(instance), + cmd->cmd_word.cmdFrameID, cmd->trace_id); + ps3_need_wait_hard_reset_request(instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_2, instance) + if (ps3_recovery_state_wait_for_normal(instance) == PS3_SUCCESS){ +- ret = ps3_hard_recovery_request(instance); ++ ret = ps3_hard_recovery_request_with_retry(instance); + if (ret != PS3_SUCCESS){ + LOG_WARN("host_no:%u hard recovery request NOK\n", + PS3_HOST(instance)); +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_mgr_cmd.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_mgr_cmd.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_mgr_cmd.h 2025-06-10 20:13:00.225053632 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_mgr_cmd.h 2025-06-10 20:13:00.533064376 +0800 +@@ -54,9 +54,6 @@ + S32 ps3_scsi_task_mgr_abort(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data, U16 aborted_cmd_frame_id, struct scsi_cmnd *scmd); + +-S32 ps3_scsi_task_mgr_reset(struct ps3_instance *instance, +- struct ps3_cmd *cmd); +- + void ps3_mgr_cmd_word_build(struct ps3_cmd *cmd); + + S32 ps3_sas_expander_all_get(struct ps3_instance *instance); +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_module_para.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_module_para.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_module_para.c 2025-06-10 20:13:00.225053632 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_module_para.c 2025-06-10 20:13:00.534064411 +0800 +@@ -12,7 +12,7 @@ + static U32 cli_ver = PS3_IOCTL_VERSION; + module_param(cli_ver, uint, S_IRUGO | S_IRUSR); + MODULE_PARM_DESC(cli_ver, +- "The version for communication between driver and cli."); ++ "The version for communication between driver and CLI"); + #endif + + static U32 g_throttle_que_depth = PS3_DEVICE_QDEPTH_DEFAULT_VALUE; +@@ -36,7 +36,7 @@ + #ifndef _WINDOWS + module_param(g_use_clustering, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_use_clustering, +- "Make SCSI mid layer bio merge feature enable/disable. Default: enable(1)"); ++ "SCSI mid-layer bio merge feature enable/disable. Default: enable(1)"); + #endif + static U32 g_scsi_cmd_timeout = 0; + #ifndef _WINDOWS +@@ -52,12 +52,12 @@ + #if 0 + module_param(g_ps3_r1x_lock_flag, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_ps3_r1x_lock_flag, +- "R1X write confilct check func. 0 - hash+bitmap, 1 - " ++ "R1X write conflict check func. 0 - hash+bitmap, 1 - " + "hash+rangetree. Default: 0"); + #endif + module_param(g_ps3_r1x_lock_enable, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_ps3_r1x_lock_enable, +- "Enable/disable r1x write confilct check feature enable/disable. Default: enable(1)"); ++ "R1x write conflict check feature enable/disable. Default: enable(1)"); + #endif + + #if defined(PS3_SUPPORT_DEBUG) || \ +@@ -78,7 +78,7 @@ + #ifndef _WINDOWS + module_param(g_ps3_r1x_rb_diff_cmds, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_ps3_r1x_rb_diff_cmds, +- "Raid1x read balancing outstanding threshold. Default: 4"); ++ "R1x read balancing outstanding threshold. Default: 4"); + #endif + + #endif +@@ -129,11 +129,18 @@ + "Direct detect stream or not feature enable/disable. Default: enable(1)"); + #endif + ++static S32 g_device_busy_threshold = PS3_DEVICE_IO_BUSY_THRESHOLD; ++#ifndef _WINDOWS ++module_param(g_device_busy_threshold, int, 0644); ++MODULE_PARM_DESC(g_device_busy_threshold, ++ "Device busy threshold value. Default: 8"); ++#endif ++ + #ifndef __cplusplus + static char g_log_path[80] = {0}; + #ifndef _WINDOWS + module_param_string(g_log_path, g_log_path, 80, S_IRUGO | S_IWUSR); +-MODULE_PARM_DESC(g_log_path, "The path host driver will be saved little than 80 chars. Default: /var/log"); ++MODULE_PARM_DESC(g_log_path, "The log path of host driver will be saved little than 80 chars. Default: /var/log"); + #endif + #endif + +@@ -154,7 +161,7 @@ + + module_param(g_log_level, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_log_level, +- "specify driver log level." ++ "Specify driver log level." + #ifdef PS3_CFG_RELEASE + "0 - error, 1 - warn, 2 - info, 3 - debug. Default: 2"); + #else +@@ -182,7 +189,7 @@ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) + module_param(g_r1x_conflict_queue_enable, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_r1x_conflict_queue_enable, +- "R1X conflict queue function is feature enable enable/disable. Default: enable(1)"); ++ "R1X conflict queue function feature enable/disable. Default: enable(1)"); + #endif + #endif + +@@ -194,10 +201,10 @@ + static U32 g_enable_inject = 0; + module_param_array(g_err_inject, uint, &num_inject, 0); + MODULE_PARM_DESC(g_err_inject, +- "Err inject. Default: 0"); ++ "Err inject array. Default: 0"); + module_param(g_enable_inject, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_enable_inject, +- "Enable inject feature enable/disable. Default: disable(0)"); ++ "Err inject feature enable/disable. Default: disable(0)"); + + U32 ps3_err_inject_num_query(void) + { +@@ -256,14 +263,14 @@ + #ifndef _WINDOWS + module_param(g_aer_handle_support, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_aer_handle_support, +- "Modify driver aer handle support feature enable/disable. Default: enable(1)"); ++ "Driver aer handle support feature enable/disable. Default: enable(1)"); + #endif + + #ifndef __cplusplus + static char g_version_verbose[512] = {0}; + #ifndef _WINDOWS + module_param_string(g_version_verbose, g_version_verbose, 511, S_IRUGO); +-MODULE_PARM_DESC(g_version_verbose, "Display detailed version information about ps3stor driver."); ++MODULE_PARM_DESC(g_version_verbose, "Display detailed version information about ps3stor driver"); + #endif + #endif + +@@ -290,21 +297,26 @@ + #if ((defined PS3_HARDWARE_FPGA && defined PS3_MODEL_V200) \ + || defined(PS3_HARDWARE_HAPS_V200) || defined(PS3_HARDWARE_ASIC)) + static U32 g_enable_heartbeat = 1; ++module_param(g_enable_heartbeat, uint, 0644); ++MODULE_PARM_DESC(g_enable_heartbeat, ++ "Heartbeat query feature enable/disable. Default: enable(1)"); + #else + static U32 g_enable_heartbeat = 0; +-#endif +-#ifndef _WINDOWS + module_param(g_enable_heartbeat, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_enable_heartbeat, +- "Enable heartbeat feature enable/disable. Default: enable(1)"); ++ "Heartbeat query feature enable/disable. Default: disable(0)"); + #endif + + static U32 g_hil_mode = 0xFFFF; + #ifndef _WINDOWS ++#if defined(PS3_SUPPORT_DEBUG) || \ ++ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ ++ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) + module_param(g_hil_mode, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_hil_mode, + "Set HIL operational mode." +- "0 - SW mode, 1 - HW mode, 2 - Enhanced HW mode, 3 - SW assist mode. Default: 0xFFFF"); ++ "0 - SW mode, 1 - HW mode, 2 - Enhanced HW mode, 3 - SW assist mode. Default: 65535(0xFFFF)"); ++#endif + #endif + + static U32 g_avaliable_func_id = 0xFF; +@@ -315,7 +327,7 @@ + module_param(g_avaliable_func_id, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_avaliable_func_id, + "Set function id." +- "0 - Func0, 1 - Func1, 2 - Unlimited. Default: 0xFF"); ++ "0 - Func0, 1 - Func1, 2 - Unlimited. Default: 255(0xFF)"); + #endif + #endif + +@@ -326,7 +338,7 @@ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) + module_param(g_pci_irq_mode, uint, S_IRUGO | S_IWUSR); + MODULE_PARM_DESC(g_pci_irq_mode, +- "specify pci irq mode." ++ "Specify pci irq mode." + "0 - none specify, 1 - legacy, 2 - msi, 3 - msix. Default: 0"); + #endif + #endif +@@ -338,15 +350,19 @@ + (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0))) + S32 g_ps3_tagset_enable = 1; + module_param(g_ps3_tagset_enable, int, 0444); +-MODULE_PARM_DESC(g_ps3_tagset_enable, "Shared host tagset enable/disable Default: enable(1)"); ++MODULE_PARM_DESC(g_ps3_tagset_enable, "Shared host tagset enable/disable. Default: enable(1)"); + #else + S32 g_ps3_tagset_enable = 0; + module_param(g_ps3_tagset_enable, int, 0444); +-MODULE_PARM_DESC(g_ps3_tagset_enable, "Shared host tagset enable/disable Default: disable(0)"); ++MODULE_PARM_DESC(g_ps3_tagset_enable, "Shared host tagset enable/disable. Default: disable(0)"); + #endif + + #endif + ++static U32 g_smp_affinity_enable = 1; ++module_param(g_smp_affinity_enable, int, 0444); ++MODULE_PARM_DESC(g_smp_affinity_enable, "SMP affinity feature enable/disable. Default: enable(1)"); ++ + void ps3_version_verbose_fill(void) + { + #ifndef __cplusplus +@@ -367,9 +383,6 @@ + "build_time", PS3_DRV_BUILD_TIME); + + len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", +- "arch", PS3_DRV_ARCH); +- +- len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", + "product_support", PS3_DRV_PRODUCT_SUPPORT); + #endif + } +@@ -466,6 +479,16 @@ + g_direct_check_stream_enable = val; + } + ++S32 ps3_device_busy_threshold_query(void) ++{ ++ return g_device_busy_threshold; ++} ++ ++void ps3_device_busy_threshold_modify(S32 busy) ++{ ++ g_device_busy_threshold = busy; ++} ++ + void ps3_log_level_modify(U32 level) + { + ps3_level_set(level); +@@ -573,12 +596,12 @@ + return; + } + +-U32 ps3_avaliable_func_id_query(void) ++U32 ps3_available_func_id_query(void) + { + return g_avaliable_func_id; + } + +-void ps3_avaliable_func_id_modify(U32 val) ++void ps3_available_func_id_modify(U32 val) + { + g_avaliable_func_id = val; + return; +@@ -613,3 +636,9 @@ + return (g_ps3_tagset_enable == 1) ? PS3_TRUE: PS3_FALSE; + } + #endif ++ ++Bool ps3_smp_affinity_query(void) ++{ ++ return (g_smp_affinity_enable == 1) ? PS3_TRUE : PS3_FALSE; ++} ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_module_para.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_module_para.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_module_para.h 2025-06-10 20:13:00.225053632 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_module_para.h 2025-06-10 20:13:00.484062667 +0800 +@@ -43,6 +43,10 @@ + + U32 ps3_direct_check_stream_query(void); + ++S32 ps3_device_busy_threshold_query(void); ++ ++void ps3_device_busy_threshold_modify(S32 busy); ++ + void ps3_log_level_modify(U32 level); + + char* ps3_log_path_query(void); +@@ -86,9 +90,9 @@ + + void ps3_hil_mode_modify(U32 val); + +-U32 ps3_avaliable_func_id_query(void); ++U32 ps3_available_func_id_query(void); + +-void ps3_avaliable_func_id_modify(U32 val); ++void ps3_available_func_id_modify(U32 val); + + void ps3_direct_check_stream_modify(U32 val); + +@@ -103,6 +107,8 @@ + Bool ps3_tagset_enable_query(void); + #endif + ++Bool ps3_smp_affinity_query(void); ++ + #ifndef _WINDOWS + #ifdef PS3_SUPPORT_INJECT + U32 ps3_err_inject_num_query(void); +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_nvme_resp_to_scsi.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_nvme_resp_to_scsi.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_nvme_resp_to_scsi.c 2025-06-10 20:13:00.225053632 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_nvme_resp_to_scsi.c 2025-06-10 20:13:00.534064411 +0800 +@@ -54,7 +54,7 @@ + SCSI_ASCQ_LOGICAL_BLOCK_APPTAG_CHECK_FAILED = 0x02, + SCSI_ASCQ_NO_ACCESS_RIGHTS = 0x02, + SCSI_ASCQ_LOGICAL_BLOCK_REFTAG_CHECK_FAILED = 0x03, +- SCSI_ASCQ_SANITIZE_COMMAND_FAILED = 0x03, ++ SCSI_ASCQ_SANITIZE_COMMAND_FAILED = 0x03, + SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_FORMAT_IN_PROGRESS = 0x04, + SCSI_ASCQ_DATA_OFFSET_ERROR = 0x05, + SCSI_ASCQ_POWER_LOSS_EXPECTED = 0x08, +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_platform_utils.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_platform_utils.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_platform_utils.c 2025-06-10 20:13:00.226053667 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_platform_utils.c 2025-06-10 20:13:00.537064516 +0800 +@@ -250,7 +250,7 @@ + struct scsi_device *__ps3_scsi_device_lookup_check(struct Scsi_Host *shost, + U32 channel, U32 id, U32 lun) + { +- struct scsi_device *sdev; ++ struct scsi_device *sdev = NULL; + + list_for_each_entry(sdev, &shost->__devices, siblings) { + if (sdev->sdev_state == SDEV_DEL) +@@ -266,8 +266,8 @@ + struct scsi_device *ps3_scsi_device_lookup_check(struct Scsi_Host *shost, + U32 channel, U32 id, U32 lun) + { +- struct scsi_device *sdev; +- unsigned long flags; ++ struct scsi_device *sdev = NULL; ++ unsigned long flags = 0; + + spin_lock_irqsave(shost->host_lock, flags); + sdev = __ps3_scsi_device_lookup_check(shost, channel, id, lun); +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_platform_utils.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_platform_utils.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_platform_utils.h 2025-06-10 20:13:00.226053667 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_platform_utils.h 2025-06-10 20:13:00.537064516 +0800 +@@ -32,7 +32,7 @@ + #else + #define ps3_container_of container_of + #endif +-#define MAX_MDELAY (5) ++#define MAX_MDELAY (1) + + #ifdef _WINDOWS + typedef struct { +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_qos.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_qos.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_qos.c 2025-06-10 20:13:00.233053911 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_qos.c 2025-06-10 20:13:00.510063574 +0800 +@@ -2,6 +2,7 @@ + #include + #include + #include ++#include + #include + #include "ps3_ioc_manager.h" + #include "ps3_util.h" +@@ -31,7 +32,7 @@ + U64 *depth) + { + Bool ret = PS3_TRUE; +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3TfifoDepth, *depth); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3TfifoDepth, *depth); + if (*depth == U64_MAX) { + LOG_INFO("host_no:%u read reg ps3TfifoDepth failed!\n", + PS3_HOST(instance)); +@@ -50,7 +51,7 @@ + U64 *depth) + { + Bool ret = PS3_TRUE; +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3CmdQueueDepth, *depth); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3CmdQueueDepth, *depth); + + if (*depth == U64_MAX) { + LOG_INFO("host_no:%u read reg ps3CmdQueueDepth failed!\n", +@@ -70,7 +71,7 @@ + U64 *depth) + { + Bool ret = PS3_TRUE; +- PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MgrQueueDepth, *depth); ++ PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MgrQueueDepth, *depth); + + if (*depth == U64_MAX) { + LOG_INFO("host_no:%u read reg ps3MgrQueueDepth failed!\n", +@@ -592,7 +593,7 @@ + } + _out: + INJECT_START(PS3_ERR_IJ_QOS_NOT_AWAKE_PD, &can_notify) +- return can_notify; ++ return can_notify; + } + + static Bool ps3_qos_single_pd_notify(struct ps3_qos_pd_context *qos_pd_ctx, +@@ -738,7 +739,7 @@ + } + } + ps3_spin_unlock_irqrestore(qos_vd_mgr->vd_quota_wait_q.rsc_lock, flag); +- LOG_INFO("clean qos device vd quota waitq host_no:%u diskid:%u\n", ++ LOG_FILE_INFO("clean qos device vd quota waitq host_no:%u diskid:%u\n", + PS3_HOST(qos_vd_mgr->instance), qos_vd_mgr->id); + } + +@@ -763,7 +764,7 @@ + qos_vd_mgr->vd_quota_wait_q.count--; + PS3_QOS_STAT_END(instance, cmd, PS3_QOS_VD_QUEUE); + if (ps3_qos_tg_decision(cmd)) { +- ret = ps3_scsi_cmd_send(instance, cmd); ++ ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); + if (unlikely(ret != PS3_SUCCESS)) { + ps3_qos_cmd_update(instance, cmd); + ps3_qos_cmd_resend_fail(cmd, ret); +@@ -894,7 +895,7 @@ + "t_id:0x%llx CFID:%u seq[%u %u]\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + cmd->req_frame->hwReq.reqHead.virtDiskSeq, +- vd_entry->virtDiskSeq); ++ (!vd_entry) ? 0 : vd_entry->virtDiskSeq); + ps3_qos_update_pd_quota(cmd); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, + SCSI_STATUS_TASK_ABORTED, PS3_FALSE); +@@ -931,7 +932,7 @@ + can_send--; + ps3_atomic_inc(waitq->used_rsc); + if (ps3_qos_pd_resend_check(instance, cmd)) { +- ret = ps3_scsi_cmd_send(instance, cmd); ++ ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); + if (unlikely(ret != PS3_SUCCESS)) { + ps3_qos_cmd_update(instance, cmd); + ps3_qos_cmd_resend_fail(cmd, ret); +@@ -1145,7 +1146,7 @@ + if (ps3_qos_vd_seq_check(cmd)) { + continue; + } +- ret = ps3_scsi_cmd_send(instance, cmd); ++ ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); + if (unlikely(ret != PS3_SUCCESS)) { + ps3_qos_update_vd_quota(cmd); + ps3_qos_update_pd_quota(cmd); +@@ -1187,7 +1188,7 @@ + wait_q->count--; + qos_tg_ctx->total_wait_cmd_cnt--; + PS3_QOS_STAT_END(instance, cmd, PS3_QOS_TAG_QUEUE); +- ret = ps3_scsi_cmd_send(instance, cmd); ++ ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); + if (unlikely(ret != PS3_SUCCESS)) { + ps3_qos_cmd_resend_fail(cmd, ret); + } else { +@@ -1233,7 +1234,7 @@ + waitq->count--; + qos_tg_ctx->total_wait_cmd_cnt--; + PS3_QOS_STAT_END(instance, cmd, PS3_QOS_TAG_QUEUE); +- ret = ps3_scsi_cmd_send(instance, cmd); ++ ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); + if (unlikely(ret != PS3_SUCCESS)) { + ps3_qos_cmd_resend_fail(cmd, ret); + ps3_atomic_inc(&qos_tg_ctx->mgr_free_cnt); +@@ -1263,7 +1264,7 @@ + ps3_atomic_inc(&qos_vd_mgr->exclusive_cmd_cnt); + continue; + } +- ret = ps3_scsi_cmd_send(instance, cmd); ++ ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); + if (unlikely(ret != PS3_SUCCESS)) { + ps3_qos_update_vd_quota(cmd); + ps3_qos_update_pd_quota(cmd); +@@ -1340,7 +1341,7 @@ + U32 cpu_num = 0; + + qos_pd_ctx = &instance->qos_context.pd_ctx; +- if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1) { ++ if (ps3_is_last_func(instance)) { + cpu_num = num_online_cpus(); + if (instance->irq_context.is_balance_current_perf_mode) { + INJECT_START(PS3_ERR_IJ_SET_HIGH_IOPS_CHANNEL_IN_QOS, instance); +@@ -1382,7 +1383,7 @@ + qos_pd_mgr->poll_que_id = 1; + qos_pd_mgr->poll_start_que_id = 1; + ps3_atomic_set(&qos_pd_mgr->processing_cnt, 0); +- ++ qos_pd_mgr->pd_init_quota = 0; + qos_pd_mgr->instance = instance; + qos_pd_mgr->total_wait_cmd_cnt = 0; + qos_pd_mgr->total_waited_direct_cmd = 0; +@@ -1507,13 +1508,14 @@ + U16 jbod_vd_quota = 0; + + qos_vd_ctx = &instance->qos_context.vd_ctx; +- if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_0) { +- qos_vd_ctx->vd_exclusive_cnt = 0; +- qos_vd_ctx->jbod_exclusive_cnt = 0; +- } else { ++ if (ps3_is_last_func(instance)) { + qos_vd_ctx->vd_exclusive_cnt = g_ps3_qos_vd_exclusive; + qos_vd_ctx->jbod_exclusive_cnt = g_ps3_qos_jbod_exclusive; ++ } else { ++ qos_vd_ctx->vd_exclusive_cnt = 0; ++ qos_vd_ctx->jbod_exclusive_cnt = 0; + } ++ + jbod_vd_quota = instance->qos_context.tg_ctx.share + qos_vd_ctx->jbod_exclusive_cnt; + + max_vd_count = instance->qos_context.max_vd_count; +@@ -1623,21 +1625,40 @@ + U16 i = 0; + struct qos_wait_queue *wait_q = NULL; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; ++ U32 tag_exclusive = 0; + + ps3_tfifo_depth_get(instance, &tfifo_depth); +- ++ INJECT_START(PS3_ERR_IJ_QOS_FORCE_TFIFO_ZERO_DEPTH, &tfifo_depth) ++ if (tfifo_depth == 0) { ++ ret = -PS3_FAILED; ++ LOG_ERROR("hno:%u:tfifo_depth is invalid func:%u\n", ++ PS3_HOST(instance), ++ ps3_get_pci_function(instance->pdev)); ++ goto out; ++ } + qos_tg_ctx = &instance->qos_context.tg_ctx; + qos_tg_ctx->instance = instance; +- qos_tg_ctx->high_pri_exclusive_cnt = QOS_HIGH_PRI_EXCLUSIVE_CMD_COUNT >> 1; +- qos_tg_ctx->mgr_exclusive_cnt = g_ps3_qos_mgr_exclusive >> 1; +- if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_0) { +- qos_tg_ctx->share = PS3_QOS_CS_FUNC0_SHARE_CMD; +- } else { +- qos_tg_ctx->share = tfifo_depth - qos_tg_ctx->mgr_exclusive_cnt - qos_tg_ctx->high_pri_exclusive_cnt +- - instance->ctrl_info.maxVdCount * g_ps3_qos_vd_exclusive +- - g_ps3_qos_jbod_exclusive; ++ ++ qos_tg_ctx->high_pri_exclusive_cnt = QOS_HIGH_PRI_EXCLUSIVE_CMD_COUNT; ++ qos_tg_ctx->mgr_exclusive_cnt = g_ps3_qos_mgr_exclusive; ++ if (!ps3_ioc_multi_func_support(instance)) { ++ tag_exclusive = qos_tg_ctx->mgr_exclusive_cnt + qos_tg_ctx->high_pri_exclusive_cnt + ++ g_ps3_qos_jbod_exclusive + instance->ctrl_info.maxVdCount * g_ps3_qos_vd_exclusive; ++ } else { ++ qos_tg_ctx->high_pri_exclusive_cnt = qos_tg_ctx->high_pri_exclusive_cnt >> 1; ++ qos_tg_ctx->mgr_exclusive_cnt = qos_tg_ctx->mgr_exclusive_cnt >> 1; ++ tag_exclusive = qos_tg_ctx->high_pri_exclusive_cnt + qos_tg_ctx->mgr_exclusive_cnt; ++ if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1) { ++ tag_exclusive += (g_ps3_qos_jbod_exclusive + ++ instance->ctrl_info.maxVdCount * g_ps3_qos_vd_exclusive); ++ } + } + ++ if (tfifo_depth > tag_exclusive) ++ qos_tg_ctx->share = tfifo_depth - tag_exclusive; ++ else ++ qos_tg_ctx->share = tag_exclusive; ++ + ps3_atomic_set(&qos_tg_ctx->mgr_free_cnt, qos_tg_ctx->mgr_exclusive_cnt); + ps3_atomic_set(&qos_tg_ctx->share_free_cnt, qos_tg_ctx->share); + ps3_atomic_set(&qos_tg_ctx->mgr_share_used, 0); +@@ -1878,7 +1899,7 @@ + } + + INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, instance) +- if (!ps3_is_instance_state_normal(instance)) { ++ if (!ps3_is_instance_state_normal(instance, PS3_TRUE)) { + LOG_INFO_LIM("hno:%u instance state is not normal\n", PS3_HOST(instance)); + ret = -PS3_RECOVERED; + goto l_out; +@@ -2025,7 +2046,7 @@ + return found; + } + +-static void ps3_vd_cmd_waitq_clean(struct ps3_instance *instance, U16 disk_id , int result) ++static void ps3_vd_cmd_waitq_clean(struct ps3_instance *instance, U16 disk_id, int result) + { + ULong flag = 0; + struct ps3_cmd *cmd = NULL; +@@ -2130,13 +2151,36 @@ + ps3_vd_cmd_waitq_clean(instance, vd_id, resp_status); + ps3_mgr_cmd_waitq_clean(instance, priv_data, resp_status); + +- LOG_INFO("qos clean vd. host_no:%u type:%u disk_id:%u\n", ++ LOG_FILE_INFO("qos clean vd. host_no:%u type:%u disk_id:%u\n", + PS3_HOST(instance), priv_data->dev_type, vd_id); + } + + #define PS3_QOS_JBOD_VD_MGR(instance) \ + (&instance->qos_context.vd_ctx.qos_vd_mgrs[instance->qos_context.max_vd_count]) + ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 9, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) ++void ps3_linx80_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry) ++{ ++ U16 pd_id = 0; ++ struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; ++ ++ if (!PS3_QOS_INITED(instance)) ++ goto _out; ++ ++ pd_id = PS3_PDID(&pd_entry->disk_pos); ++ qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); ++ if (ps3_atomic_read(&qos_pd_mgr->valid) != PS3_TRUE) ++ goto _out; ++ ++ ps3_pd_quota_waitq_clean(qos_pd_mgr, 0, PS3_STATUS_VD_MEMBER_OFFLINE); ++ cancel_work_sync(&qos_pd_mgr->resend_work); ++ LOG_INFO("linx80 update pd qos rsc. host_no:%u pd_id:%u dev_type:%u\n", ++ PS3_HOST(instance), pd_id, pd_entry->dev_type); ++ ++_out: ++ return; ++} ++#endif + static void ps3_hba_qos_pd_clean(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data, S32 resp_status) + { +@@ -2154,7 +2198,7 @@ + ps3_jbod_cmd_waitq_clean(instance, priv_data, resp_status); + ps3_mgr_cmd_waitq_clean(instance, priv_data, resp_status); + +- LOG_INFO("qos clean pd. host_no:%u diskid:%u\n", ++ LOG_FILE_INFO("qos clean pd. host_no:%u diskid:%u\n", + PS3_HOST(instance), disk_id); + } + +@@ -2243,7 +2287,7 @@ + priv_data->dev_deling = PS3_TRUE; + wmb(); + disk_id = PS3_PDID(&priv_data->disk_pos); +- LOG_INFO("qos disk del. host_no:%u dev_t:%u diskid:%u\n", ++ LOG_FILE_INFO("qos disk del. host_no:%u dev_t:%u diskid:%u\n", + PS3_HOST(instance), priv_data->dev_type, disk_id); + if (priv_data->dev_type == PS3_DEV_TYPE_VD) { + ps3_qos_dev_end(instance, priv_data); +@@ -2344,7 +2388,7 @@ + return ps3_atomic_inc_return(&qos_pd_ctx->workq_id_cnt) % qos_pd_ctx->workq_count; + } + +-static void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_pd_entry *pd_entry) ++void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_pd_entry *pd_entry) + { + struct ps3_qos_pd_context *pd_ctx = NULL; + struct PS3QosInfo *qos_cfg_info = NULL; +@@ -2352,12 +2396,14 @@ + qos_cfg_info = &qos_pd_mgr->instance->ctrl_info.qosInfo; + qos_pd_mgr->pd_quota = pd_entry->normal_quota; + qos_pd_mgr->direct_quota = pd_entry->direct_quota; ++ qos_pd_mgr->dev_type = pd_entry->dev_type; + switch (pd_entry->dev_type) { + case PS3_DEV_TYPE_SAS_HDD: + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = qos_cfg_info->sasHddQuota > 0 ? + qos_cfg_info->sasHddQuota : g_ps3_qos_sas_pd_quota; + } ++ qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; +@@ -2366,6 +2412,7 @@ + qos_pd_mgr->pd_quota = qos_cfg_info->sasSsdQuota > 0 ? + qos_cfg_info->sasSsdQuota : g_ps3_qos_sas_pd_quota; + } ++ qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; +@@ -2374,6 +2421,7 @@ + qos_pd_mgr->pd_quota = qos_cfg_info->sataHddQuota > 0 ? + qos_cfg_info->sataHddQuota : g_ps3_qos_hdd_pd_quota; + } ++ qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; +@@ -2382,6 +2430,7 @@ + qos_pd_mgr->pd_quota = qos_cfg_info->sataSsdQuota > 0 ? + qos_cfg_info->sataSsdQuota : g_ps3_qos_ssd_pd_quota; + } ++ qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; +@@ -2395,6 +2444,7 @@ + qos_pd_mgr->direct_quota = qos_cfg_info->nvmeDirectQuota > 0 ? + qos_cfg_info->nvmeDirectQuota : g_ps3_qos_nvme_pd_quota; + } ++ qos_pd_mgr->pd_init_quota = qos_pd_mgr->direct_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->direct_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->direct_quota - (qos_pd_mgr->direct_quota / 10); + break; +@@ -2473,14 +2523,19 @@ + + pd_id = PS3_PDID(&pd_entry->disk_pos); + qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); ++ + if ((ps3_atomic_add_unless(&qos_pd_mgr->valid, 1, 1) != 0) || ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 9, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) ++ ((ps3_sas_is_support_smp(instance)) && (!ps3_check_pd_is_vd_member(pd_entry->config_flag))) || ++ (pd_entry->config_flag == MIC_PD_STATE_JBOD)) { ++#else + (pd_entry->config_flag == MIC_PD_STATE_JBOD)) { ++#endif + if (pd_entry->config_flag == MIC_PD_STATE_JBOD) { + ps3_qos_vd_member_del(instance, &pd_entry->disk_pos); + } + + ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); +- qos_pd_mgr->dev_type = pd_entry->dev_type; + qos_pd_mgr->disk_id = pd_id; + qos_pd_mgr->vd_id = 0; + qos_pd_mgr->workq_id = ps3_qos_pd_workq_id_get(&instance->qos_context.pd_ctx); +@@ -2503,6 +2558,52 @@ + qos_pd_mgr->clearing = PS3_FALSE; + } + ++void ps3_qos_vd_attr_change(struct ps3_instance *instance, ++ struct PS3VDEntry *vd_entry_old, struct PS3VDEntry *vd_entry) ++{ ++ struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; ++ U16 change_type = PS3_QOS_VD_TYPE_CHANGE_INVALID; ++ U16 i = 0; ++ U16 j = 0; ++ U16 pd_id = 0; ++ ++ if (!PS3_QOS_INITED(instance) || vd_entry->isNvme) ++ goto l_out; ++ ++ if (!vd_entry->isSsd) ++ change_type = PS3_QOS_VD_TYPE_CHANGE_TO_HDD; ++ else ++ change_type = PS3_QOS_VD_TYPE_CHANGE_TO_SSD; ++ ++ for (i = 0; i < vd_entry->spanCount; i++) { ++ for (j = 0; j < vd_entry->span[i].spanPdNum; j++) { ++ pd_id = vd_entry->span[i].extent[j].phyDiskID.ps3Dev.phyDiskID; ++ if (pd_id <= PS3_MAX_PD_COUNT(instance)) { ++ qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); ++ switch (change_type) { ++ case PS3_QOS_VD_TYPE_CHANGE_TO_SSD: ++ qos_pd_mgr->pd_quota = qos_pd_mgr->adjust_max_quota; ++ break; ++ case PS3_QOS_VD_TYPE_CHANGE_TO_HDD: ++ if (vd_entry_old != NULL) ++ qos_pd_mgr->pd_quota = instance->cmd_context.max_scsi_cmd_count; ++ else ++ qos_pd_mgr->pd_quota = qos_pd_mgr->adjust_max_quota; ++ break; ++ default: ++ break; ++ } ++ } ++ } ++ } ++ ++ LOG_INFO_IN_IRQ(instance, "host_no:%u qos vd[%u:%u:%u] attr change:%u complete\n", ++ PS3_HOST(instance), PS3_CHANNEL(&vd_entry->diskPos), ++ PS3_TARGET(&vd_entry->diskPos), PS3_VDID(&vd_entry->diskPos), change_type); ++l_out: ++ return; ++} ++ + void ps3_qos_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry, + struct scsi_device *sdev, Bool is_vd_member) + { +@@ -2514,16 +2615,22 @@ + } + + pd_id = PS3_PDID(&pd_entry->disk_pos); ++ ps3_mutex_lock(&instance->dev_context.dev_priv_lock); + priv_data = PS3_SDEV_PRI_DATA(sdev); +- if (is_vd_member) { +- ps3_hba_qos_pd_clean(instance, priv_data, PS3_STATUS_DEVICE_NOT_FOUND); ++ if (priv_data != NULL) { ++ if (is_vd_member) { ++ ps3_hba_qos_pd_clean(instance, priv_data, PS3_STATUS_DEVICE_NOT_FOUND); ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ++ } else { ++ ps3_hba_qos_pd_clean(instance, priv_data, PS3_STATUS_VD_MEMBER_OFFLINE); ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ++ qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); ++ ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); ++ qos_pd_mgr->vd_id = 0; ++ } + } else { +- ps3_hba_qos_pd_clean(instance, priv_data, PS3_STATUS_VD_MEMBER_OFFLINE); +- qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); +- ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); +- qos_pd_mgr->vd_id = 0; ++ ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + } +- + LOG_INFO("update pd qos rsc. host_no:%u pd_id:%u dev_type:%u is_vd_member:%u\n", + PS3_HOST(instance), pd_id, pd_entry->dev_type, is_vd_member); + +@@ -2543,6 +2650,32 @@ + qos_vd_mgr->valid = PS3_TRUE; + } + ++static void ps3_qos_r1x_member_init(struct ps3_qos_pd_mgr *qos_pd_mgr, ++ struct ps3_pd_entry *pd_entry, U16 judge_type) ++{ ++ switch (judge_type) { ++ case PS3_IS_SSD_ODD_R1X_VD: ++ if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { ++ qos_pd_mgr->direct_quota = qos_pd_mgr->pd_init_quota >> 1; ++ qos_pd_mgr->adjust_max_quota = qos_pd_mgr->direct_quota; ++ qos_pd_mgr->adjust_min_quota = qos_pd_mgr->direct_quota - (qos_pd_mgr->direct_quota / 10); ++ } else { ++ qos_pd_mgr->pd_quota = qos_pd_mgr->pd_init_quota >> 1; ++ qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; ++ qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); ++ } ++ break; ++ case PS3_IS_SSD_EVEN_R1X_VD: ++ case PS3_IS_VALID_R1X_VD: ++ if (qos_pd_mgr->vd_id > 0) ++ ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); ++ break; ++ case PS3_IS_HDD_R1X_VD: ++ default: ++ break; ++ } ++} ++ + void ps3_qos_vd_init(struct ps3_instance *instance, struct PS3VDEntry *vd_entry) + { + struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; +@@ -2550,6 +2683,7 @@ + U16 pd_id = 0; + struct ps3_pd_entry *pd_entry = NULL; + U16 i, j = 0; ++ U16 judge_type = PS3_IS_VALID_R1X_VD; + + if(!PS3_QOS_INITED(instance)) { + return; +@@ -2557,6 +2691,7 @@ + + vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), + PS3_VDID(&vd_entry->diskPos)); ++ judge_type = ps3_odd_r1x_judge(vd_entry); + for (i = 0; i < vd_entry->spanCount; i++) { + for (j = 0; j < vd_entry->span[i].spanPdNum; j++) { + pd_id = vd_entry->span[i].extent[j].phyDiskID.ps3Dev.phyDiskID; +@@ -2564,7 +2699,14 @@ + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, pd_id); + if (pd_entry) { + qos_pd_mgr = ps3_qos_pd_mgr_init(instance, pd_entry); +- if (!qos_pd_mgr->vd_id && qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { ++ if (unlikely(qos_pd_mgr->dev_type != pd_entry->dev_type)) { ++ ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); ++ if (!vd_entry->isSsd) ++ qos_pd_mgr->pd_quota = instance->cmd_context.max_scsi_cmd_count; ++ } ++ ++ ps3_qos_r1x_member_init(qos_pd_mgr, pd_entry, judge_type); ++ if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { + if (qos_pd_mgr->pd_quota > qos_pd_mgr->direct_quota) { + qos_pd_mgr->pd_quota = qos_pd_mgr->direct_quota; + } +@@ -2616,7 +2758,7 @@ + if (time_after(jiffies, timeout_jiffies)) { + if (ps3_qos_single_pd_notify(qos_pd_ctx, qos_pd_mgr)) { + LOG_INFO("awake qos pd quota waitq by poll. host_no:%u vid:%u pid:%u\n", +- PS3_HOST(instance), qos_pd_mgr->vd_id ,qos_pd_mgr->disk_id); ++ PS3_HOST(instance), qos_pd_mgr->vd_id, qos_pd_mgr->disk_id); + } + } + +@@ -2772,7 +2914,7 @@ + PS3_HOST(softq_mgr->instance), softq_mgr->id); + } + +- return waitq_flag; ++ return waitq_flag; + } + + static Bool ps3_qos_cq_rc_get(struct ps3_cmd *cmd, +@@ -2989,7 +3131,7 @@ + waitq->count--; + softq_mgr->total_wait_cmd_cnt--; + PS3_QOS_STAT_END(instance, cmd, PS3_QOS_MGR_QUEUE); +- ret = ps3_scsi_cmd_send(instance, cmd); ++ ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); + if (unlikely(ret != PS3_SUCCESS)) { + ps3_raid_qos_cmd_update(cmd); + ps3_qos_cmd_resend_fail(cmd, ret); +@@ -3024,9 +3166,14 @@ + { + S32 ret = PS3_SUCCESS; + U32 mgrq_depth = 0; +- U32 high_mgr_cmd = PS3_QOS_HIGH_PRI_MGR_CMD_COUNT >> 1; ++ U32 high_mgr_cmd = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; + ++ if (!ps3_ioc_multi_func_support(instance)) ++ high_mgr_cmd = PS3_QOS_HIGH_PRI_MGR_CMD_COUNT; ++ else ++ high_mgr_cmd = PS3_QOS_HIGH_PRI_MGR_CMD_COUNT >> 1; ++ + mgrq_depth = instance->qos_context.cq_ctx.mgrq_depth; + if (mgrq_depth <= high_mgr_cmd) { + ret = -PS3_FAILED; +@@ -3122,7 +3269,6 @@ + + instance = cmd->instance; + if (cmd->cmdq_count == 1) { +- PS3_BUG_ON(cmd->cmdq_info[0].que_id != softq_mgr->id); + cmd->cmdq_info[0].get_rc = PS3_TRUE; + } else { + if (cmd->cmdq_info[0].que_id == softq_mgr->id) { +@@ -3133,7 +3279,6 @@ + cmd->cmdq_info[1].get_rc = PS3_TRUE; + } + } else { +- PS3_BUG_ON(cmd->cmdq_info[1].que_id != softq_mgr->id); + cmd->cmdq_info[1].get_rc = PS3_TRUE; + } + } +@@ -3168,7 +3313,7 @@ + can_send--; + ps3_atomic_dec(&softq_mgr->free_cnt); + if (ps3_qos_cmdq_resend_judge(softq_mgr, cmd)) { +- ret = ps3_scsi_cmd_send(instance, cmd); ++ ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); + if (unlikely(ret != PS3_SUCCESS)) { + ps3_raid_qos_cmd_update(cmd); + ps3_qos_cmd_resend_fail(cmd, ret); +@@ -3386,7 +3531,7 @@ + + goto _out; + _cq_ctx_exit: +- ps3_qos_tg_context_exit(instance); ++ ps3_qos_cq_context_exit(instance); + _out: + return ret; + } +@@ -3613,7 +3758,7 @@ + ps3_qos_cmdq_clean(instance, vd_id, NULL, resp_status); + ps3_qos_mgrq_clean(instance, priv_data, resp_status); + +- LOG_INFO("qos clean vd. host_no:%u type:%u disk_id:%u\n", ++ LOG_FILE_INFO("qos clean vd. host_no:%u type:%u disk_id:%u\n", + PS3_HOST(instance), priv_data->dev_type, vd_id); + } + +@@ -3723,7 +3868,7 @@ + ps3_qos_cq_context_exit(instance); + ps3_qos_pd_context_exit(instance); + +- LOG_WARN("raid qos exit. hno:%u\n", PS3_HOST(instance)); ++ LOG_INFO("raid qos exit. hno:%u\n", PS3_HOST(instance)); + } + + void ps3_hba_qos_prepare(struct ps3_instance *instance) +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_qos.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_qos.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_qos.h 2025-06-10 20:13:00.234053946 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_qos.h 2025-06-10 20:13:00.537064516 +0800 +@@ -62,6 +62,12 @@ + PS3_QOS_QUOTA_ADJUST_INVALID + }; + ++enum ps3_qos_vd_change_type { ++ PS3_QOS_VD_TYPE_CHANGE_TO_HDD, ++ PS3_QOS_VD_TYPE_CHANGE_TO_SSD, ++ PS3_QOS_VD_TYPE_CHANGE_INVALID ++}; ++ + struct qos_wait_queue { + ps3_list_head wait_list; + U32 count; +@@ -117,6 +123,7 @@ + ps3_spinlock adjust_quota_lock; + S32 adjust_max_quota; + S32 adjust_min_quota; ++ S32 pd_init_quota; + }; + + struct ps3_qos_pd_context { +@@ -167,7 +174,7 @@ + void (*qos_waitq_notify)(struct ps3_instance *instance); + Bool (*qos_pd_resend_check)(struct ps3_cmd *cmd); + Bool (*qos_waitq_abort)(struct ps3_cmd *cmd); +- void (*qos_vd_clean)(struct ps3_instance *instance, struct ps3_scsi_priv_data *pri_data ,S32 ret_code); ++ void (*qos_vd_clean)(struct ps3_instance *instance, struct ps3_scsi_priv_data *pri_data, S32 ret_code); + void (*qos_pd_clean)(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data, S32 ret_code); + void (*qos_waitq_clear)(struct ps3_instance *instance, S32 ret_code); + void (*qos_waitq_poll)(struct ps3_instance *instance); +@@ -199,7 +206,7 @@ + + Bool ps3_qos_waitq_abort(struct ps3_cmd *aborted_cmd); + +-void ps3_qos_device_clean(struct ps3_instance *instance, struct ps3_scsi_priv_data *pri_data , ++void ps3_qos_device_clean(struct ps3_instance *instance, struct ps3_scsi_priv_data *pri_data, + S32 ret_code); + + void ps3_qos_disk_del(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data); +@@ -271,4 +278,13 @@ + void ps3_qos_adjust_pd_rsc(struct scsi_device *sdev, + struct ps3_instance *instance, S32 reason); + ++void ps3_qos_vd_attr_change(struct ps3_instance *instance, ++ struct PS3VDEntry *vd_entry_old, struct PS3VDEntry *vd_entry); ++ ++void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_pd_entry *pd_entry); ++ ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 9, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) ++void ps3_linx80_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry); ++#endif ++ + #endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_r1x_write_lock.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_r1x_write_lock.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_r1x_write_lock.c 2025-06-10 20:13:00.234053946 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_r1x_write_lock.c 2025-06-10 20:13:00.581066051 +0800 +@@ -83,8 +83,8 @@ + #define RW_BYTE_TO_BIT(byte) ((bit) << 3) + #define RW_BIT_BYTE_MASK 7 + #define RW_R1X_SZBLOCKIDX(lba) (lba >> SZBLOCK_SIZE_SHIFT) +-#define RW_SZBLOCK_IDX_INVALUD 0xFFFFFFFFFFFF +-#define RW_BITMAP_IDX_INVALUD 0xFFFF ++#define RW_SZBLOCK_IDX_INVALID 0xFFFFFFFFFFFF ++#define RW_BITMAP_IDX_INVALID 0xFFFF + #define RW_R1X_GET_BITMAP(bit_buff,idx) (bit_buff[idx]) + #define RW_BIT_64_MASK 63 + #define RW_BYTE_TO_U64(n) (n >> 3) +@@ -145,7 +145,7 @@ + } + ps3_spin_unlock_irqrestore(&pri_data->lock_mgr.mgr_lock, flag); + +- LOG_INFO("dev[%u:%u], wait r1x conflict queue clean begin\n", ++ LOG_FILE_INFO("dev[%u:%u], wait r1x conflict queue clean begin\n", + PS3_CHANNEL(&pri_data->disk_pos), + PS3_TARGET(&pri_data->disk_pos)); + wmb(); +@@ -153,7 +153,7 @@ + ps3_msleep(100); + rmb(); + } +- LOG_INFO("dev[%u:%u], wait r1x conflict queue clean end\n", ++ LOG_FILE_INFO("dev[%u:%u], wait r1x conflict queue clean end\n", + PS3_CHANNEL(&pri_data->disk_pos), + PS3_TARGET(&pri_data->disk_pos)); + } +@@ -260,7 +260,7 @@ + LOG_FILE_INFO("ready clean conflict queue bitmap\n"); + + for (i = 0; i < HASH_TABLE_SIZE; i++) { +- mgr->hash_item[i].sz_block_idx = RW_SZBLOCK_IDX_INVALUD; ++ mgr->hash_item[i].sz_block_idx = RW_SZBLOCK_IDX_INVALID; + } + + memset(mgr->bitmap_mgr.bit_buff, 0, PS3_R1X_BIT_MAP_SIZE); +@@ -321,6 +321,7 @@ + S32 ret = PS3_SUCCESS; + struct ps3_scsi_priv_data *pri_data = NULL; + struct scsi_cmnd *s_cmd = cmd->scmd; ++ static unsigned long j; + + ret = instance->ioc_adpter->io_cmd_build(cmd); + if (ret == -PS3_IO_CONFLICT_IN_Q) { +@@ -340,12 +341,12 @@ + + if (ret != PS3_SUCCESS) { + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); +- LOG_ERROR("t_id:0x%llx hno:%u tag:%d cmd build NOK ret:%d\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "t_id:0x%llx hno:%u tag:%d cmd build NOK ret:%d\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, ret); + goto l_cmd_release; + } + +- ret = ps3_scsi_cmd_send(instance, cmd); ++ ret = ps3_scsi_cmd_send(instance, cmd, PS3_TRUE); + if (unlikely(ret != PS3_SUCCESS)) { + if (ret == -PS3_RECOVERED || ret == -PS3_RETRY) { + ps3_errcode_to_scsi_status(instance, s_cmd, +@@ -353,8 +354,7 @@ + } else { + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + } +- +- LOG_ERROR("t_id:0x%llx hno:%u tag:%d cmd send NOK ret:%d\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "t_id:0x%llx hno:%u tag:%d cmd send NOK ret:%d\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, ret); + PS3_DEV_IO_START_ERR_INC(instance, cmd); + goto l_cmd_release; +@@ -466,7 +466,10 @@ + + ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); + if (list_empty(&mgr->conflict_cmd_list)) { +- PS3_BUG_ON(mgr->cmd_count_in_q != 0); ++ if (mgr->cmd_count_in_q != 0) { ++ LOG_INFO_LIM("cmd count in q not zero\n"); ++ PS3_BUG(); ++ } + ps3_conflict_queue_clean_bitmap( + (struct ps3_r1x_hash_bit_mgr*) + mgr->hash_mgr_conflict); +@@ -569,7 +572,7 @@ + + PS3_R1X_LOCK_TRACE("lba=%llu, len=%u, hash_idx=%u, hash item=%p, bit check.", + lba, len, hash_idx, hash_item); +- if(hash_item->sz_block_idx == RW_SZBLOCK_IDX_INVALUD) { ++ if (hash_item->sz_block_idx == RW_SZBLOCK_IDX_INVALID) { + hash_item->sz_block_idx = sz_block_idx; + hash_tmp->is_new = PS3_TRUE; + PS3_R1X_LOCK_TRACE("lba=%llu, len=%u, hash_idx=%u, bit_idx=%u, hash item=%p, new hash item.", +@@ -626,7 +629,7 @@ + hash_tmp = &tmp_array[i]; + if (hash_tmp->is_new) { + hash_tmp->hash_item->sz_block_idx = +- RW_SZBLOCK_IDX_INVALUD; ++ RW_SZBLOCK_IDX_INVALID; + } + } + +@@ -767,7 +770,7 @@ + hash_tmp = &tmp_array_conflict[i]; + if(PS3_TRUE == hash_tmp->is_new){ + hash_tmp->hash_item->sz_block_idx = +- RW_SZBLOCK_IDX_INVALUD; ++ RW_SZBLOCK_IDX_INVALID; + } + } + } +@@ -803,7 +806,7 @@ + hash_tmp = &tmp_array[i]; + if(PS3_TRUE == hash_tmp->is_new){ + hash_tmp->hash_item->sz_block_idx = +- RW_SZBLOCK_IDX_INVALUD; ++ RW_SZBLOCK_IDX_INVALID; + } + } + +@@ -811,7 +814,7 @@ + hash_tmp = &tmp_array_conflict[i]; + if(PS3_TRUE == hash_tmp->is_new){ + hash_tmp->hash_item->sz_block_idx = +- RW_SZBLOCK_IDX_INVALUD; ++ RW_SZBLOCK_IDX_INVALID; + } + } + +@@ -911,7 +914,7 @@ + hash_tmp = &tmp_array[i]; + if(PS3_TRUE == hash_tmp->is_new){ + hash_tmp->hash_item->sz_block_idx = +- RW_SZBLOCK_IDX_INVALUD; ++ RW_SZBLOCK_IDX_INVALID; + } + } + +@@ -975,14 +978,14 @@ + } + } + +- if(PS3_TRUE == is_clean){ +- PS3_R1X_LOCK_TRACE("t_id:0x%llx lba=%llu, len=%u, szBlockIdx=%llu, bitIdx=%lu," +- "szblock_cnt=%u, cmd=%p, release hash item.", +- cmd->trace_id, lba, len, (U64)hash_item->sz_block_idx, +- (unsigned long int)hash_item->bitmap_idx, +- cmd->szblock_cnt, cmd); +- hash_item->sz_block_idx = RW_SZBLOCK_IDX_INVALUD; +- } ++ if (is_clean == PS3_TRUE) { ++ PS3_R1X_LOCK_TRACE("t_id:0x%llx lba=%llu, len=%u, szBlockIdx=%llu, bitIdx=%lu, " ++ "szblock_cnt=%u, cmd=%p, release hash item.", ++ cmd->trace_id, lba, len, (U64)hash_item->sz_block_idx, ++ (unsigned long int)hash_item->bitmap_idx, ++ cmd->szblock_cnt, cmd); ++ hash_item->sz_block_idx = RW_SZBLOCK_IDX_INVALID; ++ } + + left -= len; + lba += len; +@@ -1028,11 +1031,16 @@ + (void)instance; + (void)bitmap_block_cnt; + +- PS3_BUG_ON(SZBLOCK_SIZE & LOCK_BLOCK_SIZE_MASK); ++ if (SZBLOCK_SIZE & LOCK_BLOCK_SIZE_MASK) { ++ LOG_FILE_ERROR("hno: %u, SZBLOCK_SIZE check NOK\n", PS3_HOST(instance)); ++ goto exit; ++ } + bit_map_size = PS3_R1X_BIT_MAP_SIZE; + sz_block_bit_cnt = SZBLOCK_SIZE >> LOCK_BLOCK_SIZE_SHIFT; +- PS3_BUG_ON(sz_block_bit_cnt & RW_BIT_64_MASK); +- ++ if (sz_block_bit_cnt & RW_BIT_64_MASK) { ++ LOG_FILE_ERROR("hno: %u, sz_block_bit_cnt check NOK\n", PS3_HOST(instance)); ++ goto exit; ++ } + total_size = sizeof(struct ps3_r1x_hash_bit_mgr) + bit_map_size; + buff = (U8*)(void*)ps3_vzalloc(instance, total_size); + if(NULL == buff) { +@@ -1042,9 +1050,15 @@ + + bitmap_block_size = RW_BIT_TO_BYTE(sz_block_bit_cnt); + mgr = (struct ps3_r1x_hash_bit_mgr*)(void*)buff; +- for(i = 0; i < HASH_TABLE_SIZE; ++i){ +- mgr->hash_item[i].sz_block_idx = RW_SZBLOCK_IDX_INVALUD; +- PS3_BUG_ON(RW_BITMAP_IDX_INVALUD < (i*bitmap_block_size)); ++ for (i = 0; i < HASH_TABLE_SIZE; ++i) { ++ mgr->hash_item[i].sz_block_idx = RW_SZBLOCK_IDX_INVALID; ++ if (RW_BITMAP_IDX_INVALID < (i * bitmap_block_size)) { ++ LOG_ERROR("hno: %u, bitmap_block_size check NOK\n", PS3_HOST(instance)); ++ PS3_BUG(); ++ ps3_vfree(instance, buff); ++ mgr = NULL; ++ goto exit; ++ } + mgr->hash_item[i].bitmap_idx = i*bitmap_block_size; + } + mgr->bitmap_mgr.bit_block_size = (U8)RW_BYTE_TO_U64(bitmap_block_size); +@@ -1278,36 +1292,36 @@ + + ps3_spin_lock_init(&mgr->mgr_lock); + +- if (PS3_R1X_HASHBIT_LOCK == g_ps3_r1x_lock_flag) { +- mgr->hash_mgr = ps3_r1x_lock_hash_bit_init(instance); +- mgr->try_lock = (PS3_R1X_LOCK_FUNC)(void*)ps3_r1x_hash_bit_lock; +- mgr->resend_try_lock = (PS3_R1X_LOCK_FUNC)(void*)ps3_r1x_hash_bit_lock_of_conflict_queue; +- mgr->unlock = (PS3_R1X_UNLOCK_FUNC)(void*)ps3_r1x_hash_bit_unlock; +- } else if(PS3_R1X_HASHRANGE_LOCK == g_ps3_r1x_lock_flag) { +- LOG_DEBUG("hno:%u vd[%u:%u] use rb tree r1x\n", ++ if (g_ps3_r1x_lock_flag == PS3_R1X_HASHBIT_LOCK) { ++ mgr->hash_mgr = ps3_r1x_lock_hash_bit_init(instance); ++ mgr->try_lock = (PS3_R1X_LOCK_FUNC)(void *)ps3_r1x_hash_bit_lock; ++ mgr->resend_try_lock = (PS3_R1X_LOCK_FUNC)(void *)ps3_r1x_hash_bit_lock_of_conflict_queue; ++ mgr->unlock = (PS3_R1X_UNLOCK_FUNC)(void *)ps3_r1x_hash_bit_unlock; ++ } else if (g_ps3_r1x_lock_flag == PS3_R1X_HASHRANGE_LOCK) { ++ LOG_DEBUG("hno:%u vd[%u:%u] use rb tree r1x\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); +- mgr->hash_mgr = ps3_r1x_hash_range_init(instance); +- mgr->try_lock = (PS3_R1X_LOCK_FUNC)(void*)ps3_r1x_hash_range_lock; +- mgr->resend_try_lock = (PS3_R1X_LOCK_FUNC)(void*)ps3_r1x_hash_range_lock; +- mgr->unlock = (PS3_R1X_UNLOCK_FUNC)(void*)ps3_r1x_hash_range_unlock; +- } ++ mgr->hash_mgr = ps3_r1x_hash_range_init(instance); ++ mgr->try_lock = (PS3_R1X_LOCK_FUNC)(void *)ps3_r1x_hash_range_lock; ++ mgr->resend_try_lock = (PS3_R1X_LOCK_FUNC)(void *)ps3_r1x_hash_range_lock; ++ mgr->unlock = (PS3_R1X_UNLOCK_FUNC)(void *)ps3_r1x_hash_range_unlock; ++ } + INJECT_START(PS3_ERR_IJ_FORCE_HASH_MGR_NULL, &mgr->hash_mgr); +- if (unlikely(NULL == mgr->hash_mgr)) { +- LOG_ERROR("hno:%u vd[%u:%u] r1x hash mgr init failed\n", ++ if (unlikely(mgr->hash_mgr == NULL)) { ++ LOG_ERROR("hno:%u vd[%u:%u] r1x hash mgr init failed\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); + goto l_err; +- } ++ } + +- mgr->hash_mgr_conflict = ps3_r1x_lock_hash_bit_init(instance); ++ mgr->hash_mgr_conflict = ps3_r1x_lock_hash_bit_init(instance); + INJECT_START(PS3_ERR_IJ_FORCE_MGR_CONFLICT_NULL, &mgr->hash_mgr_conflict); +- if (unlikely(NULL == mgr->hash_mgr_conflict)) { +- LOG_ERROR("hno:%u vd[%u:%u] r1x hash mgr conflict init failed\n", ++ if (unlikely(mgr->hash_mgr_conflict == NULL)) { ++ LOG_ERROR("hno:%u vd[%u:%u] r1x hash mgr conflict init failed\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); +- goto l_err; +- } ++ goto l_err; ++ } + + mgr->thread_stop = PS3_FALSE; + mgr->dev_deling = PS3_FALSE; +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_rb_tree.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_rb_tree.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_rb_tree.c 2025-06-10 20:13:00.234053946 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_rb_tree.c 2025-06-10 20:13:00.538064551 +0800 +@@ -306,9 +306,9 @@ + void *pKeyCur = NULL; + Ps3Cmp_e cmprc = PS3_EQ; + +- PS3_BUG_ON(NULL == pOps->cmpkey); +- PS3_BUG_ON((NULL == pOps->getkey) && +- (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&pOps->flags))); ++ BUG_ON(pOps->cmpkey == NULL); ++ BUG_ON((pOps->getkey == NULL) && ++ (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&pOps->flags))); + + ppLinker = &pRoot->pRoot; + while (NULL != (*ppLinker)) +@@ -597,7 +597,7 @@ + void *pKey = NULL; + S32 rc = 0; + +- PS3_BUG_ON((NULL == pOps->getkey) && ++ BUG_ON((pOps->getkey == NULL) && + (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&pOps->flags))); + + if (!RBT_NODE_IS_EMPTY(pNode)) +@@ -714,7 +714,7 @@ + Ps3RbNode_s *pNext = NULL; + S32 rc = 0; + +- PS3_BUG_ON(NULL == visit); ++ BUG_ON(visit == NULL); + + RBT_FOR_EACH_SAFE(pNode, pNext, pRoot) + { +@@ -728,3 +728,4 @@ + end: + return rc; + } ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_rb_tree.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_rb_tree.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_rb_tree.h 2025-06-10 20:13:00.235053981 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_rb_tree.h 2025-06-10 20:13:00.538064551 +0800 +@@ -8,9 +8,7 @@ + #endif + + #include "ps3_driver_log.h" +-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) + #include "ps3_define.h" +-#endif + #include "ps3_err_def.h" + + static inline void setBitNonAtomic(U32 nr, volatile ULong *addr) +@@ -128,7 +126,7 @@ + + static inline void ps3RbRootFini(Ps3RbRoot_s *pRoot) + { +- PS3_BUG_ON(pRoot->pRoot != NULL); ++ BUG_ON(pRoot->pRoot != NULL); + } + + void ps3RbtColorAfterAdd(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode); +@@ -211,8 +209,8 @@ + + static inline void ps3RbTreeFini(Ps3RbTree_s *pTree) + { +- PS3_BUG_ON(pTree->nodenr != 0); +- ps3RbRootFini(&pTree->root); ++ BUG_ON(pTree->nodenr != 0); ++ ps3RbRootFini(&pTree->root); + } + + static inline Ps3RbNode_s* ps3RbTreeHeadNode(Ps3RbTree_s *pTree) +@@ -340,3 +338,4 @@ + RBT_FOR_EACH_SAFE((_p_node), (_p_next), &(_p_tree)->root) + + #endif ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_recovery.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_recovery.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_recovery.c 2025-06-10 20:13:00.241054190 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_recovery.c 2025-06-10 20:13:00.571065702 +0800 +@@ -34,47 +34,41 @@ + static S32 ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance); + static S32 ps3_recovery_ready_to_running(struct ps3_instance *instance); + static void ps3_can_queue_reset(struct ps3_instance *instance, U32 cur_max_fw_cmds); +-static void ps3_cmd_force_stop(struct ps3_instance *instance); + static void ps3_cmd_reset_flag_set(struct ps3_instance *instance, U8 reset_flag); + static S32 ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance); + + enum { + PS3_RECOVERY_INTER_ERR_SUCCESS = 0, + PS3_RECOVERY_INTER_ERR_INTERRUPT = 1, +- PS3_RECOVERY_INTER_ERR_FAILED = 2 , +- PS3_RECOVERY_INTER_ERR_NEED_RECOVERY = 3 , +- PS3_RECOVERY_INTER_ERR_PCIE_ERR = 4 , ++ PS3_RECOVERY_INTER_ERR_FAILED = 2, ++ PS3_RECOVERY_INTER_ERR_NEED_RECOVERY = 3, ++ PS3_RECOVERY_INTER_ERR_PCIE_ERR = 4, ++ PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME = 5, + }; + + static inline void ps3_wait_watchdog_dect_recovery( + struct ps3_instance *instance) + { + U16 wait_step = 100; ++ U16 cur_cnt = 0; ++ Bool printed = PS3_TRUE; ++ + while(!instance->watchdog_context.is_halt && + instance->watchdog_context.watchdog_queue != NULL) { + ps3_msleep(wait_step); ++ if (printed && ((++cur_cnt) * wait_step > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { ++ printed = PS3_FALSE; ++ LOG_WARN("host:%u wait watchdog recovery.\n", PS3_HOST(instance)); ++ } + } + } + +-Bool ps3_no_need_recovery(struct ps3_instance *instance) +-{ +- Bool ret = PS3_FALSE; +- if ((!instance->state_machine.is_load) && +- !instance->is_host_added) { +- LOG_ERROR("hno:%u driver is load[%d] or suspend or host not add[%d]!\n", +- PS3_HOST(instance), instance->state_machine.is_load, +- instance->is_host_added); +- ret = PS3_TRUE; +- } +- +- return ret; +-} +- + struct ps3_recovery_context *ps3_recovery_context_alloc(void) + { + struct ps3_recovery_context *context; + + context = (struct ps3_recovery_context *)kzalloc(sizeof(struct ps3_recovery_context), GFP_KERNEL); ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_ALLOC_FAIL, &context) + if (!context) + return NULL; + +@@ -107,7 +101,8 @@ + struct ps3_instance *instance = + ps3_container_of(work, struct ps3_instance, + recovery_irq_work); +- ++ S32 ret = PS3_SUCCESS; ++ U32 count = 0; + LOG_INFO("hno:%u recovery irq triggered\n", + PS3_HOST(instance)); + +@@ -124,8 +119,14 @@ + PS3_HEARTBEAT_HARDRESET_DECIDE; + } + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); +- +- if(ps3_hard_recovery_request(instance) == PS3_SUCCESS){ ++ while ((ret = ps3_hard_recovery_request(instance)) == -PS3_RETRY) { ++ if (count++ == ps3_use_hard_reset_max_retry()) { ++ ret = -PS3_FAILED; ++ break; ++ } ++ ps3_mdelay(10); ++ } ++ if (ret == PS3_SUCCESS) { + LOG_INFO("hno[%u], recovery success!\n", + PS3_HOST(instance)); + }else{ +@@ -252,9 +253,11 @@ + } + + context = ps3_recovery_context_alloc(); ++ INJECT_START(PS3_ERR_RECOVERY_CONTEXT_ALLOC_FAILED, &context); + if (context == NULL) { + LOG_ERROR("hno:%u, alloc recovery context failed !\n", + PS3_HOST(instance)); ++ ret = -PS3_FAILED; + goto l_out; + } + +@@ -264,6 +267,7 @@ + context->recovery_wq = + create_singlethread_workqueue(context->recovery_wq_name); + if (context->recovery_wq == NULL) { ++ LOG_ERROR("hno:%u create recovery_wq NOK !\n", PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_out; + } +@@ -272,12 +276,14 @@ + ps3_mutex_init(&context->ps3_watchdog_recovery_mutex); + ps3_mutex_init(&context->free_cmd_lock); + ps3_spin_lock_init(&context->recovery_lock); ++ ps3_spin_lock_init(&context->ps3_hardreset_lock); + context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; + ps3_atomic_set(&context->hardreset_ref, 0); + context->recovery_state = PS3_SOFT_RECOVERY_PROBE_PROCESS; + instance->recovery_context = context; + instance->recovery_context->hardreset_count = 0; + context->host_reset_state = PS3_HOST_RESET_INIT; ++ context->instance_change = 0; + + l_recovery_irq_init: + if (ps3_recovery_irq_start(instance) != PS3_SUCCESS) { +@@ -426,7 +432,7 @@ + l_success: + instance->recovery_context->recovery_state = dest_state; + ps3_mutex_unlock(&instance->state_machine.lock); +- LOG_FILE_WARN("hno:%u recovery state transfer from %d to %d!\n", ++ LOG_FILE_INFO("hno:%u recovery state transfer from %d to %d!\n", + PS3_HOST(instance), + recovery_origin_state,dest_state); + +@@ -439,6 +445,7 @@ + { + S32 ret = PS3_SUCCESS; + struct ps3_recovery_context *context = instance->recovery_context; ++ INJECT_START(PS3_ERR_IJ_FORCE_START_DESTROY_RECOVERY, instance) + + if (unlikely(context->recovery_wq == NULL)) { + ret = -PS3_FAILED; +@@ -491,6 +498,7 @@ + { + S32 ret = PS3_SUCCESS; + ps3_mutex_lock(&instance->state_machine.lock); ++ INJECT_START(PS3_ERR_IJ_FORCE_START_DUL_RECOVERY, instance) + if(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW){ + LOG_ERROR("hno:%u hard recovery work proc,exit!\n", + PS3_HOST(instance)); +@@ -498,7 +506,7 @@ + goto l_out; + } + ps3_mutex_unlock(&instance->state_machine.lock); +- ++ INJECT_START(PS3_ERR_IJ_FORCE_DESTROY_RECOVERY, instance) + if (unlikely(instance->recovery_context->recovery_wq == NULL)) { + ret = -PS3_FAILED; + LOG_ERROR("hno:%u recovery work sync NOK!\n", +@@ -509,6 +517,7 @@ + cancel_work_sync(&instance->recovery_context->recovery_work); + + ps3_mutex_lock(&instance->state_machine.lock); ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, instance) + if(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + if(ps3_instance_no_lock_state_transfer(instance, PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + LOG_ERROR("hno:%u transfer to PS3_INSTANCE_STATE_RECOVERY NOK!\n", +@@ -520,10 +529,10 @@ + } + ps3_mutex_unlock(&instance->state_machine.lock); + +- if (instance->peer_instance != NULL && +- instance->peer_instance->recovery_context != NULL) { ++ if (instance->peer_instance != NULL) { + ps3_mutex_lock(&instance->peer_instance->state_machine.lock); + if(instance->peer_instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PEER_STATE_DEAD, instance->peer_instance) + if(ps3_instance_no_lock_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + LOG_ERROR("hno:%u transfer to PS3_INSTANCE_STATE_RECOVERY NOK!\n", + PS3_HOST(instance->peer_instance)); +@@ -611,16 +620,6 @@ + { + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + +- if (cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) { +- if ( instance->recovery_context->recovery_state == +- PS3_SOFT_RECOVERY_PROBE_PROCESS ) { +- LOG_INFO("hno:%u instance state during probe process!\n", +- PS3_HOST(instance)); +- ret = PS3_RECOVERY_INTER_ERR_FAILED; +- goto l_out; +- } +- } +- + if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + LOG_INFO("hno:%u instance state during hard recovery!\n", +@@ -633,7 +632,8 @@ + (cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || + (cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || + (cur_state == PS3_INSTANCE_STATE_DEAD) || +- (cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY)) { ++ (cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY) || ++ (cur_state == PS3_INSTANCE_STATE_INIT)) { + if (instance->is_need_event) { + if(instance->event_context.event_abort_cmd != NULL){ + complete(&instance->event_context.event_abort_cmd->sync_done); +@@ -657,31 +657,15 @@ + goto l_out; + } + +- if (instance->peer_instance != NULL && +- instance->peer_instance->recovery_context != NULL) { +- if (peer_cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) { +- if ( instance->peer_instance->recovery_context->recovery_state == +- PS3_SOFT_RECOVERY_PROBE_PROCESS ) { +- LOG_INFO("hno:%u instance state during probe process!\n", +- PS3_HOST(instance->peer_instance)); +- ret = PS3_RECOVERY_INTER_ERR_FAILED; +- goto l_out; +- } +- } +- +- if (instance->peer_instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || +- instance->peer_instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { +- LOG_INFO("hno:%u instance state during hard recovery!\n", +- PS3_HOST(instance->peer_instance)); +- ret = PS3_RECOVERY_INTER_ERR_SUCCESS; +- goto l_out; +- } +- ++ if (instance->peer_instance != NULL) { ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_DECIDE_PEER_INSTANCE_FAIL, ++ &peer_cur_state) + if ((peer_cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || + (peer_cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || + (peer_cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || + (peer_cur_state == PS3_INSTANCE_STATE_DEAD) || +- (peer_cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY)) { ++ (peer_cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY) || ++ (peer_cur_state == PS3_INSTANCE_STATE_INIT)) { + if (instance->peer_instance->is_need_event) { + if(instance->peer_instance->event_context.event_abort_cmd != NULL){ + complete(&instance->peer_instance->event_context.event_abort_cmd->sync_done); +@@ -710,13 +694,17 @@ + static S32 ps3_hard_recovery_request_prepare(struct ps3_instance *instance) + { + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; +- U32 ioc_state = instance->ioc_adpter->ioc_state_get(instance); ++ U32 ioc_state = 0; + struct ps3_instance_state_machine *state_machine + = &instance->state_machine; + U32 cur_state = 0; + struct ps3_instance_state_machine *state_machine_peer = NULL; + U32 peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; ++ INJECT_START(PS3_ERR_IJ_PCIE_FROZEN, instance) ++ if (instance->reg_set == NULL) ++ return ret; + ++ ioc_state = instance->ioc_adpter->ioc_state_get(instance); + ps3_mutex_lock(&state_machine->lock); + cur_state = ps3_atomic_read(&state_machine->state); + +@@ -724,38 +712,42 @@ + PS3_HOST(instance), + ps3_ioc_state_print(ioc_state), namePS3InstanceState(cur_state)); + +- if (instance->peer_instance != NULL && +- instance->peer_instance->reg_set != NULL) { ++ if (instance->peer_instance != NULL) { + state_machine_peer = &instance->peer_instance->state_machine; ++ INJECT_START(PS3_ERR_IJ_PEER_PCIE_FROZEN, instance->peer_instance) ++ if (instance->peer_instance->reg_set == NULL) ++ goto l_clean; ++ + ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get(instance->peer_instance); + ps3_mutex_lock(&state_machine_peer->lock); +- peer_cur_state = ps3_atomic_read(&state_machine->state); ++ peer_cur_state = ps3_atomic_read(&state_machine_peer->state); + + LOG_INFO("hno:%u hard recovery request:%s, %s\n", + PS3_HOST(instance->peer_instance), + ps3_ioc_state_print(ioc_state), namePS3InstanceState(peer_cur_state)); + } + +- if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE +- || instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY) { ++ ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); ++ if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE) { + ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); + if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + LOG_INFO("hno:%u heartbeat hard recovery start\n", + PS3_HOST(instance)); +- ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_RECOVERY; +- ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + } ++ ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + goto l_out; + } ++ ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + + ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); + +- l_out: +- ps3_mutex_unlock(&state_machine->lock); ++l_out: + if (instance->peer_instance != NULL) { + ps3_mutex_unlock(&state_machine_peer->lock); + } ++l_clean: ++ ps3_mutex_unlock(&state_machine->lock); + return ret; + } + +@@ -763,26 +755,42 @@ + { + S32 ret = PS3_SUCCESS; + struct ps3_instance *instance_recovery = NULL; ++ ++ LOG_WARN("hno:%u ps3 hard recovery request start, IOC outstanding: %d!!\n", PS3_HOST(instance), ++ ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); + ps3_atomic_inc(&instance->recovery_context->hardreset_ref); + mb(); ++ ++ INJECT_START(PS3_ERR_IJ_ADD_INSTANCE, &instance->recovery_context->instance_change) ++ if (instance->recovery_context->instance_change) { ++ LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); ++ ret = -PS3_RETRY; ++ goto l_out; ++ } ++ + INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_PROBE, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_REMOVE, instance) + while (instance->peer_instance != NULL && + PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { ++ ++ INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY, instance) + if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || \ + instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; + goto l_out; + } + +- if (ps3_atomic_read(&instance->pcie_err_handle_ref) != 0) { +- instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; +- break; ++ INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE, &instance->recovery_context->instance_change) ++ if (instance->recovery_context->instance_change) { ++ LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); ++ ret = -PS3_RETRY; ++ goto l_out; + } ++ + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_INIT) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_PENDING; + } +- ++ INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, instance) + ps3_atomic_dec(&instance->recovery_context->hardreset_ref); + ps3_msleep(10); + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_CONTINUE) { +@@ -834,7 +842,7 @@ + } + INJECT_START(PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE_1, &ret) + l_out: +- LOG_INFO("hno:%u hard recovery request:%d!\n", ++ LOG_INFO("hno:%u hard recovery request end, ret:%d!\n", + PS3_HOST(instance), ret); + + ps3_atomic_dec(&instance->recovery_context->hardreset_ref); +@@ -967,7 +975,7 @@ + static S32 ps3_recovery_request_prepare(struct ps3_instance *instance) + { + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; +- U32 ioc_state = instance->ioc_adpter->ioc_state_get(instance); ++ U32 ioc_state = 0; + struct ps3_instance_state_machine *state_machine + = &instance->state_machine; + U32 cur_state = 0; +@@ -975,12 +983,14 @@ + U32 peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; + + ps3_mutex_lock(&state_machine->lock); ++ ioc_state = instance->ioc_adpter->ioc_state_get(instance); + cur_state = ps3_atomic_read(&state_machine->state); + ++ INJECT_START(PS3_ERR_IJ_CHANGE_FW_TO_HALT_IN_PREPARE, &ioc_state); + LOG_INFO("hno:%u recovery request:%s, %s\n", + PS3_HOST(instance), + ps3_ioc_state_print(ioc_state), namePS3InstanceState(cur_state)); +- ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PCIE_ERR, instance) + if (ps3_pci_err_recovery_get(instance) || + (instance->peer_instance != NULL && ps3_pci_err_recovery_get(instance->peer_instance))) { + LOG_WARN("hno:%u pci recovery resetting\n", +@@ -989,21 +999,25 @@ + goto l_out; + } + +- if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE +- || instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY) { ++ ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); ++ if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE) { + ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); + if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + LOG_INFO("hno:%u heartbeat recovery start\n", + PS3_HOST(instance)); +- ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_RECOVERY; +- ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + } ++ ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + goto l_out; + } ++ ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_IOC_HALT, instance) + if (ioc_state == PS3_FW_STATE_HALT) { +- ps3_instance_state_transfer_to_dead(instance); ++ ps3_instance_state_transfer_to_dead_nolock(instance); ++ if (instance->peer_instance != NULL) ++ ps3_instance_state_transfer_to_dead_nolock(instance->peer_instance); ++ + LOG_ERROR("hno:%u IOC state has halt, instance state to dead!\n", + PS3_HOST(instance)); + ret = PS3_RECOVERY_INTER_ERR_FAILED; +@@ -1020,31 +1034,32 @@ + goto l_out; + } + +- if (instance->peer_instance != NULL && +- instance->peer_instance->reg_set != NULL) { ++ if (instance->peer_instance != NULL) { + state_machine_peer = &instance->peer_instance->state_machine; +- ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get(instance); +- ps3_mutex_lock(&state_machine_peer->lock); +- peer_cur_state = ps3_atomic_read(&state_machine->state); +- LOG_INFO("hno:%u recovery request:%s, %s\n", +- PS3_HOST(instance->peer_instance), +- ps3_ioc_state_print(ioc_state), namePS3InstanceState(peer_cur_state)); +- ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_PCIE_ERR, instance) + if (ps3_pci_err_recovery_get(instance->peer_instance)) { + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance->peer_instance)); + ret = PS3_RECOVERY_INTER_ERR_SUCCESS; +- goto l_out_peer; ++ goto l_out; + } ++ ps3_mutex_lock(&state_machine_peer->lock); ++ ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get(instance); ++ peer_cur_state = ps3_atomic_read(&state_machine->state); ++ LOG_INFO("hno:%u recovery request:%s, %s\n", ++ PS3_HOST(instance->peer_instance), ++ ps3_ioc_state_print(ioc_state), namePS3InstanceState(peer_cur_state)); + ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_IOC_HALT, instance) + if (ioc_state == PS3_FW_STATE_HALT) { +- ps3_instance_state_transfer_to_dead(instance->peer_instance); ++ ps3_instance_state_transfer_to_dead_nolock(instance->peer_instance); ++ ps3_instance_state_transfer_to_dead_nolock(instance); + LOG_ERROR("hno:%u ioc state has halt, instance state to dead!\n", + PS3_HOST(instance->peer_instance)); + ret = PS3_RECOVERY_INTER_ERR_FAILED; + goto l_out_peer; + } +- ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, instance) + if (peer_cur_state == PS3_INSTANCE_STATE_DEAD || + peer_cur_state == PS3_INSTANCE_STATE_QUIT || + peer_cur_state == PS3_INSTANCE_STATE_SUSPEND) { +@@ -1109,8 +1124,19 @@ + { + S32 ret = PS3_SUCCESS; + struct ps3_instance *instance_recovery = NULL; ++ ++ LOG_WARN("hno:%u ps3 recovery request start, IOC outstanding: %d!!\n", PS3_HOST(instance), ++ ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); + ps3_atomic_inc(&instance->recovery_context->hardreset_ref); + mb(); ++ INJECT_START(PS3_ERR_IJ_ADD_INSTANCE, &instance->recovery_context->instance_change) ++ if (instance->recovery_context->instance_change) { ++ LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); ++ ret = -PS3_RETRY; ++ goto l_out; ++ } ++ INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_PROBE, instance) ++ INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_REMOVE, instance) + while (instance->peer_instance != NULL && + PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { + if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || \ +@@ -1119,14 +1145,15 @@ + goto l_out; + } + +- if (ps3_atomic_read(&instance->pcie_err_handle_ref) != 0) { +- instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; +- break; +- } +- + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_INIT) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_PENDING; + } ++ INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE, &instance->recovery_context->instance_change) ++ if (instance->recovery_context->instance_change) { ++ LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); ++ ret = -PS3_RETRY; ++ goto l_out; ++ } + + ps3_atomic_dec(&instance->recovery_context->hardreset_ref); + ps3_msleep(10); +@@ -1139,12 +1166,13 @@ + ps3_atomic_inc(&instance->recovery_context->hardreset_ref); + mb(); + } +- ++ INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, instance) + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; + } + LOG_INFO("hno:%u peer_instance[%p], hard recovery request Function[%d]\n", + PS3_HOST(instance), instance->peer_instance, ps3_get_pci_function(instance->pdev)); ++ INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_3, instance) + if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_0 || + (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1 && instance->peer_instance == NULL)) { + instance_recovery = instance; +@@ -1166,9 +1194,7 @@ + goto l_out; + } + +- if (instance_recovery->peer_instance != NULL && +- instance_recovery->peer_instance->recovery_context != NULL && +- instance_recovery->peer_instance->reg_set != NULL) { ++ if (instance_recovery->peer_instance != NULL) { + if (ps3_pci_err_recovery_get(instance_recovery->peer_instance)) { + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance_recovery->peer_instance)); +@@ -1176,7 +1202,8 @@ + goto l_out; + } + +- if (ps3_recovery_is_state_halt(instance_recovery->peer_instance)) { ++ if (instance_recovery->peer_instance->reg_set == NULL || ++ ps3_recovery_is_state_halt(instance_recovery->peer_instance)) { + LOG_WARN("hno:%u driver_state:DEAD or HALT now !!!\n", + PS3_HOST(instance_recovery->peer_instance)); + ret = -PS3_FAILED; +@@ -1195,7 +1222,7 @@ + } + + l_out: +- LOG_INFO("hno:%u recovery request:%d!\n", ++ LOG_INFO("hno:%u recovery request end, ret:%d!\n", + PS3_HOST(instance), ret); + ps3_atomic_dec(&instance->recovery_context->hardreset_ref); + return ret; +@@ -1204,8 +1231,8 @@ + static Bool ps3_recovery_reg(struct ps3_instance *instance) + { + Bool ret = PS3_FALSE; +- HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; +- HilReg0Ps3RegisterFPs3FirmwareVersion_u *pver = NULL; ++ union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; ++ union HilReg0Ps3RegisterFPs3FirmwareVersion *pver = NULL; + U32 cur_max_fw_cmds = 0; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + U64 value = 0; +@@ -1215,16 +1242,17 @@ + if (value == U64_MAX) { + goto l_out; + } +- ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; ++ ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FirmwareVersion, ver); + if (ver == U64_MAX) { + goto l_out; + } +- pver = (HilReg0Ps3RegisterFPs3FirmwareVersion_u *)&ver; ++ pver = (union HilReg0Ps3RegisterFPs3FirmwareVersion *)&ver; + if (!ps3_ioc_mgr_max_fw_cmd_get(instance, &cur_max_fw_cmds)) { + goto l_out; + } + fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_REG_FAILED, &fw_cur_state) + if (fw_cur_state != PS3_FW_STATE_RUNNING) { + goto l_out; + } +@@ -1248,6 +1276,7 @@ + } + return ret; + } ++ + static S32 ps3_recovery_complete(struct ps3_instance *instance) + { + S32 ret = PS3_SUCCESS; +@@ -1259,6 +1288,10 @@ + goto l_out; + } + ++ if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { ++ goto l_out; ++ } ++ + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_14, instance) + if (ps3_recovery_finish(instance) != PS3_SUCCESS) { + ps3_instance_state_transfer_to_dead(instance); +@@ -1279,15 +1312,12 @@ + PS3_HOST(instance)); + }else{ + context->recovery_result = PS3_SUCCESS; +- LOG_INFO("hno:%u hard recovery success!\n", ++ LOG_WARN("hno:%u hard recovery success!\n", + PS3_HOST(instance)); + } +- +- if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY) { +- ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); +- instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_NULL; +- ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); +- } ++ ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); ++ instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_NULL; ++ ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + + return; + } +@@ -1437,8 +1467,8 @@ + cmd = context->cmd_buf[i]; + + ps3_mutex_lock(&instance->state_machine.lock); +- if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ +- LOG_WARN("hno:%u soft reset proc is interrupt!\n", ++ if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { ++ LOG_WARN("hno:%u soft reset proc is interrupt!\n", + PS3_HOST(instance)); + ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; + ps3_mutex_unlock(&instance->state_machine.lock); +@@ -1494,7 +1524,7 @@ + } + + for (i = 0; (i < msecs); i += interval_check_ms) { +- if (!ps3_is_instance_state_normal(instance)) { ++ if (!ps3_is_instance_state_normal(instance, PS3_TRUE)) { + ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; + break; + } +@@ -1783,7 +1813,7 @@ + ps3_need_wait_hard_reset_request(instance); + ret = ps3_hard_recovery_handle(instance); + } else { +- LOG_ERROR("hno:%u transfer to recovery failed!,cur_state:%s\n", ++ LOG_ERROR("hno:%u transfer to recovery failed!, cur_state:%s\n", + PS3_HOST(instance), + namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); + ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); +@@ -2204,14 +2234,19 @@ + goto l_out; + } + ++ if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { ++ goto l_out; ++ } ++ + if ((ret = ps3_recovery_ready_to_running(instance)) != PS3_SUCCESS) { +- LOG_ERROR("hno:%u hard reset to ready NOK!\n", ++ LOG_ERROR("hno:%u hard reset to running NOK!\n", + PS3_HOST(instance)); + + if (ret == -PS3_IN_PCIE_ERR) { + err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; + goto l_out; + } ++ INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL, instance) + if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_READY, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + LOG_ERROR("hno:%u transfer to recovery NOK!\n", +@@ -2234,7 +2269,7 @@ + if (instance->is_need_event) { + ps3_dev_mgr_vd_info_clear(instance); + } +- ++ INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL, instance) + if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_READY, + PS3_INSTANCE_STATE_PRE_OPERATIONAL) != PS3_SUCCESS) { + LOG_ERROR("hno:%u transfer to pre-operational NOK!\n", +@@ -2263,6 +2298,10 @@ + goto l_out; + } + ++ if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { ++ goto l_out; ++ } ++ + if (ps3_hard_recovery_pre_operational_to_operational(instance) != PS3_SUCCESS) { + LOG_ERROR("hno:%u pre operational NOK!\n", + PS3_HOST(instance)); +@@ -2363,10 +2402,27 @@ + ps3_ioc_notify_unload(instance); + } + } +-static inline Ps3Bool_t ps3_hard_reset_multi_unnormal_handle(struct ps3_instance *instance) ++ ++static inline S32 ps3_hard_reset_error_code_decide(struct ps3_instance *instance) + { +- Ps3Bool_t is_exit_hard_reset = PS3_FALSE; ++ S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + ++ if (PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance)) { ++ err_code = PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME; ++ goto l_out; ++ } ++ ++ if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) && ++ instance->peer_instance == NULL) { ++ err_code = PS3_RECOVERY_INTER_ERR_FAILED; ++ } ++ ++l_out: ++ return err_code; ++} ++ ++static inline S32 ps3_hard_reset_multi_unnormal_handle(struct ps3_instance *instance) ++{ + + if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { + LOG_WARN("host_no[%u], reset while probe or in shutdown/remove," +@@ -2382,9 +2438,6 @@ + } else if (PS3_IS_INSTANCE_SUSPEND(instance)) { + ps3_hard_reset_unnormal_handle(instance); + } +- if (instance->peer_instance == NULL) { +- is_exit_hard_reset = PS3_TRUE; +- } + } + if (instance->peer_instance != NULL && PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { + LOG_WARN("host_no[%u], reset while probe or in shutdown/remove," +@@ -2401,16 +2454,24 @@ + ps3_hard_reset_unnormal_handle(instance->peer_instance); + } + } +- return is_exit_hard_reset; ++ return ps3_hard_reset_error_code_decide(instance); + } + + static void ps3_recovery_wait_reg_access_done(struct ps3_instance *instance) + { ++ U16 cur_cnt = 0; ++ Bool printed = PS3_TRUE; ++ + LOG_DEBUG("hno:%u recovery wait reg access done start\n", + PS3_HOST(instance)); +- ps3_wait_scsi_cmd_done(instance, PS3_FALSE); +- while (ps3_atomic_read(&instance->reg_op_count) != 0){ ++ ps3_wait_scsi_cmd_done(instance, PS3_TRUE); ++ ps3_wait_mgr_cmd_done(instance, PS3_TRUE); ++ while (ps3_atomic_read(&instance->reg_op_count) != 0) { + ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); ++ if (printed && ((++cur_cnt) * PS3_LOOP_TIME_INTERVAL_20MS > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { ++ printed = PS3_FALSE; ++ LOG_WARN("host:%u wait reg access done.\n", PS3_HOST(instance)); ++ } + } + LOG_DEBUG("hno:%u recovery wait reg access done end\n", + PS3_HOST(instance)); +@@ -2423,6 +2484,7 @@ + } + ps3_mutex_unlock(&instance->state_machine.lock); + ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_FINISH); ++ INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ, instance) + } + + static S32 ps3_hard_recovery_handle(struct ps3_instance *instance) +@@ -2434,6 +2496,8 @@ + S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + U32 wait_count = 0; + ULong flags = 0; ++ U16 cur_cnt = 0; ++ Bool printed = PS3_TRUE; + + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_0, instance) + if (ps3_pci_err_recovery_get(instance)) { +@@ -2466,8 +2530,8 @@ + ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_SHALLOW); + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC1_PROBE, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC1_REMOVE, instance) +- if (instance->is_scan_host_finish == PS3_TRUE +- && instance->is_probe_finish == PS3_FALSE) { ++ if (instance->is_scan_host_finish ++ && !instance->is_probe_finish) { + LOG_INFO("hno:%u recovery wait until probe finish/failed\n", + PS3_HOST(instance)); + while (wait_count < PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT) { +@@ -2502,6 +2566,12 @@ + while(ps3_use_hard_reset_max_retry() > retries) { + LOG_DEBUG("hno:%u request IOC state to fault! retries:%d\n", + PS3_HOST(instance), retries); ++ ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); ++ if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY && ++ retries != 0) { ++ instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_RETRY; ++ } ++ ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + + instance->dump_context.is_hard_recovered = PS3_TRUE; + if (instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_RECOVERY) { +@@ -2526,6 +2596,10 @@ + + while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + ps3_msleep(10); ++ if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { ++ printed = PS3_FALSE; ++ LOG_WARN("host:%u wait err scsi process\n", PS3_HOST(instance)); ++ } + } + instance->ioc_adpter->irq_disable(instance); + INJECT_START(PS3_ERR_IJ_WAIT_IOCTL_IN_RECOVERY, instance) +@@ -2534,6 +2608,7 @@ + #endif + + INJECT_START(PS3_ERR_IJ_WAIT_READY, instance); ++ INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_4, instance); + err_code = ps3_hard_recovery_to_ready(instance); + if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { + LOG_INFO("hno:%u IOC state to ready failed! retries:%d\n", +@@ -2571,15 +2646,22 @@ + } + + INJECT_START(PS3_ERR_IJ_FWSTATE_REMOVE, instance) +- if (ps3_hard_reset_multi_unnormal_handle(instance)) { +- goto l_offline; ++ err_code = ps3_hard_reset_multi_unnormal_handle(instance); ++ if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { ++ LOG_INFO("driver loading or unloading err_code:%d\n", ++ err_code); ++ if (err_code == PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME) ++ goto l_out; ++ else ++ goto l_offline; + } +- ++ INJECT_START(PS3_ERR_IJ_FORCE_WAIT_CLI_CMD, instance); + INJECT_START(PS3_ERR_IJ_WATCHDOG_WAIT_RUNNING, instance); + err_code = ps3_hard_recovery_to_pre_operational(instance); + if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { + LOG_INFO("hno:%u IOC state to pre-operatioal failed! retries:%d\n", + PS3_HOST(instance), retries); ++ INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL1, instance->peer_instance) + if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + if(instance->peer_instance != NULL) { + if (ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_READY, +@@ -2601,7 +2683,7 @@ + PS3_HOST(instance), retries); + + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_1, instance) +- if (instance->peer_instance != NULL && (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance) == PS3_FALSE) && \ ++ if (instance->peer_instance != NULL && !PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance) && + instance->peer_instance->recovery_function.hardreset_handle_init_running_cb != NULL) { + if(ps3_atomic_read(&instance->peer_instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ + err_code = instance->peer_instance->recovery_function.hardreset_handle_init_running_cb( \ +@@ -2610,6 +2692,8 @@ + LOG_INFO("hno:%u IOC state to pre-operatioal failed! retries:%d\n", + PS3_HOST(instance), retries); + if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { ++ INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_PEER_DEAD_FAIL, ++ instance->peer_instance) + if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + LOG_WARN("hno:%u transfer to recovery NOK!\n", +@@ -2628,6 +2712,7 @@ + PS3_HOST(instance), retries); + } + } ++ INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_2, instance) + + err_code = ps3_hard_recovery_to_operational(instance); + if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { +@@ -2647,7 +2732,7 @@ + + if (instance->peer_instance != NULL && \ + instance->peer_instance->recovery_function.hardreset_handle_post_cb != NULL) { +- if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance) == PS3_FALSE) { ++ if (!PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { + if(ps3_atomic_read(&instance->peer_instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ + err_code = instance->peer_instance->recovery_function.hardreset_handle_post_cb( \ + instance->peer_instance); +@@ -2672,8 +2757,8 @@ + } + + cur_state = ps3_atomic_read(&instance->state_machine.state); +- if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL || +- ps3_use_hard_reset_max_retry() == retries) { ++ if ((cur_state != PS3_INSTANCE_STATE_OPERATIONAL || ++ ps3_use_hard_reset_max_retry() == retries) && !PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { + LOG_ERROR("hno:%u hard reset failed! cur_state:%s\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state)); +@@ -2682,7 +2767,7 @@ + + ret = ps3_recovery_complete(instance); + if(ret != PS3_SUCCESS){ +- LOG_INFO("hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", ++ LOG_WARN("hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state),ret); + if (ret == -PS3_IN_PCIE_ERR) { + goto l_out; +@@ -2697,10 +2782,11 @@ + LOG_INFO("hno:%u hard reset finish! cur_state:%s\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); + } else { +- if(PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance) == PS3_FALSE) { ++ if (!PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { + if(ps3_atomic_read(&instance->peer_instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ + ret = instance->peer_instance->recovery_function.hardreset_handle_finish_cb( \ + instance->peer_instance); ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PEER_COMPLETE_FAILED, &ret) + } + if (ret != PS3_SUCCESS) { + LOG_WARN("hno:%u hardreset handle running cb NOK\n", +@@ -2715,7 +2801,9 @@ + ps3_hard_recovery_state_finish(instance); + } + } +- ++ ps3_ioc_can_hardreset_set(instance, PS3_IOC_CAN_HARDRESET); ++ if (instance->peer_instance != NULL) ++ ps3_ioc_can_hardreset_set(instance->peer_instance, PS3_IOC_CAN_HARDRESET); + return ret; + l_offline: + ps3_instance_state_transfer_to_dead(instance); +@@ -2741,11 +2829,17 @@ + static S32 ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance) + { + S32 ret = PS3_SUCCESS; ++ U16 cur_cnt = 0; ++ Bool printed = PS3_TRUE; + + ps3_cmd_reset_flag_set(instance, PS3_CMD_FLAG_HARDRESET); + + while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + ps3_msleep(10); ++ if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { ++ printed = PS3_FALSE; ++ LOG_WARN("host:%u cmd stop wait err scsi process\n", PS3_HOST(instance)); ++ } + } + + ps3_all_reply_fifo_complete(instance); +@@ -2760,17 +2854,30 @@ + static S32 ps3_recovery_ready_to_running(struct ps3_instance *instance) + { + S32 ret = PS3_SUCCESS; ++ U16 cur_cnt = 0; ++ Bool printed = PS3_TRUE; + + ps3_cmd_reset_flag_set(instance, PS3_CMD_FLAG_HARDRESET); + + while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + ps3_msleep(10); ++ if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { ++ printed = PS3_FALSE; ++ LOG_WARN("host:%u to running wait err scsi process\n", PS3_HOST(instance)); ++ } + } + + ps3_all_reply_fifo_complete(instance); + +- ps3_cmd_force_stop(instance); ++ INJECT_START(PS3_ERR_IJ_RECOVERY_BLOCK_BEFORE_RUNNING, instance); + ++ ps3_cmd_force_stop(instance); ++ if (!ps3_bit_pos_update(instance)) { ++ LOG_ERROR("hno:%u update bit pos NOK\n", ++ PS3_HOST(instance)); ++ ret = -PS3_FAILED; ++ goto l_out; ++ } + if ((ret = instance->ioc_adpter->ioc_init_proc(instance)) != PS3_SUCCESS) { + LOG_ERROR("hno:%u init IOC frame NOK\n", + PS3_HOST(instance)); +@@ -2890,7 +2997,7 @@ + ps3_r1x_write_unlock(&data->lock_mgr, cmd); + } + } else { +- LOG_ERROR("hno:%u force stop scsi has Null pointer CFID[%u]\n", ++ LOG_WARN("hno:%u force stop scsi has Null pointer CFID[%u]\n", + PS3_HOST(instance), i); + } + peer_cmd = cmd->r1x_peer_cmd; +@@ -2914,7 +3021,7 @@ + #endif + } + ps3_mutex_unlock(&instance->recovery_context->free_cmd_lock); +- LOG_WARN("hno:%u force stop scsi cmd count[%u]\n", ++ LOG_WARN("hno:%u force stop scsi cmd count[%u] during hard recovery\n", + PS3_HOST(instance), count); + + return; +@@ -2997,9 +3104,6 @@ + continue; + } + } +- LOG_FILE_WARN("hno:%u force dead CFID:%d\n", +- PS3_HOST(instance), i); +- cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + } + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); + } +@@ -3030,7 +3134,7 @@ + } + } + +-static void ps3_cmd_force_stop(struct ps3_instance *instance) ++void ps3_cmd_force_stop(struct ps3_instance *instance) + { + S32 ret_code = 0; + struct ps3_cmd_context *context = &instance->cmd_context; +@@ -3046,7 +3150,7 @@ + + ps3_r1x_conflict_queue_clean_all(instance, ret_code, PS3_FALSE); + +- ps3_qos_hard_reset(instance); ++ ps3_qos_hard_reset(instance); + #ifdef PS3_SUPPORT_INJECT + ps3_inject_clear(); + #endif +@@ -3060,7 +3164,7 @@ + Bool is_support_halt = PS3_FALSE; + U32 hard_reset_enable = 0; + S32 cur_state = PS3_INSTANCE_STATE_INIT; +- if (!ps3_ioc_state_halt_support_get(instance)) { ++ if (!ps3_feature_support_reg_get(instance)) { + goto l_out; + } + +@@ -3084,10 +3188,6 @@ + goto l_out; + } + +- if (!ps3_ioc_recovery_support_get(instance)) { +- goto l_out; +- } +- + hard_reset_enable = ps3_hard_reset_enable_query(); + cur_state = ps3_atomic_read(&instance->state_machine.state); + +@@ -3109,7 +3209,6 @@ + S32 ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance) + { + S32 ret = PS3_SUCCESS; +- + if (instance->peer_instance != NULL && + instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_CONTINUE; +@@ -3145,7 +3244,7 @@ + ps3_msleep(PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); + } + } else { +- ret = ps3_hard_recovery_request(instance); ++ ret = ps3_hard_recovery_request_with_retry(instance); + if (ret != PS3_SUCCESS){ + LOG_WARN("hno:%u hard recovery request NOK\n", + PS3_HOST(instance)); +@@ -3158,7 +3257,7 @@ + ret = -PS3_FAILED; + } + +- LOG_ERROR("device[%d] hard reset success,exit init proc %d.\n", instance->pdev->dev.id, ret); ++ LOG_WARN("device[%d] hard reset success,exit init proc %d.\n", instance->pdev->dev.id, ret); + return ret; + l_out: + if (ps3_recovery_is_state_halt(instance)) { +@@ -3193,7 +3292,7 @@ + LOG_ERROR("device[%d] hard reset NOK,exit init proc.\n", instance->pdev->dev.id); + goto l_end; + } +- LOG_ERROR("device[%d] hard reset success,exit init proc.\n", instance->pdev->dev.id); ++ LOG_WARN("device[%d] hard reset success,exit init proc.\n", instance->pdev->dev.id); + ret = -PS3_FAILED; + l_end: + return ret; +@@ -3213,6 +3312,7 @@ + PS3_HOST(instance)); + return -PS3_IN_PCIE_ERR; + } ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_NOT_SUPPORT, instance) + if(!PS3_IS_INSTANCE_PROBE_INIT(instance)) { + + if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) +@@ -3232,8 +3332,8 @@ + } + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + +- if (PS3_IS_INSTANCE_PROBE(instance) && instance->is_scan_host_finish == PS3_TRUE +- && instance->is_probe_finish == PS3_FALSE) { ++ if (PS3_IS_INSTANCE_PROBE(instance) && instance->is_scan_host_finish ++ && !instance->is_probe_finish) { + LOG_INFO("hno:%u recovery wait until probe finish/failed\n", + PS3_HOST(instance)); + while (wait_count < PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT) { +@@ -3262,6 +3362,8 @@ + S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + U32 ioc_state = 0; + S32 ret = PS3_SUCCESS; ++ U16 cur_cnt = 0; ++ Bool printed = PS3_TRUE; + + LOG_DEBUG("hno:%u function[%d], hardreset handle wait ready start.\n", + PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); +@@ -3273,6 +3375,10 @@ + + while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + ps3_msleep(10); ++ if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { ++ printed = PS3_FALSE; ++ LOG_WARN("host:%u wait ready wait err scsi process\n", PS3_HOST(instance)); ++ } + } + instance->ioc_adpter->irq_disable(instance); + #ifndef _WINDOWS +@@ -3305,11 +3411,14 @@ + } + goto l_out; + } +- if (instance->state_machine.is_load && ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_RECOVERY, +- PS3_INSTANCE_STATE_READY) != PS3_SUCCESS) { +- LOG_ERROR("hno:%u transfer to ready NOK!\n", +- PS3_HOST(instance)); +- err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; ++ if (instance->state_machine.is_load || ++ instance->state_machine.is_suspend) { ++ if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_RECOVERY, ++ PS3_INSTANCE_STATE_READY) != PS3_SUCCESS) { ++ LOG_ERROR("hno:%u transfer to ready NOK!\n", ++ PS3_HOST(instance)); ++ err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; ++ } + } + + l_out: +@@ -3358,6 +3467,7 @@ + S32 ret = PS3_SUCCESS; + + cur_state = ps3_atomic_read(&instance->state_machine.state); ++ INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_FINISH_STATE_NOOPERATIONAL, &cur_state) + if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { + ps3_instance_state_transfer_to_dead(instance); + LOG_ERROR("hno:%u hard reset NOK! cur_state:%s\n", +@@ -3369,7 +3479,7 @@ + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_15, instance) + ret = ps3_recovery_complete(instance); + if(ret != PS3_SUCCESS){ +- LOG_INFO("hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", ++ LOG_WARN("hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state),ret); + return ret; + } +@@ -3384,8 +3494,8 @@ + S32 ps3_hardreset_handle_offline(struct ps3_instance *instance) + { + U32 cur_state = 0; +- cur_state = ps3_atomic_read(&instance->state_machine.state); + ps3_instance_state_transfer_to_dead(instance); ++ cur_state = ps3_atomic_read(&instance->state_machine.state); + LOG_ERROR("hno:%u hard reset finish! cur_state:%s\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); + return PS3_SUCCESS; +@@ -3433,3 +3543,34 @@ + l_out: + return ret; + } ++ ++S32 ps3_hard_recovery_request_with_retry(struct ps3_instance *instance) ++{ ++ S32 ret = PS3_SUCCESS; ++ U32 count = 0; ++ ++ while ((ret = ps3_hard_recovery_request(instance)) == -PS3_RETRY) { ++ if (count++ == ps3_use_hard_reset_max_retry()) { ++ ret = -PS3_FAILED; ++ break; ++ } ++ ps3_mdelay(10); ++ } ++ ++ return ret; ++} ++S32 ps3_recovery_request_with_retry(struct ps3_instance *instance) ++{ ++ S32 ret = PS3_SUCCESS; ++ U32 count = 0; ++ ++ while ((ret = ps3_recovery_request(instance)) == -PS3_RETRY) { ++ if (count++ == ps3_use_hard_reset_max_retry()) { ++ ret = -PS3_FAILED; ++ break; ++ } ++ ps3_mdelay(10); ++ } ++ ++ return ret; ++} +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_recovery.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_recovery.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_recovery.h 2025-06-10 20:13:00.241054190 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_recovery.h 2025-06-10 20:13:00.538064551 +0800 +@@ -39,17 +39,25 @@ + #define PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL (5) + #define PS3_RECOVERY_CONTEXT_MAX_NUM (8) + #define PS3_RECOVERY_IRQ_NAME_MAX_LENTH (48) ++#define PS3_RECOVERY_WHILE_PRINT_REACH_TIME (10 * 1000) + + enum { + PS3_HEARTBEAT_NULL = 0, + PS3_HEARTBEAT_HARDRESET_DECIDE = 1, +- PS3_HEARTBEAT_HARDRESET_RECOVERY =2, ++ PS3_HEARTBEAT_HARDRESET_RECOVERY = 2, ++ PS3_HEARTBEAT_HARDRESET_RETRY = 3, ++}; ++ ++enum { ++ PS3_IOC_CANNOT_HARDRESET = 0, ++ PS3_IOC_CAN_HARDRESET = 1, + }; + + struct ps3_recovery_context + { + ps3_mutex free_cmd_lock; + ps3_spinlock recovery_lock; ++ ps3_spinlock ps3_hardreset_lock; + U32 ioc_recovery_count; + U8 recovery_state; + U8 reserved1; +@@ -67,7 +75,8 @@ + S32 recovery_result; + U32 hardreset_count; + U8 parall_hardreset_state; +- U8 reserved[7]; ++ U8 instance_change; ++ U8 reserved[6]; + ps3_atomic32 hardreset_ref; + ps3_mutex ps3_watchdog_recovery_mutex; + }; +@@ -89,7 +98,8 @@ + #define PS3_IS_INSTANCE_PROBE_INIT(instance) (!((instance)->is_probe_finish || (instance)->is_probe_failed) && \ + !(instance)->state_machine.is_load) + +-#define PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance) ((instance)->state_machine.is_suspend) ++#define PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance) (PS3_IS_INSTANCE_SUSPEND(instance) || \ ++ PS3_IS_INSTANCE_RESUME(instance)) + + #define PS3_IS_INSTANCE_SUSPEND(instance) ((instance)->state_machine.is_suspend && \ + (instance)->is_suspend) +@@ -123,7 +133,6 @@ + + void ps3_recovery_work_queue_destory(struct ps3_instance *instance); + #endif +-Bool ps3_no_need_recovery(struct ps3_instance *instance); + + S32 ps3_hardreset_handle_pre(struct ps3_instance *instance); + +@@ -140,9 +149,10 @@ + S32 ps3_softreset_handle_pre(struct ps3_instance *instance); + + S32 ps3_softreset_handle_post(struct ps3_instance *instance); +- +-#ifndef _WINDOWS ++S32 ps3_hard_recovery_request_with_retry(struct ps3_instance *instance); ++S32 ps3_recovery_request_with_retry(struct ps3_instance *instance); + irqreturn_t ps3_recovery_irq_handler(S32 virq, void *dev_id); +- #endif + S32 ps3_recovery_irq_start(struct ps3_instance *instance); ++ ++void ps3_cmd_force_stop(struct ps3_instance *instance); + #endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_sas_transport.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_sas_transport.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_sas_transport.c 2025-06-10 20:13:00.241054190 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_sas_transport.c 2025-06-10 20:13:00.538064551 +0800 +@@ -39,7 +39,7 @@ + goto l_out; + } + +- if (!ps3_is_instance_state_normal(instance)) { ++ if (!ps3_is_instance_state_normal(instance, PS3_TRUE)) { + ret = -EFAULT; + goto l_out; + } +@@ -125,12 +125,21 @@ + ret = -EINVAL; + goto l_no_free_cmd; + } +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); ++ if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { ++ LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp linkerror pre check NOK\n", ++ phy->identify.sas_address, PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -ENXIO; ++ goto l_no_free_cmd; ++ } + cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) + if (cmd == NULL) { + LOG_WARN("hno:%u not get a cmd packet\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -ENOMEM; + goto l_no_free_cmd; + } +@@ -145,6 +154,10 @@ + ps3_mgr_cmd_word_build(cmd); + INJECT_START(PS3_ERR_IJ_CMD_POLLING, &cmd) + send_result = ps3_cmd_send_sync(instance, cmd); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ + ret = ps3_mgr_complete_proc(instance, cmd, send_result); + if (ret == -PS3_CMD_NO_RESP) { + LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", +@@ -279,12 +292,21 @@ + ret = -ENXIO; + goto l_out; + } +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); ++ if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { ++ LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp phyctrl pre check NOK\n", ++ phy->identify.sas_address, PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -ENXIO; ++ goto l_no_free_cmd; ++ } + cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) + if (cmd == NULL) { + LOG_WARN("hno:%u not get a cmd packet\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -ENOMEM; + goto l_no_free_cmd; + } +@@ -299,6 +321,10 @@ + ps3_mgr_cmd_word_build(cmd); + INJECT_START(PS3_ERR_IJ_CMD_POLLING, &cmd) + send_result = ps3_cmd_send_sync(instance, cmd); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ + ret = ps3_mgr_complete_proc(instance, cmd, send_result); + if (ret == -PS3_CMD_NO_RESP) { + LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", +@@ -627,11 +653,21 @@ + goto l_out; + } + ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); ++ if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { ++ LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp pre check NOK\n", ++ sas_addr, PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -EFAULT; ++ goto l_no_free_cmd; ++ } + cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) + if (cmd == NULL) { + LOG_WARN("hno:%u not get a cmd packet\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -ENOMEM; + goto l_no_free_cmd; + } +@@ -641,6 +677,7 @@ + req_data_len = ps3_sas_req_to_ext_buf(instance, req, cmd->ext_buf); + if (req_data_len == 0) { + ret = -ENOMEM; ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + goto l_out_failed; + } + +@@ -650,6 +687,10 @@ + ps3_sas_smp_reqframe_build(cmd, sas_addr, req_data_len); + ps3_mgr_cmd_word_build(cmd); + send_result = ps3_cmd_send_sync(instance, cmd); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ + ret = ps3_mgr_complete_proc(instance, cmd, send_result); + if (ret == -PS3_CMD_NO_RESP) { + LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", +@@ -758,11 +799,19 @@ + ret = -EFAULT; + goto l_out; + } +- ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { ++ LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp pre check NOK\n", ++ sas_addr, PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = -EFAULT; ++ goto l_no_free_cmd; ++ } + cmd = ps3_mgr_cmd_alloc(instance); + if (cmd == NULL) { + LOG_WARN("hno:%u Failed to get a cmd packet\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = -ENOMEM; + goto l_no_free_cmd; + } +@@ -772,6 +821,7 @@ + req_data_len = ps3_sas_req_to_ext_buf(instance, &job->request_payload, cmd->ext_buf); + if (req_data_len == 0) { + ret = -ENOMEM; ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + goto l_out_failed; + } + +@@ -781,6 +831,10 @@ + ps3_sas_smp_reqframe_build(cmd, sas_addr, req_data_len); + ps3_mgr_cmd_word_build(cmd); + send_result = ps3_cmd_send_sync(instance, cmd); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) ++ send_result = ps3_cmd_wait_sync(instance, cmd); ++ + ret = ps3_mgr_complete_proc(instance, cmd, send_result); + if (ret == -PS3_CMD_NO_RESP) { + LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", +@@ -813,7 +867,7 @@ + } + #endif + +-S32 ps3_sas_attach_transport() ++S32 ps3_sas_attach_transport(void) + { + S32 ret = PS3_SUCCESS; + static struct sas_function_template ps3_sas_transport_functions = { +@@ -834,7 +888,7 @@ + return ret; + } + +-void ps3_sas_release_transport() ++void ps3_sas_release_transport(void) + { + if(ps3_sas_transport_template != NULL) { + sas_release_transport(ps3_sas_transport_template); +@@ -842,3 +896,4 @@ + } + } + #endif ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsi_cmd_err.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsi_cmd_err.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsi_cmd_err.c 2025-06-10 20:13:00.285055725 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsi_cmd_err.c 2025-06-10 20:13:00.548064900 +0800 +@@ -33,6 +33,7 @@ + #include "ps3_nvme_resp_to_scsi.h" + #include "ps3_scsi_cmd_err.h" + #include "ps3_ioc_manager.h" ++#include "ps3_mgr_channel.h" + + static void ps3_scsi_sense_print(struct ps3_instance *instance, + const U8 *sense_buffer, U8 len, S32 CFID); +@@ -161,7 +162,9 @@ + status = err_code; + break; + case SCSI_STATUS_RESERVATION_CONFLICT: +-#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,6,0)) ++#if ((defined(RHEL_MAJOR) && \ ++ ((RHEL_MAJOR < 9) || (RHEL_MAJOR == 9 && RHEL_MINOR < 3))) || \ ++ (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 38))) + host_status = DID_NEXUS_FAILURE; + #endif + status = err_code; +@@ -218,7 +221,7 @@ + Ps3SasDirectRespFrameIU_s *frame = NULL; + + ps3_scsih_cdb_opcode_get(cmd->scmd->cmnd, &opcode, &sub_opcode); +- LOG_FILE_WARN("tid:0x%llx hno:%u op:0x%x sub_op:0x%x " ++ LOG_FILE_INFO("tid:0x%llx hno:%u op:0x%x sub_op:0x%x " + "tag:%u\n", cmd->trace_id, PS3_HOST(cmd->instance), + opcode, sub_opcode, cmd->index); + +@@ -264,7 +267,7 @@ + S32 cur_state = PS3_INSTANCE_STATE_INIT; + + if (!instance->state_machine.is_load) { +- LOG_ERROR_IN_IRQ(instance, ++ LOG_WARN_IN_IRQ(instance, + "hno:%u instance state not is_load\n", PS3_HOST(instance)); + ret = PS3_DRV_FALSE; + goto l_out; +@@ -273,7 +276,7 @@ + cur_state = ps3_atomic_read(&instance->state_machine.state); + if (cur_state == PS3_INSTANCE_STATE_DEAD || + cur_state == PS3_INSTANCE_STATE_QUIT) { +- LOG_ERROR_IN_IRQ(instance, ++ LOG_WARN_IN_IRQ(instance, + "hno:%u instance state is dead/quit\n", PS3_HOST(instance)); + ret = PS3_DRV_FALSE; + goto l_out; +@@ -287,13 +290,15 @@ + { + S32 ret = PS3_SUCCESS; + +- if (!ps3_is_instance_state_normal(instance)){ ++ static unsigned long j; ++ ++ if (!ps3_is_instance_state_normal(instance, PS3_TRUE)) { + ret = -PS3_FAILED; + goto l_out; + } + + if (ps3_pci_err_recovery_get(instance)) { +- LOG_WARN("hno:%u host in pci recovery\n", ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u host in pci recovery\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_out; +@@ -360,7 +365,7 @@ + struct ps3_cmd *cmd = NULL; + U16 idx = 0; + struct scsi_cmnd *s_cmd = NULL; +- ++ static unsigned long j; + ps3_msleep(ps3_task_reset_delay_time_query()); + + ps3_atomic_inc(&instance->is_err_scsi_processing); +@@ -404,7 +409,7 @@ + #ifndef _WINDOWS + scsi_print_command(s_cmd); + #endif +- LOG_WARN("hno:%u SCSI commands pending to target" ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u SCSI commands pending to target" + " tid:0x%llx [%u:%u]: frame_id:%d\n", + PS3_HOST(instance), cmd->trace_id, channel, id, cmd->index); + ret = -PS3_FAILED; +@@ -482,6 +487,7 @@ + U32 id = 0; + U16 disk_id = 0; + PS3RespFrame_u *frame = cmd->resp_frame; ++ static unsigned long j; + #ifndef _WINDOWS + channel = scmd->device->channel; + id = scmd->device->id; +@@ -520,10 +526,10 @@ + } + + } else { +- LOG_WARN("tid:0x%llx hno:%u [chl:%u, id:%u, devid:%u], CFID:%u respStatus:%u\n", ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u [chl:%u, id:%u, devid:%u], CFID:%u respStatus:%u\n", + cmd->trace_id, PS3_HOST(instance), channel, id, disk_id, + cmd->index, frame->normalRespFrame.respStatus); +- + ps3_err_scsi_errcode_mapping(cmd, mode, PS3_FALSE); + } + return; +@@ -598,8 +604,13 @@ + " [scmd cmd_flags:0x%llx, retries:%d, allowd:%d]\n", + PS3_HOST(instance), SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, + cmd->scmd->retries, cmd->scmd->allowed); +- +- cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR); ++ if (cmd->reply_word.retStatus == PS3_NVME_RESP_STATUS_SQ_FULL && ++ cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { ++ cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_OK) | SCSI_STATUS_TASK_SET_FULL; ++ cmd->scmd->retries = ((cmd->scmd->retries == 0) ? 1 : cmd->scmd->retries); ++ } else { ++ cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR); ++ } + } else { + cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + } +@@ -610,32 +621,6 @@ + return ret; + } + +-S32 ps3_err_scsi_task_pre_check(struct ps3_instance *instance) +-{ +- S32 ret = PS3_SUCCESS; +- +- if (!instance->state_machine.is_load) { +- LOG_WARN("hno:%u instance state not is_load\n", +- PS3_HOST(instance)); +- ret = -PS3_FAILED; +- goto l_out; +- } +- +- if(!ps3_is_instance_state_normal(instance)) { +- ret = -PS3_FAILED; +- goto l_out; +- } +- +- if (ps3_pci_err_recovery_get(instance)) { +- LOG_WARN("hno:%u host in pci recovery\n", +- PS3_HOST(instance)); +- ret = -PS3_FAILED; +- goto l_out; +- } +-l_out: +- return ret; +-} +- + void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, U8 resp_status, Bool cmd_lock) + { + struct ps3_instance *instance = cmd->instance; +@@ -657,7 +642,7 @@ + PS3_IO_BACK_ERR_INC(instance, s_cmd); + PS3_DEV_BUSY_DEC(s_cmd); + +- ps3_errcode_to_scsi_status(cmd->instance, s_cmd, resp_status, NULL, 0 ,cmd); ++ ps3_errcode_to_scsi_status(cmd->instance, s_cmd, resp_status, NULL, 0, cmd); + + #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) + s_cmd->SCp.ptr = NULL; +@@ -710,7 +695,7 @@ + ps3_scsi_target_query(scmd)); + + INJECT_START(PS3_ERR_IJ_SCSI_TASK_PRE_CHECK_FAILED, instance) +- if (ps3_err_scsi_task_pre_check(instance) != PS3_SUCCESS) { ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { + LOG_WARN("hno:%u pre check NOK!\n", + PS3_HOST(instance)); + ret = FAILED; +@@ -724,7 +709,7 @@ + goto l_out; + } + cmd_frame_id = SCMD_GET_REQUEST(scmd)->tag; +- INJECT_START(PS3_ERR_IJ_ABORT_PRE1_FORCE_ABORTED_CMD_DONE ,scmd) ++ INJECT_START(PS3_ERR_IJ_ABORT_PRE1_FORCE_ABORTED_CMD_DONE, scmd) + aborted_cmd = ps3_cmd_find(instance, cmd_frame_id); + if (aborted_cmd == NULL || aborted_cmd->scmd == NULL) { + LOG_INFO("host_no:%u there is no aborted cmd CFID:%u\n", +@@ -733,7 +718,7 @@ + ret = SUCCESS; + goto l_out; + } +- INJECT_START(PS3_ERR_IJ_ABORT_PRE2_FORCE_ABORTED_CMD_DONE ,scmd) ++ INJECT_START(PS3_ERR_IJ_ABORT_PRE2_FORCE_ABORTED_CMD_DONE, scmd) + + LOG_FILE_WARN("tid:0x%llx hno:%u task aborted CFID:%u ready \n", + aborted_cmd->trace_id, PS3_HOST(instance), cmd_frame_id); +@@ -784,11 +769,13 @@ + } + ps3_mutex_unlock(&instance->task_abort_lock); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_FREE1, aborted_cmd); ++ INJECT_START(PS3_ERR_IJ_ABORT_BLOCK1, instance); + if (!aborted_peer_cmd->is_r1x_scsi_complete) { + ret = ps3_scsi_task_mgr_abort(instance, scsi_priv_data, + aborted_peer_cmd->index, scmd); + ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; + aborted_peer_cmd->is_aborting = 0; ++ INJECT_START(PS3_ERR_IJ_ABORT_BLOCK2, instance); + if (ret == SUCCESS) { + LOG_INFO("hno:%u task abort peer cmd:%d success !\n", + PS3_HOST(instance), aborted_peer_cmd->index); +@@ -801,8 +788,9 @@ + } else { + goto l_busy_clean_out; + } ++ } else { ++ aborted_peer_cmd->is_aborting = 0; + } +- aborted_peer_cmd->is_aborting = 0; + } + + ret = ps3_scsi_task_mgr_abort(instance, scsi_priv_data, +@@ -857,6 +845,7 @@ + S32 ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) + { + S32 ret = PS3_SUCCESS; ++ S32 send_result = PS3_SUCCESS; + struct ps3_instance *instance = scsi_host_data(scmd); + struct ps3_scsi_priv_data *scsi_priv_data = NULL; + struct ps3_scsi_priv_data pending_priv_data; +@@ -867,7 +856,7 @@ + PS3_SDEV_TARGET(scmd->device)); + + ps3_mutex_lock(&instance->dev_context.dev_priv_lock); +- INJECT_START(PS3_ERR_IJ_PRIV_DATA_NULL1 ,scmd->device) ++ INJECT_START(PS3_ERR_IJ_PRIV_DATA_NULL1, scmd->device) + scsi_priv_data = scsi_device_private_data(scmd); + if(scsi_priv_data == NULL) { + ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); +@@ -882,23 +871,13 @@ + goto l_out; + } + +-#ifndef _WINDOWS +- LOG_WARN("hno:%u enter ready reset[%u:%u:%u:%#x], CFID:%d op:0x%x\n", +- PS3_HOST(instance), scsi_priv_data->disk_pos.diskDev.ps3Dev.softChan, +- scsi_priv_data->disk_pos.diskDev.ps3Dev.devID, +- scsi_priv_data->disk_pos.diskDev.ps3Dev.phyDiskID, +- scsi_priv_data->disk_pos.diskMagicNum, SCMD_GET_REQUEST(scmd)->tag, +- scmd->cmnd[0]); +-#else +- LOG_WARN("hno:%u enter ready reset[%u:%u:%u:%#x], op:0x%x\n", ++ LOG_WARN("hno:%u enter ready reset[%u:%u:%u:%#x], CFID:%d\n", + PS3_HOST(instance), scsi_priv_data->disk_pos.diskDev.ps3Dev.softChan, + scsi_priv_data->disk_pos.diskDev.ps3Dev.devID, + scsi_priv_data->disk_pos.diskDev.ps3Dev.phyDiskID, +- scsi_priv_data->disk_pos.diskMagicNum, +- scsi_cmnd_cdb(scmd)[0]); +-#endif ++ scsi_priv_data->disk_pos.diskMagicNum, SCMD_GET_REQUEST(scmd)->tag); + +- if (ps3_err_scsi_task_pre_check(instance) != PS3_SUCCESS) { ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { + LOG_WARN("hno:%u pre check NOK!\n", + PS3_HOST(instance)); + #ifndef _WINDOWS +@@ -931,11 +910,7 @@ + ps3_wait_scsi_cmd_done(instance, PS3_TRUE); + LOG_WARN("hno[%u], task reset wait scsi delivering cmd count[%d] !\n", PS3_HOST(instance), + ps3_atomic_read(&instance->cmd_statistics.cmd_delivering)); +- while (ps3_atomic_read(&instance->cmd_statistics.cmd_delivering) != 0){ +- LOG_INFO("host_no:%u scsi commands in delivering, wait a while!\n", +- PS3_HOST(instance)); +- ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); +- } ++ ps3_wait_mgr_cmd_done(instance, PS3_TRUE); + LOG_WARN("hno:%u task reset wait delivering cmd end !\n", PS3_HOST(instance)); + + ps3_r1x_conflict_queue_clean(scsi_priv_data, SCSI_STATUS_TASK_ABORTED); +@@ -944,18 +919,37 @@ + ps3_qos_device_clean(instance, scsi_priv_data, SCSI_STATUS_TASK_ABORTED); + ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + ++ ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ++ INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); ++ if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { ++ LOG_WARN_LIM("hno:%u mgr reset cmd pre check NOK CFID:%d\n", ++ PS3_HOST(instance), SCMD_GET_REQUEST(scmd)->tag); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ ret = FAILED; ++ goto l_err; ++ } + cmd = ps3_scsi_task_mgr_reset_build(instance, &pending_priv_data); + if (cmd == NULL) { + LOG_ERROR("hno:%u task reset cmd NOK!\n", + PS3_HOST(instance)); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = FAILED; +- goto l_out; ++ goto l_err; + } + +- ret = ps3_scsi_task_mgr_reset(instance, cmd); +-#ifndef _WINDOWS +- ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; ++ send_result = ps3_cmd_send_sync(instance, cmd); ++ ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ++ if (send_result == PS3_SUCCESS) ++ send_result = ps3_cmd_wait_sync(instance, cmd); + ++ ret = ps3_mgr_complete_proc(instance, cmd, send_result); ++ LOG_INFO("host_no:%u reset finish CFID:%u t_id:0x%llx!\n", ++ PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id); ++ ++ if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ++ ps3_task_cmd_free(instance, cmd); ++ ++ ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; + if (ret == SUCCESS) { + LOG_INFO("hno:%u target reset success !\n", PS3_HOST(instance)); + ret = ps3_err_scsi_io_processing(instance, scmd->device->id, +@@ -964,16 +958,9 @@ + ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; + ps3_can_queue_depth_update(instance); + } +-#else +- if (ret == PS3_SUCCESS) { +- LOG_INFO("hno:%u target reset success !\n", PS3_HOST(instance)); +- ret = ps3_err_scsi_io_processing(instance, PS3_SDEV_TARGET(scmd->device), +- PS3_SDEV_CHANNEL(scmd->device)); +- ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; +- } +-#endif ++l_err: + ps3_mutex_lock(&instance->dev_context.dev_priv_lock); +- INJECT_START(PS3_ERR_IJ_PRIV_DATA_NULL2 ,scmd->device) ++ INJECT_START(PS3_ERR_IJ_PRIV_DATA_NULL2, scmd->device) + scsi_priv_data = scsi_device_private_data(scmd); + if (scsi_priv_data == NULL) { + ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); +@@ -1048,7 +1035,7 @@ + LOG_WARN("hno:%u ready to host reset,instance state: %s\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); + if (PS3_DEVICE_IS_SWITCH(instance->dev_id) && +- instance->is_scan_host_finish == PS3_FALSE) { ++ !instance->is_scan_host_finish) { + LOG_INFO("host_no:%u instance deviceId:%u is probe, exit failed!\n", + PS3_HOST(instance), instance->dev_id); + ret = -PS3_FAILED; +@@ -1106,39 +1093,13 @@ + return ret; + } + +-#ifdef _WINDOWS +-S32 ps3_reset_host(struct ps3_instance *instance) +-{ +- S32 ret = PS3_SUCCESS; +- S32 cur_state = PS3_INSTANCE_STATE_INIT; +- LOG_INFO("hno:%u Host reset is requested, IOC outstanding: %d!!\n", +- PS3_HOST(instance), +- ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); +- +- if (ps3_host_reset_pre_check(instance) != PS3_SUCCESS) { +- ret = -PS3_FAILED; +- goto l_out; +- } +- +- ret = ps3_hard_recovery_request(instance); +- if (ret != PS3_SUCCESS) { +- cur_state = ps3_atomic_read(&instance->state_machine.state); +- LOG_ERROR("hno:%u recovery request failed, %s!\n", +- PS3_HOST(instance), namePS3InstanceState(cur_state)); +- ret = -PS3_FAILED; +- } +- +-l_out: +- return ret; +-} +-#else + S32 ps3_reset_host(struct ps3_instance *instance) + { + S32 ret = SUCCESS; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + LOG_INFO("hno:%u Host reset is requested, IOC outstanding: %d!!\n", + PS3_HOST(instance), +- ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); ++ ps3_atomic_read(&instance->cmd_statistics.io_outstanding)); + ps3_atomic_inc(&instance->host_reset_processing); + if (ps3_host_reset_pre_check(instance) != PS3_SUCCESS) { + ret = FAILED; +@@ -1212,7 +1173,7 @@ + } + ps3_mutex_unlock(&instance->state_machine.lock); + +- ret = ps3_hard_recovery_request(instance); ++ ret = ps3_hard_recovery_request_with_retry(instance); + if (ret != PS3_SUCCESS) { + cur_state = ps3_atomic_read(&instance->state_machine.state); + LOG_ERROR("hno:%u recovery request NOK, %s!\n", +@@ -1235,7 +1196,7 @@ + instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_FINISH; + } + ps3_mutex_unlock(&instance->state_machine.lock); +- ret = ps3_hard_recovery_request(instance); ++ ret = ps3_hard_recovery_request_with_retry(instance); + if (ret != PS3_SUCCESS) { + cur_state = ps3_atomic_read(&instance->state_machine.state); + LOG_ERROR("hno:%u recovery request NOK, %s!\n", +@@ -1283,7 +1244,6 @@ + PS3_HOST(instance), ret); + return ret; + } +-#endif + + S32 ps3_err_reset_target(struct scsi_cmnd *scmd) + { +@@ -1354,7 +1314,7 @@ + spin_unlock_irqrestore(instance->host->host_lock, flags); + } + +- LOG_WARN_LIM("reset timer [%u:%u:%u:%llu], tag:%d op:0x%x " ++ LOG_FILE_WARN("reset timer [%u:%u:%u:%llu], tag:%d op:0x%x " + "timeout:%u alloc_time:%lu cur_time:%lu\n", + PS3_HOST(instance), scmd->device->channel, + scmd->device->id, (U64)scmd->device->lun, SCMD_GET_REQUEST(scmd)->tag, +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsi_cmd_err.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsi_cmd_err.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsi_cmd_err.h 2025-06-10 20:13:00.285055725 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsi_cmd_err.h 2025-06-10 20:13:00.548064900 +0800 +@@ -32,6 +32,7 @@ + #define PS3_SENSE_RESP_CODE_MASK (0x7F) + #define PS3_SENSE_KEY_MASK (0xF) + #define PS3_ABORT_WAIT_CMD_FLIGHT_END 50 ++#define PS3_NVME_RESP_STATUS_SQ_FULL (0x102) + + enum ps3_sas_resp_code { + PS3_SAS_RESP_CODE_TASK_MGR_COMPLETE = 0x0, +@@ -83,8 +84,6 @@ + S32 ps3_err_scsi_io_processing(struct ps3_instance *instance, + U32 id, U32 channel); + +-S32 ps3_err_scsi_task_pre_check(struct ps3_instance *instance); +- + S32 ps3_reset_host(struct ps3_instance *instance); + + void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, U8 resp_status, Bool cmd_lock); +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsih.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsih.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsih.c 2025-06-10 20:13:00.265055027 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsih.c 2025-06-10 20:13:00.542064690 +0800 +@@ -162,6 +162,7 @@ + INJECT_START(PS3_ERR_IJ_FORCE_STREAM_DETECT_TRUE, &is_stream); + + INJECT_START(PS3_ERR_IJ_FORCE_RAND_CMD, cmd); ++ INJECT_START(PS3_ERR_IJ_FORCE_STREAM_DETECT_FALSE, &is_stream); + return is_stream; + } + Bool ps3_raid_scsih_stream_is_direct(const struct ps3_cmd *cmd) +@@ -171,19 +172,30 @@ + + if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { + if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { +- if (!(cmd->io_attr.vd_entry->isSsd && ++ if (cmd->io_attr.vd_entry->isNvme || !(cmd->io_attr.vd_entry->isSsd && + (ps3_atomic_read(&p_priv_data->rd_io_outstand) > PS3_VD_IO_16_OUTSTANDING) && + (cmd->io_attr.num_blocks > PS3_BLOCK_NUM_OF_32K))) { + is_direct = PS3_FALSE; + } + } + } ++ + return is_direct; + } + Bool ps3_hba_scsih_stream_is_direct(const struct ps3_cmd *cmd) + { + Bool is_direct = PS3_TRUE; +- cmd = cmd; ++ struct ps3_scsi_priv_data *p_priv_data = scsi_device_private_data(cmd->scmd); ++ ++ if (p_priv_data->dev_type == PS3_DEV_TYPE_VD && ++ cmd->io_attr.vd_entry->isNvme && ++ ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { ++ if (ps3_atomic_read(&p_priv_data->rd_io_outstand) > PS3_VD_IO_16_OUTSTANDING && ++ cmd->io_attr.num_blocks > PS3_BLOCK_NUM_OF_32K) { ++ is_direct = PS3_FALSE; ++ } ++ } ++ + return is_direct; + } + +@@ -213,7 +225,8 @@ + ret = PS3_FALSE; + PS3_IO_BACK_ERR_INC(instance, s_cmd); + PS3_DEV_BUSY_DEC(s_cmd); +- LOG_ERROR_LIM("hno:%u host_Reset_state:%d\n", PS3_HOST(instance),instance->recovery_context->host_reset_state); ++ LOG_WARN_LIM("hno:%u host_Reset_state:%d\n", PS3_HOST(instance), ++ instance->recovery_context->host_reset_state); + goto l_out; + } + +@@ -255,7 +268,7 @@ + { + Bool ret = PS3_TRUE; + struct ps3_scsi_priv_data *data = NULL; +- ++ static unsigned long j; + *scsi_result = PS3_SUCCESS; + if (unlikely(instance->task_manager_host_busy)) { + PS3_IO_BACK_ERR_INC(instance, s_cmd); +@@ -269,7 +282,7 @@ + data = (struct ps3_scsi_priv_data*)s_cmd->device->hostdata; + if (unlikely(data == NULL)) { + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); +- LOG_ERROR("hno:%u device_priv_data is null s_cmd result:%d\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u device_priv_data is null s_cmd result:%d\n", + PS3_HOST(instance), s_cmd->result); + goto l_scsi_done; + } +@@ -286,7 +299,7 @@ + if (data->dev_type == PS3_DEV_TYPE_VD) { + if (unlikely(ps3_scsih_is_illegel_vd_io(s_cmd, instance))) { + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_BAD_TARGET); +- LOG_ERROR("hno:%u dev_type:%s id:%u " ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u dev_type:%s id:%u " + "max_vd_count:%u vd id NOK\n", PS3_HOST(instance), + namePS3DevType((enum PS3DevType)data->dev_type), + s_cmd->device->id, instance->ctrl_info.maxVdCount); +@@ -410,9 +423,10 @@ + { + Bool ret = PS3_DRV_TRUE; + S32 cur_state = PS3_INSTANCE_STATE_INIT; +- ++ static unsigned long j; + if (!instance->state_machine.is_load) { +- LOG_ERROR("hno:%u instance state not is_load\n", PS3_HOST(instance)); ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "hno:%u instance state not is_load\n", PS3_HOST(instance)); + *host_status = DID_ERROR; + goto l_out; + } +@@ -420,7 +434,8 @@ + cur_state = ps3_atomic_read(&instance->state_machine.state); + if (cur_state == PS3_INSTANCE_STATE_DEAD || + cur_state == PS3_INSTANCE_STATE_QUIT) { +- LOG_ERROR("hno:%u instance state is dead/quit\n", PS3_HOST(instance)); ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "hno:%u instance state is dead/quit\n", PS3_HOST(instance)); + *host_status = DID_BAD_TARGET; + goto l_out; + } +@@ -430,7 +445,7 @@ + cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { + ret = PS3_DRV_FALSE; + *host_status = DID_BUS_BUSY; +- LOG_ERROR("hno:%u cannot request scsi cmd due to %s\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u cannot request scsi cmd due to %s\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); + goto l_out; + } +@@ -462,7 +477,7 @@ + struct ps3_cmd *cmd = NULL; + struct ps3_instance *instance = NULL; + struct ps3_scsi_priv_data *data = (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; +- ++ static unsigned long j; + instance = (struct ps3_instance *)s_host->hostdata; + if (unlikely(instance == NULL)) { + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); +@@ -480,10 +495,24 @@ + goto l_out; + } + ++ INJECT_START(PS3_ERR_IJ_CMD_BLOCK_BEFORE_DELIVER_CNT, instance); ++ if (unlikely(s_cmd->cmd_len > PS3_FRAME_CDB_BUFLEN)) { ++ LOG_ERROR("hno:%u cmd len %u check NOK\n", PS3_HOST(instance), s_cmd->cmd_len); ++ PS3_BUG(); ++ s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_ERROR); ++ goto l_scsi_done; ++ } ++ + ps3_scsi_cmd_deliver_get(instance); ++ INJECT_START(PS3_ERR_IJ_CMD_SEND_INSTANCE_RECOVERY, instance); ++ if (unlikely(!ps3_is_instance_state_normal(instance, PS3_TRUE))) { ++ ret = SCSI_MLQUEUE_HOST_BUSY; ++ goto l_cmd_stat_dec; ++ } ++ + cmd = ps3_scsi_cmd_alloc(instance, SCMD_GET_REQUEST(s_cmd)->tag); + if (unlikely(cmd == NULL)) { +- LOG_ERROR("hno:%u tag:%d ps3_cmd_get NOK ret:%d\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tag:%d ps3_cmd_get NOK ret:%d\n", + PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag, ret); + PS3_IO_BACK_ERR_INC(instance, s_cmd); + PS3_IO_OUTSTAND_DEC(instance, s_cmd); +@@ -494,8 +523,9 @@ + goto l_scsi_done; + } + ++ INJECT_START(PS3_ERR_IJ_CMD_BLOCK_BEFORE_SEND_TO_IOC, instance); + if (cmd->scmd != NULL) { +- LOG_ERROR("hno:%u CFID:%u cmd is exist\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u CFID:%u cmd is exist\n", + PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag); + PS3_BUG(); + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); +@@ -551,7 +581,8 @@ + goto l_cmd_release; + } + +- ret = ps3_scsi_cmd_send(instance, cmd); ++ INJECT_START(PS3_ERR_IJ_CMD_SEND_WAIT_RECOVERY_END, instance); ++ ret = ps3_scsi_cmd_send(instance, cmd, PS3_TRUE); + if (unlikely(ret != PS3_SUCCESS)) { + ps3_qos_cmd_update(instance, cmd); + if (ret == -PS3_RECOVERED) { +@@ -697,16 +728,11 @@ + { + Bool ret = PS3_FALSE; + +-#ifndef _WINDOWS +- BUG_ON(cmd == NULL || cmd->instance == NULL || +- pd_entry == NULL); +-#else + if (cmd == NULL || cmd->instance == NULL || + pd_entry == NULL) { +- LOG_ERROR_LIM("host parameter NOK\n"); ++ LOG_ERROR_LIM("sata direct support judge parameter NOK\n"); + goto l_out; + } +-#endif + + if (cmd->instance->ctrl_info.capabilities.supportSataNcq == 0) { + LOG_DEBUG("IOC SATA NCQ not support\n"); +@@ -746,32 +772,23 @@ + U16 sector_size = 0; + U32 num_blocks = 0; + U32 date_len = 0; +- ++ static unsigned long j; + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { +-#ifndef _WINDOWS +- PS3_BUG_ON(cmd->io_attr.vd_entry == NULL); +-#else + if (cmd->io_attr.vd_entry == NULL) { +- LOG_ERROR("host parameter NOK\n"); ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "host parameter NOK\n"); + goto l_out; + } +-#endif + sector_size = cmd->io_attr.vd_entry->sectorSize; + + } else { + sector_size = cmd->io_attr.pd_entry->sector_size; + } + if (sector_size == 0) { +- LOG_ERROR("host parameter NOK\n"); ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "host parameter NOK\n"); + goto l_out; + } + num_blocks = cmd->io_attr.num_blocks; +- +-#ifndef _WINDOWS + date_len = num_blocks << ilog2(sector_size); +-#else +- date_len = num_blocks * sector_size; +-#endif + + l_out: + return date_len; +@@ -791,10 +808,11 @@ + } + + if (ps3_scsih_cdb_opts_parse(cmd) == PS3_SUCCESS) { +- if (likely(cmd->io_attr.cdb_opts.protect == 0)) { ++ if (likely(cmd->io_attr.cdb_opts.protect == 0 && ++ cmd->io_attr.cdb_opts.fua == 0)) { + ret = PS3_TRUE; + } else { +- LOG_DEBUG("SATA not support protected cdb\n"); ++ LOG_DEBUG("SATA cdb_opts is 0x%x\n", cmd->io_attr.cdb_opts.option); + } + } else { + LOG_DEBUG("SATA options parse failure\n"); +@@ -809,8 +827,18 @@ + return PS3_TRUE; + } + +-static inline Bool ps3_scsih_nvme_direct_is_need(const struct ps3_cmd *cmd) ++static inline Bool ps3_scsih_nvme_direct_is_need(struct ps3_cmd *cmd) + { ++ if (ps3_scsih_cdb_opts_parse(cmd) == PS3_SUCCESS) { ++ if (likely(cmd->io_attr.cdb_opts.protect != 0)) { ++ LOG_DEBUG("NVMe protect is 0x%x\n", cmd->io_attr.cdb_opts.protect); ++ return PS3_FALSE; ++ } ++ } else { ++ LOG_DEBUG("NVMe options parse failure\n"); ++ return PS3_FALSE; ++ } ++ + return (ps3_scsih_datelen_buflen_is_match(cmd) == PS3_TRUE); + } + +@@ -818,14 +846,10 @@ + const struct ps3_pd_entry *pd_entry) + { + Bool ret = PS3_FALSE; +- +-#ifndef _WINDOWS +- PS3_BUG_ON(pd_entry == NULL); +-#else + if (pd_entry == NULL) { +- return ret; ++ PS3_BUG(); ++ goto l_out; + } +-#endif + + switch (pd_entry->dev_type) + { +@@ -844,7 +868,7 @@ + ret = PS3_FALSE; + break; + } +- ++l_out: + return ret; + } + +@@ -852,14 +876,16 @@ + const struct ps3_pd_entry *pd_entry) + { + Bool ret = PS3_FALSE; +- +-#ifndef _WINDOWS +- PS3_BUG_ON(pd_entry == NULL); +-#else + if (pd_entry == NULL) { ++ LOG_ERROR("tid:0x%llx hno:%u CFID:%d pd entry is NULL\n", ++ cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); ++ PS3_BUG(); ++ return ret; ++ } ++ if (pd_entry->is_direct_disable) { ++ LOG_DEBUG("Direct is disable\n"); + return ret; + } +-#endif + switch (pd_entry->dev_type) + { + case PS3_DEV_TYPE_SATA_SSD: +@@ -965,9 +991,12 @@ + goto l_out; + } + +- if (ps3_scsih_is_sync_cache(scsi_cmnd_cdb(cmd->scmd)) && ++ if ((!ps3_scsih_is_protocal_rw(cmd->scmd->cmnd)) && + ps3_scsih_is_sas_jbod_cmd(cmd)) { +- } else if (unlikely(cmd->io_attr.num_blocks == 0)) { ++ goto l_out; ++ } ++ ++ if (unlikely(cmd->io_attr.num_blocks == 0)) { + LOG_DEBUG("tid:0x%llx hno:%u num blocks is zero\n", + cmd->trace_id, PS3_HOST(cmd->instance)); + goto l_out; +@@ -1022,8 +1051,10 @@ + } + + if ((cmd->io_attr.vd_entry->raidLevel == RAID1)) { +- PS3_BUG_ON(cmd->io_attr.vd_entry->mapBlock == 0); +- ++ if (cmd->io_attr.vd_entry->mapBlock == 0) { ++ PS3_BUG(); ++ goto l_out; ++ } + if (cmd->instance->is_raid1_direct_skip_mapblock_check) { + LOG_DEBUG("hba raid1, skip MapBlock check\n"); + } else { +@@ -1207,12 +1238,42 @@ + return ret; + } + ++static inline void ps3_req_frame_head_init(PS3ReqFrameHead_s *req_head) ++{ ++ req_head->cmdType = 0; ++ req_head->cmdSubType = 0; ++ req_head->cmdFrameID = 0; ++ req_head->control = 0; ++ req_head->devID.diskID = 0; ++ req_head->timeout = 0; ++ req_head->virtDiskSeq = 0; ++ req_head->reserved1[0] = 0; ++ req_head->reserved1[1] = 0; ++ req_head->reserved1[2] = 0; ++ req_head->reserved1[3] = 0; ++ req_head->traceID = 0; ++} ++ ++static inline U32 ps3_hw_vd_max_io_size_get(U8 enum_size) ++{ ++ U32 max_size = PS3_HW_VD_MAX_IO_SIZE_1M; ++ ++ switch (enum_size) { ++ case PS3_ENUM_HW_VD_MAX_IO_SIZE_1M: ++ default: ++ break; ++ } ++ return max_size; ++} ++ + static S32 ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) + { + S32 ret = PS3_SUCCESS; + S32 dma_map_ret = 0; + Bool is_need_split = PS3_FALSE; + struct ps3_scsi_priv_data *data = scsi_device_private_data(cmd->scmd); ++ U32 hw_vd_max_num_blk = 0; ++ U32 hw_vd_max_io_size = 0; + + cmd->io_attr.dev_type = data->dev_type; + if (cmd->is_inserted_c_q == 0) { +@@ -1233,6 +1294,8 @@ + goto l_out; + } + ++ ps3_req_frame_head_init(&cmd->req_frame->hwReq.reqHead); ++ + cmd->io_attr.disk_id = data->disk_pos.diskDev.ps3Dev.phyDiskID; + #ifndef _WINDOWS + cmd->io_attr.is_retry_cmd = (cmd->scmd->retries != 0); +@@ -1258,6 +1321,15 @@ + PS3_HOST(cmd->instance), cmd->io_attr.num_blocks, + cmd->io_attr.vd_entry->maxIOSize); + cmd->io_attr.is_force_normal = PS3_TRUE; ++ } ++ ++ hw_vd_max_io_size = ps3_hw_vd_max_io_size_get(cmd->instance->ctrl_info.hwVdMaxIOSize); ++ hw_vd_max_num_blk = hw_vd_max_io_size >> ps3_blocksize_to_shift(cmd->io_attr.vd_entry->sectorSize); ++ if (unlikely(cmd->io_attr.num_blocks > hw_vd_max_num_blk && ++ cmd->io_attr.num_blocks > cmd->io_attr.vd_entry->maxIOSize)) { ++ LOG_DEBUG("hno:%u. numblk:%u > max size, hw max numblk:%u maxIOSize:%u\n", ++ PS3_HOST(cmd->instance), cmd->io_attr.num_blocks, ++ hw_vd_max_num_blk, cmd->io_attr.vd_entry->maxIOSize); + goto l_skip_r1x_write_lock; + } + +@@ -1296,7 +1368,6 @@ + S32 ret = -PS3_FAILED; + U32 table_size = ARRAY_SIZE(g_req_frame_func_table); + U32 i = 0; +- + #ifdef _WINDOWS + ps3_scsi_need_remap_check(cmd); + if (cmd->scmd->is_remap_databuff) { +@@ -1342,6 +1413,7 @@ + const struct ps3_cmd *cmd) + { + Bool ret = PS3_FALSE; ++ (void)vd_info; + + if (ps3_scsih_is_sync_cache(scsi_cmnd_cdb(cmd->scmd))) { + LOG_DEBUG("hno:%u is SYNCHRONIZE_CACHE\n", +@@ -1357,7 +1429,6 @@ + goto l_out; + } + +- PS3_BUG_ON(vd_info->mapBlock == 0); + l_out: + return ret; + } +@@ -1391,7 +1462,16 @@ + + req_head->mapBlockVer = cmd->io_attr.vd_entry->mapBlockVer; + +- PS3_BUG_ON(vd_info->mapBlock == 0); ++ if (vd_info->mapBlock == 0) { ++ PS3_BUG(); ++ ret = -PS3_FAILED; ++ goto l_out; ++ } ++ ++ if (vd_info->isSsd && cmd->instance->ioc_adpter->ssd_vd_qmask_calculate != NULL) { ++ if (cmd->instance->ioc_adpter->ssd_vd_qmask_calculate(cmd)) ++ goto l_hba_ssd_vd; ++ } + + que_offset = PS3_CMD_WORD_QUE_CALC(vd_info->diskPos.diskDev.ps3Dev.virtDiskID, lba, + vd_info->mapBlock, (cmd->instance->ctrl_info.vdQueueNum - 1)); +@@ -1410,6 +1490,7 @@ + LOG_DEBUG("hno:%u map_block:%llu not same map block qMask 0x:%x\n", + PS3_HOST(cmd->instance), vd_info->mapBlock, cmd->cmd_word.qMask); + } ++l_hba_ssd_vd: + + LOG_DEBUG("tid:0x%llx hno:%u CFID:%d que:%d ver:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, +@@ -1425,13 +1506,6 @@ + S32 ret = PS3_SUCCESS; + + INJECT_START(PS3_ERR_IJ_IO_RW_FLAG_SET_UNKOWN, cmd); +- if (unlikely(cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_UNKOWN || +- cmd->io_attr.rw_flag >= PS3_SCSI_CMD_TYPE_COUNT)) { +- ret = -PS3_FAILED; +- LOG_ERROR_LIM("hno:%u cmd word set type NOK CFID:%d ret:%d rw_flag:%d\n", +- PS3_HOST(cmd->instance), cmd->index, ret, cmd->io_attr.rw_flag); +- goto l_out; +- } + + switch (cmd->io_attr.rw_flag) { + case PS3_SCSI_CMD_TYPE_READ: +@@ -1448,10 +1522,11 @@ + default: + cmd->cmd_word.type = PS3_CMDWORD_TYPE_MGR; + ret = -PS3_FAILED; ++ LOG_ERROR_LIM("hno:%u cmd word set type NOK CFID:%d ret:%d rw_flag:%d\n", ++ PS3_HOST(cmd->instance), cmd->index, ret, cmd->io_attr.rw_flag); + break; + } + +-l_out: + return ret; + } + +@@ -1480,15 +1555,6 @@ + } + + ret = ps3_scsih_vd_cmd_word_cpu_set(cmd, vd_info); +- if (unlikely(ret != PS3_SUCCESS)) { +- LOG_ERROR_LIM("tid:0x%llx hno:%u vd cmd word cpu set NOK, " +- "cmd:%u chl:%u id:%u\n", +- cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, +- PS3_SDEV_CHANNEL(cmd->scmd->device), +- PS3_SDEV_TARGET(cmd->scmd->device)); +- ret = -PS3_FAILED; +- goto l_out; +- } + + cmd->cmd_word.direct = cmd->io_attr.direct_flag; + #ifndef _WINDOWS +@@ -1566,7 +1632,7 @@ + }; + + if (rw_flag >= PS3_SCSI_CMD_TYPE_COUNT) { +- return rw_type_table[rw_flag]; ++ return rw_type_table[PS3_SCSI_CMD_TYPE_UNKOWN]; + } + + return rw_type_table[rw_flag]; +@@ -1725,7 +1791,7 @@ + S32 ps3_scsih_cmd_build(struct ps3_cmd *cmd) + { + S32 ret = PS3_SUCCESS; +- ++ static unsigned long j; + ret = ps3_scsih_cmd_build_prepare(cmd); + if (unlikely(ret != PS3_SUCCESS)) { + LOG_DEBUG("tid:0x%llx hno:%u cmd_word build prepare fail CFID:%d ret:%d\n", +@@ -1738,7 +1804,8 @@ + + ret = ps3_scsih_cmd_word_build(cmd); + if (unlikely(ret != PS3_SUCCESS)) { +- LOG_ERROR("tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + ret = SCSI_MLQUEUE_HOST_BUSY; + goto l_out; +@@ -1746,7 +1813,7 @@ + + ret = ps3_scsih_req_frame_build(cmd); + if (unlikely(ret != PS3_SUCCESS)) { +- LOG_ERROR("tid:0x%llx hno:%u req_frame NOK CFID:%d ret:%d\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u req_frame NOK CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + ret = SCSI_MLQUEUE_HOST_BUSY; + goto l_out; +@@ -1805,7 +1872,8 @@ + ret = ps3_scsih_nvme_req_frame_build(cmd); + break; + default: +- BUG(); ++ PS3_BUG(); ++ ret = -PS3_FAILED; + break; + } + return ret; +@@ -1814,7 +1882,7 @@ + static inline U32 ps3_scsih_data_direction_build(const struct ps3_cmd *cmd) + { + U32 ret; +- ++ static unsigned long j; + if((cmd->scmd->sc_data_direction == DMA_BIDIRECTIONAL) + || (cmd->scmd->sc_data_direction == DMA_TO_DEVICE)){ + ret = PS3_DATA_DIRECTION_WRITE; +@@ -1822,7 +1890,7 @@ + || (cmd->scmd->sc_data_direction == DMA_NONE)){ + ret = PS3_DATA_DIRECTION_READ; + } else { +- LOG_ERROR("hno:%u tid:0x%llx date direction:%d check NOK", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tid:0x%llx date direction:%d check NOK", + PS3_HOST(cmd->instance),cmd->trace_id, cmd->scmd->sc_data_direction); + ret = PS3_DATA_DIRECTION_WRITE; + } +@@ -1834,8 +1902,6 @@ + { + S32 ret = PS3_SUCCESS; + struct ps3_scsi_priv_data *p_priv_data = scsi_device_private_data(cmd->scmd); +- PS3_BUG_ON(cmd->scmd->cmd_len > PS3_FRAME_CDB_BUFLEN); +- + ps3_scsih_req_frame_head_build(cmd, PS3_REQFRAME_FORMAT_FRONTEND); + + memcpy(req->cdb, cmd->scmd->cmnd, cmd->scmd->cmd_len); +@@ -1858,7 +1924,6 @@ + } + + return ret; +- + } + + static inline void ps3_align_16bytes_check(U64 addr) +@@ -1990,19 +2055,20 @@ + U16 ret_sge_count = 0; + U16 ext_sge_pos = 0; + U16 ext_sge_size = 0; +- ++ static unsigned long j; + cmd->io_attr.sgl_buf_len = 0; + max_drv_sge_count = ps3_drv_max_sge_count(cmd, frame_sge_count); + + if (unlikely(ps3_is_invalid_ossgl_count(os_sge_count, + max_drv_sge_count))) { +- LOG_ERROR("tid:0x%llx hno:%u CFID:%u io is " ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u CFID:%u io is " + "too huge max_drv_sge_count:%d os_sge_count:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, + max_drv_sge_count , os_sge_count); + goto l_out; + } + ++ memset(&cmd->req_frame->hwReq.sgl, 0, sizeof(cmd->req_frame->hwReq.sgl)); + ext_sge_pos = ps3_scsih_frame_ext_sge_pos(cmd, frame_sge_count, os_sge_count); + ext_sge_size = ps3_scsih_ext_sge_size_calc(ext_sge_pos, frame_sge_count, + os_sge_count); +@@ -2042,20 +2108,30 @@ + S32 ret = PS3_SUCCESS; + PS3FrontEndReqFrame_s *req = &cmd->req_frame->frontendReq; + U16 sge_count = 0; ++ static unsigned long j; + ++ memset(&req->reserved, 0, sizeof(req->reserved)); ++ req->vdAccAttr.isAccActive = 0; ++ req->vdAccAttr.reserved1 = 0; ++ memset(&req->vdAccAttr.reserved2, 0, sizeof(req->vdAccAttr.reserved2)); + + sge_count = ps3_scsih_frontend_data_buf_build(cmd, req); + if (sge_count == 0 && cmd->os_sge_map_count != 0) { +- ret = -PS3_FAILED; +- LOG_ERROR("hno:%u tid:0x%llx drv_sge_count:%u " +- "os_sge_count:%u\n", PS3_HOST(cmd->instance), +- cmd->trace_id, sge_count, cmd->os_sge_map_count ); +- goto l_out; ++ cmd->io_attr.is_use_frontend_prp = PS3_FALSE; ++ sge_count = ps3_scsih_frontend_data_buf_build(cmd, req); ++ if (sge_count == 0 && cmd->os_sge_map_count != 0) { ++ ret = -PS3_FAILED; ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tid:0x%llx drv_sge_count:%u " ++ "os_sge_count:%u\n", PS3_HOST(cmd->instance), ++ cmd->trace_id, sge_count, cmd->os_sge_map_count); ++ goto l_out; ++ } + } + + ret = ps3_scsih_vd_frontend_req_build(cmd, req, sge_count); + if (unlikely(ret != PS3_SUCCESS)) { +- LOG_ERROR("tid:0x%llx hno:%u CFID:%d ret:%d frondend build NOK\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u CFID:%d ret:%d frondend build NOK\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + } + +@@ -2066,7 +2142,7 @@ + static inline S32 ps3_vd_adv_to_normal_req_frame_rebuild(struct ps3_cmd *cmd) + { + S32 ret = PS3_SUCCESS; +- ++ static unsigned long j; + cmd->io_attr.direct_flag = PS3_CMDWORD_DIRECT_NORMAL; + cmd->io_attr.is_use_frontend_prp = PS3_FALSE; + memset((void *) &cmd->cmd_word, 0, sizeof(struct PS3CmdWord)); +@@ -2074,7 +2150,8 @@ + memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); + ret = ps3_scsih_vd_cmd_word_build(cmd); + if (unlikely(ret != PS3_SUCCESS)) { +- LOG_ERROR("tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + ret = -PS3_FAILED; + goto l_out; +@@ -2089,13 +2166,15 @@ + static S32 ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd) + { + S32 ret = PS3_SUCCESS; ++ static unsigned long j; + if ((cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) || + (cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_ADVICE)) { + ret = ps3_vd_direct_req_frame_build(cmd); + + if ((ret != PS3_SUCCESS) && + (cmd->io_attr.pd_entry->dev_type == PS3_DEV_TYPE_NVME_SSD) ) { +- LOG_WARN("tid:0x%llx hno:%u advice direct NVMe vd NOK, to normal" ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u advice direct NVMe vd NOK, to normal" + "is_use_frontend_prp:%d\n", cmd->trace_id, + PS3_HOST(cmd->instance), cmd->io_attr.is_use_frontend_prp); + ret = ps3_vd_adv_to_normal_req_frame_rebuild(cmd); +@@ -2112,11 +2191,11 @@ + PS3SoftwareZone_s *zone = NULL; + U32 num_blocks = cmd->io_attr.num_blocks; + S32 ret = PS3_SUCCESS; +- ++ static unsigned long j; + INJECT_START(PS3_ERR_IJ_SOFT_ZONE_TYPE_SET_UNKOWN, &type); + if(unlikely((type < PS3_DEV_TYPE_SAS_HDD) || + (type >= PS3_DEV_TYPE_COUNT))) { +- LOG_ERROR("tid:0x%llx hno:%u type:%d\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u type:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), type); + ret = -PS3_FAILED; + goto l_ret; +@@ -2153,8 +2232,8 @@ + U64 sge_addr = 0; + U32 first_prp_len = 0; + U32 nvme_page_size_mask = nvme_page_size - 1; ++ static unsigned long j; + (void)data_len; +- + LOG_DEBUG("hno:%u CFID:%u sge_count:%u\n", + PS3_HOST(cmd->instance), cmd->index, total_sge_count); + +@@ -2178,7 +2257,7 @@ + } else if (ps3_utility_mod64(sge_addr + sg_dma_len(sge_ptr), + nvme_page_size)) { + prp_convert_support = PS3_FALSE; +- LOG_WARN("hno:%u CFID:%u index:%u " ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u CFID:%u index:%u " + "sge_addr:0x%llx len:%u\n", + PS3_HOST(cmd->instance), cmd->index, + index, sge_addr, sg_dma_len(sge_ptr)); +@@ -2187,7 +2266,7 @@ + } else { + if ((total_sge_count > 1) && (index == (total_sge_count - 1))) { + if (ps3_utility_mod64(sge_addr, nvme_page_size)) { +- LOG_WARN("hno:%u CFID:%u index:%u " ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u CFID:%u index:%u " + "sge_addr:0x%llx len:%u\n", + PS3_HOST(cmd->instance), cmd->index, + index, sge_addr, sg_dma_len(sge_ptr)); +@@ -2199,7 +2278,8 @@ + if ((total_sge_count > 1) && (index != (total_sge_count - 1))) { + if (ps3_utility_mod64(sg_dma_len(sge_ptr), nvme_page_size) || + ps3_utility_mod64(sge_addr, nvme_page_size)) { +- LOG_WARN("middle hno:%u CFID:%u index:%u " ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "middle hno:%u CFID:%u index:%u " + "sge_addr:0x%llx len:%u\n", + PS3_HOST(cmd->instance), cmd->index, + index, sge_addr, sg_dma_len(sge_ptr)); +@@ -2214,7 +2294,7 @@ + } + + static U16 ps3_scsih_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, +- U8 frame_prp_count, U32 data_len) ++ U8 frame_prp_count, U32 data_len, Bool is_need_clean_sgl) + { + struct scsi_cmnd *scp = cmd->scmd; + ps3_scatter_gather_element *sge_scmd = scsi_sglist(scp); +@@ -2224,7 +2304,10 @@ + U64 sge_addr = sg_dma_address_u64(sge_scmd); + U32 first_prp_len = 0; + U16 prp_entry_count = 0; ++ static unsigned long j; + ++ if (is_need_clean_sgl) ++ memset(&cmd->req_frame->hwReq.sgl, 0, sizeof(cmd->req_frame->hwReq.sgl)); + *prp_ptr = sge_addr; + prp_entry_count++; + first_prp_len = page_size - (sge_addr & nvme_page_size_mask); +@@ -2251,8 +2334,9 @@ + frame_prp_count--; + + for (;;) { +- if (prp_entry_count >= cmd->instance->cmd_context.max_prp_count) { +- LOG_ERROR("tid:0x%llx hno:%u CFID:%u prp_entry_count:%u " ++ if (prp_entry_count > cmd->instance->cmd_context.max_prp_count) { ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u CFID:%u prp_entry_count:%u " + "max_prp_count:%u\n", cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index, prp_entry_count, cmd->instance->cmd_context.max_prp_count); + prp_entry_count = 0; +@@ -2376,9 +2460,9 @@ + U32 max_prp_count = cmd->instance->cmd_context.max_prp_count; + U64 max_nvme_data_size = (U64)(max_prp_count - (U32)PS3_FRAME_REQ_PRP_NUM_FE - 1) * + cmd->instance->cmd_attr.nvme_page_size; +- ++ static unsigned long j; + if (unlikely(max_nvme_data_size < data_len)) { +- LOG_ERROR("tid:0x%llx hno:%u io is too huge " ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u io is too huge " + "[max_nvme_data_size:%llu][data_len:%d]\n", + cmd->trace_id, PS3_HOST(cmd->instance), + max_nvme_data_size , data_len); +@@ -2388,27 +2472,16 @@ + return ret; + } + +-static U16 ps3_scsih_nvme_normal_cmd_split(struct ps3_cmd *cmd, +- PS3FrontEndReqFrame_s *req, U32 data_len) +-{ +- U16 prp_count = 0; +- +- (void)cmd; +- (void)req; +- (void)data_len; +- +- return prp_count; +-} +- + static U16 ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, + PS3FrontEndReqFrame_s *req) + { + U16 sge_count = 0; + U32 data_len = 0; +- ++ static unsigned long j; + if (cmd->io_attr.is_use_frontend_prp) { + if (cmd->os_sge_map_count == 0) { +- LOG_WARN("tid:0x%llx hno:%u CFID:%u os_sge_map_count==0\n", ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u CFID:%u os_sge_map_count==0\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); + sge_count = 0; + goto l_out; +@@ -2421,14 +2494,15 @@ + + if (ps3_prp_build_check(cmd, data_len)) { + sge_count = ps3_scsih_prp_build(cmd, &req->prp.prp1, +- PS3_FRAME_REQ_PRP_NUM_FE, data_len); ++ PS3_FRAME_REQ_PRP_NUM_FE, data_len, PS3_TRUE); + + ps3_scsih_frontend_prp_build(cmd, &req->prp.prp1, + data_len, sge_count); + } else { +- LOG_WARN("tid:0x%llx hno:%u CFID:%u need split cmd\n", ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u CFID:%u nvme prp change to sgl\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); +- sge_count = ps3_scsih_nvme_normal_cmd_split(cmd, req, data_len); ++ sge_count = 0; + } + } else { + sge_count = ps3_scsih_sgl_build(cmd, req->sgl, PS3_FRAME_REQ_SGE_NUM_FE); +@@ -2442,16 +2516,26 @@ + { + S32 ret = PS3_SUCCESS; + PS3FrontEndReqFrame_s *req = &cmd->req_frame->frontendReq; +- ++ static unsigned long j; + ps3_scsih_req_frame_head_build(cmd, PS3_REQFRAME_FORMAT_FRONTEND); + ++ memset(&req->reserved, 0, sizeof(req->reserved)); ++ req->vdAccAttr.isAccActive = 0; ++ req->vdAccAttr.reserved1 = 0; ++ memset(&req->vdAccAttr.reserved2, 0, sizeof(req->vdAccAttr.reserved2)); ++ + req->sgeCount = ps3_scsih_frontend_data_buf_build(cmd, req); + if (req->sgeCount == 0 && cmd->os_sge_map_count != 0) { +- ret = -PS3_FAILED; +- LOG_ERROR("hno:%u tid:0x%llx drv_sge_count:%u " +- "os_sge_count:%u\n", PS3_HOST(cmd->instance), +- cmd->trace_id, req->sgeCount, cmd->os_sge_map_count ); +- goto l_out; ++ cmd->io_attr.is_use_frontend_prp = PS3_FALSE; ++ cmd->req_frame->hwReq.reqHead.dataFormat = PS3_SGL; ++ req->sgeCount = ps3_scsih_frontend_data_buf_build(cmd, req); ++ if (req->sgeCount == 0 && cmd->os_sge_map_count != 0) { ++ ret = -PS3_FAILED; ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tid:0x%llx drv_sge_count:%u " ++ "os_sge_count:%u\n", PS3_HOST(cmd->instance), ++ cmd->trace_id, req->sgeCount, cmd->os_sge_map_count); ++ goto l_out; ++ } + } + + memcpy(req->cdb, cmd->scmd->cmnd, cmd->scmd->cmd_len); +@@ -2478,7 +2562,7 @@ + static void ps3_scsih_req_frame_head_build(struct ps3_cmd *cmd, U8 req_frame_format) + { + PS3ReqFrameHead_s *req_head= &cmd->req_frame->hwReq.reqHead; +- ++ static unsigned long j; + req_head->reqFrameFormat = req_frame_format; + req_head->cmdSubType = 0; + req_head->cmdFrameID = cmd->index; +@@ -2491,7 +2575,8 @@ + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + req_head->devID = cmd->io_attr.vd_entry->diskPos.diskDev; + if (unlikely(req_head->devID.diskID == 0)) { +- LOG_ERROR("tid:0x%llx hno:%u chl:%u id:%u dev id:0x%x NOK\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u chl:%u id:%u dev id:0x%x NOK\n", + cmd->trace_id, PS3_HOST(cmd->instance), PS3_SDEV_CHANNEL(cmd->scmd->device), + PS3_SDEV_TARGET(cmd->scmd->device), req_head->devID.diskID); + } +@@ -2726,6 +2811,8 @@ + { + PS3NvmeRWCmd_s *rwReqFrame = &hw_reqframe->nvmeReqFrame.rwReqFrame; + rwReqFrame->numLba = cpu_to_le32(cmd->io_attr.num_blocks - 1); ++ rwReqFrame->numLba |= (U32)((U32)cmd->io_attr.cdb_opts.fua << 30); ++ + rwReqFrame->sLbaHi = cpu_to_le32((U32)(cmd->io_attr.plba >> PS3_SHIFT_DWORD)); + rwReqFrame->sLbaLo = cpu_to_le32((U32)(cmd->io_attr.plba)); + +@@ -2761,6 +2848,9 @@ + cmd->ext_buf_phys; + cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].lastSge = 0; + cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].ext = 1; ++ } else { ++ if (cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].ext != 0) ++ cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].ext = 0; + } + } + +@@ -2773,8 +2863,9 @@ + U64 lba = 0; + U16 prp_count = 0; + U32 data_len = ps3_scsih_data_buf_len(cmd, cmd->os_sge_map_count); +- ++ static unsigned long j; + hw_reqframe = &cmd->req_frame->hwReq; ++ memset(&hw_reqframe->nvmeReqFrame, 0, sizeof(PS3NvmeReqFrame_u)); + prp_ptr = &hw_reqframe->nvmeReqFrame.rwReqFrame.cDW0_9.dPtr.prp.prp1; + + ps3_scsih_req_frame_head_build(cmd, PS3_REQFRAME_FORMAT_NVME); +@@ -2783,14 +2874,14 @@ + } + + if (ps3_prp_build_check(cmd, data_len)) { +- prp_count = ps3_scsih_prp_build(cmd, prp_ptr, PS3_FRAME_REQ_PRP_NUM_HW, data_len); ++ prp_count = ps3_scsih_prp_build(cmd, prp_ptr, PS3_FRAME_REQ_PRP_NUM_HW, data_len, PS3_FALSE); + ps3_hw_nvme_ext_fill(cmd, prp_count); + ps3_hw_nvme_req_frame_build(cmd, hw_reqframe); + cmd->req_frame->hwReq.reqHead.traceID = cmd->trace_id; + lba = (U64)cmd->io_attr.lba_hi << PS3_SHIFT_DWORD | cmd->io_attr.lba_lo; + ret = ps3_software_zone_build(cmd, lba, pd_dev_type, prp_count); + } else { +- LOG_ERROR("tid:0x%llx hno:%u this io don't support prp!\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u this io don't support prp!\n", + cmd->trace_id, PS3_HOST(cmd->instance)); + ret = -PS3_FAILED; + } +@@ -2800,11 +2891,12 @@ + static S32 ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd) + { + S32 ret = PS3_SUCCESS; +- ++ static unsigned long j; + if (ps3_is_need_build_hw_req_frame(cmd)) { + ret = ps3_scsih_nvme_hw_req_frame_build(cmd); + if (ret != PS3_SUCCESS) { +- LOG_WARN("tid:0x%llx hno:%u direct NVMe NOK, to normal" ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u direct NVMe NOK, to normal " + "is_use_frontend_prp:%d\n", cmd->trace_id, + PS3_HOST(cmd->instance), cmd->io_attr.is_use_frontend_prp); + cmd->io_attr.direct_flag = PS3_CMDWORD_DIRECT_NORMAL; +@@ -2814,7 +2906,8 @@ + memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); + ret = ps3_scsih_pd_cmd_word_build(cmd); + if (unlikely(ret != PS3_SUCCESS)) { +- LOG_ERROR("tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + ret = -PS3_FAILED; + goto l_out; +@@ -2861,7 +2954,10 @@ + static inline void ps3_r1x_read_dec(struct ps3_cmd *cmd, struct ps3_r1x_read_balance_info *rb_info) + { + if (rb_info != NULL && cmd->r1x_read_pd > 0) { +- PS3_BUG_ON(cmd->r1x_read_pd > PS3_MAX_PD_NUM_ONE_VD); ++ if (cmd->r1x_read_pd > PS3_MAX_PD_NUM_ONE_VD) { ++ PS3_BUG(); ++ return; ++ } + ps3_atomic_dec(&rb_info->scsi_outstanding_cmds[cmd->r1x_read_pd]); + } + } +@@ -3186,7 +3282,19 @@ + if (os_sgl == NULL) { + break; + } +- sg_dma_address(os_sgl) = PCIE_DMA_HOST_ADDR_BIT_POS_SET(sg_dma_address_u64(os_sgl)); ++ INJECT_START(PS3_ERR_IJ_SGL_ADDR_PAGE_MODE_5, &(sg_dma_address_u64(os_sgl))); ++ if (index == 0 && cmd->instance->page_mode_change ++ && (sg_dma_address_u64(os_sgl) & cmd->instance->page_mode_addr_mask)) { ++ cmd->instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_4_ADDR_MASK; ++ if (sg_dma_address_u64(os_sgl) & PS3_PAGE_MODE_ABOVE_4_ADDR_MASK) ++ cmd->instance->page_mode_change = PS3_FALSE; ++ dev_info(&cmd->instance->pdev->dev, ++ "page mode change, addr:0x%llx\n", ++ sg_dma_address_u64(os_sgl)); ++ } ++ INJECT_START(PS3_ERR_IJ_SGL_ADDR_RESTORE, &(sg_dma_address_u64(os_sgl))); ++ sg_dma_address(os_sgl) = ++ PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(cmd->instance->dma_addr_bit_pos, sg_dma_address_u64(os_sgl)); + } + + cmd->os_sge_map_count = os_sge_count; +@@ -3210,46 +3318,23 @@ + if (os_sge_count == 0) { + goto l_out; + } +-#ifdef _WINDOWS +- if (scp->is_remap_databuff) { +- if (ps3_scsi_unremap_sgl(cmd) == PS3_SUCCESS) { +- goto l_out; +- } +- } +-#endif + scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { + if (os_sgl == NULL) { + break; + } +- sg_dma_address(os_sgl) = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR(sg_dma_address_u64(os_sgl)); ++ sg_dma_address(os_sgl) = ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(cmd->instance->dma_addr_bit_pos, ++ sg_dma_address_u64(os_sgl)); + } +-#ifndef _WINDOWS + if (scp->sdb.table.sgl) { + scsi_dma_unmap(scp); + } +-#endif + cmd->os_sge_map_count = 0; + + l_out: + return; + } + +-struct disk_type_to_proc_func_table* ps3_req_func_entry_query(U8 dev_type) +-{ +- struct disk_type_to_proc_func_table *entry = NULL; +- U32 table_size = ARRAY_SIZE(g_req_frame_func_table); +- U32 i = 0; +- +- for (; i < table_size; ++i) { +- if (dev_type == g_req_frame_func_table[i].type) { +- entry = &g_req_frame_func_table[i]; +- goto l_out; +- } +- } +-l_out: +- return entry; +-} +- + static S32 ps3_vd_access_policy_check(struct ps3_instance *instance, + U8 channel, U16 id, struct scsi_cmnd *s_cmd) + { +@@ -3257,13 +3342,14 @@ + U8 opcode = 0; + U16 sub_opcode = 0; + struct PS3VDEntry *entry = ps3_dev_mgr_lookup_vd_info(instance, channel, id); ++ static unsigned long j; + if (unlikely(entry == NULL)) { + #ifndef _WINDOWS + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_BAD_TARGET); + #else + scsi_cmnd_hoststatus_set(s_cmd, DID_BAD_TARGET); + #endif +- LOG_ERROR("hno:%u chl:%u id:%u\n", ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u chl:%u id:%u\n", + PS3_HOST(instance), channel, id); + ret = -PS3_ENODEV; + goto l_out; +@@ -3317,3 +3403,20 @@ + + return result; + } ++ ++Bool ps3_ssd_vd_qmask_calculate_hba(struct ps3_cmd *cmd) ++{ ++ Bool ret = PS3_FALSE; ++ struct ps3_scsi_priv_data *device_priv_data = NULL; ++ ++ device_priv_data = PS3_SDEV_PRI_DATA(cmd->scmd->device); ++ if (device_priv_data != NULL) { ++ cmd->cmd_word.qMask = 1 << ++ (device_priv_data->qmask_count & (cmd->instance->ctrl_info.vdQueueNum - 1)); ++ device_priv_data->qmask_count++; ++ ret = PS3_TRUE; ++ } ++ ++ return ret; ++} ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsih_cmd_parse.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsih_cmd_parse.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsih_cmd_parse.c 2025-06-10 20:13:00.266055062 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsih_cmd_parse.c 2025-06-10 20:13:00.543064725 +0800 +@@ -801,3 +801,4 @@ + ps3_scsih_cdb_parse(cdb, &num_blocks, &lba_lo, &lba_hi, &is_need_split); + *len = num_blocks; + } ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsih.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsih.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsih.h 2025-06-10 20:13:00.265055027 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsih.h 2025-06-10 20:13:00.542064690 +0800 +@@ -12,6 +12,10 @@ + #include "ps3_htp_def.h" + #include "ps3_inner_data.h" + ++#define PS3_HW_VD_MAX_IO_SIZE_1M (1ULL << 20) ++#define PS3_PAGE_MODE_ABOVE_3_ADDR_MASK 0xFFFFFF8000000000ULL ++#define PS3_PAGE_MODE_ABOVE_4_ADDR_MASK 0xFFFF000000000000ULL ++ + #define PS3_IS_R0J1(raidlevel) \ + ((raidlevel) == RAID0 || (raidlevel) == RAID1 || \ + (raidlevel) == RAID10 || (raidlevel) == RAID1E || \ +@@ -117,8 +121,6 @@ + + S32 ps3_scsi_dma_map(struct ps3_cmd *cmd); + +-struct disk_type_to_proc_func_table* ps3_req_func_entry_query(U8 dev_type); +- + Bool ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd_entry); + +@@ -142,4 +144,6 @@ + + Bool ps3_write_direct_enable(struct ps3_cmd *cmd); + ++Bool ps3_ssd_vd_qmask_calculate_hba(struct ps3_cmd *cmd); ++ + #endif +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsih_raid_engine.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsih_raid_engine.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsih_raid_engine.c 2025-06-10 20:13:00.266055062 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsih_raid_engine.c 2025-06-10 20:13:00.548064900 +0800 +@@ -100,8 +100,6 @@ + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -244,8 +242,6 @@ + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -286,8 +282,6 @@ + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -326,8 +320,6 @@ + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -399,8 +391,6 @@ + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -462,8 +452,6 @@ + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -494,8 +482,6 @@ + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -539,8 +525,6 @@ + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -693,10 +677,10 @@ + { + S32 ret = PS3_SUCCESS; + PS3VDAccAttr_s *acc_attr = &cmd->req_frame->frontendReq.vdAccAttr; +- ++ static unsigned long j; + ret = ps3_scsih_vlba_to_pd_calc(cmd); + if (ret != PS3_SUCCESS) { +- LOG_ERROR("trace_id:0x%llx host_no:%u vlba calc NOK\n", ++ LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "trace_id:0x%llx host_no:%u vlba calc NOK\n", + cmd->trace_id, PS3_HOST(cmd->instance)); + acc_attr->isAccActive = 0; + goto l_out; +@@ -718,7 +702,7 @@ + + ret = ps3_scsih_vlba_to_pd_calc(cmd); + if (ret != PS3_SUCCESS) { +- LOG_ERROR_LIM("trace_id:0x%llx host_no:%u vlba calc NOK\n", ++ LOG_WARN_LIM("trace_id:0x%llx host_no:%u vlba calc NOK\n", + cmd->trace_id, PS3_HOST(cmd->instance)); + goto l_out; + } +@@ -734,31 +718,35 @@ + U16 i = 0; + struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; + struct ps3_instance *instance = cmd->instance; +- PS3_BUG_ON(cmd->target_pd_count > PS3_QOS_MAX_PD_IN_VD); ++ if (unlikely(cmd->target_pd_count >= PS3_QOS_MAX_PD_IN_VD)) { ++ LOG_INFO("host_no:%u CFID:%u did:%u target pd count %u check NOK\n", ++ PS3_HOST(instance), cmd->index, disk_id, cmd->target_pd_count); ++ goto l_out; ++ } + if (disk_id > instance->ctrl_info.maxPdCount ) { + LOG_DEBUG("disk_id is error.host_no:%u CFID:%u did:%u\n", + PS3_HOST(instance), cmd->index, disk_id); +- goto _lout; ++ goto l_out; + } + + qos_pd_mgr = &instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; + if (ps3_atomic_read(&qos_pd_mgr->valid) != 1) { + LOG_DEBUG("qos pd is invalid. host_no:%u CFID:%u did:%u\n", + PS3_HOST(instance), cmd->index, disk_id); +- goto _lout; ++ goto l_out; + } + + for (i = 0; i < cmd->target_pd_count; i++) { + if (cmd->target_pd[i].flat_disk_id == disk_id) { + cmd->target_pd[i].strip_count++; +- goto _lout; ++ goto l_out; + } + } + + cmd->target_pd[cmd->target_pd_count].flat_disk_id = disk_id; + cmd->target_pd[cmd->target_pd_count].strip_count = 1; + cmd->target_pd_count++; +-_lout: ++l_out: + return; + } + +@@ -792,7 +780,7 @@ + ps3_r0_vlba_to_pd(cmd, vlba); + if (first_strip) { + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); +- strip_len = PS3_MIN(strip_len , left_len); ++ strip_len = PS3_MIN(strip_len, left_len); + first_strip = PS3_FALSE; + } else { + strip_len = PS3_MIN(left_len, vd_entry->stripSize); +@@ -864,7 +852,7 @@ + ps3_r00_vlba_to_pd(cmd, vlba); + if (first_strip) { + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); +- strip_len = PS3_MIN(strip_len , left_len); ++ strip_len = PS3_MIN(strip_len, left_len); + first_strip = PS3_FALSE; + } else { + strip_len = PS3_MIN(left_len, vd_entry->stripSize); +@@ -883,7 +871,6 @@ + U32 span_parity_disk_idx = 0; + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + U16 disk_id = 0; +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); + + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); +@@ -920,7 +907,7 @@ + ps3_r5_vlba_to_pd(cmd, vlba); + if (first_strip) { + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); +- strip_len = PS3_MIN(strip_len , left_len); ++ strip_len = PS3_MIN(strip_len, left_len); + first_strip = PS3_FALSE; + } else { + strip_len = PS3_MIN(left_len, vd_entry->stripSize); +@@ -940,8 +927,6 @@ + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + U16 disk_id = 0; + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -975,7 +960,7 @@ + ps3_r6_vlba_to_pd(cmd, vlba); + + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); +- strip_len = PS3_MIN(strip_len , left_len); ++ strip_len = PS3_MIN(strip_len, left_len); + left_len -= strip_len; + vlba += strip_len; + while (left_len > 0) { +@@ -998,8 +983,6 @@ + U16 disk_id = 0; + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -1039,7 +1022,7 @@ + ps3_r50_vlba_to_pd(cmd, vlba); + + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); +- strip_len = PS3_MIN(strip_len , left_len); ++ strip_len = PS3_MIN(strip_len, left_len); + left_len -= strip_len; + vlba += strip_len; + while (left_len > 0) { +@@ -1062,8 +1045,6 @@ + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + U16 disk_id = 0; + +- PS3_BUG_ON(vd_entry->stripeDataSize == 0); +- + LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); + LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); + +@@ -1098,7 +1079,7 @@ + ps3_r60_vlba_to_pd(cmd, vlba); + + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); +- strip_len = PS3_MIN(strip_len , left_len); ++ strip_len = PS3_MIN(strip_len, left_len); + left_len -= strip_len; + vlba += strip_len; + while (left_len > 0) { +@@ -1197,7 +1178,7 @@ + } + + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); +- strip_len = PS3_MIN(strip_len , left_len); ++ strip_len = PS3_MIN(strip_len, left_len); + left_len -= strip_len; + vlba += strip_len; + while (left_len > 0) { +@@ -1288,7 +1269,7 @@ + } + + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); +- strip_len = PS3_MIN(strip_len , left_len); ++ strip_len = PS3_MIN(strip_len, left_len); + left_len -= strip_len; + vlba += strip_len; + while (left_len > 0) { +@@ -1328,7 +1309,7 @@ + U16 disk_id = 0; + struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; + struct ps3_qos_pd_mgr *qos_peer_pd_mgr = NULL; +- ++ static unsigned long j; + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + vd_entry = cmd->io_attr.vd_entry; + +@@ -1375,8 +1356,9 @@ + ps3_r60_target_pd_get(cmd); + break; + default: +- LOG_ERROR("trace_id:0x%llx host_no:%u vd level:%d is illegal\n", +- cmd->trace_id, PS3_HOST(cmd->instance), ++ LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, ++ "trace_id:0x%llx host_no:%u vd level:%d is illegal\n", ++ cmd->trace_id, PS3_HOST(cmd->instance), + cmd->io_attr.vd_entry->raidLevel); + } + +@@ -1390,3 +1372,36 @@ + PS3_HOST(cmd->instance), cmd->index, cmd->cmd_word.type, cmd->target_pd_count, + cmd->io_attr.dev_type, cmd->io_attr.disk_id); + } ++ ++U16 ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry) ++{ ++ U16 ret = PS3_IS_SSD_EVEN_R1X_VD; ++ U8 span_idx = 0; ++ ++ if (!vd_entry->isSsd) { ++ ret = PS3_IS_HDD_R1X_VD; ++ goto l_out; ++ } ++ switch (vd_entry->raidLevel) { ++ case RAID10: ++ for (; span_idx < vd_entry->spanCount; span_idx++) { ++ if (VD_SPAN_PD_NUM(vd_entry, span_idx) & 1) { ++ ret = PS3_IS_SSD_ODD_R1X_VD; ++ goto l_out; ++ } ++ } ++ break; ++ case RAID1E: ++ if (VD_SPAN_PD_NUM(vd_entry, 0) & 1) { ++ ret = PS3_IS_SSD_ODD_R1X_VD; ++ goto l_out; ++ } ++ break; ++ default: ++ ret = PS3_IS_VALID_R1X_VD; ++ break; ++ } ++l_out: ++ return ret; ++} ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsih_raid_engine.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsih_raid_engine.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_scsih_raid_engine.h 2025-06-10 20:13:00.266055062 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_scsih_raid_engine.h 2025-06-10 20:13:00.548064900 +0800 +@@ -6,6 +6,13 @@ + #include "ps3_err_def.h" + #include "ps3_cmd_channel.h" + ++enum ps3_odd_r1x_vd_judge_type { ++ PS3_IS_HDD_R1X_VD, ++ PS3_IS_SSD_ODD_R1X_VD, ++ PS3_IS_SSD_EVEN_R1X_VD, ++ PS3_IS_VALID_R1X_VD ++}; ++ + Bool ps3_scsih_is_same_strip(const struct PS3VDEntry *vd_entry, U32 vlba_lo, U32 lba_length); + + S32 ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd); +@@ -16,4 +23,6 @@ + + void ps3_qos_cmd_member_pd_calc(struct ps3_cmd *cmd); + ++U16 ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry); ++ + #endif +\ No newline at end of file +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_util.h ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_util.h +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_util.h 2025-06-10 20:13:00.285055725 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_util.h 2025-06-10 20:13:00.549064934 +0800 +@@ -13,8 +13,11 @@ + + #define PS3_DRV_MAX(x, y) ((x) > (y) ? (x) : (y)) + +-#define PCIE_DMA_HOST_ADDR_HIGH_2BITS_MASK_CHECK(addr) \ +- (((1ULL) << PCIE_DMA_HOST_ADDR_BIT_POS) & (addr)) ++#define PCIE_DMA_HOST_ADDR_BIT53_MASK_CHECK(addr) \ ++ (((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS_F1)) & (addr)) ++ ++#define PCIE_DMA_HOST_ADDR_BIT54_MASK_CHECK(addr) \ ++ (((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS_F0)) & (addr)) + + enum { + PS3_BLOCK_SIZE_16 = 16, +@@ -273,7 +276,19 @@ + return shift; + } + +-#ifndef _WINDOWS ++static U8 ps3_dma_addr_bit_pos_check(dma_addr_t handle) ++{ ++ U8 bit_pos = 0; ++ ++ if (PCIE_DMA_HOST_ADDR_BIT54_MASK_CHECK(handle)) ++ bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F0; ++ else if (PCIE_DMA_HOST_ADDR_BIT53_MASK_CHECK(handle)) ++ bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F1; ++ else ++ bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS; ++ ++ return bit_pos; ++} + + static inline struct dma_pool *ps3_dma_pool_create(const char *name, + struct device *dev, size_t size, size_t align, size_t boundary) +@@ -285,21 +300,22 @@ + return pool; + } + +-static inline void *ps3_dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, +- dma_addr_t *handle) ++static inline void *ps3_dma_pool_alloc(struct ps3_instance *instance, ++ struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle) + { + void *ret = dma_pool_alloc(pool, mem_flags, handle); + if(ret != NULL) { +- *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET(*handle); ++ *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, *handle); + } + return ret; + } + +-static inline void *ps3_dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags, ++static inline void *ps3_dma_pool_zalloc(struct ps3_instance *instance, ++ struct dma_pool *pool, gfp_t mem_flags, + dma_addr_t *handle) + { + void *ret = dma_pool_zalloc(pool, mem_flags, handle); +- *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET(*handle); ++ *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, *handle); + return ret; + } + +@@ -313,7 +329,10 @@ + static inline void ps3_dma_pool_free(struct dma_pool *pool, + void *vaddr, dma_addr_t dma) + { +- dma_pool_free(pool, vaddr, PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR(dma)); ++ U8 bit_pos = 0; ++ ++ bit_pos = ps3_dma_addr_bit_pos_check(dma); ++ dma_pool_free(pool, vaddr, PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dma)); + return; + } + +@@ -350,47 +369,24 @@ + l_out: + return ret; + } +-#endif + + static inline void *ps3_dma_alloc_coherent(struct ps3_instance *instance, size_t size, + U64 *handle) + { + void *buffer = NULL; +-#ifndef _WINDOWS + buffer = dma_alloc_coherent(&instance->pdev->dev, size, handle, GFP_KERNEL); +-#else +- if (ps3_dma_alloc(instance, size, &buffer, handle) != PS3_SUCCESS) { +- goto l_out; +- } +- +- PS3_BUG_ON(PCIE_DMA_HOST_ADDR_HIGH_2BITS_MASK_CHECK(*handle)); +- if (PCIE_DMA_HOST_ADDR_HIGH_2BITS_MASK_CHECK(*handle) != 0) { +- LOG_ERROR("the high 62 bit is valid:0x%x\n", *handle); +- ps3_dma_free(instance, size, buffer); +- buffer = NULL; +- *handle = 0; +- goto l_out; +- } +- +- memset(buffer, 0, size); +- +-#endif +- *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET(*handle); +-#ifdef _WINDOWS +-l_out: +-#endif ++ *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, *handle); + return buffer; + } + + static inline void ps3_dma_free_coherent(struct ps3_instance *instance, size_t size, + void *vaddr, U64 dma_handle) + { +-#ifndef _WINDOWS +- dma_free_coherent(&instance->pdev->dev, size, vaddr, PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR(dma_handle)); +-#else +- (void)dma_handle; +- ps3_dma_free(instance, size, vaddr); +-#endif ++ U8 bit_pos = 0; ++ ++ bit_pos = ps3_dma_addr_bit_pos_check(dma_handle); ++ dma_free_coherent(&instance->pdev->dev, size, vaddr, ++ PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dma_handle)); + return; + } + +@@ -412,3 +408,4 @@ + return remainder; + } + #endif ++ +diff -urN ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_watchdog.c ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_watchdog.c +--- ps3stor-2.3.0.3/ps3stor-2.3.0.3-src-kylin_bak/ps3_watchdog.c 2025-06-10 20:13:00.285055725 +0800 ++++ ps3stor-2.5.0.30/ps3stor-2.5.0.30-src-m/ps3_watchdog.c 2025-06-10 20:13:00.549064934 +0800 +@@ -25,6 +25,7 @@ + U32 ioc_recovery_count = 0; + U32 ioc_state = PS3_FW_STATE_UNDEFINED; + S32 ret = PS3_SUCCESS; ++ U32 heartbeat_triggered = 0; + + if (ps3_pci_err_recovery_get(instance)) { + LOG_WARN_LIM("hno:%u pci recovery resetting\n", +@@ -50,13 +51,15 @@ + + if (instance->ioc_adpter->ioc_heartbeat_detect) { + if ((instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE || +- instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY) ++ instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY || ++ instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RETRY) + &&(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { + goto l_out; + } + +- if (instance->ioc_adpter->ioc_heartbeat_detect(instance) == PS3_TRUE ++ heartbeat_triggered = instance->ioc_adpter->ioc_heartbeat_detect(instance); ++ if (heartbeat_triggered == PS3_TRUE + && !ps3_pci_err_recovery_get(instance)) { + LOG_INFO("hno:%u heartbeat recovery triggered\n", + PS3_HOST(instance)); +@@ -112,6 +115,8 @@ + LOG_WARN_LIM("hno:%u can not start reset request recovery_state:%d\n", + PS3_HOST(instance), instance->recovery_context->recovery_state); + } else { ++ LOG_WARN("hno:%u ps3 watchdog recovery start, heartbeat_triggered:%u ioc_state:0x%x\n", ++ PS3_HOST(instance), heartbeat_triggered, ioc_state); + if(ps3_recovery_request(instance) == PS3_SUCCESS){ + LOG_INFO("hno[%u], recovery success!\n", + PS3_HOST(instance)); +@@ -257,7 +262,7 @@ + + destroy_workqueue(watchdog_queue); + watchdog_ctx->watchdog_queue = NULL; +- LOG_WARN("hno:%u watchdog destory work and stop\n", ++ LOG_INFO("hno:%u watchdog destroy work and stop\n", + PS3_HOST(instance)); + } + } +@@ -344,3 +349,4 @@ + PS3_HOST(instance)); + } + #endif ++ diff --git a/drivers/scsi/linkdata/ps3stor/Makefile b/drivers/scsi/linkdata/ps3stor/Makefile index f2ece28ab46d..f6d15a4841bd 100644 --- a/drivers/scsi/linkdata/ps3stor/Makefile +++ b/drivers/scsi/linkdata/ps3stor/Makefile @@ -1,57 +1,31 @@ # SPDX-License-Identifier: GPL-2.0 -# Copyright (c) LD. +EXTRA_CFLAGS += -DPS3_CFG_RELEASE +EXTRA_CFLAGS += -DPS3_HARDWARE_ASIC +EXTRA_CFLAGS += -DPS3_MODEL_V200 -obj-$(CONFIG_SCSI_PS3STOR) += ps3stor.o +ifneq ($(KERNELRELEASE),) +CONFIG_MODULE_SIG=n +obj-m += ps3stor.o -ps3stor-objs := \ - ps3_cmd_channel.o \ - ps3_device_update.o \ - ps3_ioc_manager.o \ - ps3_mgr_channel.o \ - ps3_platform_utils.o \ - ps3_scsi_cmd_err.o \ - ps3_cmd_complete.o \ - ps3_ioc_state.o \ - ps3_mgr_cmd.o \ - ps3_qos.o \ - ps3_scsih.o \ - ps3_cmd_statistics.o \ - ps3_event.o \ - ps3_ioctl.o \ - ps3_mgr_cmd_err.o \ - ps3_r1x_write_lock.o \ - ps3_scsih_cmd_parse.o \ - ps3_debug.o \ - ps3_io_trace.o \ - ps3_module_para.o \ - ps3_rb_tree.o \ - ps3_scsih_raid_engine.o \ - ps3_device_manager.o \ - ps3_instance_manager.o \ - ps3_irq.o \ - ps3_nvme_resp_to_scsi.o \ - ps3_recovery.o \ - ps3_trace_id_alloc.o \ - ps3_device_manager_sas.o \ - ps3_ioc_adp.o \ - ps3_load.o \ - ps3_pci.o \ - ps3_sas_transport.o \ - ps3_watchdog.o \ - ./linux/ps3_base.o \ - ./linux/ps3_cli.o \ - ./linux/ps3_cli_debug.o \ - ./linux/ps3_driver_log.o \ - ./linux/ps3_dump.o \ - ./linux/ps3_pcie_err_handle.o +ps3stor-objs := $(patsubst %.c, %.o, $(notdir $(wildcard $(src)/*.c))) +ps3stor-objs += $(patsubst %.c, linux/%.o, $(notdir $(wildcard $(src)/linux/*.c))) -ccflags-y += -DPS3_CFG_RELEASE -ccflags-y += -DPS3_HARDWARE_ASIC -ccflags-y += -DPS3_MODEL_V200 -ccflags-y += -Werror +ccflags-y += -Werror -frecord-gcc-switches ccflags-y += $(call cc-option, -Wmaybe-uninitialized) -ccflags-y += \ - -I$(srctree)/drivers/scsi/linkdata/ps3stor \ - -I$(srctree)/drivers/scsi/linkdata/ps3stor/linux \ - -I$(srctree)/drivers/scsi/linkdata/ps3stor/include \ - -I$(srctree)/drivers/scsi/linkdata/ps3stor/include/htp_v200 +ccflags-y += -I$(src) -I$(src)/linux -I$(src)/include/htp_v200 -I$(src)/include/ +else + KDIR ?= /lib/modules/`uname -r`/build + +all: + @echo "ARCH=$(ARCH)" + @echo "KDIR=$(KDIR)" + @echo "OS=$(OS_SYSTEM)" + @echo "EXTRA_CFLAGS=$(EXTRA_CFLAGS)" + @$(MAKE) -C $(KDIR) M=$(PWD) INCDIR=$(PWD)/linux modules +clean: + @rm -rf *.o *.d *.ko Module.* modules.* *.mod.* .*.d .*.cmd .tmp_versions *.o.ur-safe + @rm -rf ./linux/*.o + @rm -rf ./tags + @rm -rf ./output.log +endif + diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp.h index dae1c28b8d77..3db2f8dbf8e1 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_HTP_H_ #define _PS3_HTP_H_ @@ -7,40 +6,40 @@ #include "ps3_htp_dev.h" #include "ps3_htp_req_frame_hw.h" -#define PS3_DUMP_CTRL_COPY_FINISH 0x1 -#define PS3_DUMP_CTRL_DUMP_ABORT 0x2 -#define PS3_DUMP_CTRL_DUMP_FW_LOG 0x3 -#define PS3_DUMP_CTRL_DUMP_BAR_DATA 0x4 -#define PS3_DUMP_CTRL_DUMP_CORE_FILE 0x5 -#define PS3_DUMP_CTRL_DUMP_END 0x6 -#define PS3_DUMP_CTRL_DUMP_INT_READY 0x7 -#define PS3_DUMP_DMA_DONE (0x1) -#define PS3_DUMP_DMA_ABORT (0x1 << 6) -#define PS3_DUMP_DATA_UNIT_SIZE (0x400) -#define PS3_DREICT_SENSE_DATA_BUF_SIZE 72 - -#define PS3_ATU_FLAG_LOW_BITS_MASK (0x0000FFFF) -#define PS3_ATU_FLAG_HIGH_BITS_MASK (0xFFFFFFFFFFFF0000) -#define PS3_ATU_FLAG_DRIVER_SET (0xC0DE) +#define PS3_DUMP_CTRL_COPY_FINISH 0x1 +#define PS3_DUMP_CTRL_DUMP_ABORT 0x2 +#define PS3_DUMP_CTRL_DUMP_FW_LOG 0x3 +#define PS3_DUMP_CTRL_DUMP_BAR_DATA 0x4 +#define PS3_DUMP_CTRL_DUMP_CORE_FILE 0x5 +#define PS3_DUMP_CTRL_DUMP_END 0x6 +#define PS3_DUMP_CTRL_DUMP_INT_READY 0x7 +#define PS3_DUMP_DMA_DONE (0x1) +#define PS3_DUMP_DMA_ABORT (0x1 << 6) +#define PS3_DUMP_DATA_UNIT_SIZE (0x400) +#define PS3_DREICT_SENSE_DATA_BUF_SIZE 72 + +#define PS3_ATU_FLAG_LOW_BITS_MASK (0x0000FFFF) +#define PS3_ATU_FLAG_HIGH_BITS_MASK (0xFFFFFFFFFFFF0000) +#define PS3_ATU_FLAG_DRIVER_SET (0xC0DE) #define PS3_IOCTL_VERSION (0x2000000) -enum { - HIL_MODEL_SW = 0, - HIL_MODEL_HW, - HIL_MODEL_HW_ENHANCED, - HIL_MODEL_SW_ASSIST, -}; - -enum Ps3DumpType { - PS3_DUMP_TYPE_UNKNOWN = 0, - PS3_DUMP_TYPE_CRASH = 1, - PS3_DUMP_TYPE_FW_LOG = 2, - PS3_DUMP_TYPE_BAR_DATA = 3, +typedef enum{ + HIL_MODEL_SW = 0, + HIL_MODEL_HW, + HIL_MODEL_HW_ENHANCED, + HIL_MODEL_SW_ASSIST, +}hilModel_e; + +enum Ps3DumpType{ + PS3_DUMP_TYPE_UNKNOWN = 0, + PS3_DUMP_TYPE_CRASH = 1, + PS3_DUMP_TYPE_FW_LOG = 2, + PS3_DUMP_TYPE_BAR_DATA = 3, }; enum Ps3DumpState { - PS3_DUMP_STATE_INVALID = 0, + PS3_DUMP_STATE_INVALID = 0, PS3_DUMP_STATE_PRE_ABORT, PS3_DUMP_STATE_ABORTED, PS3_DUMP_STATE_START, @@ -54,226 +53,226 @@ enum Ps3CtrlSecurityState { }; struct Ps3DumpNotifyInfo { - int dumpType; + S32 dumpType; }; struct PS3LinkErrInfo { - unsigned int invalidDwordCount; - unsigned int runningDisparityErrCount; - unsigned int lossOfDwordSyncCount; - unsigned int phyResetProblemCount; + U32 invalidDwordCount; + U32 runningDisparityErrCount; + U32 lossOfDwordSyncCount; + U32 phyResetProblemCount; }; enum PhyCtrl { - PS3_SAS_CTRL_UNKNOWN = 0, - PS3_SAS_CTRL_RESET = 1, - PS3_SAS_CTRL_RESET_HARD = 2, - PS3_SAS_CTRL_DISABLE = 3 + PS3_SAS_CTRL_UNKNOWN = 0, + PS3_SAS_CTRL_RESET = 1, + PS3_SAS_CTRL_RESET_HARD = 2, + PS3_SAS_CTRL_DISABLE = 3 }; enum { PS3_UNLOAD_SUB_TYPE_RESERVED = 0, - PS3_UNLOAD_SUB_TYPE_REMOVE = 1, + PS3_UNLOAD_SUB_TYPE_REMOVE = 1, PS3_UNLOAD_SUB_TYPE_SHUTDOWN = 2, - PS3_UNLOAD_SUB_TYPE_SUSPEND = 3, + PS3_UNLOAD_SUB_TYPE_SUSPEND = 3, }; enum { - PS3_SUSPEND_TYPE_NONE = 0, - PS3_SUSPEND_TYPE_SLEEP = 1, + PS3_SUSPEND_TYPE_NONE = 0, + PS3_SUSPEND_TYPE_SLEEP = 1, PS3_SUSPEND_TYPE_HIBERNATE = 2, }; -static inline const char *namePhyCtrl(enum PhyCtrl e) +static inline const S8 * namePhyCtrl(enum PhyCtrl e) { - static const char * const myNames[] = { - [PS3_SAS_CTRL_UNKNOWN] = "PS3_SAS_CTRL_UNKNOWN", - [PS3_SAS_CTRL_RESET] = "PS3_SAS_CTRL_RESET", - [PS3_SAS_CTRL_RESET_HARD] = "PS3_SAS_CTRL_RESET_HARD", - [PS3_SAS_CTRL_DISABLE] = "PS3_SAS_CTRL_DISABLE" - }; - - return myNames[e]; + static const S8 *myNames[] = { + [PS3_SAS_CTRL_UNKNOWN] = "PS3_SAS_CTRL_UNKNOWN", + [PS3_SAS_CTRL_RESET] = "PS3_SAS_CTRL_RESET", + [PS3_SAS_CTRL_RESET_HARD] = "PS3_SAS_CTRL_RESET_HARD", + [PS3_SAS_CTRL_DISABLE] = "PS3_SAS_CTRL_DISABLE" + }; + + return myNames[e]; } struct PS3InitCmdWord { - union { - struct { - unsigned int type : 2; - unsigned int reserved1 : 1; - unsigned int direct : 2; - unsigned int reserved2 : 27; - }; - unsigned int lowAddr; - }; - - unsigned int highAddr; + union { + struct { + U32 type : 2; + U32 reserved1 : 1; + U32 direct : 2; + U32 reserved2 : 27; + }; + U32 lowAddr; + }; + + U32 highAddr; }; -struct PS3CmdWord { - unsigned short type : 2; - unsigned short reserved1 : 2; - unsigned short direct : 2; - unsigned short isrSN : 8; - unsigned short reserved2 : 2; - unsigned short cmdFrameID : 13; - unsigned short reserved3 : 3; - unsigned short phyDiskID : 12; - unsigned short reserved4 : 4; - unsigned short virtDiskID : 8; - unsigned short reserved5 : 4; - unsigned short qMask : 4; -}; +typedef struct PS3CmdWord { + U16 type : 2; + U16 reserved1 : 2; + U16 direct : 2; + U16 isrSN : 8; + U16 reserved2 : 2; + U16 cmdFrameID : 13; + U16 reserved3 : 3; + U16 phyDiskID : 12; + U16 reserved4 : 4; + U16 virtDiskID : 8; + U16 reserved5 : 4; + U16 qMask : 4; +} PS3CmdWord_s; struct PS3CmdWordSw { - unsigned int type : 2; - unsigned int noReplyWord : 1; - unsigned int cmdFrameID : 13; - unsigned int isrSN : 8; - unsigned int cmdIndex : 8; + U32 type : 2; + U32 noReplyWord : 1; + U32 cmdFrameID : 13; + U32 isrSN : 8; + U32 cmdIndex : 8; }; union PS3CmdWordU32 { struct PS3CmdWordSw cmdWord; - unsigned int val; + U32 val; }; union PS3DefaultCmdWord { - struct PS3CmdWord cmdWord; - union { - struct { - unsigned int low; - unsigned int high; - } u; - unsigned long long words; - }; + struct PS3CmdWord cmdWord; + union { + struct{ + U32 low; + U32 high; + } u; + U64 words; + }; }; -enum { - PS3_ISR_ACC_MODE_LATENCY = 0, - PS3_ISR_ACC_MODE_SSD_IOPS, - PS3_ISR_ACC_MODE_HDD_IOPS, +enum{ + PS3_ISR_ACC_MODE_LATENCY = 0, + PS3_ISR_ACC_MODE_SSD_IOPS, + PS3_ISR_ACC_MODE_HDD_IOPS, PS3_ISR_ACC_MODE_IOPS_VER0 = 2, PS3_ISR_ACC_MODE_DEV_IOPS, - PS3_ISR_ACC_MODE_MAX, + PS3_ISR_ACC_MODE_MAX, }; struct PS3ReplyFifoDesc { - unsigned long long ReplyFifoBaseAddr; - unsigned int irqNo; - unsigned short depthReplyFifo; - unsigned char isrAccMode; - unsigned char reserved; + U64 ReplyFifoBaseAddr; + U32 irqNo; + U16 depthReplyFifo; + U8 isrAccMode; + U8 reserved; }; -struct PS3ReplyWord { - unsigned short type : 2; - unsigned short diskType : 1; - unsigned short reserved1 : 1; - unsigned short mode : 2; - unsigned short reserved2 : 10; - unsigned short cmdFrameID : 13; - unsigned short reserved3 : 2; - unsigned short reserved4 : 1; - unsigned short retStatus : 15; - unsigned short retType : 1; - unsigned short reserved5 : 12; - unsigned short qMask : 4; -}; +typedef struct PS3ReplyWord { + U16 type : 2; + U16 diskType : 1; + U16 reserved1 : 1; + U16 mode : 2; + U16 reserved2 : 10; + U16 cmdFrameID : 13; + U16 reserved3 : 2; + U16 reserved4 : 1; + U16 retStatus : 15; + U16 retType : 1; + U16 reserved5 : 12; + U16 qMask : 4; +} PS3ReplyWord_s; struct PS3MgrTaskRespInfo { - unsigned char iocStatus; - unsigned char reserved1; - unsigned short iocLogInfo; - unsigned int terminationCnt; - unsigned int respInfo; - unsigned int reserved2; + U8 iocStatus; + U8 reserved1; + U16 iocLogInfo; + U32 terminationCnt; + U32 respInfo; + U32 reserved2; }; struct PS3MgrCmdReplyRespInfo { - unsigned char cmdReplyStatus; - unsigned char reserved[15]; + U8 cmdReplyStatus; + U8 reserved[15]; }; union PS3RespDetails { - unsigned int xfer_cnt; - unsigned int respData[4]; - struct PS3MgrTaskRespInfo taskMgrRespInfo; - struct PS3MgrCmdReplyRespInfo replyCmdRespInfo; -}; - - -struct PS3SasDirectRespStatus { - unsigned int status : 8; - unsigned int dataPres : 2; - unsigned int reserved : 22; -}; - - -struct Ps3SasDirectRespFrameIU { - union { - unsigned char reserved0[8]; - unsigned long long mediumErrorLba; - }; - unsigned char reserved1[2]; - unsigned char dataPres; - unsigned char status; - union { - unsigned int reserved2; - unsigned int xfer_cnt; - }; - unsigned int senseDataLen; - unsigned int respDataLen; - unsigned char data[PS3_SENSE_BUFFER_SIZE]; - unsigned char reserved3[8]; -}; - - -struct PS3NormalRespFrame { - union PS3RespDetails respDetail; - unsigned char reserved1[8]; - unsigned char sense[PS3_SENSE_BUFFER_SIZE]; - unsigned char type; - unsigned char reserved2[3]; - unsigned char respStatus; - unsigned char dataPre; - unsigned char reserved3[2]; + U32 xfer_cnt; + U32 respData[4]; + struct PS3MgrTaskRespInfo taskMgrRespInfo; + struct PS3MgrCmdReplyRespInfo replyCmdRespInfo; }; -union PS3RespFrame { - struct Ps3SasDirectRespFrameIU sasRespFrame; - struct PS3NormalRespFrame normalRespFrame; -}; - -struct Ps3DebugMemEntry { - unsigned long long debugMemAddr; - unsigned int debugMemSize; - unsigned int reserved; -}; - - -struct PS3NvmeCmdStatus { - union { - struct { - unsigned short sc : 8; - unsigned short sct : 3; - unsigned short crd : 2; - unsigned short m : 1; - unsigned short dnr : 1; - unsigned short p : 1; - }; - unsigned short cmdStatus; - }; -}; +typedef struct PS3SasDirectRespStatus { + U32 status:8; + U32 dataPres:2; + U32 reserved:22; +} PS3SasStatus_s; + + +typedef struct Ps3SasDirectRespFrameIU { + union { + U8 reserved0[8]; + U64 mediumErrorLba; + }; + U8 reserved1[2]; + U8 dataPres; + U8 status; + union { + U32 reserved2; + U32 xfer_cnt; + }; + U32 senseDataLen; + U32 respDataLen; + U8 data[PS3_SENSE_BUFFER_SIZE]; + U8 reserved3[8]; +} Ps3SasDirectRespFrameIU_s; + + +typedef struct PS3NormalRespFrame { + union PS3RespDetails respDetail; + U8 reserved1[8]; + U8 sense[PS3_SENSE_BUFFER_SIZE]; + U8 type; + U8 reserved2[3]; + U8 respStatus; + U8 dataPre; + U8 reserved3[2]; +} PS3NormalRespFrame_s; + +typedef union PS3RespFrame{ + Ps3SasDirectRespFrameIU_s sasRespFrame; + PS3NormalRespFrame_s normalRespFrame; +}PS3RespFrame_u; + + +typedef struct Ps3DebugMemEntry { + U64 debugMemAddr; + U32 debugMemSize; + U32 reserved; +} Ps3DebugMemEntry_s; + + +typedef struct PS3NvmeCmdStatus { + union { + struct { + U16 sc : 8; + U16 sct : 3; + U16 crd : 2; + U16 m : 1; + U16 dnr : 1; + U16 p : 1; + }; + U16 cmdStatus; + }; +} PS3NvmeCmdStatus_s; #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_def.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_def.h index c55fc5ad7468..796c9c8335c0 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_def.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_def.h @@ -1,531 +1,522 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_HTP_DEF_H_ #define _PS3_HTP_DEF_H_ +#include "ps3_types.h" - - +typedef unsigned char Bool; #define PCIE_DMA_HOST_ADDR_BIT_POS (44) -#define PCIE_DMA_HOST_ADDR_BIT_POS_SET(addr) \ +#define PCIE_DMA_HOST_ADDR_BIT_POS_SET(addr) \ (((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS)) | (addr)) -#define PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR(addr) \ +#define PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR(addr) \ ((~((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS))) & (addr)) #define PCIE_DMA_HOST_ADDR_BIT_POS_F0 (54) #define PCIE_DMA_HOST_ADDR_BIT_POS_F1 (53) #define PCIE_DMA_HOST_ADDR_BIT_POS_VALID (52) -#define PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(bit_pos, addr) \ +#define PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(bit_pos, addr) \ ((addr) + ((1ULL) << (bit_pos))) -#define PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, addr) \ +#define PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, addr) \ ((addr) - ((1ULL) << (bit_pos))) enum PS3FWDiagKey { - PS3_FW_DIAG_FLUSH = 0X00, - PS3_FW_DIAG_1ST_KEY = 0x52, - PS3_FW_DIAG_2ND_KEY = 0x5F, - PS3_FW_DIAG_3RD_KEY = 0x55, - PS3_FW_DIAG_4TH_KEY = 0x5F, - PS3_FW_DIAG_5TH_KEY = 0x52, - PS3_FW_DIAG_6TH_KEY = 0x45, - PS3_FW_DIAG_7TH_KEY = 0x41, - PS3_FW_DIAG_8TH_KEY = 0x44, - PS3_FW_DIAG_9TH_KEY = 0x59, + PS3_FW_DIAG_FLUSH = 0X00, + PS3_FW_DIAG_1ST_KEY = 0x52, + PS3_FW_DIAG_2ND_KEY = 0x5F, + PS3_FW_DIAG_3RD_KEY = 0x55, + PS3_FW_DIAG_4TH_KEY = 0x5F, + PS3_FW_DIAG_5TH_KEY = 0x52, + PS3_FW_DIAG_6TH_KEY = 0x45, + PS3_FW_DIAG_7TH_KEY = 0x41, + PS3_FW_DIAG_8TH_KEY = 0x44, + PS3_FW_DIAG_9TH_KEY = 0x59, }; enum PS3FWStateAct { - PS3_FW_STATE_ACT_INIT_READY = 0X00000001, + PS3_FW_STATE_ACT_INIT_READY = 0X00000001, }; enum PS3RegDoorBellType { - PS3_REG_DOORBELL_STATE_TO_READY = 1, - PS3_REG_DOORBELL_STATE_TO_FAULT = 2, - PS3_REG_DOORBELL_STATE_TO_HALT = 3, + PS3_REG_DOORBELL_STATE_TO_READY = 1, + PS3_REG_DOORBELL_STATE_TO_FAULT = 2, + PS3_REG_DOORBELL_STATE_TO_HALT = 3, }; enum PS3FWSoftResetAct { - PS3_FW_STATE_ACT_SHALLOW_SOFT_RESET = 0X00000001, - PS3_FW_STATE_ACT_DEEP_SOFT_RESET = 0X00000002, + PS3_FW_STATE_ACT_SHALLOW_SOFT_RESET = 0X00000001, + PS3_FW_STATE_ACT_DEEP_SOFT_RESET = 0X00000002, }; enum PS3PerfModeType { - PS3_PERF_MODE_BALANCE = 0, - PS3_PERF_MODE_IOPS = 1, - PS3_PERF_MODE_LATENCY = 2, + PS3_PERF_MODE_BALANCE = 0, + PS3_PERF_MODE_IOPS = 1, + PS3_PERF_MODE_LATENCY = 2, }; enum PS3BitPos { PS3_BIT_POS_DEFAULT = 0, - PS3_BIT_POS_44 = 1, - PS3_BIT_POS_45 = 2, - PS3_BIT_POS_46 = 3, - PS3_BIT_POS_47 = 4, - PS3_BIT_POS_48 = 5, - PS3_BIT_POS_49 = 6, - PS3_BIT_POS_50 = 7, - PS3_BIT_POS_51 = 8, - PS3_BIT_POS_52 = 9, - PS3_BIT_POS_53 = 10, - PS3_BIT_POS_54 = 11, + PS3_BIT_POS_44 = 1, + PS3_BIT_POS_45 = 2, + PS3_BIT_POS_46 = 3, + PS3_BIT_POS_47 = 4, + PS3_BIT_POS_48 = 5, + PS3_BIT_POS_49 = 6, + PS3_BIT_POS_50 = 7, + PS3_BIT_POS_51 = 8, + PS3_BIT_POS_52 = 9, + PS3_BIT_POS_53 = 10, + PS3_BIT_POS_54 = 11, }; enum PS3CmdType { - PS3_CMD_INIT_IOC = 0x0, - PS3_CMD_VD_SCSI_IO_RW = 0x1, - PS3_CMD_VD_SCSI_IO_NORW = 0x2, - PS3_CMD_PD_SCSI_IO_RW = 0x3, - PS3_CMD_PD_SCSI_IO_NORW = 0x4, - PS3_CMD_MANAGEMENT = 0x5, - PS3_CMD_SCSI_TASK_MANAGEMENT = 0x6, - PS3_CMD_IOCTL = 0x7, - PS3_CMD_SAS_MANAGEMENT = 0x8, - PS3_CMD_COUNT = 0x9, - PS3_CMD_INVALID = 0xff, + PS3_CMD_INIT_IOC = 0x0, + PS3_CMD_VD_SCSI_IO_RW = 0x1, + PS3_CMD_VD_SCSI_IO_NORW = 0x2, + PS3_CMD_PD_SCSI_IO_RW = 0x3, + PS3_CMD_PD_SCSI_IO_NORW = 0x4, + PS3_CMD_MANAGEMENT = 0x5, + PS3_CMD_SCSI_TASK_MANAGEMENT = 0x6, + PS3_CMD_IOCTL = 0x7, + PS3_CMD_SAS_MANAGEMENT = 0x8, + PS3_CMD_COUNT = 0x9, + PS3_CMD_INVALID = 0xff, }; enum { - PS3_SGL = 0x0, - PS3_PRP = 0x1, + PS3_SGL = 0x0, + PS3_PRP = 0x1, }; enum { - PS3_CMD_OPERATOR_TYPE_HOST = 0x0, - PS3_CMD_OPERATOR_TYPE_UEFI = 0x1, - PS3_CMD_OPERATOR_TYPE_IOC = 0x2, + PS3_CMD_OPERATOR_TYPE_HOST = 0x0, + PS3_CMD_OPERATOR_TYPE_UEFI = 0x1, + PS3_CMD_OPERATOR_TYPE_IOC = 0x2, }; enum { - PS3_PCI_IRQ_LEGACY = 0, - PS3_PCI_IRQ_MSI = 1, - PS3_PCI_IRQ_MSIX = 2, + PS3_PCI_IRQ_LEGACY = 0, + PS3_PCI_IRQ_MSI = 1, + PS3_PCI_IRQ_MSIX = 2, }; -#define PS3_DRV_SYSTEM_ID_MAX_LEN 64 -#define PS3_SENSE_BUFFER_SIZE (96) -#define PS3_RESP_FRAME_BUFFER_SIZE (128) +#define PS3_DRV_SYSTEM_ID_MAX_LEN 64 +#define PS3_SENSE_BUFFER_SIZE (96) +#define PS3_RESP_FRAME_BUFFER_SIZE (128) -#define PS3_REQUEST_CONTROL_DIR_NONE 0x00 -#define PS3_REQUEST_CONTROL_DIR_READ 0x01 -#define PS3_REQUEST_CONTROL_DIR_WRITE 0x02 -#define PS3_REQUEST_CONTROL_DIR_BOTH 0x03 +#define PS3_REQUEST_CONTROL_DIR_NONE 0x00 +#define PS3_REQUEST_CONTROL_DIR_READ 0x01 +#define PS3_REQUEST_CONTROL_DIR_WRITE 0x02 +#define PS3_REQUEST_CONTROL_DIR_BOTH 0x03 -#define PS3_MAX_PD_COUNT_IN_SPAN 32 -#define PS3_MAX_SPAN_IN_VD 8 +#define PS3_MAX_PD_COUNT_IN_SPAN 32 +#define PS3_MAX_SPAN_IN_VD 8 -#define PS3_IOC_INIT_STATE_MASK 0xFFFF -#define PS3_IOC_RECOVERY_COUNT_MASK 0xFFFFFFFF +#define PS3_IOC_INIT_STATE_MASK 0xFFFF +#define PS3_IOC_RECOVERY_COUNT_MASK 0xFFFFFFFF -#define PS3_START_STATE_SPACE 0x0100 +#define PS3_START_STATE_SPACE 0x0100 #define PS3_DRV_MGR_FLUSH_RETRY_MAX_COUNT 1 -#define MAX_MGR_CMD_TOTAL_COUNT (16) +#define MAX_MGR_CMD_TOTAL_COUNT (16) -#define PS3_HOT_RESET_OFFSET \ - (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG10_ADDR - \ - HIL_REG1_PS3_REGISTER_F_BASEADDR) +#define PS3_HOT_RESET_OFFSET (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG10_ADDR - HIL_REG1_PS3_REGISTER_F_BASEADDR) union HilRegPs3RegisterHotReset { - unsigned long long val; - struct { + U64 val; + struct{ - unsigned char isHotReset : 1; - unsigned char reserved0 : 7; - unsigned char reserved1[7]; - } reg; + U8 isHotReset : 1; + U8 reserved0 : 7; + U8 reserved1[7] ; + }reg; }; -#define PS3_ATU_SUPPORT_OFFSET \ - (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG8_ADDR - \ - HIL_REG1_PS3_REGISTER_F_BASEADDR) +#define PS3_ATU_SUPPORT_OFFSET (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG8_ADDR - HIL_REG1_PS3_REGISTER_F_BASEADDR) union HilRegPs3RegisterFPs3AtuSupport { - unsigned long long val; - struct { + U64 val; + struct{ - unsigned char bitPos; - unsigned char reserved[7]; + U8 bitPos; + U8 reserved[7]; } reg; }; -#define PS3_CAN_HARD_RESET_OFFSET \ - (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG9_ADDR - \ - HIL_REG1_PS3_REGISTER_F_BASEADDR) +#define PS3_CAN_HARD_RESET_OFFSET (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG9_ADDR - HIL_REG1_PS3_REGISTER_F_BASEADDR) union HilRegPs3RegisterFPs3CanHardReset { - unsigned long long val; - struct { + U64 val; + struct{ - unsigned char canHardReset : 1; - unsigned char reserved0 : 7; - unsigned char reserved1[7]; + U8 canHardReset : 1; + U8 reserved0 : 7; + U8 reserved1[7]; } reg; }; -enum PS3FWRunState { - PS3_FW_STATE_UNDEFINED = 0x00, - PS3_FW_STATE_START = 0x01, - PS3_FW_STATE_READY = 0x02, - PS3_FW_STATE_WAIT = 0x03, - PS3_FW_STATE_RUNNING = 0x04, - PS3_FW_STATE_FLUSHING = 0x05, - PS3_FW_STATE_RESET = 0x06, - PS3_FW_STATE_CRITICAL = 0x09, - PS3_FW_STATE_FAULT = 0xE0, - PS3_FW_STATE_HALT = 0xF0, - PS3_FW_STATE_END, - PS3_FW_STATE_MASK = 0xFF, - PS3_FW_STATE_WDT_MASK = 0xFF0000FF, -}; +typedef enum PS3FWRunState { + PS3_FW_STATE_UNDEFINED = 0x00, + PS3_FW_STATE_START = 0x01, + PS3_FW_STATE_READY = 0x02, + PS3_FW_STATE_WAIT = 0x03, + PS3_FW_STATE_RUNNING = 0x04, + PS3_FW_STATE_FLUSHING = 0x05, + PS3_FW_STATE_RESET = 0x06, + PS3_FW_STATE_CRITICAL = 0x09, + PS3_FW_STATE_FAULT = 0xE0, + PS3_FW_STATE_HALT = 0xF0, + PS3_FW_STATE_END, + PS3_FW_STATE_MASK = 0xFF, + PS3_FW_STATE_WDT_MASK = 0xFF0000FF, +}PS3FWRunState_e; -enum PS3FWStartState { - PS3_START_STATE_UNDEFINED = 0x0000, - PS3_START_STATE_INIT_BASE = 0x0100, - PS3_START_STATE_INIT_HARDWARE = 0x0200, - PS3_START_STATE_INIT_SOFTWARE = 0x0300, - PS3_START_STATE_INIT_DATAPATH = 0x0400, - PS3_START_STATE_INIT_THREAD = 0x0500, - PS3_START_STATE_SCAN_DEVICE = 0x0600, - PS3_START_STATE_FLUSH_CACHE = 0x0700, - PS3_START_STATE_INIT_RESET = 0x0800, - PS3_START_STATE_FINISHED = 0x0900, - PS3_START_STATE_MASK = 0xFF00, - PS3_START_STATE_WDT_MASK = 0xFF00FF00, -}; +typedef enum PS3FWStartState { + PS3_START_STATE_UNDEFINED = 0x0000, + PS3_START_STATE_INIT_BASE = 0x0100, + PS3_START_STATE_INIT_HARDWARE = 0x0200, + PS3_START_STATE_INIT_SOFTWARE = 0x0300, + PS3_START_STATE_INIT_DATAPATH = 0x0400, + PS3_START_STATE_INIT_THREAD = 0x0500, + PS3_START_STATE_SCAN_DEVICE = 0x0600, + PS3_START_STATE_FLUSH_CACHE = 0x0700, + PS3_START_STATE_INIT_RESET = 0x0800, + PS3_START_STATE_FINISHED = 0x0900, + PS3_START_STATE_MASK = 0xFF00, + PS3_START_STATE_WDT_MASK = 0xFF00FF00, +}PS3FWStartState_e; -#define PS3_FW_RESET_FLAG (0X00000001) -#define PS3_FW_DIAG_ENABLE (0X00000001) -#define PS3_FW_HARD_RESET_ACT (0X00000001) +#define PS3_FW_RESET_FLAG (0X00000001) +#define PS3_FW_DIAG_ENABLE (0X00000001) +#define PS3_FW_HARD_RESET_ACT (0X00000001) -#define PS3_FW_MAX_CMD_MASK (0X0000FFFF) -#define PS3_FW_MAX_MSIX_VECTORS_MASK (0X0000FFFF) -#define PS3_FW_MAX_CHAIN_SIZE_MASK (0XFFFFFFFF) -#define PS3_FW_MAX_RAID_MAP_SIZE_MASK (0XFFFFFFFF) -#define PS3_FW_MAX_NVME_PAGE_SIZE_MASK (0xFFFFFFFF) +#define PS3_FW_MAX_CMD_MASK (0X0000FFFF) +#define PS3_FW_MAX_MSIX_VECTORS_MASK (0X0000FFFF) +#define PS3_FW_MAX_CHAIN_SIZE_MASK (0XFFFFFFFF) +#define PS3_FW_MAX_RAID_MAP_SIZE_MASK (0XFFFFFFFF) +#define PS3_FW_MAX_NVME_PAGE_SIZE_MASK (0xFFFFFFFF) -#define PS3_FW_INTERRUPT_STATUS_MASK (0X00000001) -#define PS3_FW_INTERRUPT_CMD_INTR_CAP_MASK (0X00000004) -#define PS3_FW_INTERRUPT_CMD_MSI_CAP_MASK (0X00000002) -#define PS3_FW_INTERRUPT_CMD_MSIX_CAP_MASK (0X00000001) -#define PS3_FW_INTERRUPT_CLEAR_MASK (0X00000001) +#define PS3_FW_INTERRUPT_STATUS_MASK (0X00000001) +#define PS3_FW_INTERRUPT_CMD_INTR_CAP_MASK (0X00000004) +#define PS3_FW_INTERRUPT_CMD_MSI_CAP_MASK (0X00000002) +#define PS3_FW_INTERRUPT_CMD_MSIX_CAP_MASK (0X00000001) +#define PS3_FW_INTERRUPT_CLEAR_MASK (0X00000001) enum PS3FWFeatureSupportMask { - PS3_FW_FEATURE_SUPPORT_SYNC_CACHE = 0X00000001, - PS3_FW_FEATURE_SUPPORT_DMA64 = 0X00000002, + PS3_FW_FEATURE_SUPPORT_SYNC_CACHE = 0X00000001, + PS3_FW_FEATURE_SUPPORT_DMA64 = 0X00000002, }; enum PS3FWCtrlMask { - PS3_FW_CTRL_CMD_TRIGGER_SNAPSHOT = 0X00000001, - PS3_FW_CTRL_CMD_CRASHDUMP_COLLECTION_DONE = 0X00000002, - PS3_FW_CTRL_CMD_CRASHDUMP_DMA_CLEAR = 0X00000004, + PS3_FW_CTRL_CMD_TRIGGER_SNAPSHOT = 0X00000001, + PS3_FW_CTRL_CMD_CRASHDUMP_COLLECTION_DONE = 0X00000002, + PS3_FW_CTRL_CMD_CRASHDUMP_DMA_CLEAR = 0X00000004, }; enum PS3FWCtrlStatusMask { - PS3_FW_CTRL_STATUS_CRASHDUMP_DONE = 0X00000001, - PS3_FW_CTRL_STATUS_RSVR = 0X00000002, - PS3_FW_CTRL_STATUS_CRASHDUMP_MAP = 0X00000004, + PS3_FW_CTRL_STATUS_CRASHDUMP_DONE = 0X00000001, + PS3_FW_CTRL_STATUS_RSVR = 0X00000002, + PS3_FW_CTRL_STATUS_CRASHDUMP_MAP = 0X00000004, }; enum PS3CmdTrigger { - PS3_CMD_TRIGGER_UNLOAD = 0X0001, - PS3_CMD_TRIGGER_UNLOAD_SUSPEND = 0X0002, + PS3_CMD_TRIGGER_UNLOAD = 0X0001, + PS3_CMD_TRIGGER_UNLOAD_SUSPEND = 0X0002, }; enum PS3RegCmdState { - PS3_DOORBELL_DONE = 0X0001, + PS3_DOORBELL_DONE = 0X0001, }; enum PS3Debug12Mask { - PS3_DEBUG12__HOT_RESET = 0X00000001, + PS3_DEBUG12__HOT_RESET = 0X00000001, }; enum PS3MgrControlFlag { - PS3_REQUEST_CONTROL_SKIP_REFIRE = 0x0, - PS3_REQUEST_CONTROL_SENSE32 = 0x1, - PS3_REQUEST_CONTROL_SENSE64 = 0x2, + PS3_REQUEST_CONTROL_SKIP_REFIRE = 0x0, + PS3_REQUEST_CONTROL_SENSE32 = 0x1, + PS3_REQUEST_CONTROL_SENSE64 = 0x2, }; enum PS3TaskCmdSubType { - PS3_TASK_CMD_SCSI_TASK_ABORT, - PS3_TASK_CMD_SCSI_TASK_RESET, - PS3_TASK_CMD_COUNT, + PS3_TASK_CMD_SCSI_TASK_ABORT, + PS3_TASK_CMD_SCSI_TASK_RESET, + PS3_TASK_CMD_COUNT, - PS3_TASK_CMD_INVALID = 0xffff, + PS3_TASK_CMD_INVALID = 0xffff, }; + enum PS3MgrCmdSubType { - PS3_MGR_CMD_GET_CTRL_INFO = 0x0, - PS3_MGR_CMD_UNLOAD, - PS3_MGR_CMD_SUBSCRIBE_EVENT, - PS3_MGR_CMD_GET_VD_LIST, - PS3_MGR_CMD_GET_PD_LIST, - PS3_MGR_CMD_GET_VD_INFO, - PS3_MGR_CMD_GET_PD_INFO, - PS3_MGR_CMD_GET_BOOTDRIVE_INFO, - PS3_MGR_CMD_GET_BIOS_INFO, - - PS3_MGR_CMD_GET_SNAPSHOT_ATTR, - PS3_MGR_CMD_SET_CRASH_DUMP, - PS3_MGR_CMD_CANCEL, - PS3_MGR_CMD_ABORT, - PS3_MGR_CMD_DEV_ADD_ACK, - PS3_MGR_CMD_DEV_DEL_DONE, - - PS3_SAS_SMP_REQUEST, - PS3_SAS_GET_LINK_ERR, - PS3_SAS_PHY_CTRL, - PS3_SAS_GET_EXPANDERS, - PS3_SAS_GET_PHY_INFO, - PS3_SAS_GET_EXPANDER_INFO, - - PS3_MGR_CMD_AUTODUMP_NOTIFY, - - PS3_MGR_CMD_SECURITY_RANDOM_GET, - PS3_MGR_CMD_SECURITY_PASSWORD, - PS3_MGR_CMD_WEBSUBSCRIBE_EVENT, - - PS3_MGR_CMD_PRESERVED_INFO_GET, - PS3_MGR_CMD_GET_PD_SN_LIST, - PS3_MGR_CMD_PD_REF_CLEAR, - PS3_MGR_CMD_COUNT, - PS3_MGR_CMD_INVALID = 0xff -}; - -static inline const char *namePS3MgrCmdSubType(enum PS3MgrCmdSubType type) + PS3_MGR_CMD_GET_CTRL_INFO = 0x0, + PS3_MGR_CMD_UNLOAD, + PS3_MGR_CMD_SUBSCRIBE_EVENT, + PS3_MGR_CMD_GET_VD_LIST, + PS3_MGR_CMD_GET_PD_LIST, + PS3_MGR_CMD_GET_VD_INFO, + PS3_MGR_CMD_GET_PD_INFO, + PS3_MGR_CMD_GET_BOOTDRIVE_INFO, + PS3_MGR_CMD_GET_BIOS_INFO, + + PS3_MGR_CMD_GET_SNAPSHOT_ATTR, + PS3_MGR_CMD_SET_CRASH_DUMP, + PS3_MGR_CMD_CANCEL, + PS3_MGR_CMD_ABORT, + PS3_MGR_CMD_DEV_ADD_ACK, + PS3_MGR_CMD_DEV_DEL_DONE, + + PS3_SAS_SMP_REQUEST, + PS3_SAS_GET_LINK_ERR, + PS3_SAS_PHY_CTRL, + PS3_SAS_GET_EXPANDERS, + PS3_SAS_GET_PHY_INFO, + PS3_SAS_GET_EXPANDER_INFO, + + PS3_MGR_CMD_AUTODUMP_NOTIFY, + + PS3_MGR_CMD_SECURITY_RANDOM_GET, + PS3_MGR_CMD_SECURITY_PASSWORD, + PS3_MGR_CMD_WEBSUBSCRIBE_EVENT, + + PS3_MGR_CMD_PRESERVED_INFO_GET, + PS3_MGR_CMD_GET_PD_SN_LIST, + PS3_MGR_CMD_PD_REF_CLEAR, + PS3_MGR_CMD_COUNT, + PS3_MGR_CMD_INVALID = 0xff +}; + +static inline const S8 * namePS3MgrCmdSubType(enum PS3MgrCmdSubType type) { - static const char * const myNames[] = { - [PS3_MGR_CMD_GET_CTRL_INFO] = "PS3_MGR_CMD_GET_CTRL_INFO", - [PS3_MGR_CMD_UNLOAD] = "PS3_MGR_CMD_UNLOAD", - [PS3_MGR_CMD_SUBSCRIBE_EVENT] = "PS3_MGR_CMD_SUBSCRIBE_EVENT", - [PS3_MGR_CMD_GET_VD_LIST] = "PS3_MGR_CMD_GET_VD_LIST", - [PS3_MGR_CMD_GET_PD_LIST] = "PS3_MGR_CMD_GET_PD_LIST", - [PS3_MGR_CMD_GET_VD_INFO] = "PS3_MGR_CMD_GET_VD_INFO", - [PS3_MGR_CMD_GET_PD_INFO] = "PS3_MGR_CMD_GET_PD_INFO", - [PS3_MGR_CMD_GET_BOOTDRIVE_INFO] = - "PS3_MGR_CMD_GET_BOOTDRIVE_INFO", - [PS3_MGR_CMD_GET_BIOS_INFO] = "PS3_MGR_CMD_GET_BIOS_INFO", - - [PS3_MGR_CMD_GET_SNAPSHOT_ATTR] = - "PS3_MGR_CMD_GET_SNAPSHOT_ATTR", - [PS3_MGR_CMD_SET_CRASH_DUMP] = "PS3_MGR_CMD_SET_CRASH_DUMP", - [PS3_MGR_CMD_CANCEL] = "PS3_MGR_CMD_CANCEL", - [PS3_MGR_CMD_ABORT] = "PS3_MGR_CMD_ABORT", - [PS3_MGR_CMD_DEV_ADD_ACK] = "PS3_MGR_CMD_DEV_ADD_ACK", - [PS3_MGR_CMD_DEV_DEL_DONE] = "PS3_MGR_CMD_DEV_DEL_DONE", - - [PS3_SAS_SMP_REQUEST] = "PS3_SAS_SMP_REQUEST", - [PS3_SAS_GET_LINK_ERR] = "PS3_SAS_GET_LINK_ERR", - [PS3_SAS_PHY_CTRL] = "PS3_SAS_PHY_CTRL", - [PS3_SAS_GET_EXPANDERS] = "PS3_SAS_GET_EXPANDERS", - [PS3_SAS_GET_PHY_INFO] = "PS3_SAS_GET_PHY_INFO", - [PS3_SAS_GET_EXPANDER_INFO] = "PS3_SAS_GET_EXPANDER_INFO", - [PS3_MGR_CMD_AUTODUMP_NOTIFY] = "PS3_MGR_CMD_AUTODUMP_NOTIFY", - - [PS3_MGR_CMD_SECURITY_RANDOM_GET] = - "PS3_MGR_CMD_SECURITY_RANDOM_GET", - [PS3_MGR_CMD_SECURITY_PASSWORD] = - "PS3_MGR_CMD_SECURITY_PASSWORD", - [PS3_MGR_CMD_WEBSUBSCRIBE_EVENT] = - "PS3_MGR_CMD_WEBSUBSCRIBE_EVENT", - - [PS3_MGR_CMD_PRESERVED_INFO_GET] = - "PS3_MGR_CMD_PRESERVED_INFO_GET", - [PS3_MGR_CMD_GET_PD_SN_LIST] = "PS3_MGR_CMD_GET_PD_SN_LIST", - [PS3_MGR_CMD_PD_REF_CLEAR] = "PS3_MGR_CMD_PD_REF_CLEAR", - [PS3_MGR_CMD_COUNT] = "PS3_MGR_CMD_INVALID", - }; - - if (type < PS3_MGR_CMD_COUNT && type < ARRAY_SIZE(myNames)) + static const S8 *myNames[] = { + [PS3_MGR_CMD_GET_CTRL_INFO] = "PS3_MGR_CMD_GET_CTRL_INFO", + [PS3_MGR_CMD_UNLOAD] = "PS3_MGR_CMD_UNLOAD", + [PS3_MGR_CMD_SUBSCRIBE_EVENT] = "PS3_MGR_CMD_SUBSCRIBE_EVENT", + [PS3_MGR_CMD_GET_VD_LIST] = "PS3_MGR_CMD_GET_VD_LIST", + [PS3_MGR_CMD_GET_PD_LIST] = "PS3_MGR_CMD_GET_PD_LIST", + [PS3_MGR_CMD_GET_VD_INFO] = "PS3_MGR_CMD_GET_VD_INFO", + [PS3_MGR_CMD_GET_PD_INFO] = "PS3_MGR_CMD_GET_PD_INFO", + [PS3_MGR_CMD_GET_BOOTDRIVE_INFO] = "PS3_MGR_CMD_GET_BOOTDRIVE_INFO", + [PS3_MGR_CMD_GET_BIOS_INFO] = "PS3_MGR_CMD_GET_BIOS_INFO", + + [PS3_MGR_CMD_GET_SNAPSHOT_ATTR] = "PS3_MGR_CMD_GET_SNAPSHOT_ATTR", + [PS3_MGR_CMD_SET_CRASH_DUMP] = "PS3_MGR_CMD_SET_CRASH_DUMP", + [PS3_MGR_CMD_CANCEL] = "PS3_MGR_CMD_CANCEL", + [PS3_MGR_CMD_ABORT] = "PS3_MGR_CMD_ABORT", + [PS3_MGR_CMD_DEV_ADD_ACK] = "PS3_MGR_CMD_DEV_ADD_ACK", + [PS3_MGR_CMD_DEV_DEL_DONE] = "PS3_MGR_CMD_DEV_DEL_DONE", + + [PS3_SAS_SMP_REQUEST] = "PS3_SAS_SMP_REQUEST", + [PS3_SAS_GET_LINK_ERR] = "PS3_SAS_GET_LINK_ERR", + [PS3_SAS_PHY_CTRL] = "PS3_SAS_PHY_CTRL", + [PS3_SAS_GET_EXPANDERS] = "PS3_SAS_GET_EXPANDERS", + [PS3_SAS_GET_PHY_INFO] = "PS3_SAS_GET_PHY_INFO", + [PS3_SAS_GET_EXPANDER_INFO] = "PS3_SAS_GET_EXPANDER_INFO", + [PS3_MGR_CMD_AUTODUMP_NOTIFY] = "PS3_MGR_CMD_AUTODUMP_NOTIFY", + + [PS3_MGR_CMD_SECURITY_RANDOM_GET] = "PS3_MGR_CMD_SECURITY_RANDOM_GET", + [PS3_MGR_CMD_SECURITY_PASSWORD] = "PS3_MGR_CMD_SECURITY_PASSWORD", + [PS3_MGR_CMD_WEBSUBSCRIBE_EVENT] = "PS3_MGR_CMD_WEBSUBSCRIBE_EVENT", + + [PS3_MGR_CMD_PRESERVED_INFO_GET] = "PS3_MGR_CMD_PRESERVED_INFO_GET", + [PS3_MGR_CMD_GET_PD_SN_LIST] = "PS3_MGR_CMD_GET_PD_SN_LIST", + [PS3_MGR_CMD_PD_REF_CLEAR] = "PS3_MGR_CMD_PD_REF_CLEAR", + [PS3_MGR_CMD_COUNT] = "PS3_MGR_CMD_INVALID", + }; + + if (type < PS3_MGR_CMD_COUNT && type < (sizeof(myNames) / sizeof(myNames[0]))) { return myNames[type]; + } return "PS3_MGR_CMD_INVALID"; + } enum PS3CmdIocErrCode { - PS3_IOC_ERR_CODE_OK = 0x00, - PS3_IOC_ERR_CODE_ERR = 0x01, - PS3_IOC_STATE_INVALID_STATUS = 0xFFFF, -}; - -enum PS3CmdStatusCode { - SCSI_STATUS_GOOD = 0x00, - SCSI_STATUS_CHECK_CONDITION = 0x02, - SCSI_STATUS_CONDITION_MET = 0x04, - SCSI_STATUS_BUSY = 0x08, - SCSI_STATUS_RESERVATION_CONFLICT = 0x18, - SCSI_STATUS_TASK_SET_FULL = 0x28, - SCSI_STATUS_ACA_ACTIVE = 0x30, - SCSI_STATUS_TASK_ABORTED = 0x40, - - PS3_STATUS_DEVICE_NOT_FOUND = 0x80, - PS3_STATUS_IO_ABORTED = 0x81, - PS3_STATUS_REQ_ILLEGAL = 0x82, - PS3_STATUS_RESET_FAIL = 0x83, - PS3_STATUS_VD_OFFLINE = 0x84, - PS3_STATUS_ACCESS_BLOCK = 0x85, - PS3_STATUS_INTERNAL_SOFT_ERR = 0x86, - PS3_STATUS_INTERNAL_ERR = 0x87, - PS3_STATUS_HOST_NOT_FOUND = 0x88, - PS3_STATUS_HOST_RESET = 0x89, - PS3_STATUS_PCI_RECOVERY = 0x8A, - PS3_STATUS_VD_MEMBER_OFFLINE = 0x8B, - PS3_STATUS_UNDERRUN = 0x8C, - PS3_STATUS_OVERRUN = 0x8D, - PS3_STATUS_DIF_GRD_ERROR = 0x8E, - PS3_STATUS_DIF_REF_ERROR = 0x8F, - PS3_STATUS_DIF_APP_ERROR = 0x90, - PS3_STATUS_ACCESS_RO = 0x91, -}; + PS3_IOC_ERR_CODE_OK = 0x00, + PS3_IOC_ERR_CODE_ERR = 0x01, + PS3_IOC_STATE_INVALID_STATUS = 0xFFFF, +}; + +typedef enum PS3CmdStatusCode { + SCSI_STATUS_GOOD = 0x00, + SCSI_STATUS_CHECK_CONDITION = 0x02, + SCSI_STATUS_CONDITION_MET = 0x04, + SCSI_STATUS_BUSY = 0x08, + SCSI_STATUS_RESERVATION_CONFLICT = 0x18, + SCSI_STATUS_TASK_SET_FULL = 0x28, + SCSI_STATUS_ACA_ACTIVE = 0x30, + SCSI_STATUS_TASK_ABORTED = 0x40, + + PS3_STATUS_DEVICE_NOT_FOUND = 0x80, + PS3_STATUS_IO_ABORTED = 0x81, + PS3_STATUS_REQ_ILLEGAL = 0x82, + PS3_STATUS_RESET_FAIL = 0x83, + PS3_STATUS_VD_OFFLINE = 0x84, + PS3_STATUS_ACCESS_BLOCK = 0x85, + PS3_STATUS_INTERNAL_SOFT_ERR = 0x86, + PS3_STATUS_INTERNAL_ERR = 0x87, + PS3_STATUS_HOST_NOT_FOUND = 0x88, + PS3_STATUS_HOST_RESET = 0x89, + PS3_STATUS_PCI_RECOVERY = 0x8A, + PS3_STATUS_VD_MEMBER_OFFLINE = 0x8B, + PS3_STATUS_UNDERRUN = 0x8C, + PS3_STATUS_OVERRUN = 0x8D, + PS3_STATUS_DIF_GRD_ERROR = 0x8E, + PS3_STATUS_DIF_REF_ERROR = 0x8F, + PS3_STATUS_DIF_APP_ERROR = 0x90, + PS3_STATUS_ACCESS_RO = 0x91, +} PS3CmdStatusCode_e; enum PS3CmdWordType { - PS3_CMDWORD_TYPE_INIT = 0x00, - PS3_CMDWORD_TYPE_ABORT = 0x00, - PS3_CMDWORD_TYPE_MGR = 0x01, - PS3_CMDWORD_TYPE_READ = 0x02, - PS3_CMDWORD_TYPE_WRITE = 0x03, + PS3_CMDWORD_TYPE_INIT = 0x00, + PS3_CMDWORD_TYPE_ABORT = 0x00, + PS3_CMDWORD_TYPE_MGR = 0x01, + PS3_CMDWORD_TYPE_READ = 0x02, + PS3_CMDWORD_TYPE_WRITE = 0x03, }; -#define PS3_CMD_TYPE_IS_RW(type) \ +#define PS3_CMD_TYPE_IS_RW(type) \ ((type) == PS3_CMDWORD_TYPE_READ || (type) == PS3_CMDWORD_TYPE_WRITE) enum PS3ReqFrameCtrl { - PS3_DATA_BUF_SGL = 0x00, + PS3_DATA_BUF_SGL = 0x00, - PS3_DATA_BUF_PRP = 0x02, + PS3_DATA_BUF_PRP = 0x02, }; enum PS3CmdWordDirect { - PS3_CMDWORD_DIRECT_NORMAL = 0x00, - PS3_CMDWORD_DIRECT_RESERVE = 0x01, - PS3_CMDWORD_DIRECT_OK = 0x02, - PS3_CMDWORD_DIRECT_ADVICE = 0x03, + PS3_CMDWORD_DIRECT_NORMAL = 0x00, + PS3_CMDWORD_DIRECT_RESERVE = 0x01, + PS3_CMDWORD_DIRECT_OK = 0x02, + PS3_CMDWORD_DIRECT_ADVICE = 0x03, }; enum PS3CmdWordPort { - PS3_CMDWORD_PORT_SAS0 = 0x00, - PS3_CMDWORD_PORT_SAS1 = 0x01, - PS3_CMDWORD_PORT_NVME = 0x02, - PS3_CMDWORD_PORT_RESERVE = 0x03, + PS3_CMDWORD_PORT_SAS0 = 0x00, + PS3_CMDWORD_PORT_SAS1 = 0x01, + PS3_CMDWORD_PORT_NVME = 0x02, + PS3_CMDWORD_PORT_RESERVE = 0x03, }; enum PS3CmdWordFormat { - PS3_CMDWORD_FORMAT_FRONTEND = 0x00, - PS3_CMDWORD_FORMAT_HARDWARE = 0x01, + PS3_CMDWORD_FORMAT_FRONTEND = 0x00, + PS3_CMDWORD_FORMAT_HARDWARE = 0x01, }; enum PS3ReplyWordFlag { - PS3_REPLY_WORD_FLAG_SUCCESS = 0x00, - PS3_REPLY_WORD_FLAG_FAIL = 0X01, - PS3_REPLY_WORD_FLAG_REPEAT_REPLY = 0x0F, - PS3_REPLY_WORD_FLAG_INVALID = 0X7FFF, + PS3_REPLY_WORD_FLAG_SUCCESS = 0x00, + PS3_REPLY_WORD_FLAG_FAIL = 0X01, + PS3_REPLY_WORD_FLAG_REPEAT_REPLY = 0x0F, + PS3_REPLY_WORD_FLAG_INVALID = 0X7FFF, }; enum PS3ReplyWordMask { - PS3_REPLY_WORD_MASK_FLAG = 0X7FFF, + PS3_REPLY_WORD_MASK_FLAG = 0X7FFF, }; -enum PS3ReplyWordMode { - PS3_REPLY_WORD_MODE_NORMAL = 0x00, - PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_NORMAL = 0X01, - PS3_REPLY_WORD_MODE_DIRECT_OK = 0X02, - PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_DIRECT = 0X03, +enum PS3ReplyWordMode{ + PS3_REPLY_WORD_MODE_NORMAL = 0x00, + PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_NORMAL = 0X01, + PS3_REPLY_WORD_MODE_DIRECT_OK = 0X02, + PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_DIRECT = 0X03, }; -enum PS3RetType { - PS3_NOT_HARD_RET = 0x00, - PS3_HARD_RET = 0X01, +enum PS3RetType{ + PS3_NOT_HARD_RET = 0x00, + PS3_HARD_RET = 0X01, }; enum PS3CmdWordVer { - PS3_CMDWORD_VER_0 = 0x0, - PS3_CMDWORD_VER_1 = 0x1, - PS3_CMDWORD_VER_UPDATING = 0x2, - PS3_CMDWORD_VER_INVALID = 0x3, + PS3_CMDWORD_VER_0 = 0x0, + PS3_CMDWORD_VER_1 = 0x1, + PS3_CMDWORD_VER_UPDATING = 0x2, + PS3_CMDWORD_VER_INVALID = 0x3, }; enum PS3CmdWordNoReplyWord { - PS3_CMD_WORD_NEED_REPLY_WORD = 0, - PS3_CMD_WORD_NO_REPLY_WORD = 1, + PS3_CMD_WORD_NEED_REPLY_WORD = 0, + PS3_CMD_WORD_NO_REPLY_WORD = 1, }; enum PS3ChannelType { - PS3_CHAN_TYPE_UNKNOWN = 0, - PS3_CHAN_TYPE_VD = 1, - PS3_CHAN_TYPE_PD = 2, + PS3_CHAN_TYPE_UNKNOWN = 0, + PS3_CHAN_TYPE_VD = 1, + PS3_CHAN_TYPE_PD = 2, }; enum PS3DiskType { - PS3_DISK_TYPE_UNKNOWN = 0, - PS3_DISK_TYPE_VD = 1, - PS3_DISK_TYPE_PD = 2, + PS3_DISK_TYPE_UNKNOWN = 0, + PS3_DISK_TYPE_VD = 1, + PS3_DISK_TYPE_PD = 2, }; #define PS3_CONTROL_PAGE_TYPE_BIT_OFFSET (0x1) -#define PS3_CONTROL_PAGE_TYPE_BIT_NUM (0x1) -#define PS3_CONTROL_PAGE_TYPE_MASK (0x1) +#define PS3_CONTROL_PAGE_TYPE_BIT_NUM (0x1) +#define PS3_CONTROL_PAGE_TYPE_MASK (0x1) enum PS3PageType { - PS3_CONTROL_PAGE_TYPE_OF_SGE = 0, - PS3_CONTROL_PAGE_TYPE_OF_PRP = 1, - PS3_CONTROL_PAGE_TYPE_MAX = 2, + PS3_CONTROL_PAGE_TYPE_OF_SGE = 0, + PS3_CONTROL_PAGE_TYPE_OF_PRP = 1, + PS3_CONTROL_PAGE_TYPE_MAX = 2, }; -static inline const char *namePS3DiskType(enum PS3DiskType e) +static inline const S8 * namePS3DiskType(enum PS3DiskType e) { - static const char * const myNames[] = { - [PS3_DISK_TYPE_UNKNOWN] = "PS3_DISK_TYPE_UNKNOWN", - [PS3_DISK_TYPE_VD] = "PS3_DISK_TYPE_VD", - [PS3_DISK_TYPE_PD] = "PS3_DISK_TYPE_PD" - }; + static const S8 *myNames[] = { + [PS3_DISK_TYPE_UNKNOWN] = "PS3_DISK_TYPE_UNKNOWN", + [PS3_DISK_TYPE_VD] = "PS3_DISK_TYPE_VD", + [PS3_DISK_TYPE_PD] = "PS3_DISK_TYPE_PD" + }; - return myNames[e]; + return myNames[e]; } -static inline const char *namePS3ChannelType(enum PS3ChannelType e) +static inline const S8 * namePS3ChannelType(enum PS3ChannelType e) { - static const char * const myNames[] = { - [PS3_CHAN_TYPE_UNKNOWN] = "PS3_CHAN_TYPE_UNKNOWN", - [PS3_CHAN_TYPE_VD] = "PS3_CHAN_TYPE_VD", - [PS3_CHAN_TYPE_PD] = "PS3_CHAN_TYPE_PD" - }; + static const S8 *myNames[] = { + [PS3_CHAN_TYPE_UNKNOWN] = "PS3_CHAN_TYPE_UNKNOWN", + [PS3_CHAN_TYPE_VD] = "PS3_CHAN_TYPE_VD", + [PS3_CHAN_TYPE_PD] = "PS3_CHAN_TYPE_PD" + }; - return myNames[e]; + return myNames[e]; } + enum PS3DrvMgrErrorCode { - PS3_DRV_MGR_TIMEOUT = 1, + PS3_DRV_MGR_TIMEOUT = 1, PS3_DRV_MGR_UNRUNING, PS3_DRV_MGR_INVAL_CMD, PS3_DRV_MGR_NORESOURCE, @@ -534,8 +525,8 @@ enum PS3DrvMgrErrorCode { PS3_DRV_MGR_DEV_DATA_ERR, PS3_DRV_MGR_BUSY, PS3_DRV_MGR_EVT_REPEAT, - PS3_DRV_MGR_EVT_CANCEL_ERR, - PS3_DRV_MGR_FLUSH_FAILED, + PS3_DRV_MGR_EVT_CANCLE_ERR, + PS3_DRV_MGR_FLUSH_FAIELD, PS3_DRV_MGR_SMP_BACKEND_ERR, PS3_DRV_MGR_LINK_GET_BACKEND_ERR, PS3_DRV_MGR_PHY_CTL_BACKEND_ERR, @@ -543,19 +534,21 @@ enum PS3DrvMgrErrorCode { PS3_DRV_MGR_TM_FAILED, }; + enum PS3IoctlRetCode { - PS3_IOCTL_STATUS_OK = 0, - PS3_IOCTL_STATUS_INVALID_REQ = 1, - PS3_IOCTL_STATUS_NO_HBA = 2, - PS3_IOCTL_STATUS_BUSY = 3, - PS3_IOCTL_STATUS_NOT_READY = 4, - PS3_IOCTL_STATUS_INVALIED_PARAM = 5, - PS3_IOCTL_STATUS_REQ_ERR = 6, - PS3_IOCTL_STATUS_NEED_RETRY = 7, + PS3_IOCTL_STATUS_OK = 0, + PS3_IOCTL_STATUS_INVALID_REQ = 1, + PS3_IOCTL_STATUS_NO_HBA = 2, + PS3_IOCTL_STATUS_BUSY = 3, + PS3_IOCTL_STATUS_NOT_READY = 4, + PS3_IOCTL_STATUS_INVALIED_PARAM = 5, + PS3_IOCTL_STATUS_REQ_ERR = 6, + PS3_IOCTL_STATUS_NEED_RETRY = 7, }; + enum PS3HwVdMaxIOSize { - PS3_ENUM_HW_VD_MAX_IO_SIZE_1M = 0, + PS3_ENUM_HW_VD_MAX_IO_SIZE_1M = 0, PS3_ENUM_HW_VD_MAX_IO_SIZE_OTHER, }; diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_dev.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_dev.h index 9dd72764d9c5..9aee3064261a 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_dev.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_dev.h @@ -1,329 +1,315 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_HTP_DEV_H_ #define _PS3_HTP_DEV_H_ #include "ps3_htp_def.h" -#define PS3_MAX_CHANNEL_NUM 15 -#define PS3_MAX_RANDOM_NUM 32 -#define PS3_MAX_IV_NUM 16 -#define PS3_SECURITY_CIPHER_NUM_MAX 2 -#define PS3_STABLE_WRITES_MASK (0x1) - +#define PS3_MAX_CHANNEL_NUM 15 +#define PS3_MAX_RANDOM_NUM 32 +#define PS3_MAX_IV_NUM 16 +#define PS3_SECURITY_CIPHER_NUM_MAX 2 +#define PS3_STABLE_WRITES_MASK (0x1) struct PS3IocCtrlProp { - unsigned int enableSnapshot : 1; - unsigned int enableSoftReset : 1; - unsigned int reserved1 : 30; - unsigned int reserved2; + U32 enableSnapshot : 1; + U32 enableSoftReset : 1; + U32 reserved1:30; + U32 reserved2; }; - struct PS3IocCtrlCapable { - unsigned int supportUnevenSpans : 1; - unsigned int supportJbodSecure : 1; - unsigned int supportNvmePassthru : 1; - unsigned int supportDirectCmd : 1; - unsigned int supportAcceleration : 1; - unsigned int supportSataDirectCmd : 1; - unsigned int supportSataNcq : 1; - unsigned int reserved1 : 25; - unsigned int reserved2[3]; + U32 supportUnevenSpans : 1; + U32 supportJbodSecure : 1; + U32 supportNvmePassthru : 1; + U32 supportDirectCmd : 1; + U32 supportAcceleration : 1; + U32 supportSataDirectCmd: 1; + U32 supportSataNcq : 1; + U32 reserved1 : 25; + U32 reserved2[3]; }; #define PS3_IOC_CLUSTER_SERIAL_NO_SIZE 16 struct PS3ChannelAttr { - unsigned short channelType : 4; - unsigned short maxDevNum : 12; + U16 channelType : 4; + U16 maxDevNum : 12; }; struct PS3ChannelInfo { - unsigned char channelNum; - unsigned char reserved; - struct PS3ChannelAttr channels[PS3_MAX_CHANNEL_NUM]; + U8 channelNum; + U8 reserved; + struct PS3ChannelAttr channels[PS3_MAX_CHANNEL_NUM]; }; struct PS3QosInfo { - unsigned short tfifoDepth; - unsigned short sataHddQuota; - unsigned short sataSsdQuota; - unsigned short sasHddQuota; - unsigned short sasSsdQuota; - unsigned short nvmeVdQuota; - unsigned short nvmeDirectQuota; - unsigned short nvmeNormalQuota; + U16 tfifoDepth; + U16 sataHddQuota; + U16 sataSsdQuota; + U16 sasHddQuota; + U16 sasSsdQuota; + U16 nvmeVdQuota; + U16 nvmeDirectQuota; + U16 nvmeNormalQuota; }; struct PS3IocCtrlInfo { - - unsigned short maxVdCount; - - unsigned short maxPdCount; - - unsigned int maxSectors; - struct PS3IocCtrlProp properties; - struct PS3IocCtrlCapable capabilities; - - unsigned char scsiTaskAbortTimeout; - unsigned char scsiTaskResetTimeout; - - unsigned short offsetOfVDID; - unsigned char reserved1[2]; - - unsigned short cancelTimeOut; - - unsigned int vdIOThreshold; - - unsigned char iocPerfMode; - - unsigned char vdQueueNum; - - unsigned char ioTimeOut; - unsigned char hwVdMaxIOSize : 4; - unsigned char reserved2 : 4; - - struct PS3ChannelInfo channelInfo; - - struct PS3QosInfo qosInfo; - unsigned short isotoneTimeOut; - unsigned char reserved3[2]; - - unsigned char reserved4[32]; + U16 maxVdCount; + U16 maxPdCount; + U32 maxSectors; + struct PS3IocCtrlProp properties; + struct PS3IocCtrlCapable capabilities; + U8 scsiTaskAbortTimeout; + U8 scsiTaskResetTimeout; + U16 offsetOfVDID; + U8 reserved1[2]; + U16 cancelTimeOut; + U32 vdIOThreshold; + U8 iocPerfMode; + U8 vdQueueNum; + U8 ioTimeOut; + U8 hwVdMaxIOSize:4; + U8 reserved2:4; + struct PS3ChannelInfo channelInfo; + struct PS3QosInfo qosInfo; + U16 isotoneTimeOut; + U8 reserved3[2]; + U8 reserved4[32]; }; struct PS3Dev { - union { - unsigned short phyDiskID; - unsigned short virtDiskID; - }; - unsigned short softChan : 4; - unsigned short devID : 12; + union { + U16 phyDiskID; + U16 virtDiskID; + }; + U16 softChan : 4; + U16 devID : 12; }; -union PS3DiskDev { - unsigned int diskID; - struct PS3Dev ps3Dev; -}; +typedef union PS3DiskDev { + U32 diskID; + struct PS3Dev ps3Dev; +}PS3DiskDev_u; struct PS3DiskDevPos { - union { - struct { - unsigned char checkSum; - unsigned char enclId; - unsigned char phyId; - }; - unsigned int diskMagicNum; - }; - union PS3DiskDev diskDev; + union { + struct { + U8 checkSum; + U8 enclId; + U8 phyId; + }; + U32 diskMagicNum; + }; + PS3DiskDev_u diskDev; }; + struct PS3PhyDevice { - struct PS3DiskDevPos diskPos; - unsigned char diskState; - unsigned char configFlag; - unsigned char driverType : 4; - unsigned char mediumType : 4; - unsigned char reserved; - unsigned char reserved1[4]; + struct PS3DiskDevPos diskPos; + U8 diskState; + U8 configFlag; + U8 driverType:4; + U8 mediumType:4; + U8 reserved; + U8 reserved1[4]; }; + struct PS3VirtDevice { - struct PS3DiskDevPos diskPos; - unsigned char accessPolicy; - unsigned char isHidden; - unsigned char diskState; - unsigned char reserved; - unsigned char reserved1[4]; + struct PS3DiskDevPos diskPos; + U8 accessPolicy; + U8 isHidden; + U8 diskState; + U8 reserved; + U8 reserved1[4]; }; union PS3Device { - struct PS3PhyDevice pd; - struct PS3VirtDevice vd; + struct PS3PhyDevice pd; + struct PS3VirtDevice vd; }; struct PS3DevList { - unsigned short count; - unsigned char reserved[6]; - union PS3Device devs[0]; + U16 count; + U8 reserved[6]; + union PS3Device devs[0]; }; struct PS3PDInfo { - struct PS3DiskDevPos diskPos; - unsigned char diskState; - unsigned char configFlag; - unsigned char driverType : 4; - unsigned char mediumType : 4; - unsigned char scsiInterfaceType; - unsigned char taskAbortTimeout; - unsigned char taskResetTimeout; - union { - struct { - unsigned char supportNCQ : 1; - unsigned char protect : 1; - unsigned char isDirectDisable : 1; - unsigned char reserved : 5; - }; - unsigned char pdFlags; - }; - unsigned char reserved1; - unsigned short sectorSize; - unsigned char reserved2[2]; - unsigned char enclId; - unsigned char phyId; - unsigned char dmaAddrAlignShift; - unsigned char dmaLenAlignShift; - unsigned char reserved3[4]; - unsigned int maxIOSize; - unsigned int devQueDepth; - unsigned short normalQuota; - unsigned short directQuota; - unsigned char reserved4[20]; + struct PS3DiskDevPos diskPos; + U8 diskState; + U8 configFlag; + U8 driverType:4; + U8 mediumType:4; + U8 scsiInterfaceType; + U8 taskAbortTimeout; + U8 taskResetTimeout; + union { + struct { + U8 supportNCQ:1; + U8 protect:1; + U8 isDirectDisable:1; + U8 reserved:5; + }; + U8 pdFlags; + }; + U8 reserved1; + U16 sectorSize; + U8 reserved2[2]; + U8 enclId; + U8 phyId; + U8 dmaAddrAlignShift; + U8 dmaLenAlignShift; + U8 reserved3[4]; + U32 maxIOSize; + U32 devQueDepth; + U16 normalQuota; + U16 directQuota; + U8 reserved4[20]; }; -struct PS3Extent { - union PS3DiskDev phyDiskID; - unsigned char state; - unsigned char reserved[3]; +struct PS3Extent { + PS3DiskDev_u phyDiskID; + U8 state; + U8 reserved[3]; }; struct PS3Span { - unsigned int spanStripeDataSize; - unsigned char spanState; - unsigned char spanPdNum; - unsigned char reserved[2]; - struct PS3Extent extent[PS3_MAX_PD_COUNT_IN_SPAN]; + U32 spanStripeDataSize; + U8 spanState; + U8 spanPdNum; + U8 reserved[2]; + struct PS3Extent extent[PS3_MAX_PD_COUNT_IN_SPAN]; }; struct PS3VDEntry { - struct PS3DiskDevPos diskPos; - unsigned short sectorSize; - unsigned short stripSize; - unsigned int stripeDataSize; - unsigned short physDrvCnt; - unsigned short diskGrpId; - unsigned char accessPolicy; - - unsigned char reserved1; - unsigned char dmaAddrAlignShift; - unsigned char dmaLenAlignShift; - unsigned char isDirectEnable : 1; - unsigned char isHidden : 1; - unsigned char isNvme : 1; - unsigned char isSsd : 1; - unsigned char bdev_bdi_cap : 2; - unsigned char isWriteDirectEnable : 1; - unsigned char reserved2 : 1; - unsigned char raidLevel; - unsigned char spanCount; - unsigned char diskState; - unsigned short umapBlkDescCnt : 3; - unsigned short umapNumblk : 13; - unsigned short dev_busy_scale; - unsigned long long startLBA; - unsigned long long extentSize; - unsigned long long mapBlock; - unsigned long long capacity; - unsigned char isTaskMgmtEnable; - unsigned char taskAbortTimeout; - unsigned char taskResetTimeout; - unsigned char mapBlockVer; - unsigned int maxIOSize; - unsigned int devQueDepth; - unsigned short virtDiskSeq; - unsigned short normalQuota; - unsigned short directQuota; - unsigned short reserved4[21]; - struct PS3Span span[PS3_MAX_SPAN_IN_VD]; + struct PS3DiskDevPos diskPos; + U16 sectorSize; + U16 stripSize; + U32 stripeDataSize; + U16 physDrvCnt; + U16 diskGrpId; + U8 accessPolicy; + + U8 reserved1; + U8 dmaAddrAlignShift; + U8 dmaLenAlignShift; + U8 isDirectEnable:1; + U8 isHidden:1; + U8 isNvme:1; + U8 isSsd:1; + U8 bdev_bdi_cap:2; + U8 isWriteDirectEnable:1; + U8 reserved2:1; + U8 raidLevel; + U8 spanCount; + U8 diskState; + U16 umapBlkDescCnt:3; + U16 umapNumblk:13; + U16 dev_busy_scale; + U64 startLBA; + U64 extentSize; + U64 mapBlock; + U64 capacity; + U8 isTaskMgmtEnable; + U8 taskAbortTimeout; + U8 taskResetTimeout; + U8 mapBlockVer; + U32 maxIOSize; + U32 devQueDepth; + U16 virtDiskSeq; + U16 normalQuota; + U16 directQuota; + U16 reserved4[21]; + struct PS3Span span[PS3_MAX_SPAN_IN_VD]; }; struct PS3VDInfo { - unsigned short count; - unsigned char reserved[6]; - struct PS3VDEntry vds[0]; + U16 count; + U8 reserved[6]; + struct PS3VDEntry vds[0]; }; struct PS3DrvSysInfo { - unsigned char version; - unsigned char systemIDLen; - unsigned char reserved[6]; - unsigned char systemID[PS3_DRV_SYSTEM_ID_MAX_LEN]; + U8 version; + U8 systemIDLen; + U8 reserved[6]; + U8 systemID[PS3_DRV_SYSTEM_ID_MAX_LEN]; }; struct PS3PhyInfo { - unsigned long long sasAddr; - unsigned long long attachedSasAddr; - unsigned char phyId; - unsigned char negLinkRate; - unsigned char slotId; - unsigned char attachDevType; - unsigned char initiatorPortProtocol : 4; - unsigned char targetPortProtocols : 4; - unsigned char attachInitiatorPortProtocol : 4; - unsigned char attachTargetPortProtocols : 4; - unsigned char minLinkRateHw : 4; - unsigned char maxLinkRateHw : 4; - unsigned char minLinkRate : 4; - unsigned char maxLinkRate : 4; - unsigned char enable : 1; - unsigned char reserve : 7; - unsigned char reserved[7]; + U64 sasAddr; + U64 attachedSasAddr; + U8 phyId; + U8 negLinkRate; + U8 slotId; + U8 attachDevType; + U8 initiatorPortProtocol:4; + U8 targetPortProtocols:4; + U8 attachInitiatorPortProtocol:4; + U8 attachTargetPortProtocols:4; + U8 minLinkRateHw:4; + U8 maxLinkRateHw:4; + U8 minLinkRate:4; + U8 maxLinkRate:4; + U8 enable:1; + U8 reserve:7; + U8 reserved[7]; }; struct PS3ExpanderInfo { - unsigned long long sasAddr; - unsigned long long parentSasAddr; - unsigned char parentId; - unsigned char enclID; - unsigned char devType; - unsigned char phyCount; - unsigned char reserved[4]; + U64 sasAddr; + U64 parentSasAddr; + U8 parentId; + U8 enclID; + U8 devType; + U8 phyCount; + U8 reserved[4]; }; struct PS3Expanders { - unsigned char count; - unsigned char reserved[7]; - unsigned long long hbaSasAddr[3]; - struct PS3ExpanderInfo expanders[0]; + U8 count; + U8 reserved[7]; + U64 hbaSasAddr[3]; + struct PS3ExpanderInfo expanders[0]; }; struct PS3BiosInfo { - unsigned char biosState; - unsigned char biosMode; + U8 biosState; + U8 biosMode; - unsigned char biosAbs; - unsigned char devMaxNum; + U8 biosAbs; + U8 devMaxNum; }; struct PS3BootDriveInfo { - unsigned char hasBootDrive : 1; - unsigned char isPD : 1; - unsigned char reserved_9 : 6; - unsigned char enclID; - unsigned short slotID; - unsigned short vdID; - unsigned char pad[2]; + U8 hasBootDrive :1; + U8 isPD :1; + U8 reserved_9 :6; + U8 enclID ; + U16 slotID ; + U16 vdID ; + U8 pad[2]; }; struct PS3RandomInfo { - unsigned char randomNum[PS3_MAX_RANDOM_NUM]; - unsigned char iv[PS3_MAX_IV_NUM]; + U8 randomNum[PS3_MAX_RANDOM_NUM]; + U8 iv[PS3_MAX_IV_NUM]; }; struct PS3SecurityPwHead { - unsigned char cipherNum; - unsigned int cipherLegth[PS3_SECURITY_CIPHER_NUM_MAX]; - unsigned int cipherOffset[PS3_SECURITY_CIPHER_NUM_MAX]; - unsigned char iv[PS3_MAX_IV_NUM]; + U8 cipherNum; + U32 cipherLegth[PS3_SECURITY_CIPHER_NUM_MAX]; + U32 cipherOffset[PS3_SECURITY_CIPHER_NUM_MAX]; + U8 iv[PS3_MAX_IV_NUM]; }; #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_event.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_event.h index e7aec7470eb1..1d41b0e8ccb2 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_event.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_event.h @@ -1,38 +1,75 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_HTP_EVENT_H_ #define _PS3_HTP_EVENT_H_ #include "ps3_htp_def.h" #include "ps3_htp_dev.h" -#include "ps3_htp_mgr_evt.h" +#include "ps3_mgr_evt.h" #include "ps3_evtcode_trans.h" -#define PS3_EVENT_DETAIL_BUF_MAX (20) + +#define PS3_EVENT_DETAIL_BUF_MAX (20) enum PS3EventLevel { - PS3_EVENT_LEVEL_INFO, - PS3_EVENT_LEVEL_WARN, - PS3_EVENT_LEVEL_CRITICAL, + PS3_EVENT_LEVEL_INFO, + PS3_EVENT_LEVEL_WARN, + PS3_EVENT_LEVEL_CRITICAL, }; +#if 0 + +MgrEvtType_e { + PS3_EVENT_TYPE_NONE = 0X00000000, + + PS3_EVENT_TYPE_PD_COUNT_CHANGE = 0X00000001, + + PS3_EVENT_TYPE_VD_COUNT_CHANGE = 0X00000002, + PS3_EVENT_TYPE_CTRL_INFO_CHANGE = 0X00000004, + PS3_EVENT_TYPE_PD_ATTR_CHANGE = 0X00000008, + PS3_EVENT_TYPE_VD_ATTR_CHANGE = 0X00000010, + PS3_EVENT_TYPE_OTHER = 0X00000020, + PS3_EVENT_TYPE_ALL = 0XFFFFFFFF, +}; +#endif struct PS3EventDetail { - unsigned int eventCode; - unsigned int timestamp; - enum MgrEvtType eventType; - union { - struct PS3DiskDevPos devicePos; - unsigned char EnclId; - }; + U32 eventCode; + U32 timestamp; + MgrEvtType_e eventType; + union { + struct PS3DiskDevPos devicePos; + U8 EnclId; + }; }; struct PS3EventInfo { - unsigned int eventTypeMap; - unsigned int eventCount; + U32 eventTypeMap; + U32 eventCount; + struct PS3EventDetail eventDetail[PS3_EVENT_DETAIL_BUF_MAX]; + U8 reserved[8]; +}; +#if 0 + +enum PS3EventCode { + PS3_EVENT_CODE_NONE = 0X00000000, + + PS3_EVENT_CODE_PD_ADD = 0X00000001, + PS3_EVENT_CODE_PD_DEL = 0X00000002, + PS3_EVENT_CODE_PD_CHANGE = 0X00000003, + PS3_EVENT_CODE_SES_ADD = 0X00000004, + PS3_EVENT_CODE_SES_DEL = 0X00000005, + PS3_EVENT_CODE_PD_COUNT_CHANGE = 0X00000006, + + PS3_EVENT_CODE_VD_ADD = 0X00000011, + PS3_EVENT_CODE_VD_DEL = 0X00000012, + PS3_EVENT_CODE_VD_COUNT_CHANGE = 0X00000013, - struct PS3EventDetail eventDetail[PS3_EVENT_DETAIL_BUF_MAX]; - unsigned char reserved[8]; + PS3_EVENT_CODE_PD_ATTR_CHANGE = 0X00000021, + + PS3_EVENT_CODE_PD_INFO_CHANGE = 0X00000022, + + PS3_EVENT_CODE_OTHER = 0X00000040, }; #endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_ioctl.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_ioctl.h index e658599d0ec6..0dc3e4f7dda9 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_ioctl.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_ioctl.h @@ -1,113 +1,114 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_HTP_IOCTL_H_ #define _PS3_HTP_IOCTL_H_ #include "ps3_htp.h" #include "ps3_htp_reqframe.h" -#define PS3_MAX_IOCTL_SGE_NUM 16 -#define PS3_IOCTL_SENSE_SIZE 96 -#define PS3_IOCTL_MAX_FRAME_SIZE 128 + + +#define PS3_MAX_IOCTL_SGE_NUM 16 +#define PS3_IOCTL_SENSE_SIZE 96 +#define PS3_IOCTL_MAX_FRAME_SIZE 128 #ifndef PS3_SCSI_HOST_PROC_NAME -#define PS3_SCSI_HOST_PROC_NAME "ps3stor" +#define PS3_SCSI_HOST_PROC_NAME "ps3stor" #endif -#define PS3_PRODUCT_MODEL "ps3stor" +#define PS3_PRODUCT_MODEL "ps3stor" #ifndef PS3_SCSI_HOST_PROC_NAME_V100 -#define PS3_SCSI_HOST_PROC_NAME_V100 "ps3" +#define PS3_SCSI_HOST_PROC_NAME_V100 "ps3" #endif -#define PS3_PRODUCT_MODEL_V100 "ps3" - -#define PS3_PSW_PRODUCT_MODEL "psw" +#define PS3_PRODUCT_MODEL_V100 "ps3" +#define PS3_PSW_PRODUCT_MODEL "psw" struct PS3CmdIoctlHeader { - unsigned char cmdType; - unsigned char version; - unsigned short deviceId; - unsigned short cmdSubType; - unsigned char cmdResult; - unsigned char sglOffset; - unsigned short index; - unsigned short control; - unsigned int sgeCount; - unsigned short timeout; - unsigned char sglChainOffset; - unsigned char syncFlag; - unsigned int abortCmdFrameId; + U8 cmdType; + U8 version; + U16 deviceId; + U16 cmdSubType; + U8 cmdResult; + U8 sglOffset; + U16 index; + U16 control; + U32 sgeCount; + U16 timeout; + U8 sglChainOffset; + U8 syncFlag; + U32 abortCmdFrameId; }; + union PS3IoctlFrame { - unsigned char value[PS3_IOCTL_MAX_FRAME_SIZE]; - struct PS3CmdIoctlHeader header; + U8 value[PS3_IOCTL_MAX_FRAME_SIZE]; + struct PS3CmdIoctlHeader header; }; + #ifdef _WINDOWS #define PS3_IOCTL_SIG "ps3stor" #define PS3_IOCTL_FUNCTION 0x801 #define PS3_DEBUG_CLI_FUNCTION 0x802 -#define PS3_CTL_CODE \ - CTL_CODE(FILE_DEVICE_MASS_STORAGE, PS3_IOCTL_FUNCTION, \ - METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) -#define PS3_DBG_CLI_CODE \ - CTL_CODE(FILE_DEVICE_MASS_STORAGE, PS3_DEBUG_CLI_FUNCTION, \ - METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define PS3_CTL_CODE CTL_CODE(FILE_DEVICE_MASS_STORAGE, PS3_IOCTL_FUNCTION, \ + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define PS3_DBG_CLI_CODE CTL_CODE(FILE_DEVICE_MASS_STORAGE, PS3_DEBUG_CLI_FUNCTION, \ + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) struct PS3IoctlSyncCmd { - unsigned short hostId; - unsigned short sglOffset; - unsigned short sgeCount; - unsigned short reserved; - unsigned long long traceId; - struct PS3Sge Sgl[PS3_MAX_IOCTL_SGE_NUM]; - unsigned char data[0]; + U16 hostId; + U16 sglOffset; + U16 sgeCount; + U16 reserved; + U64 traceId; + struct PS3Sge Sgl[PS3_MAX_IOCTL_SGE_NUM]; + UCHAR data[0]; }; -struct _PS3_IO_CONTROL { - SRB_IO_CONTROL SrbHeader; - unsigned long reserved; - struct PS3IoctlSyncCmd ps3Ioctl; -}; +typedef struct _PS3_IO_CONTROL { + SRB_IO_CONTROL SrbHeader; + ULONG reserved; + struct PS3IoctlSyncCmd ps3Ioctl; +}PS3_IO_CONTRL, * PPS3_IO_CONTROL; #else #define PS3_CMD_IOCTL_SYNC_CMD _IOWR('M', 1, struct PS3IoctlSyncCmd) #ifndef __WIN32__ -#define PS3_EVENT_NOTICE_SIG (SIGRTMIN + 7) -enum { - PS3_IOCTL_CMD_NORMAL = 0, - PS3_IOCTL_CMD_WEB_SUBSCRIBE, +#define PS3_EVENT_NOTICE_SIG (SIGRTMIN+7) +enum{ + PS3_IOCTL_CMD_NORMAL = 0, + PS3_IOCTL_CMD_WEB_SUBSCRIBE, }; struct PS3IoctlSyncCmd { - unsigned short hostId; - unsigned short sglOffset; - unsigned short sgeCount; - unsigned short reserved1; - unsigned int resultCode; - unsigned char reserved2[4]; - unsigned char sense[PS3_IOCTL_SENSE_SIZE]; - unsigned long long traceId; - unsigned char reserved3[120]; - union PS3IoctlFrame msg; - struct PS3Sge sgl[PS3_MAX_IOCTL_SGE_NUM]; + U16 hostId; + U16 sglOffset; + U16 sgeCount; + U16 reserved1; + U32 resultCode; + U8 reserved2[4]; + U8 sense[PS3_IOCTL_SENSE_SIZE]; + U64 traceId; + U8 reserved3[120]; + union PS3IoctlFrame msg; + struct PS3Sge sgl[PS3_MAX_IOCTL_SGE_NUM]; }; #endif struct PS3IoctlAsynCmd { - unsigned short hostId; - unsigned short reserved1; + U16 hostId; + U16 reserved1; - unsigned int seqNum; + U32 seqNum; - unsigned short eventLevel; + U16 eventLevel; - unsigned short eventType; - unsigned char reserved2[4]; + U16 eventType; + U8 reserved2[4]; }; #endif + #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_pci.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_pci.h index 904cc089c100..8de282aa7f7f 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_pci.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_pci.h @@ -1,54 +1,53 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_HTP_PCI_H_ #define _PS3_HTP_PCI_H_ -#define PCI_DEVICE_ID 0x02 +#define PCI_DEVICE_ID 0x02 enum { - PCI_VENDOR_ID_STARS = 0x1eb6, - PCI_VENDOR_ID_PS3_FPGA = 0x1eb6, - PCI_VENDOR_ID_PS3_SWITCH_FPGA = 0x1eb6, - PCI_VENDOR_ID_PS3_ASIC = 0x1666, - PCI_VENDOR_ID_PS3 = 0x1ff2, - PCI_DEVICE_ID_PS3_RAID = 0x0001, - PCI_DEVICE_ID_PS3_HBA = 0x0002, - PCI_DEVICE_ID_PS3_SWITCH = 0x0003, - PCI_DEVICE_ID_PS3_SWITCH_FPGA = 0x6004, - PCI_DEVICE_ID_PS3_RAID_FPGA = 0xabcd, - PCI_DEVICE_ID_STARS_HBA_2120_16i = 0x20a1, - PCI_DEVICE_ID_STARS_IOC_2020_18i = 0x20a2, + PCI_VENDOR_ID_STARS = 0x1eb6, + PCI_VENDOR_ID_PS3_FPGA = 0x1eb6, + PCI_VENDOR_ID_PS3_SWITCH_FPGA = 0x1eb6, + PCI_VENDOR_ID_PS3_ASIC = 0x1666, + PCI_VENDOR_ID_PS3 = 0x1ff2, + PCI_DEVICE_ID_PS3_RAID = 0x0001, + PCI_DEVICE_ID_PS3_HBA = 0x0002, + PCI_DEVICE_ID_PS3_SWITCH = 0x0003, + PCI_DEVICE_ID_PS3_SWITCH_FPGA = 0x6004, + PCI_DEVICE_ID_PS3_RAID_FPGA = 0xabcd, + PCI_DEVICE_ID_STARS_HBA_2120_16i = 0x20a1, + PCI_DEVICE_ID_STARS_IOC_2020_18i = 0x20a2, PCI_DEVICE_ID_STARS_IOC_2213_16i = 0x20a3, - PCI_DEVICE_ID_STARS_ROC_2020_10i = 0x30a2, - PCI_SUBVERDOR_PS3_SWITCH_FPGA = 0x1eb6, - PCI_SUBSYSTEM_PS3_SWITCH_FPGA = 0x6004, - PCI_CLASS_CODE_PS3_SWITCH_FPGA = 0x058000, + PCI_DEVICE_ID_STARS_ROC_2020_10i = 0x30a2, + PCI_SUBVERDOR_PS3_SWITCH_FPGA = 0x1eb6, + PCI_SUBSYSTEM_PS3_SWITCH_FPGA = 0x6004, + PCI_CLASS_CODE_PS3_SWITCH_FPGA = 0x058000, }; -static inline const char *namePciDevType(unsigned short e) +static inline const S8 * namePciDevType(U16 e) { - switch (e) { - case PCI_DEVICE_ID_PS3_RAID: - return "PCI_DEVICE_ID_PS3_RAID"; - case PCI_DEVICE_ID_PS3_RAID_FPGA: - return "PCI_DEVICE_ID_PS3_RAID_FPGA"; - case PCI_DEVICE_ID_PS3_HBA: - return "PCI_DEVICE_ID_PS3_HBA"; - case PCI_DEVICE_ID_PS3_SWITCH: - return "PCI_DEVICE_ID_PS3_SWITCH"; - case PCI_DEVICE_ID_PS3_SWITCH_FPGA: - return "PCI_DEVICE_ID_PS3_SWITCH_FPGA"; - case PCI_DEVICE_ID_STARS_HBA_2120_16i: - return "PCI_DEVICE_ID_STARS_HBA_2120_16i"; - case PCI_DEVICE_ID_STARS_IOC_2020_18i: - return "PCI_DEVICE_ID_STARS_IOC_2020_18i"; - case PCI_DEVICE_ID_STARS_ROC_2020_10i: - return "PCI_DEVICE_ID_STARS_ROC_2020_10i"; + switch (e) { + case PCI_DEVICE_ID_PS3_RAID: + return "PCI_DEVICE_ID_PS3_RAID"; + case PCI_DEVICE_ID_PS3_RAID_FPGA: + return "PCI_DEVICE_ID_PS3_RAID_FPGA"; + case PCI_DEVICE_ID_PS3_HBA: + return "PCI_DEVICE_ID_PS3_HBA"; + case PCI_DEVICE_ID_PS3_SWITCH: + return "PCI_DEVICE_ID_PS3_SWITCH"; + case PCI_DEVICE_ID_PS3_SWITCH_FPGA: + return "PCI_DEVICE_ID_PS3_SWITCH_FPGA"; + case PCI_DEVICE_ID_STARS_HBA_2120_16i: + return "PCI_DEVICE_ID_STARS_HBA_2120_16i"; + case PCI_DEVICE_ID_STARS_IOC_2020_18i: + return "PCI_DEVICE_ID_STARS_IOC_2020_18i"; + case PCI_DEVICE_ID_STARS_ROC_2020_10i: + return "PCI_DEVICE_ID_STARS_ROC_2020_10i"; case PCI_DEVICE_ID_STARS_IOC_2213_16i: return "PCI_DEVICE_ID_STARS_IOC_2213_16i"; - default: - return "PCI_DEVICE_ID_INVALID"; - } + default: + return "PCI_DEVICE_ID_INVALID"; + } } #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_req_frame_hw.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_req_frame_hw.h index a3c6c6ce4b20..6301ae4c2e9d 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_req_frame_hw.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_req_frame_hw.h @@ -1,12 +1,10 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ #ifndef _PS3_HTP_REQ_FRAME_HW_H_ #define _PS3_HTP_REQ_FRAME_HW_H_ #include "ps3_htp_def.h" -#define ENCODE_CCS_XFERLEN(x) (((unsigned int)(x) >> 2)) -#define DECODE_CCS_XFERLEN(x) (((unsigned int)(x) << 2)) +#define ENCODE_CCS_XFERLEN(x) (((U32)(x) >> 2)) +#define DECODE_CCS_XFERLEN(x) (((U32)(x) << 2)) #ifdef _WINDOWS #define __attribute__(x) @@ -14,83 +12,83 @@ #endif struct PS3NvmeSglDesc { - unsigned long long addr; - union { - struct { - unsigned char reserved[7]; - unsigned char subtype : 4; - unsigned char type : 4; - } generic; - - struct { - unsigned int length; - unsigned char reserved[3]; - unsigned char subtype : 4; - unsigned char type : 4; - } unkeyed; - - struct { - unsigned long long length : 24; - unsigned long long key : 32; - unsigned long long subtype : 4; - unsigned long long type : 4; - } keyed; - }; + U64 addr; + union { + struct { + U8 reserved[7]; + U8 subtype : 4; + U8 type : 4; + } generic; + + struct { + U32 length; + U8 reserved[3]; + U8 subtype : 4; + U8 type : 4; + } unkeyed; + + struct { + U64 length : 24; + U64 key : 32; + U64 subtype : 4; + U64 type : 4; + } keyed; + }; }; struct PS3NvmeCmdDw0_9 { - unsigned short opcode : 8; - unsigned short fuse : 2; - unsigned short reserved1 : 4; - unsigned short psdt : 2; - unsigned short cID; + U16 opcode : 8; + U16 fuse : 2; + U16 reserved1 : 4; + U16 psdt : 2; + U16 cID; - unsigned int nsID; + U32 nsID; - unsigned int reserved2; - unsigned int reserved3; + U32 reserved2; + U32 reserved3; - unsigned long long mPtr; + U64 mPtr; - union { - struct { - unsigned long long prp1; - unsigned long long prp2; - } prp; - struct PS3NvmeSglDesc sgl1; + union { + struct { + U64 prp1; + U64 prp2; + } prp; + struct PS3NvmeSglDesc sgl1; - } dPtr; + } dPtr; }; -struct PS3NvmeCommonCmd { - struct PS3NvmeCmdDw0_9 cDW0_9; +typedef struct PS3NvmeCommonCmd { + struct PS3NvmeCmdDw0_9 cDW0_9; - unsigned int cDW10; - unsigned int cDW11; - unsigned int cDW12; - unsigned int cDW13; - unsigned int cDW14; - unsigned int cDW15; -}; + U32 cDW10; + U32 cDW11; + U32 cDW12; + U32 cDW13; + U32 cDW14; + U32 cDW15; +} PS3NvmeCommonCmd_s; -struct PS3NvmeRWCmd { - struct PS3NvmeCmdDw0_9 cDW0_9; +typedef struct PS3NvmeRWCmd { + struct PS3NvmeCmdDw0_9 cDW0_9; - unsigned int sLbaLo; - unsigned int sLbaHi; - unsigned int numLba; - unsigned int cDW13; - unsigned int cDW14; - unsigned int cDW15; -}; + U32 sLbaLo; + U32 sLbaHi; + U32 numLba; + U32 cDW13; + U32 cDW14; + U32 cDW15; +} PS3NvmeRWCmd_s; -union PS3NvmeReqFrame { - struct PS3NvmeCommonCmd commonReqFrame; - struct PS3NvmeRWCmd rwReqFrame; -}; +typedef union PS3NvmeReqFrame { + PS3NvmeCommonCmd_s commonReqFrame; + PS3NvmeRWCmd_s rwReqFrame; +} PS3NvmeReqFrame_u; #ifdef _WINDOWS #pragma pack(pop) diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_reqframe.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_reqframe.h index fa642602fb86..3fa045d579a8 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_reqframe.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_reqframe.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_HTP_REQFRAME_H_ #define _PS3_HTP_REQFRAME_H_ @@ -9,288 +8,289 @@ #include "ps3_htp_req_frame_hw.h" enum { - PS3_FRAME_SGE_BUFSIZE = 4096, - PS3_FRAME_SGE_SHIFT = 12, - PS3_FRAME_REQ_SGE_NUM_FE = 8, - PS3_FRAME_REQ_PRP_NUM_FE = 2, - PS3_FRAME_REQ_SGE_NUM_HW = 8, - PS3_FRAME_REQ_PRP_NUM_HW = 2, - PS3_FRAME_REQ_SGE_NUM_MGR = 11, - PS3_FRAME_REQ_EXT_SGE_MIN = 2, - PS3_FRAME_CDB_BUFLEN = 32, - PS3_FRAME_LUN_BUFLEN = 8, - PS3_DEBUG_MEM_ARRAY_MAX_NUM = 16, - PS3_MAX_DMA_MEM_SIZE = 4096, - PS3_MAX_DEBUG_MEM_SIZE_PARA = 65536, - PS3_DRV_NAME_MAX_LEN = 32, - PS3_DRV_VERSION_MAX_LEN = 24, + PS3_FRAME_SGE_BUFSIZE = 4096, + PS3_FRAME_SGE_SHIFT = 12, + PS3_FRAME_REQ_SGE_NUM_FE = 8, + PS3_FRAME_REQ_PRP_NUM_FE = 2, + PS3_FRAME_REQ_SGE_NUM_HW = 8, + PS3_FRAME_REQ_PRP_NUM_HW = 2, + PS3_FRAME_REQ_SGE_NUM_MGR = 11, + PS3_FRAME_REQ_EXT_SGE_MIN = 2, + PS3_FRAME_CDB_BUFLEN = 32, + PS3_FRAME_LUN_BUFLEN = 8, + PS3_DEBUG_MEM_ARRAY_MAX_NUM = 16, + PS3_MAX_DMA_MEM_SIZE = 4096, + PS3_MAX_DEBUG_MEM_SIZE_PARA = 65536, + PS3_DRV_NAME_MAX_LEN = 32, + PS3_DRV_VERSION_MAX_LEN = 24, }; enum { - PS3_DATA_DIRECTION_WRITE = 0, - PS3_DATA_DIRECTION_READ = 1, + PS3_DATA_DIRECTION_WRITE = 0, + PS3_DATA_DIRECTION_READ = 1, }; enum { - PS3_REQFRAME_FORMAT_FRONTEND = 0, - PS3_REQFRAME_FORMAT_SAS = 1, - PS3_REQFRAME_FORMAT_SATA = 2, - PS3_REQFRAME_FORMAT_NVME = 3, + PS3_REQFRAME_FORMAT_FRONTEND = 0, + PS3_REQFRAME_FORMAT_SAS = 1, + PS3_REQFRAME_FORMAT_SATA = 2, + PS3_REQFRAME_FORMAT_NVME = 3, }; enum { - PS3_LINUX_FRAME = 0, - PS3_WINDOWS_FRAME = 1, + PS3_LINUX_FRAME = 0, + PS3_WINDOWS_FRAME = 1, }; enum { - PS3_COMPAT_VER_DEFAULT = 0, - PS3_COMPAT_VER_1 = 1, - PS3_COMPAT_VER_MAX = 0xffff, -}; - -struct PS3Sge { - unsigned long long addr; - unsigned int length; - unsigned int reserved1 : 30; - unsigned int lastSge : 1; - unsigned int ext : 1; + PS3_COMPAT_VER_DEFAULT = 0, + PS3_COMPAT_VER_1 = 1, + PS3_COMPAT_VER_MAX = 0xffff, }; -struct PS3Prp { - unsigned long long prp1; - unsigned long long prp2; -}; - - - -struct PS3SoftwareZone { - unsigned long long virtDiskLba; - unsigned int numBlocks; - unsigned char opcode; - unsigned char sglOffset; - unsigned char sglFormat : 2; - unsigned char isResendCmd : 1; - unsigned char reserved1 : 5; - unsigned char reserved2; - unsigned short subOpcode; - unsigned short sgeCount : 9; - unsigned short reserved3 : 7; - unsigned char reserved4[4]; -}; - -struct PS3ReqFrameHead { - unsigned char cmdType; - unsigned char cmdSubType; - unsigned short cmdFrameID; - union { - struct { - unsigned int noReplyWord : 1; - unsigned int dataFormat : 1; - unsigned int reqFrameFormat : 2; - unsigned int mapBlockVer : 2; - unsigned int isWrite : 1; - unsigned int isStream1 : 1; - unsigned int reserved : 24; - }; - unsigned int control; - }; - union PS3DiskDev devID; - unsigned short timeout; - unsigned short virtDiskSeq; - unsigned short reserved1[4]; - unsigned long long traceID; -}; - -struct PS3HwReqFrame { - struct PS3ReqFrameHead reqHead; - struct PS3SoftwareZone softwareZone; - unsigned char reserved[8]; - union { - struct IODT_V1 sasReqFrame; - union PS3NvmeReqFrame nvmeReqFrame; - }; - struct PS3Sge sgl[PS3_FRAME_REQ_SGE_NUM_FE]; -}; - -struct PS3VDAccAttr { - unsigned long long firstPdStartLba; - unsigned char firstSpanNo; - unsigned char fisrtSeqInSpan; - unsigned char secondSeqInSapn; - unsigned char thirdSeqInSapn; - unsigned char clineCount; - unsigned char isAccActive : 1; - unsigned char isStream : 1; - unsigned char reserved1 : 6; - unsigned short ioOutStandingCnt; - unsigned char reserved2[16]; -}; - - -struct PS3FrontEndReqFrame { - struct PS3ReqFrameHead reqHead; - unsigned char cdb[PS3_FRAME_CDB_BUFLEN]; - struct PS3VDAccAttr vdAccAttr; - unsigned int dataXferLen; - unsigned char reserved[25]; - unsigned char sgeOffset; - unsigned short sgeCount; - union { - struct PS3Sge sgl[PS3_FRAME_REQ_SGE_NUM_FE]; - struct PS3Prp prp; - }; -}; +typedef struct PS3Sge { + U64 addr; + U32 length; + U32 reserved1 : 30; + U32 lastSge : 1; + U32 ext : 1; +} PS3Sge_s; + +typedef struct PS3Prp { + U64 prp1; + U64 prp2; +} PS3Prp_s; + + + +typedef struct PS3SoftwareZone { + U64 virtDiskLba; + U32 numBlocks; + U8 opcode; + U8 sglOffset; + U8 sglFormat : 2; + U8 isResendCmd : 1; + U8 reserved1 : 5; + U8 reserved2; + U16 subOpcode; + U16 sgeCount : 9; + U16 reserved3 : 7; + U8 reserved4[4]; +} PS3SoftwareZone_s; + +typedef struct PS3ReqFrameHead +{ + U8 cmdType; + U8 cmdSubType; + U16 cmdFrameID; + union{ + struct { + U32 noReplyWord : 1; + U32 dataFormat : 1; + U32 reqFrameFormat : 2; + U32 mapBlockVer : 2; + U32 isWrite : 1; + U32 isStream1 : 1; + U32 reserved : 24; + }; + U32 control; + }; + PS3DiskDev_u devID; + U16 timeout; + U16 virtDiskSeq; + U16 reserved1[4]; + U64 traceID; +} PS3ReqFrameHead_s; + +typedef struct PS3HwReqFrame { + PS3ReqFrameHead_s reqHead; + PS3SoftwareZone_s softwareZone; + U8 reserved[8]; + union { + IODT_V1_s sasReqFrame; + PS3NvmeReqFrame_u nvmeReqFrame; + }; + PS3Sge_s sgl[PS3_FRAME_REQ_SGE_NUM_FE]; +} PS3HwReqFrame_s; + +typedef struct PS3VDAccAttr { + U64 firstPdStartLba; + U8 firstSpanNo; + U8 fisrtSeqInSpan; + U8 secondSeqInSapn; + U8 thirdSeqInSapn; + U8 clineCount; + U8 isAccActive : 1; + U8 isStream : 1; + U8 reserved1 : 6; + U16 ioOutStandingCnt; + U8 reserved2[16]; +} PS3VDAccAttr_s; + + +typedef struct PS3FrontEndReqFrame { + PS3ReqFrameHead_s reqHead; + U8 cdb[PS3_FRAME_CDB_BUFLEN]; + PS3VDAccAttr_s vdAccAttr; + U32 dataXferLen; + U8 reserved[25]; + U8 sgeOffset; + U16 sgeCount; + union { + PS3Sge_s sgl[PS3_FRAME_REQ_SGE_NUM_FE]; + PS3Prp_s prp; + }; +} PS3FrontEndReqFrame_s; struct PS3MgrDev { - struct PS3DiskDevPos devID; - unsigned short num; - unsigned char devType; - unsigned char reserved[17]; + struct PS3DiskDevPos devID; + U16 num; + U8 devType; + U8 reserved[17]; }; struct PS3MgrEvent { - unsigned int eventTypeMap; - unsigned int eventTypeMapProcResult; - unsigned int eventLevel; - unsigned char reserved[20]; + U32 eventTypeMap; + U32 eventTypeMapProcResult; + U32 eventLevel; + U8 reserved[20]; }; struct PS3SasMgr { - unsigned long long sasAddr; - unsigned char enclID; - unsigned char startPhyID; - unsigned char phyCount; - unsigned char reserved1; - unsigned short reqLen; - unsigned char reserved2[2]; + U64 sasAddr; + U8 enclID; + U8 startPhyID; + U8 phyCount; + U8 reserved1; + U16 reqLen; + U8 reserved2[2]; }; struct PS3SasPhySet { - unsigned long long sasAddr; - unsigned char phyID; - unsigned char minLinkRate; - unsigned char maxLinkRate; - unsigned char phyCtrl; - unsigned char reserved[3]; + U64 sasAddr; + U8 phyID; + U8 minLinkRate; + U8 maxLinkRate; + U8 phyCtrl; + U8 reserved[3]; }; union PS3MgrReqDiffValue { - unsigned char word[32]; - unsigned short originalCmdFrameID; - unsigned char eventStart; - struct PS3MgrDev dev; - struct PS3MgrEvent event; - struct PS3SasMgr sasMgr; - struct PS3SasPhySet phySet; - unsigned char unLoadType; - int isRetry; + U8 word[32]; + U16 originalCmdFrameID; + U8 eventStart; + struct PS3MgrDev dev; + struct PS3MgrEvent event; + struct PS3SasMgr sasMgr; + struct PS3SasPhySet phySet; + U8 unLoadType; + BOOL isRetry; }; -struct PS3MgrReqFrame { - struct PS3ReqFrameHead reqHead; - unsigned short sgeCount; - unsigned char sgeOffset; - unsigned char syncFlag; - unsigned short timeout; - unsigned char abortFlag; - unsigned char pendingFlag; - union PS3MgrReqDiffValue value; - unsigned char osType; - unsigned char suspend_type; - unsigned char reserved[6]; - struct PS3Sge sgl[PS3_FRAME_REQ_SGE_NUM_MGR]; -}; +typedef struct PS3MgrReqFrame { + PS3ReqFrameHead_s reqHead; + U16 sgeCount; + U8 sgeOffset; + U8 syncFlag; + U16 timeout; + U8 abortFlag; + U8 pendingFlag; + union PS3MgrReqDiffValue value; + U8 osType; + U8 suspend_type; + U8 reserved[6]; + struct PS3Sge sgl[PS3_FRAME_REQ_SGE_NUM_MGR]; +}PS3MgrReqFrame_s; -struct PS3MgrTaskReqFrame { - struct PS3ReqFrameHead reqHead; - unsigned short taskID; - unsigned char lun[PS3_FRAME_LUN_BUFLEN]; - unsigned char abortedCmdType; - unsigned char reserved[5]; -}; +typedef struct PS3MgrTaskReqFrame { + PS3ReqFrameHead_s reqHead; + U16 taskID; + U8 lun[PS3_FRAME_LUN_BUFLEN]; + U8 abortedCmdType; + U8 reserved[5]; +} PS3MgrTaskReqFrame_s; union PS3ReqFrame { - struct PS3MgrTaskReqFrame taskReq; - struct PS3MgrReqFrame mgrReq; - struct PS3FrontEndReqFrame frontendReq; - struct PS3HwReqFrame hwReq; - unsigned char word[256]; + PS3MgrTaskReqFrame_s taskReq; + PS3MgrReqFrame_s mgrReq; + PS3FrontEndReqFrame_s frontendReq; + PS3HwReqFrame_s hwReq; + U8 word[256]; }; -struct PS3DrvInfo { - char drvName[PS3_DRV_NAME_MAX_LEN]; - char drvVersion[PS3_DRV_VERSION_MAX_LEN]; - unsigned long long bus; - unsigned char dev : 5; - unsigned char func : 3; - unsigned char domain_support : 1; - unsigned char reserved : 7; - unsigned short compatVer; - unsigned int domain; - unsigned char reserved1[56]; -}; +typedef struct PS3DrvInfo { + char drvName[PS3_DRV_NAME_MAX_LEN]; + char drvVersion[PS3_DRV_VERSION_MAX_LEN]; + U64 bus; + U8 dev:5; + U8 func:3; + U8 domain_support:1; + U8 reserved:7; + U16 compatVer; + U32 domain; + U8 reserved1[56]; +} PS3DrvInfo_s; enum { - PS3_MEM_TYPE_UNKNOWN = 0, - PS3_MEM_TYPE_SO = 1, - PS3_MEM_TYPE_RO = 2, + PS3_MEM_TYPE_UNKNOWN = 0, + PS3_MEM_TYPE_SO = 1, + PS3_MEM_TYPE_RO = 2, }; -struct PS3HostMemInfo { - unsigned long long startAddr; - unsigned long long endAddr; - unsigned char type; - unsigned char reserved[7]; -}; +typedef struct PS3HostMemInfo { + U64 startAddr; + U64 endAddr; + U8 type; + U8 reserved[7]; +} PS3HostMemInfo_s; struct PS3InitReqFrame { - struct PS3ReqFrameHead reqHead; - unsigned char ver; - unsigned char reserved0; - unsigned short length; - unsigned char operater; - unsigned char pageSize; - unsigned char pciIrqType; - unsigned char osType; - unsigned char reserved1[6]; - unsigned short msixVector; - unsigned long long timeStamp; - unsigned long long reqFrameBufBaseAddr; - unsigned long long hostMemInfoBaseAddr; - unsigned int hostMemInfoNum; - unsigned char reserved2[20]; - - unsigned long long replyFifoDescBaseAddr; - - unsigned long long respFrameBaseAddr; - unsigned int eventTypeMap; - unsigned short reqFrameMaxNum; - unsigned short respFrameMaxNum; - unsigned long long filterTableAddr; - unsigned int filterTableLen; - unsigned short bufSizePerRespFrame; - unsigned char hilMode; - unsigned char reserved3[33]; - unsigned long long systemInfoBufAddr; - unsigned long long debugMemArrayAddr; - unsigned int debugMemArrayNum; - unsigned int dumpDmaBufLen; - unsigned long long dumpDmaBufAddr; - unsigned int dumpIsrSN; - unsigned short drvInfoBufLen; - unsigned char reserverd4[2]; - unsigned long long drvInfoBufAddr; - unsigned char reserved5[36]; - unsigned int respStatus; + PS3ReqFrameHead_s reqHead; + U8 ver; + U8 reserved0; + U16 length; + U8 operater; + U8 pageSize; + U8 pciIrqType; + U8 osType; + U8 reserved1[6]; + U16 msixVector; + U64 timeStamp; + U64 reqFrameBufBaseAddr; + U64 hostMemInfoBaseAddr; + U32 hostMemInfoNum; + U8 reserved2[20]; + + U64 replyFifoDescBaseAddr; + + U64 respFrameBaseAddr; + U32 eventTypeMap; + U16 reqFrameMaxNum; + U16 respFrameMaxNum; + U64 filterTableAddr; + U32 filterTableLen; + U16 bufSizePerRespFrame; + U8 hilMode; + U8 reserved3[33]; + U64 systemInfoBufAddr; + U64 debugMemArrayAddr; + U32 debugMemArrayNum; + U32 dumpDmaBufLen; + U64 dumpDmaBufAddr; + U32 dumpIsrSN; + U16 drvInfoBufLen; + U8 reserverd4[2]; + U64 drvInfoBufAddr; + U8 reserved5[36]; + U32 respStatus; }; #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_sas.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_sas.h index 858cadcac99c..209e7197e041 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_sas.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_sas.h @@ -1,320 +1,320 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ #ifndef _PS3_IODT_H_ #define _PS3_IODT_H_ #include "ps3_htp_def.h" + enum IodtProtocolType { - PROTOCOL_SMP = 0b000, - PROTOCOL_SSP = 0b001, - PROTOCOL_STP = 0b010, - PROTOCOL_DIRT = 0b111, + PROTOCOL_SMP = 0b000, + PROTOCOL_SSP = 0b001, + PROTOCOL_STP = 0b010, + PROTOCOL_DIRT = 0b111, }; enum IodtFrameType { - FRAMETYPE_SSP_CMD = 0b001, - FRAMETYPE_SSP_SMP = 0b001, - FRAMETYPE_SATA_NONDATA = 0b001, + FRAMETYPE_SSP_CMD = 0b001, + FRAMETYPE_SSP_SMP = 0b001, + FRAMETYPE_SATA_NONDATA = 0b001, - FRAMETYPE_SSP_TASK = 0b010, - FRAMETYPE_SATA_PIO = 0b010, + FRAMETYPE_SSP_TASK = 0b010, + FRAMETYPE_SATA_PIO = 0b010, - FRAMETYPE_SATA_DMA = 0b011, + FRAMETYPE_SATA_DMA = 0b011, - FRAMETYPE_SATA_FPDMA = 0b100, + FRAMETYPE_SATA_FPDMA = 0b100, - FRAMETYPE_SATA_ATAPI = 0b101, - FRAMETYPE_DIRECT = 0b111, + FRAMETYPE_SATA_ATAPI = 0b101, + FRAMETYPE_DIRECT = 0b111, }; enum IodtIuSrc { - IU_SRC_MEM = 0b00, - IU_SRC_IODT = 0b01, - IU_SRC_TUPLE = 0b10, - IU_SRC_SATA = 0b11, + IU_SRC_MEM = 0b00, + IU_SRC_IODT = 0b01, + IU_SRC_TUPLE = 0b10, + IU_SRC_SATA = 0b11, }; enum IodtSgeMode { - IODT_SGEMODE_DIRECT = 0x0, - IODT_SGEMODE_SGL = 0x1, + IODT_SGEMODE_DIRECT = 0x0, + IODT_SGEMODE_SGL = 0x1, }; enum IodtEedpMode { - EEDP_MODE_CHECK = 0x0, - EEDP_MODE_INSERT = 0x1, - EEDP_MODE_REPLACE = 0x2, - EEDP_MODE_RMV = 0x3, + EEDP_MODE_CHECK = 0x0, + EEDP_MODE_INSERT = 0x1, + EEDP_MODE_REPLACE = 0x2, + EEDP_MODE_RMV = 0x3, }; enum AbortCtrl { - ABT_SASSATA_TASK = 0b00, - ABT_SAS_TASKSET = 0b01, - ABT_LOCAL_BY_DISK = 0b10, - ABT_LOCAL_BY_PORT = 0b11, + ABT_SASSATA_TASK = 0b00, + ABT_SAS_TASKSET = 0b01, + ABT_LOCAL_BY_DISK = 0b10, + ABT_LOCAL_BY_PORT = 0b11, - ABT_MGT_IO = 0b00, - ABT_SOFTRESET = 0b01, - ABT_READ_NCQ_ERR_LOG = 0b10, - ABT_SMP = 0b11, + ABT_MGT_IO = 0b00, + ABT_SOFTRESET = 0b01, + ABT_READ_NCQ_ERR_LOG = 0b10, + ABT_SMP = 0b11, }; enum DirectFlag { - DIRECT_FLAG_NORMAL = 0b00, - DIRECT_FLAG_DIRECT = 0b10, + DIRECT_FLAG_NORMAL = 0b00, + DIRECT_FLAG_DIRECT = 0b10, }; enum CmdWordType { - CMD_WORD_TYPE_ABORT = 0b00, - CMD_WORD_TYPE_MGT = 0b01, - CMD_WORD_TYPE_READ = 0b10, - CMD_WORD_TYPE_WRITE = 0b11, + CMD_WORD_TYPE_ABORT = 0b00, + CMD_WORD_TYPE_MGT = 0b01, + CMD_WORD_TYPE_READ = 0b10, + CMD_WORD_TYPE_WRITE = 0b11, }; enum SmpFrameType { - SMP_REQ = 0x40, - SMP_RESP = 0x41, + SMP_REQ = 0x40, + SMP_RESP = 0x41, }; enum eedpMode { - EEDP_NONE = 0b0000, - EEDP_CHK = 0b0001, - EEDP_INST = 0b0010, - EEDP_REPL = 0b0100, - EEDP_RMV = 0b1000, -}; - -union IoDmaCfg { - struct { - unsigned char eedpEn : 1; - unsigned char eedpSgMod : 1; - unsigned char twoSglMod : 1; - unsigned char sgMode : 1; - unsigned char eedpMode : 4; - }; - unsigned char byte; + EEDP_NONE = 0b0000, + EEDP_CHK = 0b0001, + EEDP_INST = 0b0010, + EEDP_REPL = 0b0100, + EEDP_RMV = 0b1000, }; - -struct __packed SspTaskFrameIu { - unsigned long long LUN; - unsigned short reserved0; - unsigned char function; - unsigned char reserved1; - unsigned short manageTag; - unsigned char reserved2[14]; -}; - - -union __packed SmpFrameIu { - struct { - unsigned char frameType; - unsigned char reqestBytes[31]; - }; - unsigned char smpIURaw[32]; -}; - - -struct __packed DfifoWordCommon { - - union { - struct { - unsigned short type : 2; - unsigned short rsv1 : 2; - unsigned short direct : 2; - unsigned short rFifoID : 4; - unsigned short rsv2 : 6; - }; - unsigned short WD0; - }; - - - union { - - struct { - union { - - struct { - unsigned short darID : 13; - unsigned short rsv3 : 2; - - unsigned short function : 1; - }; - - struct { - unsigned short manageIptt : 13; - }; - }; - }; - - struct { - union { - - struct { - unsigned short reqFrameID : 13; - }; - - struct { - unsigned short manageReqFrameID : 13; - }; - }; - }; - unsigned short WD1; - }; - - union { - struct { - unsigned short phyDiskID : 12; - unsigned short rsv4 : 2; - unsigned short abortCtrl : 2; - }; - unsigned short WD2; - }; -}; - -struct __packed IODT_V1 { - union { - - struct __packed { - union { - struct { - union { - struct { - unsigned char - protocolType : 3; - unsigned char - frameType : 3; - unsigned char iuSrc : 2; - }; - unsigned char byte0; - }; - - union IoDmaCfg dmaCfg; - }; - unsigned short config; - }; - - - - unsigned short cmdLen : 9; - unsigned short rsv0 : 7; - - union { - struct { - unsigned int taskDarID : 13; - unsigned int resv0 : 19; - }; - struct { - unsigned int dataBufLenDWAlign : 24; - - unsigned int rsvd0 : 1; - unsigned int cmdDir : 1; - unsigned int refTagEn : 1; - unsigned int appTagEn : 1; - unsigned int guardTagEn : 1; - unsigned int refTagInc : 1; - unsigned int rsv1 : 1; - unsigned int aborted : 1; - }; - }; - }; - unsigned long long QW0; - }; - - - union { - struct __packed { - struct DfifoWordCommon commonWord; - unsigned short rsv2 : 1; - unsigned short sataCtl : 1; - unsigned short rsv3 : 2; - unsigned short sasCtl : 1; - unsigned short sataByteBlock0 : 1; - unsigned short sataByteBlock1 : 1; - unsigned short rsv4 : 9; - }; - unsigned long long QW1; - }; - - - union { - unsigned long long dataBaseAddr; - unsigned long long QW2; - }; - - - union { - unsigned long long eedpBaseAddr; - unsigned long long QW3; - }; - - - union { - - struct { - unsigned long long cmdIUAddr; - unsigned long long rsv9; - - unsigned long long refTag : 32; - unsigned long long appTag : 16; - unsigned long long rsv10 : 16; - - unsigned long long rsv11; - } A; - - union { - unsigned char cdb[32]; - struct SspTaskFrameIu taskIU; - union SmpFrameIu smpIU; - } B; - - - struct { - unsigned long long opCode : 8; - unsigned long long rsv12 : 56; - - unsigned long long lba : 48; - unsigned long long rsv13 : 16; - - unsigned long long refTag : 32; - unsigned long long appTag : 16; - unsigned long long rsv14 : 16; - - unsigned long long rsv15; - } C; - - struct { - unsigned int ataCmd : 8; - unsigned int ataDev : 8; - unsigned int ataCtl : 8; - unsigned int ataIcc : 8; - unsigned int ataSecCnt : 16; - unsigned int ataFeature : 16; - - union { - struct { - unsigned long long ataLba : 48; - unsigned long long rsv16 : 16; - }; - struct { - unsigned char lba0; - unsigned char lba1; - unsigned char lba2; - unsigned char lba3; - unsigned char lba4; - unsigned char lba5; - }; - unsigned char lba[6]; - }; - - unsigned int ataAuxiliary; - unsigned int rsv17; - - unsigned long long rsv18; - } D; - }; -}; +typedef union IoDmaCfg { + struct { + U8 eedpEn : 1; + U8 eedpSgMod : 1; + U8 twoSglMod : 1; + U8 sgMode : 1; + U8 eedpMode : 4; + }; + U8 byte; +} IoDmaCfg_u; + + +typedef struct __attribute__((packed)) SspTaskFrameIu { + U64 LUN; + U16 reserved0; + U8 function; + U8 reserved1; + U16 manageTag; + U8 reserved2[14]; +} SspTaskFrameIu_s; + + +typedef union __attribute__((packed)) SmpFrameIu { + struct { + U8 frameType; + U8 reqestBytes[31]; + }; + U8 smpIURaw[32]; +} SmpFrameIu_s; + + +typedef struct __attribute__((packed)) DfifoWordCommon { + + union { + struct { + U16 type : 2; + U16 rsv1 : 2; + U16 direct : 2; + U16 rFifoID : 4; + U16 rsv2 : 6; + }; + U16 WD0; + }; + + + union{ + + struct { + union{ + + struct { + U16 darID : 13; + U16 rsv3 : 2; + + U16 function : 1; + }; + + struct{ + U16 manageIptt : 13; + }; + }; + }; + + struct { + union{ + + struct{ + U16 reqFrameID : 13; + }; + + + struct{ + U16 manageReqFrameID : 13; + }; + }; + }; + U16 WD1; + }; + + + union { + struct { + U16 phyDiskID : 12; + U16 rsv4 : 2; + U16 abortCtrl : 2; + }; + U16 WD2; + }; +}DfifoWordCommon_s; + +typedef struct __attribute__((packed)) IODT_V1 { + union { + + struct __attribute__((packed)) { + union { + struct { + union { + struct { + U8 protocolType : 3; + U8 frameType : 3; + U8 iuSrc : 2; + }; + U8 byte0; + }; + + IoDmaCfg_u dmaCfg; + }; + U16 config; + }; + + + + + U16 cmdLen : 9; + U16 rsv0 : 7; + + union { + struct { + U32 taskDarID : 13; + U32 : 19; + }; + struct { + U32 dataBufLenDWAlign : 24; + + U32 rsvd0 : 1; + U32 cmdDir : 1; + U32 refTagEn : 1; + U32 appTagEn : 1; + U32 guardTagEn : 1; + U32 refTagInc : 1; + U32 rsv1 : 1; + U32 aborted : 1; + }; + }; + }; + U64 QW0; + }; + + + union { + struct __attribute__((packed)) { + DfifoWordCommon_s commonWord; + U16 rsv2 : 1; + U16 sataCtl : 1; + U16 rsv3 : 2; + U16 sasCtl : 1; + U16 sataByteBlock0 : 1; + U16 sataByteBlock1 : 1; + U16 rsv4 : 9; + }; + U64 QW1; + }; + + + union { + U64 dataBaseAddr; + U64 QW2; + }; + + + union { + U64 eedpBaseAddr; + U64 QW3; + }; + + + union { + + struct { + U64 cmdIUAddr; + U64 rsv9; + + U64 refTag : 32; + U64 appTag : 16; + U64 rsv10 : 16; + + U64 rsv11; + } A; + + union { + U8 cdb[32]; + SspTaskFrameIu_s taskIU; + SmpFrameIu_s smpIU; + } B; + + + struct { + U64 opCode : 8; + U64 rsv12 : 56; + + U64 lba : 48; + U64 rsv13 : 16; + + U64 refTag : 32; + U64 appTag : 16; + U64 rsv14 : 16; + + U64 rsv15; + } C; + + struct { + U32 ataCmd : 8; + U32 ataDev : 8; + U32 ataCtl : 8; + U32 ataIcc : 8; + U32 ataSecCnt : 16; + U32 ataFeature : 16; + + union { + struct { + U64 ataLba : 48; + U64 rsv16 : 16; + }; + struct { + U8 lba0; + U8 lba1; + U8 lba2; + U8 lba3; + U8 lba4; + U8 lba5; + }; + U8 lba[6]; + }; + + U32 ataAuxiliary; + U32 rsv17; + + U64 rsv18; + } D; + }; +} IODT_V1_s; enum { CMD_LEN_THR = 32, @@ -322,4 +322,4 @@ enum { CMD_LEN_L = 11, }; -#endif +#endif \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h index c0a1f806e3c9..302aaeaa8803 100644 --- a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h +++ b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h @@ -1,11 +1,10 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef __S1861_GLOBAL_BASEADDR_REG_H__ #define __S1861_GLOBAL_BASEADDR_REG_H__ -#define HIL_REG0_PS3_REGISTER_F_BASEADDR 0x24000000UL -#define HIL_REG0_PS3_REGISTER_F_SIZE 0x10000UL -#define HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR 0x24010000UL -#define HIL_REG0_PS3_REQUEST_QUEUE_SIZE 0x200UL -#define HIL_REG0_PS3_REGISTER_S_SIZE 0x1FE00UL +#define HIL_REG0_PS3_REGISTER_F_BASEADDR 0x24000000UL +#define HIL_REG0_PS3_REGISTER_F_SIZE 0x10000UL +#define HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR 0x24010000UL +#define HIL_REG0_PS3_REQUEST_QUEUE_SIZE 0x200UL +#define HIL_REG0_PS3_REGISTER_S_SIZE 0x1FE00UL #endif - diff --git a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h index c6a7f371613f..004a76a5fa6a 100644 --- a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h +++ b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h @@ -1,1079 +1,1055 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_H__ #define __S1861_HIL_REG0_PS3_REGISTER_F_REG_H__ #include "s1861_global_baseaddr.h" #ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_MACRO__ -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x40) -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x48) -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x50) -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x58) -#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x100) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x108) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x110) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x118) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x120) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x128) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x130) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x138) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x140) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x200) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x208) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x210) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x218) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x220) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x228) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x230) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x238) -#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_RST (0x0000000002FAF080) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x240) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x248) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_RST (0x0000000000000001) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x300) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x308) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_RST (0x0000000000001FFF) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x310) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_RST (0x0000000000000FFF) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x318) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x320) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x328) -#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_RST (0x0000000000000007) -#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x330) -#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x338) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_RST (0x000000000000007F) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x340) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x348) -#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_RST (0x0000000000000400) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x350) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_RST (0x0000000000001000) -#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x358) -#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_RST (0x0000000000000400) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x360) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x400) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x408) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x410) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x418) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x420) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x440) -#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x500) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x508) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x510) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x518) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x520) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x600) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x608) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x610) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x618) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x620) -#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x628) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x630) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x638) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x640) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x648) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x650) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x658) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x660) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x668) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x670) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x678) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x680) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x688) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x690) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x698) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a0) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a8) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b0) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b8) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c0) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c8) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d0) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d8) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x700) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_RST (0xFFFFFFFFFFFFFFFF) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x708) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_ADDR \ - (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x710) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_RST \ - (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x40) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x48) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x50) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x58) +#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x100) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x108) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x110) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x118) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x120) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x128) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x130) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x138) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x140) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x200) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x208) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x210) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x218) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x220) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x228) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x230) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x238) +#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_RST (0x0000000002FAF080) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x240) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x248) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_RST (0x0000000000000001) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x300) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x308) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_RST (0x0000000000001FFF) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x310) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_RST (0x0000000000000FFF) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x318) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x320) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x328) +#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_RST (0x0000000000000007) +#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x330) +#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x338) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_RST (0x000000000000007F) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x340) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x348) +#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_RST (0x0000000000000400) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x350) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_RST (0x0000000000001000) +#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x358) +#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_RST (0x0000000000000400) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x360) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x400) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x408) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x410) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x418) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x420) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x440) +#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x500) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x508) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x510) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x518) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x520) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x600) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x608) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x610) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x618) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x620) +#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x628) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x630) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x638) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x640) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x648) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x650) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x658) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x660) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x668) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x670) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x678) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x680) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x688) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x690) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x698) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a0) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a8) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b0) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b8) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c0) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c8) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d0) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d8) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x700) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_RST (0xFFFFFFFFFFFFFFFF) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x708) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x710) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_RST (0x0000000000000000) #endif #ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_STRUCT__ union HilReg0Ps3RegisterFPs3Doorbell { - unsigned long long val; - struct { - unsigned long long cmd : 16; - unsigned long long reserved1 : 48; + U64 val; + struct{ + + U64 cmd : 16; + U64 reserved1 : 48; } reg; }; union HilReg0Ps3RegisterFPs3DoorbellIrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3DoorbellIrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3IrqControl { - unsigned long long val; - struct { - unsigned long long global : 1; - unsigned long long fwState : 1; - unsigned long long tbd : 30; - unsigned long long reserved3 : 32; + U64 val; + struct{ + + U64 global : 1; + U64 fwState : 1; + U64 tbd : 30; + U64 reserved3 : 32; } reg; }; union HilReg0Ps3RegisterFPs3SoftresetKey { - unsigned long long val; - struct { - unsigned long long ps3SoftresetKey : 8; - unsigned long long reserved1 : 56; + U64 val; + struct{ + + U64 ps3SoftresetKey : 8; + U64 reserved1 : 56; } reg; }; union HilReg0Ps3RegisterFPs3SoftresetState { - unsigned long long val; - struct { - unsigned long long rpt : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 rpt : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Softreset { - unsigned long long val; - struct { - unsigned long long cmd : 8; - unsigned long long reserved1 : 56; + U64 val; + struct{ + + U64 cmd : 8; + U64 reserved1 : 56; } reg; }; union HilReg0Ps3RegisterFPs3SoftresetIrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3SoftresetIrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow { - unsigned long long val; - struct { - unsigned long long rpt : 64; + U64 val; + struct{ + + U64 rpt : 64; } reg; }; union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh { - unsigned long long val; - struct { - unsigned long long rpt : 8; - unsigned long long reserved1 : 56; + U64 val; + struct{ + + U64 rpt : 8; + U64 reserved1 : 56; } reg; }; union HilReg0Ps3RegisterFPs3SoftresetTimeCnt { - unsigned long long val; - struct { - unsigned long long rpt : 64; + U64 val; + struct{ + + U64 rpt : 64; } reg; }; union HilReg0Ps3RegisterFPs3SoftresetTimeOutEn { - unsigned long long val; - struct { - unsigned long long rpt : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 rpt : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3HardresetKey { - unsigned long long val; - struct { - unsigned long long ps3HardresetKey : 8; - unsigned long long reserved1 : 56; + U64 val; + struct{ + + U64 ps3HardresetKey : 8; + U64 reserved1 : 56; } reg; }; union HilReg0Ps3RegisterFPs3HardresetState { - unsigned long long val; - struct { - unsigned long long rpt : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 rpt : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Hardreset { - unsigned long long val; - struct { - unsigned long long config : 8; - unsigned long long reserved1 : 56; + U64 val; + struct{ + + U64 config : 8; + U64 reserved1 : 56; } reg; }; union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow { - unsigned long long val; - struct { - unsigned long long rpt : 64; + U64 val; + struct{ + + U64 rpt : 64; } reg; }; union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh { - unsigned long long val; - struct { - unsigned long long rpt : 8; - unsigned long long reserved1 : 56; + U64 val; + struct{ + + U64 rpt : 8; + U64 reserved1 : 56; } reg; }; union HilReg0Ps3RegisterFPs3HardresetTimeCnt { - unsigned long long val; - struct { - unsigned long long rpt : 64; + U64 val; + struct{ + + U64 rpt : 64; } reg; }; union HilReg0Ps3RegisterFPs3HardresetTimeOutEn { - unsigned long long val; - struct { - unsigned long long rpt : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 rpt : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3KeyGapCfg { - unsigned long long val; - struct { - unsigned long long ps3KeyGapCfg : 64; + U64 val; + struct{ + + U64 ps3KeyGapCfg : 64; } reg; }; union HilReg0Ps3RegisterFPs3HardresetIrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3HardresetIrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3SocFwState { - unsigned long long val; - struct { - unsigned long long ps3SocFwState : 8; - unsigned long long ps3SocFwStartState : 8; - unsigned long long ps3SocBootState : 8; - unsigned long long tbd : 8; - unsigned long long reserved4 : 32; + U64 val; + struct{ + + U64 ps3SocFwState : 8; + U64 ps3SocFwStartState : 8; + U64 ps3SocBootState : 8; + U64 tbd : 8; + U64 reserved4 : 32; } reg; }; union HilReg0Ps3RegisterFPs3MaxFwCmd { - unsigned long long val; - struct { - unsigned long long ps3MaxFwCmd : 16; - unsigned long long reserved1 : 48; + U64 val; + struct{ + + U64 ps3MaxFwCmd : 16; + U64 reserved1 : 48; } reg; }; union HilReg0Ps3RegisterFPs3MaxChainSize { - unsigned long long val; - struct { - unsigned long long ps3MaxChainSize : 32; - unsigned long long reserved1 : 32; + U64 val; + struct{ + + U64 ps3MaxChainSize : 32; + U64 reserved1 : 32; } reg; }; union HilReg0Ps3RegisterFPs3MaxVdInfoSize { - unsigned long long val; - struct { - unsigned long long ps3MaxVdInfoSize : 32; - unsigned long long reserved1 : 32; + U64 val; + struct{ + + U64 ps3MaxVdInfoSize : 32; + U64 reserved1 : 32; } reg; }; union HilReg0Ps3RegisterFPs3MaxNvmePageSize { - unsigned long long val; - struct { - unsigned long long ps3MaxNvmePageSize : 32; - unsigned long long reserved1 : 32; + U64 val; + struct{ + + U64 ps3MaxNvmePageSize : 32; + U64 reserved1 : 32; } reg; }; union HilReg0Ps3RegisterFPs3FeatureSupport { - unsigned long long val; - struct { - unsigned long long multiDevfnSupport : 1; - unsigned long long dmaBit64Support : 1; - unsigned long long debugOcmSupport : 1; - unsigned long long tbd1 : 13; - unsigned long long fwHaltSupport : 1; - unsigned long long sglModeSupport : 1; - unsigned long long dumpCrashSupport : 1; - unsigned long long shallowSoftRecoverySupport : 1; - unsigned long long deepSoftRecoverySupport : 1; - unsigned long long hardRecoverySupport : 1; - unsigned long long tbd2 : 42; + U64 val; + struct{ + + U64 multiDevfnSupport : 1; + U64 dmaBit64Support : 1; + U64 debugOcmSupport : 1; + U64 tbd1 : 13; + U64 fwHaltSupport : 1; + U64 sglModeSupport : 1; + U64 dumpCrashSupport : 1; + U64 shallowSoftRecoverySupport : 1; + U64 deepSoftRecoverySupport : 1; + U64 hardRecoverySupport : 1; + U64 tbd2 : 42; } reg; }; union HilReg0Ps3RegisterFPs3FirmwareVersion { - unsigned long long val; - struct { - unsigned long long ps3FmVer : 8; - unsigned long long tbd : 24; - unsigned long long reserved2 : 32; + U64 val; + struct{ + + U64 ps3FmVer : 8; + U64 tbd : 24; + U64 reserved2 : 32; } reg; }; union HilReg0Ps3RegisterFPs3MaxReplyque { - unsigned long long val; - struct { - unsigned long long ps3MaxReplyque : 16; - unsigned long long reserved1 : 48; + U64 val; + struct{ + + U64 ps3MaxReplyque : 16; + U64 reserved1 : 48; } reg; }; union HilReg0Ps3RegisterFPs3HardwareVersion { - unsigned long long val; - struct { - unsigned long long chipId : 64; + U64 val; + struct{ + + U64 chipId : 64; } reg; }; union HilReg0Ps3RegisterFPs3MgrQueueDepth { - unsigned long long val; - struct { - unsigned long long ps3MgrQueueDepth : 16; - unsigned long long reserved1 : 48; + U64 val; + struct{ + + U64 ps3MgrQueueDepth : 16; + U64 reserved1 : 48; } reg; }; union HilReg0Ps3RegisterFPs3CmdQueueDepth { - unsigned long long val; - struct { - unsigned long long ps3CmdQueueDepth : 16; - unsigned long long reserved1 : 48; + U64 val; + struct{ + + U64 ps3CmdQueueDepth : 16; + U64 reserved1 : 48; } reg; }; union HilReg0Ps3RegisterFPs3TfifoDepth { - unsigned long long val; - struct { - unsigned long long ps3TfifoDepth : 16; - unsigned long long reserved1 : 48; + U64 val; + struct{ + + U64 ps3TfifoDepth : 16; + U64 reserved1 : 48; } reg; }; union HilReg0Ps3RegisterFPs3MaxSecR1xCmds { - unsigned long long val; - struct { - unsigned long long ps3MaxSecR1xCmds : 16; - unsigned long long reserved1 : 48; + U64 val; + struct{ + + U64 ps3MaxSecR1xCmds : 16; + U64 reserved1 : 48; } reg; }; union HilReg0Ps3RegisterFPs3HilAdvice2directCnt0 { - unsigned long long val; - struct { - unsigned long long rpt : 32; - unsigned long long reserved1 : 32; + U64 val; + struct{ + + U64 rpt : 32; + U64 reserved1 : 32; } reg; }; union HilReg0Ps3RegisterFPs3HilAdvice2directCnt1 { - unsigned long long val; - struct { - unsigned long long rpt : 32; - unsigned long long reserved1 : 32; + U64 val; + struct{ + + U64 rpt : 32; + U64 reserved1 : 32; } reg; }; union HilReg0Ps3RegisterFPs3HilAdvice2directCnt2 { - unsigned long long val; - struct { - unsigned long long rpt : 32; - unsigned long long reserved1 : 32; + U64 val; + struct{ + + U64 rpt : 32; + U64 reserved1 : 32; } reg; }; union HilReg0Ps3RegisterFPs3HilAdvice2directCnt3 { - unsigned long long val; - struct { - unsigned long long rpt : 32; - unsigned long long reserved1 : 32; + U64 val; + struct{ + + U64 rpt : 32; + U64 reserved1 : 32; } reg; }; union HilReg0Ps3RegisterFPs3HilAdvice2directCntAll { - unsigned long long val; - struct { - unsigned long long rpt : 32; - unsigned long long reserved1 : 32; + U64 val; + struct{ + + U64 rpt : 32; + U64 reserved1 : 32; } reg; }; union HilReg0Ps3RegisterFPs3IrqStatusRpt { - unsigned long long val; - struct { - unsigned long long doorbell : 1; - unsigned long long reserved1 : 3; - unsigned long long softreset : 1; - unsigned long long reserved3 : 3; - unsigned long long dumpCtrl : 1; - unsigned long long reserved5 : 3; - unsigned long long debug0 : 1; - unsigned long long reserved7 : 3; - unsigned long long debug1 : 1; - unsigned long long reserved9 : 3; - unsigned long long debug2 : 1; - unsigned long long reserved11 : 3; - unsigned long long debug3 : 1; - unsigned long long reserved13 : 3; - unsigned long long debug4 : 1; - unsigned long long reserved15 : 3; - unsigned long long cmdTrigger : 1; - unsigned long long reserved17 : 3; - unsigned long long hardreset : 1; - unsigned long long reserved19 : 3; - unsigned long long sessioncmdAddr : 1; - unsigned long long reserved21 : 23; + U64 val; + struct{ + + U64 doorbell : 1; + U64 reserved1 : 3; + U64 softreset : 1; + U64 reserved3 : 3; + U64 dumpCtrl : 1; + U64 reserved5 : 3; + U64 debug0 : 1; + U64 reserved7 : 3; + U64 debug1 : 1; + U64 reserved9 : 3; + U64 debug2 : 1; + U64 reserved11 : 3; + U64 debug3 : 1; + U64 reserved13 : 3; + U64 debug4 : 1; + U64 reserved15 : 3; + U64 cmdTrigger : 1; + U64 reserved17 : 3; + U64 hardreset : 1; + U64 reserved19 : 3; + U64 sessioncmdAddr : 1; + U64 reserved21 : 23; } reg; }; union HilReg0Ps3RegisterFPs3DumpCtrl { - unsigned long long val; - struct { - unsigned long long cmd : 16; - unsigned long long reserved1 : 48; + U64 val; + struct{ + + U64 cmd : 16; + U64 reserved1 : 48; } reg; }; union HilReg0Ps3RegisterFPs3DumpCtrlIrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3DumpCtrlIrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3DumpStatus { - unsigned long long val; - struct { - unsigned long long dmaFinish : 1; - unsigned long long hasCrashDump : 1; - unsigned long long hasFwDump : 1; - unsigned long long hasBarDump : 1; - unsigned long long hasAutoDump : 2; - unsigned long long tbd : 10; - unsigned long long reserved6 : 48; + U64 val; + struct{ + + U64 dmaFinish : 1; + U64 hasCrashDump : 1; + U64 hasFwDump : 1; + U64 hasBarDump : 1; + U64 hasAutoDump : 2; + U64 tbd : 10; + U64 reserved6 : 48; } reg; }; union HilReg0Ps3RegisterFPs3DumpDataSize { - unsigned long long val; - struct { - unsigned long long ps3DumpDataSize : 32; - unsigned long long reserved1 : 32; + U64 val; + struct{ + + U64 ps3DumpDataSize : 32; + U64 reserved1 : 32; } reg; }; union HilReg0Ps3RegisterFPs3CmdTrigger { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3CmdTriggerIrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3CmdTriggerIrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3SoftresetCounter { - unsigned long long val; - struct { - unsigned long long rpt : 32; - unsigned long long tbd : 32; + U64 val; + struct{ + + U64 rpt : 32; + U64 tbd : 32; } reg; }; union HilReg0Ps3RegisterFPs3RegCmdState { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug0 { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug0IrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Debug0IrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Debug1 { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug1IrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Debug1IrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Debug2 { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug2IrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Debug2IrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Debug3 { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug3IrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Debug3IrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Debug4 { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug4IrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Debug4IrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3Debug5 { - unsigned long long val; + + U64 val; struct { - unsigned long long cmd : 64; + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug6 { - unsigned long long val; + + U64 val; struct { - unsigned long long cmd : 64; + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug7 { - unsigned long long val; + + U64 val; struct { - unsigned long long cmd : 64; + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug8 { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug9 { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug10 { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug11 { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3Debug12 { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3SessioncmdAddr { - unsigned long long val; - struct { - unsigned long long cmd : 64; + U64 val; + struct{ + + U64 cmd : 64; } reg; }; union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear { - unsigned long long val; - struct { - unsigned long long pulse : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 pulse : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask { - unsigned long long val; - struct { - unsigned long long level : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 level : 1; + U64 reserved1 : 63; } reg; }; struct HilReg0Ps3RegisterF { - unsigned long long reserved0[8]; - union HilReg0Ps3RegisterFPs3Doorbell ps3Doorbell; - union HilReg0Ps3RegisterFPs3DoorbellIrqClear ps3DoorbellIrqClear; - union HilReg0Ps3RegisterFPs3DoorbellIrqMask ps3DoorbellIrqMask; - union HilReg0Ps3RegisterFPs3IrqControl ps3IrqControl; - unsigned long long reserved1[20]; - union HilReg0Ps3RegisterFPs3SoftresetKey ps3SoftresetKey; - union HilReg0Ps3RegisterFPs3SoftresetState ps3SoftresetState; - union HilReg0Ps3RegisterFPs3Softreset ps3Softreset; - union HilReg0Ps3RegisterFPs3SoftresetIrqClear ps3SoftresetIrqClear; - union HilReg0Ps3RegisterFPs3SoftresetIrqMask ps3SoftresetIrqMask; - - union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow - ps3SoftresetKeyShiftRegLow; - union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh - ps3SoftresetKeyShiftRegHigh; - union HilReg0Ps3RegisterFPs3SoftresetTimeCnt ps3SoftresetTimeCnt; - union HilReg0Ps3RegisterFPs3SoftresetTimeOutEn ps3SoftresetTimeOutEn; - unsigned long long reserved2[23]; - union HilReg0Ps3RegisterFPs3HardresetKey ps3HardresetKey; - union HilReg0Ps3RegisterFPs3HardresetState ps3HardresetState; - union HilReg0Ps3RegisterFPs3Hardreset ps3Hardreset; - - union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow - ps3HardresetKeyShiftRegLow; - union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh - ps3HardresetKeyShiftRegHigh; - union HilReg0Ps3RegisterFPs3HardresetTimeCnt ps3HardresetTimeCnt; - union HilReg0Ps3RegisterFPs3HardresetTimeOutEn ps3HardresetTimeOutEn; - union HilReg0Ps3RegisterFPs3KeyGapCfg ps3KeyGapCfg; - union HilReg0Ps3RegisterFPs3HardresetIrqClear ps3HardresetIrqClear; - union HilReg0Ps3RegisterFPs3HardresetIrqMask ps3HardresetIrqMask; - unsigned long long reserved3[22]; - union HilReg0Ps3RegisterFPs3SocFwState ps3SocFwState; - union HilReg0Ps3RegisterFPs3MaxFwCmd ps3MaxFwCmd; - union HilReg0Ps3RegisterFPs3MaxChainSize ps3MaxChainSize; - union HilReg0Ps3RegisterFPs3MaxVdInfoSize ps3MaxVdInfoSize; - union HilReg0Ps3RegisterFPs3MaxNvmePageSize ps3MaxNvmePageSize; - union HilReg0Ps3RegisterFPs3FeatureSupport ps3FeatureSupport; - union HilReg0Ps3RegisterFPs3FirmwareVersion ps3FirmwareVersion; - union HilReg0Ps3RegisterFPs3MaxReplyque ps3MaxReplyque; - union HilReg0Ps3RegisterFPs3HardwareVersion ps3HardwareVersion; - union HilReg0Ps3RegisterFPs3MgrQueueDepth ps3MgrQueueDepth; - union HilReg0Ps3RegisterFPs3CmdQueueDepth ps3CmdQueueDepth; - union HilReg0Ps3RegisterFPs3TfifoDepth ps3TfifoDepth; - union HilReg0Ps3RegisterFPs3MaxSecR1xCmds ps3MaxSecR1xCmds; - unsigned long long reserved4[19]; - union HilReg0Ps3RegisterFPs3HilAdvice2directCnt0 ps3HilAdvice2directCnt0; - union HilReg0Ps3RegisterFPs3HilAdvice2directCnt1 ps3HilAdvice2directCnt1; - union HilReg0Ps3RegisterFPs3HilAdvice2directCnt2 ps3HilAdvice2directCnt2; - union HilReg0Ps3RegisterFPs3HilAdvice2directCnt3 ps3HilAdvice2directCnt3; - union HilReg0Ps3RegisterFPs3HilAdvice2directCntAll - ps3HilAdvice2directCntAll; - unsigned long long reserved5[3]; - union HilReg0Ps3RegisterFPs3IrqStatusRpt ps3IrqStatusRpt; - unsigned long long reserved6[23]; - union HilReg0Ps3RegisterFPs3DumpCtrl ps3DumpCtrl; - union HilReg0Ps3RegisterFPs3DumpCtrlIrqClear ps3DumpCtrlIrqClear; - union HilReg0Ps3RegisterFPs3DumpCtrlIrqMask ps3DumpCtrlIrqMask; - union HilReg0Ps3RegisterFPs3DumpStatus ps3DumpStatus; - union HilReg0Ps3RegisterFPs3DumpDataSize ps3DumpDataSize; - unsigned long long reserved7[27]; - union HilReg0Ps3RegisterFPs3CmdTrigger ps3CmdTrigger; - union HilReg0Ps3RegisterFPs3CmdTriggerIrqClear ps3CmdTriggerIrqClear; - union HilReg0Ps3RegisterFPs3CmdTriggerIrqMask ps3CmdTriggerIrqMask; - union HilReg0Ps3RegisterFPs3SoftresetCounter ps3SoftresetCounter; - union HilReg0Ps3RegisterFPs3RegCmdState ps3RegCmdState; - union HilReg0Ps3RegisterFPs3Debug0 ps3Debug0; - union HilReg0Ps3RegisterFPs3Debug0IrqClear ps3Debug0IrqClear; - union HilReg0Ps3RegisterFPs3Debug0IrqMask ps3Debug0IrqMask; - union HilReg0Ps3RegisterFPs3Debug1 ps3Debug1; - union HilReg0Ps3RegisterFPs3Debug1IrqClear ps3Debug1IrqClear; - union HilReg0Ps3RegisterFPs3Debug1IrqMask ps3Debug1IrqMask; - union HilReg0Ps3RegisterFPs3Debug2 ps3Debug2; - union HilReg0Ps3RegisterFPs3Debug2IrqClear ps3Debug2IrqClear; - union HilReg0Ps3RegisterFPs3Debug2IrqMask ps3Debug2IrqMask; - union HilReg0Ps3RegisterFPs3Debug3 ps3Debug3; - union HilReg0Ps3RegisterFPs3Debug3IrqClear ps3Debug3IrqClear; - union HilReg0Ps3RegisterFPs3Debug3IrqMask ps3Debug3IrqMask; - union HilReg0Ps3RegisterFPs3Debug4 ps3Debug4; - union HilReg0Ps3RegisterFPs3Debug4IrqClear ps3Debug4IrqClear; - union HilReg0Ps3RegisterFPs3Debug4IrqMask ps3Debug4IrqMask; - union HilReg0Ps3RegisterFPs3Debug5 ps3Debug5; - union HilReg0Ps3RegisterFPs3Debug6 ps3Debug6; - union HilReg0Ps3RegisterFPs3Debug7 ps3Debug7; - union HilReg0Ps3RegisterFPs3Debug8 ps3Debug8; - union HilReg0Ps3RegisterFPs3Debug9 ps3Debug9; - union HilReg0Ps3RegisterFPs3Debug10 ps3Debug10; - union HilReg0Ps3RegisterFPs3Debug11 ps3Debug11; - union HilReg0Ps3RegisterFPs3Debug12 ps3Debug12; - unsigned long long reserved8[4]; - union HilReg0Ps3RegisterFPs3SessioncmdAddr ps3SessioncmdAddr; - union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear - ps3SessioncmdAddrIrqClear; - union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask - ps3SessioncmdAddrIrqMask; + U64 reserved0[8]; + union HilReg0Ps3RegisterFPs3Doorbell ps3Doorbell; + union HilReg0Ps3RegisterFPs3DoorbellIrqClear ps3DoorbellIrqClear; + union HilReg0Ps3RegisterFPs3DoorbellIrqMask ps3DoorbellIrqMask; + union HilReg0Ps3RegisterFPs3IrqControl ps3IrqControl; + U64 reserved1[20]; + union HilReg0Ps3RegisterFPs3SoftresetKey ps3SoftresetKey; + union HilReg0Ps3RegisterFPs3SoftresetState ps3SoftresetState; + union HilReg0Ps3RegisterFPs3Softreset ps3Softreset; + union HilReg0Ps3RegisterFPs3SoftresetIrqClear ps3SoftresetIrqClear; + union HilReg0Ps3RegisterFPs3SoftresetIrqMask ps3SoftresetIrqMask; + union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow ps3SoftresetKeyShiftRegLow; + union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh ps3SoftresetKeyShiftRegHigh; + union HilReg0Ps3RegisterFPs3SoftresetTimeCnt ps3SoftresetTimeCnt; + union HilReg0Ps3RegisterFPs3SoftresetTimeOutEn ps3SoftresetTimeOutEn; + U64 reserved2[23]; + union HilReg0Ps3RegisterFPs3HardresetKey ps3HardresetKey; + union HilReg0Ps3RegisterFPs3HardresetState ps3HardresetState; + union HilReg0Ps3RegisterFPs3Hardreset ps3Hardreset; + union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow ps3HardresetKeyShiftRegLow; + union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh ps3HardresetKeyShiftRegHigh; + union HilReg0Ps3RegisterFPs3HardresetTimeCnt ps3HardresetTimeCnt; + union HilReg0Ps3RegisterFPs3HardresetTimeOutEn ps3HardresetTimeOutEn; + union HilReg0Ps3RegisterFPs3KeyGapCfg ps3KeyGapCfg; + union HilReg0Ps3RegisterFPs3HardresetIrqClear ps3HardresetIrqClear; + union HilReg0Ps3RegisterFPs3HardresetIrqMask ps3HardresetIrqMask; + U64 reserved3[22]; + union HilReg0Ps3RegisterFPs3SocFwState ps3SocFwState; + union HilReg0Ps3RegisterFPs3MaxFwCmd ps3MaxFwCmd; + union HilReg0Ps3RegisterFPs3MaxChainSize ps3MaxChainSize; + union HilReg0Ps3RegisterFPs3MaxVdInfoSize ps3MaxVdInfoSize; + union HilReg0Ps3RegisterFPs3MaxNvmePageSize ps3MaxNvmePageSize; + union HilReg0Ps3RegisterFPs3FeatureSupport ps3FeatureSupport; + union HilReg0Ps3RegisterFPs3FirmwareVersion ps3FirmwareVersion; + union HilReg0Ps3RegisterFPs3MaxReplyque ps3MaxReplyque; + union HilReg0Ps3RegisterFPs3HardwareVersion ps3HardwareVersion; + union HilReg0Ps3RegisterFPs3MgrQueueDepth ps3MgrQueueDepth; + union HilReg0Ps3RegisterFPs3CmdQueueDepth ps3CmdQueueDepth; + union HilReg0Ps3RegisterFPs3TfifoDepth ps3TfifoDepth; + union HilReg0Ps3RegisterFPs3MaxSecR1xCmds ps3MaxSecR1xCmds; + U64 reserved4[19]; + union HilReg0Ps3RegisterFPs3HilAdvice2directCnt0 ps3HilAdvice2directCnt0; + union HilReg0Ps3RegisterFPs3HilAdvice2directCnt1 ps3HilAdvice2directCnt1; + union HilReg0Ps3RegisterFPs3HilAdvice2directCnt2 ps3HilAdvice2directCnt2; + union HilReg0Ps3RegisterFPs3HilAdvice2directCnt3 ps3HilAdvice2directCnt3; + union HilReg0Ps3RegisterFPs3HilAdvice2directCntAll ps3HilAdvice2directCntAll; + U64 reserved5[3]; + union HilReg0Ps3RegisterFPs3IrqStatusRpt ps3IrqStatusRpt; + U64 reserved6[23]; + union HilReg0Ps3RegisterFPs3DumpCtrl ps3DumpCtrl; + union HilReg0Ps3RegisterFPs3DumpCtrlIrqClear ps3DumpCtrlIrqClear; + union HilReg0Ps3RegisterFPs3DumpCtrlIrqMask ps3DumpCtrlIrqMask; + union HilReg0Ps3RegisterFPs3DumpStatus ps3DumpStatus; + union HilReg0Ps3RegisterFPs3DumpDataSize ps3DumpDataSize; + U64 reserved7[27]; + union HilReg0Ps3RegisterFPs3CmdTrigger ps3CmdTrigger; + union HilReg0Ps3RegisterFPs3CmdTriggerIrqClear ps3CmdTriggerIrqClear; + union HilReg0Ps3RegisterFPs3CmdTriggerIrqMask ps3CmdTriggerIrqMask; + union HilReg0Ps3RegisterFPs3SoftresetCounter ps3SoftresetCounter; + union HilReg0Ps3RegisterFPs3RegCmdState ps3RegCmdState; + union HilReg0Ps3RegisterFPs3Debug0 ps3Debug0; + union HilReg0Ps3RegisterFPs3Debug0IrqClear ps3Debug0IrqClear; + union HilReg0Ps3RegisterFPs3Debug0IrqMask ps3Debug0IrqMask; + union HilReg0Ps3RegisterFPs3Debug1 ps3Debug1; + union HilReg0Ps3RegisterFPs3Debug1IrqClear ps3Debug1IrqClear; + union HilReg0Ps3RegisterFPs3Debug1IrqMask ps3Debug1IrqMask; + union HilReg0Ps3RegisterFPs3Debug2 ps3Debug2; + union HilReg0Ps3RegisterFPs3Debug2IrqClear ps3Debug2IrqClear; + union HilReg0Ps3RegisterFPs3Debug2IrqMask ps3Debug2IrqMask; + union HilReg0Ps3RegisterFPs3Debug3 ps3Debug3; + union HilReg0Ps3RegisterFPs3Debug3IrqClear ps3Debug3IrqClear; + union HilReg0Ps3RegisterFPs3Debug3IrqMask ps3Debug3IrqMask; + union HilReg0Ps3RegisterFPs3Debug4 ps3Debug4; + union HilReg0Ps3RegisterFPs3Debug4IrqClear ps3Debug4IrqClear; + union HilReg0Ps3RegisterFPs3Debug4IrqMask ps3Debug4IrqMask; + union HilReg0Ps3RegisterFPs3Debug5 ps3Debug5; + union HilReg0Ps3RegisterFPs3Debug6 ps3Debug6; + union HilReg0Ps3RegisterFPs3Debug7 ps3Debug7; + union HilReg0Ps3RegisterFPs3Debug8 ps3Debug8; + union HilReg0Ps3RegisterFPs3Debug9 ps3Debug9; + union HilReg0Ps3RegisterFPs3Debug10 ps3Debug10; + union HilReg0Ps3RegisterFPs3Debug11 ps3Debug11; + union HilReg0Ps3RegisterFPs3Debug12 ps3Debug12; + U64 reserved8[4]; + union HilReg0Ps3RegisterFPs3SessioncmdAddr ps3SessioncmdAddr; + union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear ps3SessioncmdAddrIrqClear; + union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask ps3SessioncmdAddrIrqMask; }; #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h index 628fec97ac3b..1d5a06a3ab95 100644 --- a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h +++ b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h @@ -1,40 +1,40 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_H__ #define __S1861_HIL_REG0_PS3_REGISTER_S_REG_H__ #include "s1861_global_baseaddr.h" #ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_MACRO__ -#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_ADDR \ - (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x0) -#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_ADDR \ - (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x8) -#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_RST (0x0000000000000003) +#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_ADDR (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x0) +#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_ADDR (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x8) +#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_RST (0x0000000000000003) #endif #ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_STRUCT__ union HilReg0Ps3RegisterSPs3FucntionLock { - unsigned long long val; - struct { - unsigned long long lock : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 lock : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RegisterSPs3FunctionLockOwner { - unsigned long long val; - struct { - unsigned long long display : 2; - unsigned long long reserved1 : 62; + U64 val; + struct{ + + U64 display : 2; + U64 reserved1 : 62; } reg; }; struct HilReg0Ps3RegisterS { - union HilReg0Ps3RegisterSPs3FucntionLock ps3FucntionLock; - union HilReg0Ps3RegisterSPs3FunctionLockOwner ps3FunctionLockOwner; + union HilReg0Ps3RegisterSPs3FucntionLock ps3FucntionLock; + union HilReg0Ps3RegisterSPs3FunctionLockOwner ps3FunctionLockOwner; }; #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h index 2ba19081930a..19ce061a2dad 100644 --- a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h +++ b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h @@ -1,425 +1,422 @@ /* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_H__ #define __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_H__ #include "s1861_global_baseaddr.h" #ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_MACRO__ -#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x0) -#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_RST (0xFFFFFFFFFFFFFFFF) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x10) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_RST (0x0000000C1FFF0000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x18) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_RST (0x0000000300000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x20) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x28) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x30) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x38) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x40) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x48) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x50) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x58) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x60) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_ADDR(_n) \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x68 + (_n) * 0x8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_ADDR(_n) \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x88 + (_n) * 0x8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xa8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb0) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_RST (0x0000000000000002) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc0) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd0) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_RST \ - (0x000000000000003F) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe0) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_RST (0x0000000000000001) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf0) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_RST \ - (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x100) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x108) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_ADDR \ - (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x110) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x0) +#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_RST (0xFFFFFFFFFFFFFFFF) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x10) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_RST (0x0000000C1FFF0000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x18) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_RST (0x0000000300000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x20) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x28) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x30) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x38) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x40) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x48) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x50) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x58) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x60) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_ADDR(_n) (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x68 + (_n)*0x8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_ADDR(_n) (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x88 + (_n)*0x8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xa8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb0) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_RST (0x0000000000000002) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc0) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd0) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_RST (0x000000000000003F) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe0) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_RST (0x0000000000000001) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf0) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x100) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x108) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x110) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_RST (0x0000000000000000) #endif #ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_STRUCT__ union HilReg0Ps3RequestQueuePs3RequestQueue { - unsigned long long val; - struct { - unsigned long long port : 64; + U64 val; + struct{ + + U64 port : 64; } reg; }; union HilReg0Ps3RequestQueueFifoErrCnt { - unsigned long long val; - struct { - unsigned long long waddrerr : 32; - unsigned long long reserved1 : 32; + U64 val; + struct{ + + U64 waddrerr : 32; + U64 reserved1 : 32; } reg; }; union HilReg0Ps3RequestQueueFifoStatus { - unsigned long long val; - struct { - - unsigned long long filled : 16; - unsigned long long fifoDepth : 16; - unsigned long long almostfull : 1; - unsigned long long full : 1; - unsigned long long almostempty : 1; - unsigned long long empty : 1; - unsigned long long reserved6 : 28; + + U64 val; + struct{ + + U64 filled : 16; + U64 fifoDepth : 16; + U64 almostfull : 1; + U64 full : 1; + U64 almostempty : 1; + U64 empty : 1; + U64 reserved6 : 28; } reg; }; union HilReg0Ps3RequestQueueFifoLevelConfig { - unsigned long long val; - struct { - - unsigned long long cfgAempty : 16; - unsigned long long cfgAfull : 16; - unsigned long long emptyProtect : 1; - unsigned long long fullProtect : 1; - unsigned long long reserved4 : 30; + + U64 val; + struct{ + + U64 cfgAempty : 16; + U64 cfgAfull : 16; + U64 emptyProtect : 1; + U64 fullProtect : 1; + U64 reserved4 : 30; } reg; }; union HilReg0Ps3RequestQueueFifoRst { - unsigned long long val; - struct { - unsigned long long resetPls : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 resetPls : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RequestQueueFifoIOCnt { - unsigned long long val; - struct { - unsigned long long wr : 32; - unsigned long long rd : 32; + U64 val; + struct{ + + U64 wr : 32; + U64 rd : 32; } reg; }; union HilReg0Ps3RequestQueueFifoFlowCnt { - unsigned long long val; - struct { - unsigned long long overflow : 32; - unsigned long long underflow : 32; + U64 val; + struct{ + + U64 overflow : 32; + U64 underflow : 32; } reg; }; union HilReg0Ps3RequestQueueFifoIntStatus { - unsigned long long val; - struct { - - unsigned long long overflowStatus : 1; - unsigned long long underflowStatus : 1; - unsigned long long nemptyStatus : 1; - unsigned long long eccBadStatus : 1; - unsigned long long reserved4 : 60; + + U64 val; + struct{ + + U64 overflowStatus : 1; + U64 underflowStatus : 1; + U64 nemptyStatus : 1; + U64 eccBadStatus : 1; + U64 reserved4 : 60; } reg; }; union HilReg0Ps3RequestQueueFifoIntSet { - unsigned long long val; - struct { - - unsigned long long overflowSet : 1; - unsigned long long underflowSet : 1; - unsigned long long nemptySet : 1; - unsigned long long eccBadSet : 1; - unsigned long long reserved4 : 60; + + U64 val; + struct{ + + U64 overflowSet : 1; + U64 underflowSet : 1; + U64 nemptySet : 1; + U64 eccBadSet : 1; + U64 reserved4 : 60; } reg; }; union HilReg0Ps3RequestQueueFifoIntClr { - unsigned long long val; - struct { - - unsigned long long overflowClr : 1; - unsigned long long underflowClr : 1; - unsigned long long nemptyClr : 1; - unsigned long long eccBadClr : 1; - unsigned long long reserved4 : 60; + + U64 val; + struct{ + + U64 overflowClr : 1; + U64 underflowClr : 1; + U64 nemptyClr : 1; + U64 eccBadClr : 1; + U64 reserved4 : 60; } reg; }; union HilReg0Ps3RequestQueueFifoIntMask { - unsigned long long val; - struct { - - unsigned long long overflowMask : 1; - unsigned long long underflowMask : 1; - unsigned long long nemptyMask : 1; - unsigned long long eccBadMask : 1; - unsigned long long reserved4 : 60; + + U64 val; + struct{ + + U64 overflowMask : 1; + U64 underflowMask : 1; + U64 nemptyMask : 1; + U64 eccBadMask : 1; + U64 reserved4 : 60; } reg; }; union HilReg0Ps3RequestQueueFifoCntClr { - unsigned long long val; - struct { - - unsigned long long fifowrcntClr : 1; - unsigned long long fifordcntClr : 1; - unsigned long long fifoerrcntClr : 1; - unsigned long long fifoordererrwrcntClr : 1; - unsigned long long fifoordererrrdcntClr : 1; - unsigned long long fifobit1errcntClr : 1; - unsigned long long fifobit2errcntClr : 1; - unsigned long long reserved7 : 57; + + U64 val; + struct{ + + U64 fifowrcntClr : 1; + U64 fifordcntClr : 1; + U64 fifoerrcntClr : 1; + U64 fifoordererrwrcntClr : 1; + U64 fifoordererrrdcntClr : 1; + U64 fifobit1errcntClr : 1; + U64 fifobit2errcntClr : 1; + U64 reserved7 : 57; } reg; }; union HilReg0Ps3RequestQueueFifoOrderError { - unsigned long long val; - struct { - unsigned long long wrcnt : 32; - unsigned long long rdcnt : 32; + U64 val; + struct{ + + U64 wrcnt : 32; + U64 rdcnt : 32; } reg; }; union HilReg0Ps3RequestQueueFifoDinShift { - unsigned long long val; - struct { - unsigned long long val : 64; + U64 val; + struct{ + + U64 val : 64; } reg; }; union HilReg0Ps3RequestQueueFifoDoutShift { - unsigned long long val; - struct { - unsigned long long val : 64; + U64 val; + struct{ + + U64 val : 64; } reg; }; union HilReg0Ps3RequestQueueFifostatusMaxlevel { - unsigned long long val; - struct { - unsigned long long val : 16; - unsigned long long reserved1 : 48; + U64 val; + struct{ + + U64 val : 16; + U64 reserved1 : 48; } reg; }; union HilReg0Ps3RequestQueueFifoInit { - unsigned long long val; - struct { - unsigned long long stat : 2; - unsigned long long reserved1 : 62; + U64 val; + struct{ + + U64 stat : 2; + U64 reserved1 : 62; } reg; }; union HilReg0Ps3RequestQueueFifoinitEn { - unsigned long long val; - struct { - unsigned long long start : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 start : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RequestQueueFifoinitMax { - unsigned long long val; - struct { - unsigned long long num : 16; - unsigned long long reserved1 : 48; + U64 val; + struct{ + + U64 num : 16; + U64 reserved1 : 48; } reg; }; union HilReg0Ps3RequestQueueFifostatusEccCnt { - unsigned long long val; - struct { - unsigned long long bit1Err : 32; - unsigned long long bit2Err : 32; + U64 val; + struct{ + + U64 bit1Err : 32; + U64 bit2Err : 32; } reg; }; union HilReg0Ps3RequestQueueFifostatusEccAddr { - unsigned long long val; - struct { - unsigned long long errPoint : 64; + U64 val; + struct{ + + U64 errPoint : 64; } reg; }; union HilReg0Ps3RequestQueueFifoDecoderOverflow { - unsigned long long val; - struct { - - unsigned long long rCmdwordEmpty : 1; - unsigned long long rPortindexEmpty : 1; - unsigned long long rCmdbackEmpty : 1; - unsigned long long wCmdwordEmpty : 1; - unsigned long long wPortindexEmpty : 1; - unsigned long long wCmdbackEmpty : 1; - unsigned long long rCmdwordFull : 1; - unsigned long long rPortindexFull : 1; - unsigned long long rCmdbackFull : 1; - unsigned long long wCmdwordFull : 1; - unsigned long long wPortindexFull : 1; - unsigned long long wCmdbackFull : 1; - unsigned long long reserved12 : 52; + + U64 val; + struct{ + + U64 rCmdwordEmpty : 1; + U64 rPortindexEmpty : 1; + U64 rCmdbackEmpty : 1; + U64 wCmdwordEmpty : 1; + U64 wPortindexEmpty : 1; + U64 wCmdbackEmpty : 1; + U64 rCmdwordFull : 1; + U64 rPortindexFull : 1; + U64 rCmdbackFull : 1; + U64 wCmdwordFull : 1; + U64 wPortindexFull : 1; + U64 wCmdbackFull : 1; + U64 reserved12 : 52; } reg; }; union HilReg0Ps3RequestQueueFifoEccBadProject { - unsigned long long val; - struct { - unsigned long long en : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 en : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RequestQueueFifooverflowWord { - unsigned long long val; - struct { - unsigned long long record : 64; + U64 val; + struct{ + + U64 record : 64; } reg; }; union HilReg0Ps3RequestQueueFifoLevelMonitorCtl { - unsigned long long val; - struct { - unsigned long long low : 16; - unsigned long long high : 16; - unsigned long long en : 1; - unsigned long long reserved3 : 31; + U64 val; + struct{ + + U64 low : 16; + U64 high : 16; + U64 en : 1; + U64 reserved3 : 31; } reg; }; union HilReg0Ps3RequestQueueFifoLevelMonitorCntClr { - unsigned long long val; - struct { - unsigned long long en : 1; - unsigned long long reserved1 : 63; + U64 val; + struct{ + + U64 en : 1; + U64 reserved1 : 63; } reg; }; union HilReg0Ps3RequestQueueFifoLevelMonitorLow { - unsigned long long val; - struct { - unsigned long long cnt : 64; + U64 val; + struct{ + + U64 cnt : 64; } reg; }; union HilReg0Ps3RequestQueueFifoLevelMonitorMid { - unsigned long long val; - struct { - unsigned long long cnt : 64; + U64 val; + struct{ + + U64 cnt : 64; } reg; }; union HilReg0Ps3RequestQueueFifoLevelMonitorHigh { - unsigned long long val; - struct { - unsigned long long cnt : 64; + U64 val; + struct{ + + U64 cnt : 64; } reg; }; struct HilReg0Ps3RequestQueue { - union HilReg0Ps3RequestQueuePs3RequestQueue ps3RequestQueue; - union HilReg0Ps3RequestQueueFifoErrCnt fifoErrCnt; - union HilReg0Ps3RequestQueueFifoStatus fifoStatus; - union HilReg0Ps3RequestQueueFifoLevelConfig fifoLevelConfig; - union HilReg0Ps3RequestQueueFifoRst fifoRst; - union HilReg0Ps3RequestQueueFifoIOCnt fifoIOCnt; - union HilReg0Ps3RequestQueueFifoFlowCnt fifoFlowCnt; - union HilReg0Ps3RequestQueueFifoIntStatus fifoIntStatus; - union HilReg0Ps3RequestQueueFifoIntSet fifoIntSet; - union HilReg0Ps3RequestQueueFifoIntClr fifoIntClr; - union HilReg0Ps3RequestQueueFifoIntMask fifoIntMask; - union HilReg0Ps3RequestQueueFifoCntClr fifoCntClr; - union HilReg0Ps3RequestQueueFifoOrderError fifoOrderError; - union HilReg0Ps3RequestQueueFifoDinShift fifoDinShift[4]; - union HilReg0Ps3RequestQueueFifoDoutShift fifoDoutShift[4]; - union HilReg0Ps3RequestQueueFifostatusMaxlevel fifoStatusMaxLevel; - union HilReg0Ps3RequestQueueFifoInit fifoInit; - union HilReg0Ps3RequestQueueFifoinitEn fifoinitEn; - union HilReg0Ps3RequestQueueFifoinitMax fifoinitMax; - union HilReg0Ps3RequestQueueFifostatusEccCnt fifoStatusEccCnt; - union HilReg0Ps3RequestQueueFifostatusEccAddr fifoStatusEccAddr; - union HilReg0Ps3RequestQueueFifoDecoderOverflow fifoDecoderOverflow; - union HilReg0Ps3RequestQueueFifoEccBadProject fifoEccBadProject; - union HilReg0Ps3RequestQueueFifooverflowWord fifoOverFlowWord; - union HilReg0Ps3RequestQueueFifoLevelMonitorCtl fifoLevelMonitorCtl; - union HilReg0Ps3RequestQueueFifoLevelMonitorCntClr - fifoLevelMonitorCntClr; - union HilReg0Ps3RequestQueueFifoLevelMonitorLow fifoLevelMonitorLow; - union HilReg0Ps3RequestQueueFifoLevelMonitorMid fifoLevelMonitorMid; - union HilReg0Ps3RequestQueueFifoLevelMonitorHigh fifoLevelMonitorHigh; + union HilReg0Ps3RequestQueuePs3RequestQueue ps3RequestQueue; + union HilReg0Ps3RequestQueueFifoErrCnt fifoErrCnt; + union HilReg0Ps3RequestQueueFifoStatus fifoStatus; + union HilReg0Ps3RequestQueueFifoLevelConfig fifoLevelConfig; + union HilReg0Ps3RequestQueueFifoRst fifoRst; + union HilReg0Ps3RequestQueueFifoIOCnt fifoIOCnt; + union HilReg0Ps3RequestQueueFifoFlowCnt fifoFlowCnt; + union HilReg0Ps3RequestQueueFifoIntStatus fifoIntStatus; + union HilReg0Ps3RequestQueueFifoIntSet fifoIntSet; + union HilReg0Ps3RequestQueueFifoIntClr fifoIntClr; + union HilReg0Ps3RequestQueueFifoIntMask fifoIntMask; + union HilReg0Ps3RequestQueueFifoCntClr fifoCntClr; + union HilReg0Ps3RequestQueueFifoOrderError fifoOrderError; + union HilReg0Ps3RequestQueueFifoDinShift fifoDinShift[4]; + union HilReg0Ps3RequestQueueFifoDoutShift fifoDoutShift[4]; + union HilReg0Ps3RequestQueueFifostatusMaxlevel fifoStatusMaxLevel; + union HilReg0Ps3RequestQueueFifoInit fifoInit; + union HilReg0Ps3RequestQueueFifoinitEn fifoinitEn; + union HilReg0Ps3RequestQueueFifoinitMax fifoinitMax; + union HilReg0Ps3RequestQueueFifostatusEccCnt fifoStatusEccCnt; + union HilReg0Ps3RequestQueueFifostatusEccAddr fifoStatusEccAddr; + union HilReg0Ps3RequestQueueFifoDecoderOverflow fifoDecoderOverflow; + union HilReg0Ps3RequestQueueFifoEccBadProject fifoEccBadProject; + union HilReg0Ps3RequestQueueFifooverflowWord fifoOverFlowWord; + union HilReg0Ps3RequestQueueFifoLevelMonitorCtl fifoLevelMonitorCtl; + union HilReg0Ps3RequestQueueFifoLevelMonitorCntClr fifoLevelMonitorCntClr; + union HilReg0Ps3RequestQueueFifoLevelMonitorLow fifoLevelMonitorLow; + union HilReg0Ps3RequestQueueFifoLevelMonitorMid fifoLevelMonitorMid; + union HilReg0Ps3RequestQueueFifoLevelMonitorHigh fifoLevelMonitorHigh; }; #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_evtcode_trans.h b/drivers/scsi/linkdata/ps3stor/include/ps3_evtcode_trans.h index 29973a14c027..909801e0e73a 100644 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_evtcode_trans.h +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_evtcode_trans.h @@ -1,25 +1,22 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ #ifndef __PS3_EVTCODE_TRANS_H__ #define __PS3_EVTCODE_TRANS_H__ +#include "ps3_types.h" #if !(defined(PS3_PRODUCT_EXPANDER) || defined(PS3_PRODUCT_SWITCH)) -#include "ps3_htp_mgr_evt_raidhba.h" +#include "ps3_mgr_evt_raidhba.h" -#define PS3_EVT_EXT_NR (PS3_EVT_MAX_TYPE_LOCAL - MGR_EVT_EXTEND_TYPE_START) - -static inline char const *mgrEvtCodeTrans(unsigned int opCode) +static inline S8 const *mgrEvtCodeTrans(U32 opCode) { - unsigned int typeIndex = 0; - unsigned int codeIndex = 0; - const char *pEvtTransStr = NULL; - static char const *pEvtCodeInfo[MGR_EVT_EXTEND_TYPE_START][MGR_EVT_TYPE_OFFSET] = { - { - "MGR_EVT_SAS_START", - "MGR_EVT_SAS_EXPANDER_IN", - "MGR_EVT_SAS_EXPANDER_OUT", - "MGR_EVT_SAS_EXPANDER_UPDATE", - "MGR_EVT_SAS_EXPANDER_CHANGE", + U32 typeIndex = 0; + U32 codeIndex = 0; + const S8* pEvtTransStr = NULL; + static S8 const *pEvtCodeInfo[PS3_EVT_MAX_TYPE_LOCAL][MGR_EVT_TYPE_OFFSET] = { + { + "MGR_EVT_SAS_START", + "MGR_EVT_SAS_EXPANDER_IN", + "MGR_EVT_SAS_EXPANDER_OUT", + "MGR_EVT_SAS_EXPANDER_UPDATE", + "MGR_EVT_SAS_EXPANDER_CHANGE", "MGR_EVT_ENCL_TEMP_NORMAL", "MGR_EVT_ENCL_TEMP_WARNING", "MGR_EVT_ENCL_TEMP_CRITICAL", @@ -35,90 +32,90 @@ static inline char const *mgrEvtCodeTrans(unsigned int opCode) "MGR_EVT_SAS_SATA_LINK_SPEED_NOMATCH", "MGR_EVT_SAS_SATA_LN_EXCEPTION", "MGR_EVT_SAS_SATA_DRIVER_INFO", - }, - { - "MGR_EVT_PD_COUNT_START", - "MGR_EVT_DEVM_DISK_IN", - "MGR_EVT_DEVM_DISK_OUT", - "MGR_EVT_MULITPILE_PD_IN", - "MGR_EVT_MULITPILE_PD_OUT", - "MGR_EVT_DEVM_JBOD", - "MGR_EVT_DEVM_READY", - "MGR_EVT_MULITPILE_JBOD", - "MGR_EVT_MULITPILE_READY", - "MGR_EVT_BACKPLANE_ON", - "MGR_EVT_BACKPLANE_OFF", - "MGR_EVT_MULITPILE_PD_STATE_CHANGE", - "MGR_EVT_DEVM_DISK_CHANGE", - "MGR_EVT_DEFAULT_UNUSED", - "MGR_EVT_PD_PRE_READY", - }, - { - "MGR_EVT_VD_COUNT_START", - "MGR_EVT_VD_OPTIMAL", - "MGR_EVT_VD_PARTIAL_DEGRADE", - "MGR_EVT_VD_DEGRADE", - "MGR_EVT_VD_CREATED", - "MGR_EVT_VD_DELETED", - "MGR_EVT_VD_HIDDEN_CHANGE", - "MGR_EVT_MULITPILE_VD_IN", - "MGR_EVT_MULITPILE_VD_OUT", - "MGR_EVT_VD_UNLOCK", - "MGR_EVT_VD_OFFLINE", - }, - { - "MGR_EVT_CTRL_INFO_START", - "MGR_EVT_CTRL_REBOOT", - "MGR_EVT_CTRL_SHUTDOWN", - "MGR_EVT_CTRL_TIME_CHANGE", - "MGR_EVT_CTRL_EVENT_LOG_CLEARED", - "MGR_EVT_CTRL_RBLD_RATE_CHANGED", - "MGR_EVT_CTRL_ENABLEMOVEBACK_CHANGED", - "MGR_EVT_CTRL_ENABLENCQ_CHANGED", - "MGR_EVT_CTRL_AUTO_REBUILD_CHANGED", - "MGR_EVT_CTRL_EGHS_READY_CHANGED", - "MGR_EVT_CTRL_EGHS_SPARE_CHANGED", - "MGR_EVT_CTRL_BGI_RATE_CHANGED", - "MGR_EVT_CTRL_MIGRATE_RATE_CHANGED", - "MGR_EVT_CTRL_CC_RATE_CHANGED", - "MGR_EVT_CTRL_DIRECT_CHANGE", - "MGR_EVT_CTRL_PR_START", - "MGR_EVT_CTRL_PR_PAUSE", - "MGR_EVT_CTRL_PR_REMINDER_PAUSE", - "MGR_EVT_CTRL_PR_RESUME", - "MGR_EVT_CTRL_PR_DONE", - "MGR_EVT_CTRL_PR_RATE_CHANGED", - "MGR_EVT_CTRL_PR_CANT_START", - "MGR_EVT_CTRL_PR_PROP_CHANGED", - "MGR_EVT_CTRL_PARAM_CHANGE", - "MGR_EVT_CTRL_AUTO_CC_PARAM_CHANGE", - "MGR_EVT_CTRL_RECOVERY_FACTORY", - "MGR_EVT_CTRL_PROFILEID_CHANGED", - "MGR_EVT_CTRL_SANPSHOT_CREATE", - "MGR_EVT_CTRL_SANPSHOT_DELETE", - "MGR_EVT_CTRL_ENABLEPDM_CHANGED", - "MGR_EVT_CTRL_PDMSUPPORTREADYPD", - "MGR_EVT_CTRL_PDMTIMERINTERVAL", - "MGR_EVT_CTRL_SECURITY_KEY_CHANGE", - "MGR_EVT_CTRL_SECURITY_KEY_CREATE", - "MGR_EVT_CTRL_SECURITY_KEY_DESTROY", - "MGR_EVT_CTRL_SECURITY_KEY_ESCROW", - "MGR_EVT_CTRL_SECURITY_KEY_FAILED", - "MGR_EVT_CTRL_SECURITY_KEY_INVALID", - "MGR_EVT_AUTOCONFIG", - "MGR_EVT_CTRL_FOREIGN_IMPORTED_ALL", - "MGR_EVT_CTRL_FOREIGN_CLEAR", - "MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL", - "MGR_EVT_CTRL_FOREIGN_IMPORT_PART_FAIL", - "MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL_PDS", - "MGR_EVT_CTRL_FOREIGN_PD_DETECTED", - "MGR_EVT_PD_INSERT_TO_DG", - "MGR_EVT_PD_IMPORT_TO_DG", - "MGR_EVT_HARD_RESET", - "MGR_EVT_DPF_CFG_MODIFY", - "MGR_EVT_SPOR", - "MGR_EVT_ONF_ABNORMAL", - "MGR_EVT_CTRL_LOADED", + }, + { + "MGR_EVT_PD_COUNT_START", + "MGR_EVT_DEVM_DISK_IN", + "MGR_EVT_DEVM_DISK_OUT", + "MGR_EVT_MULITPILE_PD_IN", + "MGR_EVT_MULITPILE_PD_OUT", + "MGR_EVT_DEVM_JBOD", + "MGR_EVT_DEVM_READY", + "MGR_EVT_MULITPILE_JBOD", + "MGR_EVT_MULITPILE_READY", + "MGR_EVT_BACKPLANE_ON", + "MGR_EVT_BACKPLANE_OFF", + "MGR_EVT_MULITPILE_PD_STATE_CHANGE", + "MGR_EVT_DEVM_DISK_CHANGE", + "MGR_EVT_DEFAULT_UNUSED", + "MGR_EVT_PD_PRE_READY", + }, + { + "MGR_EVT_VD_COUNT_START", + "MGR_EVT_VD_OPTIMAL", + "MGR_EVT_VD_PARTIAL_DEGRADE", + "MGR_EVT_VD_DEGRADE", + "MGR_EVT_VD_CREATED", + "MGR_EVT_VD_DELETED", + "MGR_EVT_VD_HIDDEN_CHANGE", + "MGR_EVT_MULITPILE_VD_IN", + "MGR_EVT_MULITPILE_VD_OUT", + "MGR_EVT_VD_UNLOCK", + "MGR_EVT_VD_OFFLINE", + }, + { + "MGR_EVT_CTRL_INFO_START", + "MGR_EVT_CTRL_REBOOT", + "MGR_EVT_CTRL_SHUTDOWN", + "MGR_EVT_CTRL_TIME_CHANGE", + "MGR_EVT_CTRL_EVENT_LOG_CLEARED", + "MGR_EVT_CTRL_RBLD_RATE_CHANGED", + "MGR_EVT_CTRL_ENABLEMOVEBACK_CHANGED", + "MGR_EVT_CTRL_ENABLENCQ_CHANGED", + "MGR_EVT_CTRL_AUTO_REBUILD_CHANGED", + "MGR_EVT_CTRL_EGHS_READY_CHANGED", + "MGR_EVT_CTRL_EGHS_SPARE_CHANGED", + "MGR_EVT_CTRL_BGI_RATE_CHANGED", + "MGR_EVT_CTRL_MIGRATE_RATE_CHANGED", + "MGR_EVT_CTRL_CC_RATE_CHANGED", + "MGR_EVT_CTRL_DIRECT_CHANGE", + "MGR_EVT_CTRL_PR_START", + "MGR_EVT_CTRL_PR_PAUSE", + "MGR_EVT_CTRL_PR_REMINDER_PAUSE", + "MGR_EVT_CTRL_PR_RESUME", + "MGR_EVT_CTRL_PR_DONE", + "MGR_EVT_CTRL_PR_RATE_CHANGED", + "MGR_EVT_CTRL_PR_CANT_START", + "MGR_EVT_CTRL_PR_PROP_CHANGED", + "MGR_EVT_CTRL_PARAM_CHANGE", + "MGR_EVT_CTRL_AUTO_CC_PARAM_CHANGE", + "MGR_EVT_CTRL_RECOVERY_FACTORY", + "MGR_EVT_CTRL_PROFILEID_CHANGED", + "MGR_EVT_CTRL_SANPSHOT_CREATE", + "MGR_EVT_CTRL_SANPSHOT_DELETE", + "MGR_EVT_CTRL_ENABLEPDM_CHANGED", + "MGR_EVT_CTRL_PDMSUPPORTREADYPD", + "MGR_EVT_CTRL_PDMTIMERINTERVAL", + "MGR_EVT_CTRL_SECURITY_KEY_CHANGE", + "MGR_EVT_CTRL_SECURITY_KEY_CREATE", + "MGR_EVT_CTRL_SECURITY_KEY_DESTROY", + "MGR_EVT_CTRL_SECURITY_KEY_ESCROW", + "MGR_EVT_CTRL_SECURITY_KEY_FAILED", + "MGR_EVT_CTRL_SECURITY_KEY_INVALID", + "MGR_EVT_AUTOCONFIG", + "MGR_EVT_CTRL_FOREIGN_IMPORTED_ALL", + "MGR_EVT_CTRL_FOREIGN_CLEAR", + "MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL", + "MGR_EVT_CTRL_FOREIGN_IMPORT_PART_FAIL", + "MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL_PDS", + "MGR_EVT_CTRL_FOREIGN_PD_DETECTED", + "MGR_EVT_PD_INSERT_TO_DG", + "MGR_EVT_PD_IMPORT_TO_DG", + "MGR_EVT_HARD_RESET", + "MGR_EVT_DPF_CFG_MODIFY", + "MGR_EVT_SPOR", + "MGR_EVT_ONF_ABNORMAL", + "MGR_EVT_CTRL_LOADED", "MGR_EVT_CACHE_PROTECTION_CMPT_READY", "MGR_EVT_CACHE_PROTECTION_CMPT_NOT_READY", "MGR_EVT_CACHE_PROTECTION_CMPT_INSTABLE", @@ -127,333 +124,330 @@ static inline char const *mgrEvtCodeTrans(unsigned int opCode) "MGR_EVT_MEDIUM_DATA_RECOVER", "MGR_EVT_INIT_FAIL", "MGR_EVT_CTRL_POWER_MODE_CHANGED", - }, - { - "MGR_EVT_PD_ATTR_START", - "MGR_EVT_PD_INFO_CHANGE", - "MGR_EVT_PD_STATE_CHANGE", - "MGR_EVT_PD_MARKED_JBOD", - "MGR_EVT_PD_MARKED_READY", - "MGR_EVT_PD_MARKED_ONLINE", - "MGR_EVT_PD_MARKED_OFFLINE", - "MGR_EVT_PD_MARKED_FAILED", - "MGR_EVT_PD_MARKED_MISSING", - "MGR_EVT_PD_MARKED_REBUILD", - "MGR_EVT_PD_MARKED_REPLACE", - "MGR_EVT_PD_MARKED_UNCONFIGUREDBAD", - "MGR_EVT_PD_MARKED_FOREIGN", - "MGR_EVT_PD_NR_GLOBAL_SPARE_ADDED", - "MGR_EVT_PD_NR_GLOBAL_SPARE_DELETED", - "MGR_EVT_PD_NR_DEDICATED_SPARE_ADDED", - "MGR_EVT_PD_NR_DEDICATED_SPARE_DELETED", - "MGR_EVT_PD_R_GLOBAL_SPARE_ADDED", - "MGR_EVT_PD_R_GLOBAL_SPARE_DELETED", - "MGR_EVT_PD_R_DEDICATED_SPARE_ADDED", - "MGR_EVT_PD_R_DEDICATED_SPARE_DELETED", - "MGR_EVT_PD_RBLD_ABORT_BY_USER", - "MGR_EVT_PD_RBLD_DONE_PD", - "MGR_EVT_PD_RBLD_FAILED_BAD_SOURCE", - "MGR_EVT_PD_RBLD_FAILED_BAD_TARGET", - "MGR_EVT_PD_RBLD_PROGRESS", - "MGR_EVT_PD_RBLD_SUSPENDED_REMINDER", - "MGR_EVT_PD_RBLD_SUSPENDED", - "MGR_EVT_PD_RBLD_RESUME", - "MGR_EVT_PD_RBLD_START", - "MGR_EVT_PD_RBLD_START_AUTO", - "MGR_EVT_PD_RBLD_MEDIUM_ERROR", - "MGR_EVT_PD_EMERGENCY_SPARE", - "MGR_EVT_PD_RECOVER_MEDIUM_ERROR", - "MGR_EVT_PD_MOVEBACK_START", - "MGR_EVT_PD_MOVEBACK_ABORT", - "MGR_EVT_PD_MOVEBACK_ABORT_FOR_REBUILD", - "MGR_EVT_PD_MOVEBACK_DONE", - "MGR_EVT_PD_MOVEBACK_PROGRESS", - "MGR_EVT_PD_MOVEBACK_SUSPENDED", - "MGR_EVT_PD_MOVEBACK_SUSPENDED_REMINDER", - "MGR_EVT_PD_MOVEBACK_RESUME", - "MGR_EVT_PD_MOVEBACK_START_AUTO", - "MGR_EVT_PD_MOVEBACK_FAILED_BAD_SOURCE", - "MGR_EVT_PD_MOVEBACK_FAILED_BAD_TARGET", - "MGR_EVT_PD_MOVEBACK_ABORT_BY_USER", - "MGR_EVT_PD_MOVEBACK_MEDIUM_ERROR", - "MGR_EVT_PD_FGI_START", - "MGR_EVT_PD_FGI_COMPLETE", - "MGR_EVT_PD_FGI_FAILED", - "MGR_EVT_PD_FGI_PROGRESS", - "MGR_EVT_PD_FGI_ABORT", - "MGR_EVT_PD_PR_ABORTED", - "MGR_EVT_PD_PR_CORRECTED", - "MGR_EVT_PD_PR_UNCORRECTABLE", - "MGR_EVT_PD_PR_FOUND_MEDIUM_ERROR", - "MGR_EVT_PD_PR_PROGRESS", - "MGR_EVT_PD_SET_BOOT_DRIVE", - "MGR_EVT_PD_RESET_BOOT_DRIVE", - "MGR_EVT_PD_RESET_BOOT_DRIVE_WITH_DISK_OUT", - "MGR_EVT_PD_SET_BOOT_DRIVE_WITH_DISK_IN", - "MGR_EVT_PD_POWERSAVE_TO_ON", - "MGR_EVT_PD_POWERSAVE_TO_TRANSITION", - "MGR_EVT_PD_TRANSITION_TO_ON", - "MGR_EVT_PD_TRANSITION_TO_POWERSAVE", - "MGR_EVT_PD_ON_TO_POWERSAVE", - "MGR_EVT_PD_START_LOCATE", - "MGR_EVT_PD_STOP_LOCATE", - "MGR_EVT_PD_PFA_ERROR", - "MGR_EVT_PD_NOT_PRESENT", - "MGR_EVT_DEVM_DISK_FAULT", - "MGR_EVT_PHY_FLASHOFFLINE", - "MGR_EVT_PHY_FLASHONLINE", - "MGR_EVT_NFR_DONE", - "MGR_EVT_NFR_REPAIRED", - "MGR_EVT_NFR_REPORT", - "MGR_EVT_NFR_STOP", - "MGR_EVT_PD_DOWNLOAD_DONE", - "MGR_EVT_PD_DOWNLOAD_START", - "MGR_EVT_NVME_PHY_BAD", - }, - { - "MGR_EVT_VD_ATTR_START", - "MGR_EVT_MULITPILE_VD_STATE_CHANGE", - "MGR_EVT_VD_OFFLINE_OLD", - "MGR_EVT_VD_LOCK", - "MGR_EVT_VD_PASSWD_CHANGED", - "MGR_EVT_VD_SETTINGS_CHANGE", - "MGR_EVT_VD_PD_CHANGE", - "MGR_EVT_VD_STATE_CHANGE", - "MGR_EVT_PD_RBLD_DONE_LD", - "MGR_EVT_VD_FGI_START", - "MGR_EVT_VD_FGI_COMPLETE", - "MGR_EVT_VD_FGI_FAILED", - "MGR_EVT_VD_FGI_PROGRESS", - "MGR_EVT_VD_FGI_ABORT", - "MGR_EVT_VD_BGI_START", - "MGR_EVT_VD_BGI_COMPLETE", - "MGR_EVT_VD_BGI_FAILED", - "MGR_EVT_VD_BGI_PROGRESS", - "MGR_EVT_VD_BGI_ABORT", - "MGR_EVT_VD_BGI_PAUSE", - "MGR_EVT_VD_BGI_REMINDER_PAUSE", - "MGR_EVT_VD_BGI_RESUME", - "MGR_EVT_VD_BGI_CORRECTABLE_ERROR", - "MGR_EVT_VD_BGI_UNCORRECTABLE_ERROR", - "MGR_EVT_VD_ALTER_ATTR_BY_MIGRATION", - "MGR_EVT_VD_BBM_CLEARED", - "MGR_EVT_VD_BBM_PERCENT_FULL", - "MGR_EVT_VD_BBM_100_FULL", - "MGR_EVT_VD_BBM_LOG_FULL", - "MGR_EVT_VD_BBM_LOG_RCT", - "MGR_EVT_VD_BBM_LOG_WCT", - "MGR_EVT_VD_BBM_DEL_RCT", - "MGR_EVT_VD_CC_ABORTED", - "MGR_EVT_VD_CC_CORRECTED_MEDIUM_ERROR", - "MGR_EVT_VD_CC_DOUBLE_MEDIUM_ERRORS", - "MGR_EVT_VD_CC_DONE", - "MGR_EVT_VD_CC_DONE_INCON", - "MGR_EVT_VD_CC_FAILED", - "MGR_EVT_VD_CC_FAILED_UNCOR", - "MGR_EVT_VD_CC_INCONSISTENT_PARITY", - "MGR_EVT_VD_CC_INCONSISTENT_PARITY_LOGGING_DISABLED", - "MGR_EVT_VD_CC_PROGRESS", - "MGR_EVT_VD_CC_START", - "MGR_EVT_VD_CC_PAUSE", - "MGR_EVT_VD_CC_REMINDER_PAUSE", - "MGR_EVT_VD_CC_RESUME", - "MGR_EVT_VD_RW_RAID1X_WRITE_CARDBUSY", - "MGR_EVT_VD_SET_BOOT_DRIVE", - "MGR_EVT_VD_RESET_BOOT_DRIVE", - "MGR_EVT_VD_RESET_BOOT_DRIVE_WITH_DISK_OUT", - "MGR_EVT_VD_SET_BOOT_DRIVE_WITH_DISK_IN", - "MGR_EVT_ALL_CONFIGS_MISSING", - "MGR_EVT_PDS_MISSING", - "MGR_EVT_NVSRAM_RECOVER_FAIL", - "MGR_EVT_NVSRAM_UPDATE_FAIL", - "MGR_EVT_VD_ERASE_ABORT", - "MGR_EVT_VD_ERASE_COMPLETE", - "MGR_EVT_VD_ERASE_DISK_FAILED", - "MGR_EVT_VD_ERASE_FAILED", - "MGR_EVT_VD_ERASE_PROGRESS", - "MGR_EVT_VD_ERASE_START", - "MGR_EVT_VD_EXPAND_FINISH", - "MGR_EVT_VD_EXPAND_START", - "MGR_EVT_VD_FLUSH_CLEAR_FAILED", - "MGR_EVT_VD_FLUSH_RECORD_FAILED", - "MGR_EVT_VD_FLUSH_SET_INCONSIST", - "MGR_EVT_VDS_MISSING", - "MGR_EVT_VD_BBM_UNCORRECTABLE_LOGGED", - "MGR_EVT_VD_FLUSH_CACHE_PINNED", - "MGR_EVT_VD_FLUSH_OCR_CACHE_PINNED", - "MGR_EVT_VD_FLUSH_CACHE_DISCARDED", - "MGR_EVT_VD_FLUSH_CACHE_DISCARDED_DEL", - "MGR_EVT_VD_FLUSH_CACHE_DESTAGED", - "MGR_EVT_VD_CM_RECOVERY_CRC_FAIL", + }, + { + "MGR_EVT_PD_ATTR_START", + "MGR_EVT_PD_INFO_CHANGE", + "MGR_EVT_PD_STATE_CHANGE", + "MGR_EVT_PD_MARKED_JBOD", + "MGR_EVT_PD_MARKED_READY", + "MGR_EVT_PD_MARKED_ONLINE", + "MGR_EVT_PD_MARKED_OFFLINE", + "MGR_EVT_PD_MARKED_FAILED", + "MGR_EVT_PD_MARKED_MISSING", + "MGR_EVT_PD_MARKED_REBUILD", + "MGR_EVT_PD_MARKED_REPLACE", + "MGR_EVT_PD_MARKED_UNCONFIGUREDBAD", + "MGR_EVT_PD_MARKED_FOREIGN", + "MGR_EVT_PD_NR_GLOBAL_SPARE_ADDED", + "MGR_EVT_PD_NR_GLOBAL_SPARE_DELETED", + "MGR_EVT_PD_NR_DEDICATED_SPARE_ADDED", + "MGR_EVT_PD_NR_DEDICATED_SPARE_DELETED", + "MGR_EVT_PD_R_GLOBAL_SPARE_ADDED", + "MGR_EVT_PD_R_GLOBAL_SPARE_DELETED", + "MGR_EVT_PD_R_DEDICATED_SPARE_ADDED", + "MGR_EVT_PD_R_DEDICATED_SPARE_DELETED", + "MGR_EVT_PD_RBLD_ABORT_BY_USER", + "MGR_EVT_PD_RBLD_DONE_PD", + "MGR_EVT_PD_RBLD_FAILED_BAD_SOURCE", + "MGR_EVT_PD_RBLD_FAILED_BAD_TARGET", + "MGR_EVT_PD_RBLD_PROGRESS", + "MGR_EVT_PD_RBLD_SUSPENDED_REMINDER", + "MGR_EVT_PD_RBLD_SUSPENDED", + "MGR_EVT_PD_RBLD_RESUME", + "MGR_EVT_PD_RBLD_START", + "MGR_EVT_PD_RBLD_START_AUTO", + "MGR_EVT_PD_RBLD_MEDIUM_ERROR", + "MGR_EVT_PD_EMERGENCY_SPARE", + "MGR_EVT_PD_RECOVER_MEDIUM_ERROR", + "MGR_EVT_PD_MOVEBACK_START", + "MGR_EVT_PD_MOVEBACK_ABORT", + "MGR_EVT_PD_MOVEBACK_ABORT_FOR_REBUILD", + "MGR_EVT_PD_MOVEBACK_DONE", + "MGR_EVT_PD_MOVEBACK_PROGRESS", + "MGR_EVT_PD_MOVEBACK_SUSPENDED", + "MGR_EVT_PD_MOVEBACK_SUSPENDED_REMINDER", + "MGR_EVT_PD_MOVEBACK_RESUME", + "MGR_EVT_PD_MOVEBACK_START_AUTO", + "MGR_EVT_PD_MOVEBACK_FAILED_BAD_SOURCE", + "MGR_EVT_PD_MOVEBACK_FAILED_BAD_TARGET", + "MGR_EVT_PD_MOVEBACK_ABORT_BY_USER", + "MGR_EVT_PD_MOVEBACK_MEDIUM_ERROR", + "MGR_EVT_PD_FGI_START", + "MGR_EVT_PD_FGI_COMPLETE", + "MGR_EVT_PD_FGI_FAILED", + "MGR_EVT_PD_FGI_PROGRESS", + "MGR_EVT_PD_FGI_ABORT", + "MGR_EVT_PD_PR_ABORTED", + "MGR_EVT_PD_PR_CORRECTED", + "MGR_EVT_PD_PR_UNCORRECTABLE", + "MGR_EVT_PD_PR_FOUND_MEDIUM_ERROR", + "MGR_EVT_PD_PR_PROGRESS", + "MGR_EVT_PD_SET_BOOT_DRIVE", + "MGR_EVT_PD_RESET_BOOT_DRIVE", + "MGR_EVT_PD_RESET_BOOT_DRIVE_WITH_DISK_OUT", + "MGR_EVT_PD_SET_BOOT_DRIVE_WITH_DISK_IN", + "MGR_EVT_PD_POWERSAVE_TO_ON", + "MGR_EVT_PD_POWERSAVE_TO_TRANSITION", + "MGR_EVT_PD_TRANSITION_TO_ON", + "MGR_EVT_PD_TRANSITION_TO_POWERSAVE", + "MGR_EVT_PD_ON_TO_POWERSAVE", + "MGR_EVT_PD_START_LOCATE", + "MGR_EVT_PD_STOP_LOCATE", + "MGR_EVT_PD_PFA_ERROR", + "MGR_EVT_PD_NOT_PRESENT", + "MGR_EVT_DEVM_DISK_FAULT", + "MGR_EVT_PHY_FLASHOFFLINE", + "MGR_EVT_PHY_FLASHONLINE", + "MGR_EVT_NFR_DONE", + "MGR_EVT_NFR_REPAIRED", + "MGR_EVT_NFR_REPORT", + "MGR_EVT_NFR_STOP", + "MGR_EVT_PD_DOWNLOAD_DONE", + "MGR_EVT_PD_DOWNLOAD_START", + "MGR_EVT_NVME_PHY_BAD", + }, + { + "MGR_EVT_VD_ATTR_START", + "MGR_EVT_MULITPILE_VD_STATE_CHANGE", + "MGR_EVT_VD_OFFLINE_OLD", + "MGR_EVT_VD_LOCK", + "MGR_EVT_VD_PASSWD_CHANGED", + "MGR_EVT_VD_SETTINGS_CHANGE", + "MGR_EVT_VD_PD_CHANGE", + "MGR_EVT_VD_STATE_CHANGE", + "MGR_EVT_PD_RBLD_DONE_LD", + "MGR_EVT_VD_FGI_START", + "MGR_EVT_VD_FGI_COMPLETE", + "MGR_EVT_VD_FGI_FAILED", + "MGR_EVT_VD_FGI_PROGRESS", + "MGR_EVT_VD_FGI_ABORT", + "MGR_EVT_VD_BGI_START", + "MGR_EVT_VD_BGI_COMPLETE", + "MGR_EVT_VD_BGI_FAILED", + "MGR_EVT_VD_BGI_PROGRESS", + "MGR_EVT_VD_BGI_ABORT", + "MGR_EVT_VD_BGI_PAUSE", + "MGR_EVT_VD_BGI_REMINDER_PAUSE", + "MGR_EVT_VD_BGI_RESUME", + "MGR_EVT_VD_BGI_CORRECTABLE_ERROR", + "MGR_EVT_VD_BGI_UNCORRECTABLE_ERROR", + "MGR_EVT_VD_ALTER_ATTR_BY_MIGRATION", + "MGR_EVT_VD_BBM_CLEARED", + "MGR_EVT_VD_BBM_PERCENT_FULL", + "MGR_EVT_VD_BBM_100_FULL", + "MGR_EVT_VD_BBM_LOG_FULL", + "MGR_EVT_VD_BBM_LOG_RCT", + "MGR_EVT_VD_BBM_LOG_WCT", + "MGR_EVT_VD_BBM_DEL_RCT", + "MGR_EVT_VD_CC_ABORTED", + "MGR_EVT_VD_CC_CORRECTED_MEDIUM_ERROR", + "MGR_EVT_VD_CC_DOUBLE_MEDIUM_ERRORS", + "MGR_EVT_VD_CC_DONE", + "MGR_EVT_VD_CC_DONE_INCON", + "MGR_EVT_VD_CC_FAILED", + "MGR_EVT_VD_CC_FAILED_UNCOR", + "MGR_EVT_VD_CC_INCONSISTENT_PARITY", + "MGR_EVT_VD_CC_INCONSISTENT_PARITY_LOGGING_DISABLED", + "MGR_EVT_VD_CC_PROGRESS", + "MGR_EVT_VD_CC_START", + "MGR_EVT_VD_CC_PAUSE", + "MGR_EVT_VD_CC_REMINDER_PAUSE", + "MGR_EVT_VD_CC_RESUME", + "MGR_EVT_VD_RW_RAID1X_WRITE_CARDBUSY", + "MGR_EVT_VD_SET_BOOT_DRIVE", + "MGR_EVT_VD_RESET_BOOT_DRIVE", + "MGR_EVT_VD_RESET_BOOT_DRIVE_WITH_DISK_OUT", + "MGR_EVT_VD_SET_BOOT_DRIVE_WITH_DISK_IN", + "MGR_EVT_ALL_CONFIGS_MISSING", + "MGR_EVT_PDS_MISSING", + "MGR_EVT_NVSRAM_RECOVER_FAIL", + "MGR_EVT_NVSRAM_UPDATE_FAIL", + "MGR_EVT_VD_ERASE_ABORT", + "MGR_EVT_VD_ERASE_COMPLETE", + "MGR_EVT_VD_ERASE_DISK_FAILED", + "MGR_EVT_VD_ERASE_FAILED", + "MGR_EVT_VD_ERASE_PROGRESS", + "MGR_EVT_VD_ERASE_START", + "MGR_EVT_VD_EXPAND_FINISH", + "MGR_EVT_VD_EXPAND_START", + "MGR_EVT_VD_FLUSH_CLEAR_FAILED", + "MGR_EVT_VD_FLUSH_RECORD_FAILED", + "MGR_EVT_VD_FLUSH_SET_INCONSIST", + "MGR_EVT_VDS_MISSING", + "MGR_EVT_VD_BBM_UNCORRECTABLE_LOGGED", + "MGR_EVT_VD_FLUSH_CACHE_PINNED", + "MGR_EVT_VD_FLUSH_OCR_CACHE_PINNED", + "MGR_EVT_VD_FLUSH_CACHE_DISCARDED", + "MGR_EVT_VD_FLUSH_CACHE_DISCARDED_DEL", + "MGR_EVT_VD_FLUSH_CACHE_DESTAGED", + "MGR_EVT_VD_CM_RECOVERY_CRC_FAIL", "MGR_EVT_VD_BGI_COMPLETE_UNCOR", - }, - { - "MGR_EVT_DG_INFO_START", - "MGR_EVT_DG_CREATED", - "MGR_EVT_DG_DELETED", - "MGR_EVT_DG_SETTING_CHANGE", - "MGR_EVT_DG_MIGRATION_START", - "MGR_EVT_DG_MIGRATION_RECOVER", - "MGR_EVT_DG_MIGRATION_SUCCESS", - "MGR_EVT_DG_MIGRATION_ALLOC_RESOURCE_FAILED", - "MGR_EVT_DG_MIGRATION_FAILED", - "MGR_EVT_DG_MIGRATION_RECOVER_FAILED", - "MGR_EVT_DG_MIGRATION_PROGRESS", - "MGR_EVT_DG_MIGRATION_INTERNAL_WARNING", - "MGR_EVT_DG_PRSWITCH_CHANGE", - "MGR_EVT_DG_PR_ABORTED_WM_FAILED", - "MGR_EVT_DG_PR_ABORTED_SPINUP_FAILED", - }, - { - "MGR_EVT_BBU_START", - "MGR_EVT_BBU_PRESENT", - "MGR_EVT_BBU_NOT_PRESENT", - "MGR_EVT_BBU_GOOD", - "MGR_EVT_BBU_BAD", - "MGR_EVT_BBU_CAP_BELOW_THRESHOLD", - "MGR_EVT_BBU_CAP_ABOVE_THRESHOLD", - "MGR_EVT_BBU_CHARGE_STATUS", - "MGR_EVT_BBU_CHARGE_COMPLETE", - "MGR_EVT_BBU_INSERT", - "MGR_EVT_BBU_ABSENT", - "MGR_EVT_BBU_TEMPERATURE_NORMAL", - "MGR_EVT_BBU_TEMPERATURE_HIGH", - "MGR_EVT_BBU_VOLTAGE_NORMAL", - "MGR_EVT_BBU_VOLTAGE_HIGH", - "MGR_EVT_BBU_CURRENT_NORMAL", - "MGR_EVT_BBU_CURRENT_HIGH", - "MGR_EVT_BBU_LOAD_NORMAL", - "MGR_EVT_BBU_VOLTAGE_LOW", - "MGR_EVT_BBU_BATTERY_CAP_ABOVE_SOH_THRESHOLD", - "MGR_EVT_BBU_BATTERY_CAP_BELOW_SOH_THRESHOLD", - "MGR_EVT_BBU_LEARN_STAGE", - "MGR_EVT_BBU_LEARN_REQUESTED", - "MGR_EVT_BBU_LEARN_POSTPONED", - "MGR_EVT_BBU_LEARN_TIMEOUT", - "MGR_EVT_BBU_LEARN_MANUAL", - "MGR_EVT_BBU_LEARN_RESCHEDULED", - "MGR_EVT_BBU_PROPERTIES_CHANGED", - }, - { - "MGR_EVT_CONFIG_START", - "MGR_EVT_CONFIG_INFO", - "MGR_EVT_CONFIG_FLASH_READ_FAIL", - "MGR_EVT_CONFIG_FLASH_WRITE_FAIL", - "MGR_EVT_CONFIG_NVSRAM_READ_FAIL", - "MGR_EVT_CONFIG_NVSRAM_WRITE_FAIL", - "MGR_EVT_CONFIG_VERSION_MISMATCH", - "MGR_EVT_CONFIG_MEDIA_VALUE_CHECK_FAIL", - "MGR_EVT_CONFIG_ERASE_NVSRAM", - "MGR_EVT_PHY_LINKSPEED_CFG_CHANGE", - }, - { - "MGR_EVT_IO_START", - "MGR_EVT_IO_TEST", - "MGR_EVT_IO_SENSE_DATA", - "MGR_EVT_DEVICE_RESET", + }, + { + "MGR_EVT_DG_INFO_START", + "MGR_EVT_DG_CREATED", + "MGR_EVT_DG_DELETED", + "MGR_EVT_DG_SETTING_CHANGE", + "MGR_EVT_DG_MIGRATION_START", + "MGR_EVT_DG_MIGRATION_RECOVER", + "MGR_EVT_DG_MIGRATION_SUCCESS", + "MGR_EVT_DG_MIGRATION_ALLOC_RESOURCE_FAILED", + "MGR_EVT_DG_MIGRATION_FAILED", + "MGR_EVT_DG_MIGRATION_RECOVER_FAILED", + "MGR_EVT_DG_MIGRATION_PROGRESS", + "MGR_EVT_DG_MIGRATION_INTERNAL_WARNING", + "MGR_EVT_DG_PRSWITCH_CHANGE", + "MGR_EVT_DG_PR_ABORTED_WM_FAILED", + "MGR_EVT_DG_PR_ABORTED_SPINUP_FAILED", + }, + { + "MGR_EVT_BBU_START", + "MGR_EVT_BBU_PRESENT", + "MGR_EVT_BBU_NOT_PRESENT", + "MGR_EVT_BBU_GOOD", + "MGR_EVT_BBU_BAD", + "MGR_EVT_BBU_CAP_BELOW_THRESHOLD", + "MGR_EVT_BBU_CAP_ABOVE_THRESHOLD", + "MGR_EVT_BBU_CHARGE_STATUS", + "MGR_EVT_BBU_CHARGE_COMPLETE", + "MGR_EVT_BBU_INSERT", + "MGR_EVT_BBU_ABSENT", + "MGR_EVT_BBU_TEMPERATURE_NORMAL", + "MGR_EVT_BBU_TEMPERATURE_HIGH", + "MGR_EVT_BBU_VOLTAGE_NORMAL", + "MGR_EVT_BBU_VOLTAGE_HIGH", + "MGR_EVT_BBU_CURRENT_NORMAL", + "MGR_EVT_BBU_CURRENT_HIGH", + "MGR_EVT_BBU_LOAD_NORMAL", + "MGR_EVT_BBU_VOLTAGE_LOW", + "MGR_EVT_BBU_BATTERY_CAP_ABOVE_SOH_THRESHOLD", + "MGR_EVT_BBU_BATTERY_CAP_BELOW_SOH_THRESHOLD", + "MGR_EVT_BBU_LEARN_STAGE", + "MGR_EVT_BBU_LEARN_REQUESTED", + "MGR_EVT_BBU_LEARN_POSTPONED", + "MGR_EVT_BBU_LEARN_TIMEOUT", + "MGR_EVT_BBU_LEARN_MANUAL", + "MGR_EVT_BBU_LEARN_RESCHEDULED", + "MGR_EVT_BBU_PROPERTIES_CHANGED", + }, + { + "MGR_EVT_CONFIG_START", + "MGR_EVT_CONFIG_INFO", + "MGR_EVT_CONFIG_FLASH_READ_FAIL", + "MGR_EVT_CONFIG_FLASH_WRITE_FAIL", + "MGR_EVT_CONFIG_NVSRAM_READ_FAIL", + "MGR_EVT_CONFIG_NVSRAM_WRITE_FAIL", + "MGR_EVT_CONFIG_VERSION_MISMATCH", + "MGR_EVT_CONFIG_MEDIA_VALUE_CHECK_FAIL", + "MGR_EVT_CONFIG_ERASE_NVSRAM", + "MGR_EVT_PHY_LINKSPEED_CFG_CHANGE", + }, + { + "MGR_EVT_IO_START", + "MGR_EVT_IO_TEST", + "MGR_EVT_IO_SENSE_DATA", + "MGR_EVT_DEVICE_RESET", "MGR_EVT_NVME_DEVICE_RESET", "MGR_EVT_DEVICE_ABNORMAL", "MGR_EVT_IO_SENSE", - }, - { - "MGR_EVT_UKEY_START", - "MGR_EVT_UKEY_INSERT", - "MGR_EVT_UKEY_DEGRADE", + }, + { + "MGR_EVT_UKEY_START", + "MGR_EVT_UKEY_INSERT", + "MGR_EVT_UKEY_DEGRADE", "MGR_EVT_RAID_KEY_OVERCURRENT", "MGR_EVT_RAID_KEY_OVERCURRENT_RECOVER", - }, - { - "MGR_EVT_HWR_START", - "MGR_EVT_HWR_HAC_RESET_BEGIN", - "MGR_EVT_HWR_HAC_RESET_END", - "MGR_EVT_REPORT_HAC_ECC", - }, - { - "MGR_EVT_ALARM_START", - "MGR_EVT_ALARM_ENABLED", - "MGR_EVT_ALARM_DISABLED", - }, - { - "MGR_EVT_ECC_START", - "MGR_EVT_ECC_CNT_EXCEED", - "MGR_EVT_ECC_ERR_INTR", - "MGR_EVT_ECC_CNT_CLEAR", - "MGR_EVT_ECC_CLI_CHANGE", - "MGR_EVT_ECC_FACTORY_CHANGE", - }, - { - "MGR_EVT_UPGRADE_START", - "MGR_EVT_IMAGE_DOWNLOAD_ERROR", - "MGR_EVT_IMAGE_AUTHENTICATION_FAIL", - "MGR_EVT_IMAGE_VERSION_CHECK_FAIL", - "MGR_EVT_IMAGE_CHECKSUM_CHECK_FAIL", - "MGR_EVT_IMAGE_FROM_BACKUP", - "MGR_EVT_DEV_OPEN_ERROR", - "MGR_EVT_DEV_FLASH_ERROR", - "MGR_EVT_DEV_ERASE_ERROR", - "MGR_EVT_DEV_CLOSE_ERROR", - "MGR_EVT_FLASH_GENERAL_ERROR", - "MGR_EVT_FLASH_TIMEOUT", - "MGR_EVT_UPGRADE_SUCCESS", + }, + { + "MGR_EVT_HWR_START", + "MGR_EVT_HWR_HAC_RESET_BEGIN", + "MGR_EVT_HWR_HAC_RESET_END", + "MGR_EVT_REPORT_HAC_ECC", + }, + { + "MGR_EVT_ALARM_START", + "MGR_EVT_ALARM_ENABLED", + "MGR_EVT_ALARM_DISABLED", + }, + { + "MGR_EVT_ECC_START", + "MGR_EVT_ECC_CNT_EXCEED", + "MGR_EVT_ECC_ERR_INTR", + "MGR_EVT_ECC_CNT_CLEAR", + "MGR_EVT_ECC_CLI_CHANGE", + "MGR_EVT_ECC_FACTORY_CHANGE", + }, + { + "MGR_EVT_UPGRADE_START", + "MGR_EVT_IMAGE_DOWNLOAD_ERROR", + "MGR_EVT_IMAGE_AUTHENTICATION_FAIL", + "MGR_EVT_IMAGE_VERSION_CHECK_FAIL", + "MGR_EVT_IMAGE_CHECKSUM_CHECK_FAIL", + "MGR_EVT_IMAGE_FROM_BACKUP", + "MGR_EVT_DEV_OPEN_ERROR", + "MGR_EVT_DEV_FLASH_ERROR", + "MGR_EVT_DEV_ERASE_ERROR", + "MGR_EVT_DEV_CLOSE_ERROR", + "MGR_EVT_FLASH_GENERAL_ERROR", + "MGR_EVT_FLASH_TIMEOUT", + "MGR_EVT_UPGRADE_SUCCESS", "MGR_EVT_UPGRADE_SYNC_START", "MGR_EVT_UPGRADE_SYNC_FAILED", "MGR_EVT_UPGRADE_SYNC_SUCCESS", - }, - { - "MGR_EVT_TEMP_START", - "MGR_EVT_TEMP_WITHIN_OPTIMAL_RANGE", - "MGR_EVT_TEMP_ABOVE_OPTIMAL_RANGE", - "MGR_EVT_TEMP_WARNING", - "MGR_EVT_TEMP_CRITICAL", - }, - }; - - static char const *pEvtCodeExtInfo[PS3_EVT_EXT_NR][MGR_EVT_TYPE_EXTEND_OFFSET] = { - { - "MGR_EVT_PD_ATTR_EXTEND_START_START", - "MGR_EVT_PD_ERASE_ABORT", - "MGR_EVT_PD_ERASE_COMPLETE", - "MGR_EVT_PD_ERASE_FAILED", - "MGR_EVT_PD_ERASE_PROGRESS", - "MGR_EVT_PD_ERASE_START", - "MGR_EVT_PD_PDM_ABORT_BY_USER", - "MGR_EVT_PD_PDM_ABORT_FOR_REBUILD", - "MGR_EVT_PD_PDM_ABORT", - "MGR_EVT_PD_PDM_DONE", - "MGR_EVT_PD_PDM_FAILED_BAD_SOURCE", - "MGR_EVT_PD_PDM_FAILED_BAD_TARGET", - "MGR_EVT_PD_PDM_MEDIUM_ERROR", - "MGR_EVT_PD_PDM_PROGRESS", - "MGR_EVT_PD_PDM_REPLACED_SOURCE", - "MGR_EVT_PD_PDM_RESUME", - "MGR_EVT_PD_PDM_START_AUTO", - "MGR_EVT_PD_PDM_START", - "MGR_EVT_PD_PDM_SUSPENDED_REMINDER", - "MGR_EVT_PD_PDM_SUSPENDED", - "MGR_EVT_PD_PFA_ERROR_CLEAR", - "MGR_EVT_PD_SANITIZE_START", - "MGR_EVT_PD_FORMAT_START", - "MGR_EVT_PD_SANITIZE_PROGRESS", - "MGR_EVT_PD_SANITIZE_DONE", - "MGR_EVT_PD_FORMAT_DONE", - "MGR_EVT_PD_DPF_ERROR", - "MGR_EVT_PD_MARKED_SHIELD", - "MGR_EVT_PD_BBM_CORRECTED", - "MGR_EVT_PD_BBM_UNRECOVERABLE", - "MGR_EVT_PD_BBM_PUNCTURING", - "MGR_EVT_PD_BBM_REASSIGN_WR_ERROR", - "MGR_EVT_PD_UNABLE_ACCESS", - "MGR_EVT_MULITPILE_PD_UNABLE_ACCESS", - "MGR_EVT_PD_INSERT_FAIL", - "MGR_EVT_PHY_SATA_D2H_FAIL", - "MGR_EVT_PD_NOT_INSERTED", - "MGR_EVT_PD_NOT_SUPPORT", - "MGR_EVT_MULITPILE_PD_NOT_SUPPORT", - "MGR_EVT_NVDATA_INVALID", - "MGR_EVT_PD_RBLD_NON_UNMAP_PD", - "MGR_EVT_PD_MOVEBACK_NON_UNMAP_PD", - "MGR_EVT_PD_PDM_NON_UNMAP_PD", - "MGR_EVT_PD_RBLD_FAILED", + }, + { + "MGR_EVT_TEMP_START", + "MGR_EVT_TEMP_WITHIN_OPTIMAL_RANGE", + "MGR_EVT_TEMP_ABOVE_OPTIMAL_RANGE", + "MGR_EVT_TEMP_WARNING", + "MGR_EVT_TEMP_CRITICAL", + }, + { + "MGR_EVT_PD_ATTR_EXTEND_START_START", + "MGR_EVT_PD_ERASE_ABORT", + "MGR_EVT_PD_ERASE_COMPLETE", + "MGR_EVT_PD_ERASE_FAILED", + "MGR_EVT_PD_ERASE_PROGRESS", + "MGR_EVT_PD_ERASE_START", + "MGR_EVT_PD_PDM_ABORT_BY_USER", + "MGR_EVT_PD_PDM_ABORT_FOR_REBUILD", + "MGR_EVT_PD_PDM_ABORT", + "MGR_EVT_PD_PDM_DONE", + "MGR_EVT_PD_PDM_FAILED_BAD_SOURCE", + "MGR_EVT_PD_PDM_FAILED_BAD_TARGET", + "MGR_EVT_PD_PDM_MEDIUM_ERROR", + "MGR_EVT_PD_PDM_PROGRESS", + "MGR_EVT_PD_PDM_REPLACED_SOURCE", + "MGR_EVT_PD_PDM_RESUME", + "MGR_EVT_PD_PDM_START_AUTO", + "MGR_EVT_PD_PDM_START", + "MGR_EVT_PD_PDM_SUSPENDED_REMINDER", + "MGR_EVT_PD_PDM_SUSPENDED", + "MGR_EVT_PD_PFA_ERROR_CLEAR", + "MGR_EVT_PD_SANITIZE_START", + "MGR_EVT_PD_FORMAT_START", + "MGR_EVT_PD_SANITIZE_PROGRESS", + "MGR_EVT_PD_SANITIZE_DONE", + "MGR_EVT_PD_FORMAT_DONE", + "MGR_EVT_PD_DPF_ERROR", + "MGR_EVT_PD_MARKED_SHIELD", + "MGR_EVT_PD_BBM_CORRECTED", + "MGR_EVT_PD_BBM_UNRECOVERABLE", + "MGR_EVT_PD_BBM_PUNCTURING", + "MGR_EVT_PD_BBM_REASSIGN_WR_ERROR", + "MGR_EVT_PD_UNABLE_ACCESS", + "MGR_EVT_MULITPILE_PD_UNABLE_ACCESS", + "MGR_EVT_PD_INSERT_FAIL", + "MGR_EVT_PHY_SATA_D2H_FAIL", + "MGR_EVT_PD_NOT_INSERTED", + "MGR_EVT_PD_NOT_SUPPORT", + "MGR_EVT_MULITPILE_PD_NOT_SUPPORT", + "MGR_EVT_NVDATA_INVAILD", + "MGR_EVT_PD_RBLD_NON_UNMAP_PD", + "MGR_EVT_PD_MOVEBACK_NON_UNMAP_PD", + "MGR_EVT_PD_PDM_NON_UNMAP_PD", + "MGR_EVT_PD_RBLD_FAILED", "MGR_EVT_PD_SANITIZE_FAILED", "MGR_EVT_PD_SPIN_FAIL", "MGR_EVT_PD_RBLD_MEDIA_MIX_NOT_SUPPORT", @@ -475,34 +469,25 @@ static inline char const *mgrEvtCodeTrans(unsigned int opCode) "MGR_EVT_PD_PCIE_LINK_UP_WITHOUT_I2C", "MGR_EVT_PD_PCIE_ENUMERATE_FAILED", "MGR_EVT_PD_MISS_LIGHTING", - }, - }; - - if (opCode >= ((MGR_EVT_EXTEND_TYPE_START - 1) * MGR_EVT_TYPE_OFFSET) + - (PS3_EVT_MAX_TYPE_LOCAL - MGR_EVT_EXTEND_TYPE_START) - * MGR_EVT_TYPE_EXTEND_OFFSET) { - goto end; - }; - if (opCode < ((MGR_EVT_EXTEND_TYPE_START - 1) * MGR_EVT_TYPE_OFFSET)) { - typeIndex = opCode / MGR_EVT_TYPE_OFFSET; - codeIndex = opCode % MGR_EVT_TYPE_OFFSET; - pEvtTransStr = pEvtCodeInfo[typeIndex][codeIndex]; - } else { - typeIndex = (opCode - ((MGR_EVT_EXTEND_TYPE_START - 1) * MGR_EVT_TYPE_OFFSET)) - / MGR_EVT_TYPE_EXTEND_OFFSET; - codeIndex = (opCode - ((MGR_EVT_EXTEND_TYPE_START - 1) * MGR_EVT_TYPE_OFFSET)) - % MGR_EVT_TYPE_EXTEND_OFFSET; - pEvtTransStr = pEvtCodeExtInfo[typeIndex][codeIndex]; + }, }; + + if (opCode >= ((MGR_EVT_EXTEND_TYPE_START - 1) * MGR_EVT_TYPE_OFFSET) + \ + (PS3_EVT_MAX_TYPE_LOCAL - MGR_EVT_EXTEND_TYPE_START) * MGR_EVT_TYPE_EXTEND_OFFSET) { + goto end; + }; + typeIndex = opCode / MGR_EVT_TYPE_OFFSET; + codeIndex = opCode % MGR_EVT_TYPE_OFFSET; + pEvtTransStr = pEvtCodeInfo[typeIndex][codeIndex]; end: - return pEvtTransStr; + return pEvtTransStr; } #else -static inline char const *mgrEvtCodeTrans(unsigned int opCode) +static inline S8 const *mgrEvtCodeTrans(U32 opCode) { - const char * const pEvtTransStr = NULL; - return pEvtTransStr; + const S8* pEvtTransStr = NULL; + return pEvtTransStr; } #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_dev_info.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_dev_info.h deleted file mode 100644 index 689bcb3421dc..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_dev_info.h +++ /dev/null @@ -1,88 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ -#ifndef __PS3_HTP_DEV_INFO_H__ -#define __PS3_HTP_DEV_INFO_H__ - - -enum DriverType { - DRIVER_TYPE_UNKNOWN = 0, - DRIVER_TYPE_SAS, - DRIVER_TYPE_SATA, - DRIVER_TYPE_SES, - DRIVER_TYPE_NVME, - DRIVER_TYPE_EXP_SAS, - DRIVER_TYPE_VEP, - DRIVER_TYPE_CHASSIS, - DRIVER_TYPE_BACKPLANE, - DRIVER_TYPE_MAX, -}; - -static inline const char *getDriverTypeName(enum DriverType driverType) -{ - static const char * const driverTypeName[] = { - [DRIVER_TYPE_UNKNOWN] = "DRIVER_TYPE_UNKNOWN", - [DRIVER_TYPE_SAS] = "DRIVER_TYPE_SAS", - [DRIVER_TYPE_SATA] = "DRIVER_TYPE_SATA", - [DRIVER_TYPE_SES] = "DRIVER_TYPE_SES", - [DRIVER_TYPE_NVME] = "DRIVER_TYPE_NVME", - [DRIVER_TYPE_EXP_SAS] = "DRIVER_TYPE_EXP_SAS", - [DRIVER_TYPE_VEP] = "DRIVER_TYPE_VEP", - [DRIVER_TYPE_CHASSIS] = "DRIVER_TYPE_CHASSIS", - [DRIVER_TYPE_BACKPLANE] = "DRIVER_TYPE_BACKPLANE", - [DRIVER_TYPE_MAX] = "DRIVER_TYPE_MAX", - }; - - return driverTypeName[driverType]; -} - - -enum MediumType { - DEVICE_TYPE_UNKNOWN = 0, - DEVICE_TYPE_HDD, - DEVICE_TYPE_SSD, - DEVICE_TYPE_ENCLOSURE, - DEVICE_TYPE_MAX, -}; - -static inline const char *getMediumTypeName(enum MediumType mediumType) -{ - static const char * const mediumTypeName[] = { - [DEVICE_TYPE_UNKNOWN] = "DEVICE_TYPE_UNKNOWN", - [DEVICE_TYPE_HDD] = "DEVICE_TYPE_HDD", - [DEVICE_TYPE_SSD] = "DEVICE_TYPE_SSD", - [DEVICE_TYPE_ENCLOSURE] = "DEVICE_TYPE_ENCLOSURE", - [DEVICE_TYPE_MAX] = "DEVICE_TYPE_MAX", - }; - - return mediumTypeName[mediumType]; -} - - -enum DeviceState { - DEVICE_STATE_FREE = 0x0, - DEVICE_STATE_INSERTING, - DEVICE_STATE_ONLINE, - DEVICE_STATE_WAIT, - DEVICE_STATE_RECOVER, - DEVICE_STATE_PREONLINE, - DEVICE_STATE_OUTING, - DEVICE_STATE_MAX, -}; - -static inline const char *getDeviceStateName(enum DeviceState pdState) -{ - static const char * const pdStateName[] = { - [DEVICE_STATE_FREE] = "DEVICE_STATE_FREE", - [DEVICE_STATE_INSERTING] = "DEVICE_STATE_INSERTING", - [DEVICE_STATE_ONLINE] = "DEVICE_STATE_ONLINE", - [DEVICE_STATE_WAIT] = "DEVICE_STATE_WAIT", - [DEVICE_STATE_RECOVER] = "DEVICE_STATE_RECOVER", - [DEVICE_STATE_PREONLINE] = "DEVICE_STATE_PREONLINE", - [DEVICE_STATE_OUTING] = "DEVICE_STATE_OUTING", - [DEVICE_STATE_MAX] = "DEVICE_STATE_MAX", - }; - - return pdStateName[pdState]; -} - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_meta.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_meta.h deleted file mode 100644 index 04342e7a5392..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_meta.h +++ /dev/null @@ -1,127 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ - -#ifndef __PS3_HTP_META_H__ -#define __PS3_HTP_META_H__ - -enum MicPdState { - MIC_PD_STATE_UNKNOWN = 0, - MIC_PD_STATE_READY = 1, - MIC_PD_STATE_UBAD = 2, - MIC_PD_STATE_DSPARE = 3, - MIC_PD_STATE_GSPARE = 4, - MIC_PD_STATE_OFFLINE = 5, - MIC_PD_STATE_ONLINE = 6, - MIC_PD_STATE_MISSING = 7, - MIC_PD_STATE_FAILED = 8, - MIC_PD_STATE_REBUILD = 9, - MIC_PD_STATE_REPLACE = 10, - MIC_PD_STATE_FOREIGN = 11, - MIC_PD_STATE_JBOD = 12, - MIC_PD_STATE_UNSUPPORT = 13, - MIC_PD_STATE_PDM = 14, - MIC_PD_STATE_CFSHLD = 15, - MIC_PD_STATE_HSPSHLD = 16, - MIC_PD_STATE_RUNSP = 17, - MIC_PD_STATE_UBUNSP = 18, - MIC_PD_STATE_MAX -}; - - -static inline const char *getPdStateName(enum MicPdState pdSate, - unsigned char isRaid) -{ - static const char * const raidPdName[] = { - [MIC_PD_STATE_UNKNOWN] = "UNKNOWN", - [MIC_PD_STATE_READY] = "UGOOD", - [MIC_PD_STATE_UBAD] = "UBAD", - [MIC_PD_STATE_DSPARE] = "DSPARE", - [MIC_PD_STATE_GSPARE] = "GSPARE", - [MIC_PD_STATE_OFFLINE] = "OFFLINE", - [MIC_PD_STATE_ONLINE] = "ONLINE", - [MIC_PD_STATE_MISSING] = "MISSING", - [MIC_PD_STATE_FAILED] = "FAILED", - [MIC_PD_STATE_REBUILD] = "REBUILD", - [MIC_PD_STATE_REPLACE] = "REPLACE", - [MIC_PD_STATE_FOREIGN] = "FOREIGN", - [MIC_PD_STATE_JBOD] = "JBOD", - [MIC_PD_STATE_UNSUPPORT] = "UNSUPPORT", - [MIC_PD_STATE_PDM] = "PDM", - [MIC_PD_STATE_CFSHLD] = "CFSHLD", - [MIC_PD_STATE_HSPSHLD] = "HSPSHLD", - [MIC_PD_STATE_RUNSP] = "UGUNSP", - [MIC_PD_STATE_UBUNSP] = "UBUNSP", - }; - - static const char * const hbaPdName[] = { - [MIC_PD_STATE_UNKNOWN] = "UNKNOWN", - [MIC_PD_STATE_READY] = "READY", - [MIC_PD_STATE_UBAD] = "UBAD", - [MIC_PD_STATE_DSPARE] = "DSPARE", - [MIC_PD_STATE_GSPARE] = "GSPARE", - [MIC_PD_STATE_OFFLINE] = "OFFLINE", - [MIC_PD_STATE_ONLINE] = "ONLINE", - [MIC_PD_STATE_MISSING] = "MISSING", - [MIC_PD_STATE_FAILED] = "FAILED", - [MIC_PD_STATE_REBUILD] = "REBUILD", - [MIC_PD_STATE_REPLACE] = "REPLACE", - [MIC_PD_STATE_FOREIGN] = "FOREIGN", - [MIC_PD_STATE_JBOD] = "JBOD", - [MIC_PD_STATE_UNSUPPORT] = "UNSUPPORT", - [MIC_PD_STATE_PDM] = "PDM", - [MIC_PD_STATE_CFSHLD] = "CFSHLD", - [MIC_PD_STATE_HSPSHLD] = "HSPSHLD", - [MIC_PD_STATE_RUNSP] = "RUNSP", - [MIC_PD_STATE_UBUNSP] = "UBUNSP", - }; - - if (isRaid) - return raidPdName[pdSate]; - else - return hbaPdName[pdSate]; -} - - -enum MicVdState { - MIC_VD_STATE_UNKNOWN = 0, - MIC_VD_STATE_OFFLINE, - MIC_VD_STATE_OPTIMAL, - MIC_VD_STATE_PARTIAL_DEGRADE, - MIC_VD_STATE_DEGRADE -}; - -static inline const char *getVdStateName(enum MicVdState vdSate) -{ - static const char * const vdStateName[] = { [MIC_VD_STATE_UNKNOWN] = "UNKNOWN", - [MIC_VD_STATE_OFFLINE] = "OFFLINE", - [MIC_VD_STATE_OPTIMAL] = "OPTIMAL", - [MIC_VD_STATE_PARTIAL_DEGRADE] = - "PARTIALLY DEGRADED", - [MIC_VD_STATE_DEGRADE] = - "DEGRADED" }; - - return vdStateName[vdSate]; -} - - -enum RaidLevel { - RAID0 = 0x00, - RAID1 = 0x01, - RAID5 = 0x05, - RAID6 = 0x06, - JBOD = 0x0A, - RAID10 = 0x10, - RAID1E = 0x11, - RAID00 = 0x20, - RAID50 = 0x50, - RAID60 = 0x60, - RAID_UNKNOWN = 0xFF -}; - -enum VDAccessPolicy { - VD_ACCESS_POLICY_READ_WRITE = 0, - VD_ACCESS_POLICY_READ_ONLY, - VD_ACCESS_POLICY_BLOCK, - VD_ACCESS_POLICY_REMOVE_ACCESS -}; -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt.h deleted file mode 100644 index b84766940654..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt.h +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ - -#ifndef __PS3_HTP_MGR_EVT_H__ -#define __PS3_HTP_MGR_EVT_H__ - -#include "ps3_htp_mgr_evt_raidhba.h" - -struct PS3EventFilter { - unsigned char eventType; - unsigned char eventCodeCnt; - unsigned char reserved[6]; - unsigned short eventCodeTable[0]; -}; - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt_raidhba.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt_raidhba.h deleted file mode 100644 index 2aec5470fd44..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt_raidhba.h +++ /dev/null @@ -1,1866 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ -#ifndef __PS3_HTP_MGR_EVT_RAIDHBA_H__ -#define __PS3_HTP_MGR_EVT_RAIDHBA_H__ -#include "ps3_mgr_evt_common.h" - -enum MgrEvtType { - PS3_EVT_ILLEGAL_TYPE = 0, - PS3_EVT_SAS_INFO = 0x1, - PS3_EVT_PD_COUNT = 0x2, - PS3_EVT_VD_COUNT = 0x4, - PS3_EVT_CTRL_INFO = 0x8, - PS3_EVT_PD_ATTR = 0x10, - PS3_EVT_VD_ATTR = 0x20, - PS3_EVT_DG_INFO = 0x40, - PS3_EVT_BBU_INFO = 0x80, - PS3_EVT_CONFIG = 0x100, - PS3_EVT_IO_INFO = 0x200, - PS3_EVT_UKEY_INFO = 0x400, - PS3_EVT_HWR_INFO = 0x800, - PS3_EVT_ALARM_INFO = 0x1000, - PS3_EVT_ECC_INFO = 0x2000, - PS3_EVT_UPGRADE_INFO = 0x4000, - PS3_EVT_TEMP_INFO = 0x8000, - PS3_EVT_PD_ATTR_EXTEND = 0x10000, -}; - -static inline const char *nameMgrEvtType(unsigned int e) -{ - switch (e) { - case PS3_EVT_SAS_INFO: - return "PS3_EVT_SAS_INFO"; - case PS3_EVT_PD_COUNT: - return "PS3_EVT_PD_COUNT"; - case PS3_EVT_VD_COUNT: - return "PS3_EVT_VD_COUNT"; - case PS3_EVT_CTRL_INFO: - return "PS3_EVT_CTRL_INFO"; - case PS3_EVT_PD_ATTR: - return "PS3_EVT_PD_ATTR"; - case PS3_EVT_VD_ATTR: - return "PS3_EVT_VD_ATTR"; - case PS3_EVT_DG_INFO: - return "PS3_EVT_DG_INFO"; - case PS3_EVT_BBU_INFO: - return "PS3_EVT_BBU_INFO"; - case PS3_EVT_CONFIG: - return "PS3_EVT_CONFIG"; - case PS3_EVT_IO_INFO: - return "PS3_EVT_IO_INFO"; - case PS3_EVT_UKEY_INFO: - return "PS3_EVT_UKEY_INFO"; - case PS3_EVT_HWR_INFO: - return "PS3_EVT_HWR_INFO"; - case PS3_EVT_ALARM_INFO: - return "PS3_EVT_ALARM_INFO"; - case PS3_EVT_ECC_INFO: - return "PS3_EVT_ECC_INFO"; - case PS3_EVT_UPGRADE_INFO: - return "PS3_EVT_UPGRADE_INFO"; - case PS3_EVT_TEMP_INFO: - return "PS3_EVT_TEMP_INFO"; - case PS3_EVT_PD_ATTR_EXTEND: - return "PS3_EVT_PD_ATTR_EXTEND"; - default: - return "PS3_EVT_ILLEGAL_TYPE"; - } -} - -enum { - PS3_EVT_SAS_INFO_LOCAL = 1, - PS3_EVT_PD_COUNT_LOCAL = 2, - PS3_EVT_VD_COUNT_LOCAL = 3, - PS3_EVT_CTRL_INFO_LOCAL = 4, - PS3_EVT_PD_ATTR_LOCAL = 5, - PS3_EVT_VD_ATTR_LOCAL = 6, - PS3_EVT_DG_INFO_LOCAL = 7, - PS3_EVT_BBU_INFO_LOCAL = 8, - PS3_EVT_CONFIG_LOCAL = 9, - PS3_EVT_IO_INFO_LOCAL = 10, - PS3_EVT_UKEY_INFO_LOCAL = 11, - PS3_EVT_HWR_INFO_LOCAL = 12, - PS3_EVT_ALARM_INFO_LOCAL = 13, - PS3_EVT_ECC_INFO_LOCAL = 14, - PS3_EVT_UPGRADE_INFO_LOCAL = 15, - PS3_EVT_TEMP_INFO_LOCAL = 16, - PS3_EVT_PD_ATTR_EXTEND_LOCAL = 17, - PS3_EVT_DEFAULT_UNUSED_LOCAL, - PS3_EVT_MAX_TYPE_LOCAL, -}; - -static inline const char *nameMgrEvtLocalType(unsigned int e) -{ - switch (e) { - case PS3_EVT_SAS_INFO_LOCAL: - return "PS3_EVT_SAS_INFO_LOCAL"; - case PS3_EVT_PD_COUNT_LOCAL: - return "PS3_EVT_PD_COUNT_LOCAL"; - case PS3_EVT_VD_COUNT_LOCAL: - return "PS3_EVT_VD_COUNT_LOCAL"; - case PS3_EVT_CTRL_INFO_LOCAL: - return "PS3_EVT_CTRL_INFO_LOCAL"; - case PS3_EVT_PD_ATTR_LOCAL: - return "PS3_EVT_PD_ATTR_LOCAL"; - case PS3_EVT_VD_ATTR_LOCAL: - return "PS3_EVT_VD_ATTR_LOCAL"; - case PS3_EVT_DG_INFO_LOCAL: - return "PS3_EVT_DG_INFO_LOCAL"; - case PS3_EVT_BBU_INFO_LOCAL: - return "PS3_EVT_BBU_INFO_LOCAL"; - case PS3_EVT_CONFIG_LOCAL: - return "PS3_EVT_CONFIG_LOCAL"; - case PS3_EVT_IO_INFO_LOCAL: - return "PS3_EVT_IO_INFO_LOCAL"; - case PS3_EVT_UKEY_INFO_LOCAL: - return "PS3_EVT_UKEY_INFO_LOCAL"; - case PS3_EVT_HWR_INFO_LOCAL: - return "PS3_EVT_HWR_INFO_LOCAL"; - case PS3_EVT_ALARM_INFO_LOCAL: - return "PS3_EVT_ALARM_INFO_LOCAL"; - case PS3_EVT_ECC_INFO_LOCAL: - return "PS3_EVT_ECC_INFO_LOCAL"; - case PS3_EVT_UPGRADE_INFO_LOCAL: - return "PS3_EVT_UPGRADE_INFO_LOCAL"; - case PS3_EVT_TEMP_INFO_LOCAL: - return "PS3_EVT_TEMP_INFO_LOCAL"; - case PS3_EVT_PD_ATTR_EXTEND_LOCAL: - return "PS3_EVT_PD_ATTR_EXTEND_LOCAL"; - default: - return "PS3_EVT_ILLEGAL_TYPE"; - } -} - -enum MgrEvtSASInfoCode { - MGR_EVT_SAS_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_SAS_INFO_LOCAL), - MGR_EVT_SAS_EXPANDER_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x1), - MGR_EVT_SAS_EXPANDER_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0x2), - MGR_EVT_SAS_EXPANDER_UPDATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x3), - MGR_EVT_SAS_EXPANDER_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x4), - MGR_EVT_ENCL_TEMP_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x5), - MGR_EVT_ENCL_TEMP_WARNING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0x6), - MGR_EVT_ENCL_TEMP_CRITICAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_SAS_START + 0x7), - MGR_EVT_TOPO_LOOP = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0x8), - MGR_EVT_LOOP_RESOLUTION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x9), - MGR_EVT_CASCADED_SCAN_SMP_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_SAS_START + 0xa), - MGR_EVT_ENCL_EXCEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0xb), - MGR_EVT_TRI_MODE_SWITCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0xc), - MGR_EVT_CHANGE_PHY_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0xd), - MGR_EVT_REV_HIBERNATE_CMD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0xe), - MGR_EVT_PHY_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0xf), - MGR_EVT_INQUIRY_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x10), - MGR_EVT_SAS_SATA_LINK_SPEED_NOMATCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0x11), - MGR_EVT_SAS_SATA_LN_EXCEPTION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0x12), - MGR_EVT_SAS_SATA_DRIVER_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x13), - MGR_EVT_SAS_END = (MGR_EVT_SAS_START+0x14), -}; - -enum MgrEvtPdCountCode { - MGR_EVT_PD_COUNT_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_PD_COUNT_LOCAL), - MGR_EVT_DEVM_DISK_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x1), - MGR_EVT_DEVM_DISK_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x2), - MGR_EVT_MULITPILE_PD_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x3), - MGR_EVT_MULITPILE_PD_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x4), - MGR_EVT_DEVM_JBOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x5), - MGR_EVT_DEVM_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x6), - MGR_EVT_MULITPILE_JBOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x7), - MGR_EVT_MULITPILE_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x8), - MGR_EVT_BACKPLANE_ON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x9), - MGR_EVT_BACKPLANE_OFF = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0xa), - MGR_EVT_MULITPILE_PD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0xb), - MGR_EVT_DEVM_DISK_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0xc), - MGR_EVT_DEFAULT_UNUSED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0xd), - MGR_EVT_PD_PRE_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_INTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0xe), - MGR_EVT_PD_COUNT_END = (MGR_EVT_PD_COUNT_START+0xf), -}; - -enum MgrEvtVdCountCode { - MGR_EVT_VD_COUNT_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_VD_COUNT_LOCAL), - MGR_EVT_VD_OPTIMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x1), - MGR_EVT_VD_PARTIAL_DEGRADE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_COUNT_START + 0x2), - MGR_EVT_VD_DEGRADE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_COUNT_START + 0x3), - MGR_EVT_VD_CREATED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x4), - MGR_EVT_VD_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x5), - MGR_EVT_VD_HIDDEN_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x6), - MGR_EVT_MULITPILE_VD_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x7), - MGR_EVT_MULITPILE_VD_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x8), - MGR_EVT_VD_UNLOCK = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x9), - MGR_EVT_VD_OFFLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_COUNT_START + 0xa), - MGR_EVT_VD_COUNT_END = (MGR_EVT_VD_COUNT_START+0xb), -}; - -enum MgrEvtCtrlInfoCode { - MGR_EVT_CTRL_INFO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_CTRL_INFO_LOCAL), - MGR_EVT_CTRL_REBOOT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1), - MGR_EVT_CTRL_SHUTDOWN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2), - MGR_EVT_CTRL_TIME_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x3), - MGR_EVT_CTRL_EVENT_LOG_CLEARED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x4), - MGR_EVT_CTRL_RBLD_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x5), - MGR_EVT_CTRL_ENABLEMOVEBACK_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x6), - MGR_EVT_CTRL_ENABLENCQ_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x7), - MGR_EVT_CTRL_AUTO_REBUILD_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x8), - MGR_EVT_CTRL_EGHS_READY_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x9), - MGR_EVT_CTRL_EGHS_SPARE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xa), - MGR_EVT_CTRL_BGI_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xb), - MGR_EVT_CTRL_MIGRATE_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xc), - MGR_EVT_CTRL_CC_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xd), - MGR_EVT_CTRL_DIRECT_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xe), - MGR_EVT_CTRL_PR_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xf), - MGR_EVT_CTRL_PR_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x10), - MGR_EVT_CTRL_PR_REMINDER_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x11), - MGR_EVT_CTRL_PR_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x12), - MGR_EVT_CTRL_PR_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x13), - MGR_EVT_CTRL_PR_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x14), - MGR_EVT_CTRL_PR_CANT_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x15), - MGR_EVT_CTRL_PR_PROP_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x16), - MGR_EVT_CTRL_PARAM_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x17), - MGR_EVT_CTRL_AUTO_CC_PARAM_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x18), - MGR_EVT_CTRL_RECOVERY_FACTORY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x19), - MGR_EVT_CTRL_PROFILEID_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1a), - MGR_EVT_CTRL_SANPSHOT_CREATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1b), - MGR_EVT_CTRL_SANPSHOT_DELETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1c), - MGR_EVT_CTRL_ENABLEPDM_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1d), - MGR_EVT_CTRL_PDMSUPPORTREADYPD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1e), - MGR_EVT_CTRL_PDMTIMERINTERVAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1f), - MGR_EVT_CTRL_SECURITY_KEY_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x20), - MGR_EVT_CTRL_SECURITY_KEY_CREATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x21), - MGR_EVT_CTRL_SECURITY_KEY_DESTROY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x22), - MGR_EVT_CTRL_SECURITY_KEY_ESCROW = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x23), - MGR_EVT_CTRL_SECURITY_KEY_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x24), - MGR_EVT_CTRL_SECURITY_KEY_INVALID = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x25), - MGR_EVT_AUTOCONFIG = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x26), - MGR_EVT_CTRL_FOREIGN_IMPORTED_ALL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x27), - MGR_EVT_CTRL_FOREIGN_CLEAR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x28), - MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x29), - MGR_EVT_CTRL_FOREIGN_IMPORT_PART_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2a), - MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL_PDS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2b), - MGR_EVT_CTRL_FOREIGN_PD_DETECTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2c), - MGR_EVT_PD_INSERT_TO_DG = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2d), - MGR_EVT_PD_IMPORT_TO_DG = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2e), - MGR_EVT_HARD_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2f), - MGR_EVT_DPF_CFG_MODIFY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x30), - MGR_EVT_SPOR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x31), - MGR_EVT_ONF_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_CTRL_INFO_START + 0x32), - MGR_EVT_CTRL_LOADED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x33), - MGR_EVT_CACHE_PROTECTION_CMPT_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x34), - MGR_EVT_CACHE_PROTECTION_CMPT_NOT_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x35), - MGR_EVT_CACHE_PROTECTION_CMPT_INSTABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_CTRL_INFO_START + 0x36), - MGR_EVT_MAIN_MEDIUM_NOT_AVAILABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_CTRL_INFO_START + 0x37), - MGR_EVT_BACKUP_MEDIUM_NOT_AVAILABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_CTRL_INFO_START + 0x38), - MGR_EVT_MEDIUM_DATA_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x39), - MGR_EVT_INIT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x3a), - MGR_EVT_CTRL_POWER_MODE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x3b), - MGR_EVT_CTRL_INFO_END = (MGR_EVT_CTRL_INFO_START+0x3c), -}; - -enum MgrEvtPdAttrCode { - MGR_EVT_PD_ATTR_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_PD_ATTR_LOCAL), - MGR_EVT_PD_INFO_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1), - MGR_EVT_PD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x2), - MGR_EVT_PD_MARKED_JBOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3), - MGR_EVT_PD_MARKED_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4), - MGR_EVT_PD_MARKED_ONLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x5), - MGR_EVT_PD_MARKED_OFFLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x6), - MGR_EVT_PD_MARKED_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x7), - MGR_EVT_PD_MARKED_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x8), - MGR_EVT_PD_MARKED_REBUILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x9), - MGR_EVT_PD_MARKED_REPLACE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xa), - MGR_EVT_PD_MARKED_UNCONFIGUREDBAD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xb), - MGR_EVT_PD_MARKED_FOREIGN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xc), - MGR_EVT_PD_NR_GLOBAL_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xd), - MGR_EVT_PD_NR_GLOBAL_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xe), - MGR_EVT_PD_NR_DEDICATED_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xf), - MGR_EVT_PD_NR_DEDICATED_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x10), - MGR_EVT_PD_R_GLOBAL_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x11), - MGR_EVT_PD_R_GLOBAL_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x12), - MGR_EVT_PD_R_DEDICATED_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x13), - MGR_EVT_PD_R_DEDICATED_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x14), - MGR_EVT_PD_RBLD_ABORT_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x15), - MGR_EVT_PD_RBLD_DONE_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x16), - MGR_EVT_PD_RBLD_FAILED_BAD_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x17), - MGR_EVT_PD_RBLD_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x18), - MGR_EVT_PD_RBLD_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_START + 0x19), - MGR_EVT_PD_RBLD_SUSPENDED_REMINDER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1a), - MGR_EVT_PD_RBLD_SUSPENDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1b), - MGR_EVT_PD_RBLD_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1c), - MGR_EVT_PD_RBLD_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1d), - MGR_EVT_PD_RBLD_START_AUTO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1e), - MGR_EVT_PD_RBLD_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_START + 0x1f), - MGR_EVT_PD_EMERGENCY_SPARE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x20), - MGR_EVT_PD_RECOVER_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_START + 0x21), - MGR_EVT_PD_MOVEBACK_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x22), - MGR_EVT_PD_MOVEBACK_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x23), - MGR_EVT_PD_MOVEBACK_ABORT_FOR_REBUILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x24), - MGR_EVT_PD_MOVEBACK_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x25), - MGR_EVT_PD_MOVEBACK_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_START + 0x26), - MGR_EVT_PD_MOVEBACK_SUSPENDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x27), - MGR_EVT_PD_MOVEBACK_SUSPENDED_REMINDER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x28), - MGR_EVT_PD_MOVEBACK_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x29), - MGR_EVT_PD_MOVEBACK_START_AUTO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x2a), - MGR_EVT_PD_MOVEBACK_FAILED_BAD_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x2b), - MGR_EVT_PD_MOVEBACK_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x2c), - MGR_EVT_PD_MOVEBACK_ABORT_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x2d), - MGR_EVT_PD_MOVEBACK_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_START + 0x2e), - MGR_EVT_PD_FGI_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x2f), - MGR_EVT_PD_FGI_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x30), - MGR_EVT_PD_FGI_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x31), - MGR_EVT_PD_FGI_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_START + 0x32), - MGR_EVT_PD_FGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x33), - MGR_EVT_PD_PR_ABORTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_START + 0x34), - MGR_EVT_PD_PR_CORRECTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x35), - MGR_EVT_PD_PR_UNCORRECTABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_START + 0x36), - MGR_EVT_PD_PR_FOUND_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_START + 0x37), - MGR_EVT_PD_PR_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_START + 0x38), - MGR_EVT_PD_SET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x39), - MGR_EVT_PD_RESET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3a), - MGR_EVT_PD_RESET_BOOT_DRIVE_WITH_DISK_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3b), - MGR_EVT_PD_SET_BOOT_DRIVE_WITH_DISK_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3c), - MGR_EVT_PD_POWERSAVE_TO_ON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3d), - MGR_EVT_PD_POWERSAVE_TO_TRANSITION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3e), - MGR_EVT_PD_TRANSITION_TO_ON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3f), - MGR_EVT_PD_TRANSITION_TO_POWERSAVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x40), - MGR_EVT_PD_ON_TO_POWERSAVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x41), - MGR_EVT_PD_START_LOCATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x42), - MGR_EVT_PD_STOP_LOCATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x43), - MGR_EVT_PD_PFA_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_START + 0x44), - MGR_EVT_PD_NOT_PRESENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_START + 0x45), - MGR_EVT_DEVM_DISK_FAULT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x46), - MGR_EVT_PHY_FLASHOFFLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_START + 0x47), - MGR_EVT_PHY_FLASHONLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x48), - MGR_EVT_NFR_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x49), - MGR_EVT_NFR_REPAIRED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4a), - MGR_EVT_NFR_REPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4b), - MGR_EVT_NFR_STOP = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4c), - MGR_EVT_PD_DOWNLOAD_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4d), - MGR_EVT_PD_DOWNLOAD_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4e), - MGR_EVT_NVME_PHY_BAD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4f), - MGR_EVT_PD_ATTR_END = (MGR_EVT_PD_ATTR_START+0x50), -}; - -enum MgrEvtVdAttrCode { - MGR_EVT_VD_ATTR_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_VD_ATTR_LOCAL), - MGR_EVT_MULITPILE_VD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x1), - MGR_EVT_VD_OFFLINE_OLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x2), - MGR_EVT_VD_LOCK = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x3), - MGR_EVT_VD_PASSWD_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x4), - MGR_EVT_VD_SETTINGS_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x5), - MGR_EVT_VD_PD_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_INTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x6), - MGR_EVT_VD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x7), - MGR_EVT_PD_RBLD_DONE_LD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x8), - MGR_EVT_VD_FGI_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x9), - MGR_EVT_VD_FGI_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0xa), - MGR_EVT_VD_FGI_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_ATTR_START + 0xb), - MGR_EVT_VD_FGI_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_VD_ATTR_START + 0xc), - MGR_EVT_VD_FGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0xd), - MGR_EVT_VD_BGI_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0xe), - MGR_EVT_VD_BGI_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0xf), - MGR_EVT_VD_BGI_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_ATTR_START + 0x10), - MGR_EVT_VD_BGI_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_VD_ATTR_START + 0x11), - MGR_EVT_VD_BGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x12), - MGR_EVT_VD_BGI_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x13), - MGR_EVT_VD_BGI_REMINDER_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x14), - MGR_EVT_VD_BGI_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x15), - MGR_EVT_VD_BGI_CORRECTABLE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x16), - MGR_EVT_VD_BGI_UNCORRECTABLE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x17), - MGR_EVT_VD_ALTER_ATTR_BY_MIGRATION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x18), - MGR_EVT_VD_BBM_CLEARED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x19), - MGR_EVT_VD_BBM_PERCENT_FULL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x1a), - MGR_EVT_VD_BBM_100_FULL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x1b), - MGR_EVT_VD_BBM_LOG_FULL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x1c), - MGR_EVT_VD_BBM_LOG_RCT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x1d), - MGR_EVT_VD_BBM_LOG_WCT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_ATTR_START + 0x1e), - MGR_EVT_VD_BBM_DEL_RCT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x1f), - MGR_EVT_VD_CC_ABORTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x20), - MGR_EVT_VD_CC_CORRECTED_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x21), - MGR_EVT_VD_CC_DOUBLE_MEDIUM_ERRORS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x22), - MGR_EVT_VD_CC_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x23), - MGR_EVT_VD_CC_DONE_INCON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x24), - MGR_EVT_VD_CC_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_ATTR_START + 0x25), - MGR_EVT_VD_CC_FAILED_UNCOR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x26), - MGR_EVT_VD_CC_INCONSISTENT_PARITY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x27), - MGR_EVT_VD_CC_INCONSISTENT_PARITY_LOGGING_DISABLED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x28), - MGR_EVT_VD_CC_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_VD_ATTR_START + 0x29), - MGR_EVT_VD_CC_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2a), - MGR_EVT_VD_CC_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2b), - MGR_EVT_VD_CC_REMINDER_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2c), - MGR_EVT_VD_CC_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2d), - MGR_EVT_VD_RW_RAID1X_WRITE_CARDBUSY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2e), - MGR_EVT_VD_SET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2f), - MGR_EVT_VD_RESET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x30), - MGR_EVT_VD_RESET_BOOT_DRIVE_WITH_DISK_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x31), - MGR_EVT_VD_SET_BOOT_DRIVE_WITH_DISK_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x32), - MGR_EVT_ALL_CONFIGS_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x33), - MGR_EVT_PDS_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x34), - MGR_EVT_NVSRAM_RECOVER_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x35), - MGR_EVT_NVSRAM_UPDATE_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x36), - MGR_EVT_VD_ERASE_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x37), - MGR_EVT_VD_ERASE_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x38), - MGR_EVT_VD_ERASE_DISK_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x39), - MGR_EVT_VD_ERASE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_ATTR_START + 0x3a), - MGR_EVT_VD_ERASE_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_VD_ATTR_START + 0x3b), - MGR_EVT_VD_ERASE_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x3c), - MGR_EVT_VD_EXPAND_FINISH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x3d), - MGR_EVT_VD_EXPAND_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x3e), - MGR_EVT_VD_FLUSH_CLEAR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x3f), - MGR_EVT_VD_FLUSH_RECORD_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x40), - MGR_EVT_VD_FLUSH_SET_INCONSIST = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x41), - MGR_EVT_VDS_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x42), - MGR_EVT_VD_BBM_UNCORRECTABLE_LOGGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x43), - MGR_EVT_VD_FLUSH_CACHE_PINNED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x44), - MGR_EVT_VD_FLUSH_OCR_CACHE_PINNED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x45), - MGR_EVT_VD_FLUSH_CACHE_DISCARDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x46), - MGR_EVT_VD_FLUSH_CACHE_DISCARDED_DEL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x47), - MGR_EVT_VD_FLUSH_CACHE_DESTAGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x48), - MGR_EVT_VD_CM_RECOVERY_CRC_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x49), - MGR_EVT_VD_BGI_COMPLETE_UNCOR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x4a), - MGR_EVT_VD_ATTR_END = (MGR_EVT_VD_ATTR_START+0x4b), -}; - -enum MgrEvtDgInfoCode { - MGR_EVT_DG_INFO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_DG_INFO_LOCAL), - MGR_EVT_DG_CREATED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x1), - MGR_EVT_DG_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x2), - MGR_EVT_DG_SETTING_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x3), - MGR_EVT_DG_MIGRATION_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x4), - MGR_EVT_DG_MIGRATION_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x5), - MGR_EVT_DG_MIGRATION_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x6), - MGR_EVT_DG_MIGRATION_ALLOC_RESOURCE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_DG_INFO_START + 0x7), - MGR_EVT_DG_MIGRATION_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_DG_INFO_START + 0x8), - MGR_EVT_DG_MIGRATION_RECOVER_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_DG_INFO_START + 0x9), - MGR_EVT_DG_MIGRATION_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_DG_INFO_START + 0xa), - MGR_EVT_DG_MIGRATION_INTERNAL_WARNING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_DG_INFO_START + 0xb), - MGR_EVT_DG_PRSWITCH_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0xc), - MGR_EVT_DG_PR_ABORTED_WM_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_DG_INFO_START + 0xd), - MGR_EVT_DG_PR_ABORTED_SPINUP_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_DG_INFO_START + 0xe), - MGR_EVT_DG_INFO_END = (MGR_EVT_DG_INFO_START+0xf), -}; - -enum MgrEvtBbuInfoCode { - MGR_EVT_BBU_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_BBU_INFO_LOCAL), - MGR_EVT_BBU_PRESENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x1), - MGR_EVT_BBU_NOT_PRESENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x2), - MGR_EVT_BBU_GOOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x3), - MGR_EVT_BBU_BAD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0x4), - MGR_EVT_BBU_CAP_BELOW_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x5), - MGR_EVT_BBU_CAP_ABOVE_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x6), - MGR_EVT_BBU_CHARGE_STATUS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x7), - MGR_EVT_BBU_CHARGE_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x8), - MGR_EVT_BBU_INSERT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x9), - MGR_EVT_BBU_ABSENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0xa), - MGR_EVT_BBU_TEMPERATURE_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0xb), - MGR_EVT_BBU_TEMPERATURE_HIGH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_BBU_START + 0xc), - MGR_EVT_BBU_VOLTAGE_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0xd), - MGR_EVT_BBU_VOLTAGE_HIGH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0xe), - MGR_EVT_BBU_CURRENT_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0xf), - MGR_EVT_BBU_CURRENT_HIGH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0x10), - MGR_EVT_BBU_LOAD_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x11), - MGR_EVT_BBU_VOLTAGE_LOW = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0x12), - MGR_EVT_BBU_BATTERY_CAP_ABOVE_SOH_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x13), - MGR_EVT_BBU_BATTERY_CAP_BELOW_SOH_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_BBU_START + 0x14), - MGR_EVT_BBU_LEARN_STAGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x15), - MGR_EVT_BBU_LEARN_REQUESTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0x16), - MGR_EVT_BBU_LEARN_POSTPONED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x17), - MGR_EVT_BBU_LEARN_TIMEOUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_BBU_START + 0x18), - MGR_EVT_BBU_LEARN_MANUAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0x19), - MGR_EVT_BBU_LEARN_RESCHEDULED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x1a), - MGR_EVT_BBU_PROPERTIES_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x1b), - MGR_EVT_BBU_END = (MGR_EVT_BBU_START+0x1c), -}; - -enum MgrEvtConfigCode { - MGR_EVT_CONFIG_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_CONFIG_LOCAL), - MGR_EVT_CONFIG_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x1), - MGR_EVT_CONFIG_FLASH_READ_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x2), - MGR_EVT_CONFIG_FLASH_WRITE_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x3), - MGR_EVT_CONFIG_NVSRAM_READ_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x4), - MGR_EVT_CONFIG_NVSRAM_WRITE_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x5), - MGR_EVT_CONFIG_VERSION_MISMATCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x6), - MGR_EVT_CONFIG_MEDIA_VALUE_CHECK_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x7), - MGR_EVT_CONFIG_ERASE_NVSRAM = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x8), - MGR_EVT_PHY_LINKSPEED_CFG_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x9), - MGR_EVT_CONFIG_END = (MGR_EVT_CONFIG_START+0xa), -}; - -enum MgrEvtIoInfoCode { - MGR_EVT_IO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_IO_INFO_LOCAL), - MGR_EVT_IO_TEST = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x1), - MGR_EVT_IO_SENSE_DATA = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x2), - MGR_EVT_DEVICE_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x3), - MGR_EVT_NVME_DEVICE_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x4), - MGR_EVT_DEVICE_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x5), - MGR_EVT_IO_SENSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x6), - MGR_EVT_IO_END = (MGR_EVT_IO_START+0x7), -}; - -enum MgrEvtUkeyInfoCode { - MGR_EVT_UKEY_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_UKEY_INFO_LOCAL), - MGR_EVT_UKEY_INSERT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UKEY_START + 0x1), - MGR_EVT_UKEY_DEGRADE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UKEY_START + 0x2), - MGR_EVT_RAID_KEY_OVERCURRENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_UKEY_START + 0x3), - MGR_EVT_RAID_KEY_OVERCURRENT_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UKEY_START + 0x4), - MGR_EVT_UKEY_END = (MGR_EVT_UKEY_START+0x5), -}; - -enum MgrEvtHwRInfoCode { - MGR_EVT_HWR_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_HWR_INFO_LOCAL), - MGR_EVT_HWR_HAC_RESET_BEGIN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_HWR_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_HWR_START + 0x1), - MGR_EVT_HWR_HAC_RESET_END = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_HWR_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_HWR_START + 0x2), - MGR_EVT_REPORT_HAC_ECC = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_HWR_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_HWR_START + 0x3), - MGR_EVT_HWR_END = (MGR_EVT_HWR_START+0x4), -}; - -enum MgrEvtAlarmInfoCode { - MGR_EVT_ALARM_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_ALARM_INFO_LOCAL), - MGR_EVT_ALARM_ENABLED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_ALARM_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_ALARM_START + 0x1), - MGR_EVT_ALARM_DISABLED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_ALARM_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_ALARM_START + 0x2), - MGR_EVT_ALARM_END = (MGR_EVT_ALARM_START+0x3), -}; - -enum MgrEvtEccInfoCode { - MGR_EVT_ECC_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_ECC_INFO_LOCAL), - MGR_EVT_ECC_CNT_EXCEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_ECC_START + 0x1), - MGR_EVT_ECC_ERR_INTR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_ECC_START + 0x2), - MGR_EVT_ECC_CNT_CLEAR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_ECC_START + 0x3), - MGR_EVT_ECC_CLI_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_ECC_START + 0x4), - MGR_EVT_ECC_FACTORY_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_INTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_ECC_START + 0x5), - MGR_EVT_ECC_END = (MGR_EVT_ECC_START+0x6), -}; - -enum MgrEvtUpgradeInfoCode { - MGR_EVT_UPGRADE_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_UPGRADE_INFO_LOCAL), - MGR_EVT_IMAGE_DOWNLOAD_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x1), - MGR_EVT_IMAGE_AUTHENTICATION_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x2), - MGR_EVT_IMAGE_VERSION_CHECK_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x3), - MGR_EVT_IMAGE_CHECKSUM_CHECK_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x4), - MGR_EVT_IMAGE_FROM_BACKUP = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_UPGRADE_START + 0x5), - MGR_EVT_DEV_OPEN_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x6), - MGR_EVT_DEV_FLASH_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x7), - MGR_EVT_DEV_ERASE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x8), - MGR_EVT_DEV_CLOSE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x9), - MGR_EVT_FLASH_GENERAL_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0xa), - MGR_EVT_FLASH_TIMEOUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0xb), - MGR_EVT_UPGRADE_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UPGRADE_START + 0xc), - MGR_EVT_UPGRADE_SYNC_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UPGRADE_START + 0xd), - MGR_EVT_UPGRADE_SYNC_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UPGRADE_START + 0xe), - MGR_EVT_UPGRADE_SYNC_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UPGRADE_START + 0xf), - MGR_EVT_UPGRADE_END = (MGR_EVT_UPGRADE_START+0x10), -}; - -enum MgrEvtTempInfoCode { - MGR_EVT_TEMP_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_TEMP_INFO_LOCAL), - MGR_EVT_TEMP_WITHIN_OPTIMAL_RANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_TEMP_START + 0x1), - MGR_EVT_TEMP_ABOVE_OPTIMAL_RANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_TEMP_START + 0x2), - MGR_EVT_TEMP_WARNING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_TEMP_START + 0x3), - MGR_EVT_TEMP_CRITICAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_TEMP_START + 0x4), - MGR_EVT_TEMP_END = (MGR_EVT_TEMP_START+0x5), -}; - -enum MgrEvtPdAttrExtendCode { - MGR_EVT_PD_ATTR_EXTEND_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_PD_ATTR_EXTEND_LOCAL), - MGR_EVT_PD_ERASE_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1), - MGR_EVT_PD_ERASE_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2), - MGR_EVT_PD_ERASE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3), - MGR_EVT_PD_ERASE_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_EXTEND_START + 0x4), - MGR_EVT_PD_ERASE_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x5), - MGR_EVT_PD_PDM_ABORT_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x6), - MGR_EVT_PD_PDM_ABORT_FOR_REBUILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x7), - MGR_EVT_PD_PDM_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x8), - MGR_EVT_PD_PDM_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x9), - MGR_EVT_PD_PDM_FAILED_BAD_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0xa), - MGR_EVT_PD_PDM_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0xb), - MGR_EVT_PD_PDM_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0xc), - MGR_EVT_PD_PDM_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_EXTEND_START + 0xd), - MGR_EVT_PD_PDM_REPLACED_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0xe), - MGR_EVT_PD_PDM_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0xf), - MGR_EVT_PD_PDM_START_AUTO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x10), - MGR_EVT_PD_PDM_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x11), - MGR_EVT_PD_PDM_SUSPENDED_REMINDER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x12), - MGR_EVT_PD_PDM_SUSPENDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x13), - MGR_EVT_PD_PFA_ERROR_CLEAR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x14), - MGR_EVT_PD_SANITIZE_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x15), - MGR_EVT_PD_FORMAT_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x16), - MGR_EVT_PD_SANITIZE_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_EXTEND_START + 0x17), - MGR_EVT_PD_SANITIZE_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x18), - MGR_EVT_PD_FORMAT_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x19), - MGR_EVT_PD_DPF_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1a), - MGR_EVT_PD_MARKED_SHIELD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1b), - MGR_EVT_PD_BBM_CORRECTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1c), - MGR_EVT_PD_BBM_UNRECOVERABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1d), - MGR_EVT_PD_BBM_PUNCTURING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1e), - MGR_EVT_PD_BBM_REASSIGN_WR_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1f), - MGR_EVT_PD_UNABLE_ACCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x20), - MGR_EVT_MULITPILE_PD_UNABLE_ACCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x21), - MGR_EVT_PD_INSERT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x22), - MGR_EVT_PHY_SATA_D2H_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x23), - MGR_EVT_PD_NOT_INSERTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x24), - MGR_EVT_PD_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x25), - MGR_EVT_MULITPILE_PD_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x26), - MGR_EVT_NVDATA_INVALID = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x27), - MGR_EVT_PD_RBLD_NON_UNMAP_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x28), - MGR_EVT_PD_MOVEBACK_NON_UNMAP_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x29), - MGR_EVT_PD_PDM_NON_UNMAP_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2a), - MGR_EVT_PD_RBLD_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2b), - MGR_EVT_PD_SANITIZE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2c), - MGR_EVT_PD_SPIN_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2d), - MGR_EVT_PD_RBLD_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2e), - MGR_EVT_PD_RBLD_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2f), - MGR_EVT_PD_PDM_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x30), - MGR_EVT_PD_PDM_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x31), - MGR_EVT_PD_MOVEBACK_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x32), - MGR_EVT_PD_MOVEBACK_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x33), - MGR_EVT_NFR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x34), - MGR_EVT_PD_RBLD_SMALL_SIZE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x35), - MGR_EVT_PD_MOVEBACK_SMALL_SIZE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x36), - MGR_EVT_NEGO_LOWER_LINK_SPEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x37), - MGR_EVT_PD_NVME_CMD_ERR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x38), - MGR_EVT_PD_NVME_CMD_TO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x39), - MGR_EVT_PD_NVME_INSERT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3a), - MGR_EVT_PCIE_LINK_NEGO_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3b), - MGR_EVT_PD_ISOLATION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3c), - MGR_EVT_PD_REPAIR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3d), - MGR_EVT_PD_PCIE_LINK_UP_WITHOUT_I2C = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3e), - MGR_EVT_PD_PCIE_ENUMERATE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3f), - MGR_EVT_PD_MISS_LIGHTING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, - PS3_EVT_EXP_INTERNAL, PS3_EVT_IS_BATCH_FALSE, - PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x40), - MGR_EVT_PD_ATTR_EXTEND_END = (MGR_EVT_PD_ATTR_EXTEND_START+0x41), -}; - -static inline unsigned int ps3EvtCodeExtendToNormal(unsigned int evtcode) -{ - unsigned int event = 0; - - switch (evtcode) { - case PS3_EVT_PD_ATTR_EXTEND_LOCAL: - event = PS3_EVT_PD_ATTR_LOCAL; - break; - default: - event = evtcode; - break; - } - return event; -} - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_nvme_spec.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_nvme_spec.h deleted file mode 100644 index 4772b7bae537..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_nvme_spec.h +++ /dev/null @@ -1,191 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ -#ifndef __PS3_HTP_NVME_SPEC_H__ -#define __PS3_HTP_NVME_SPEC_H__ - - -enum NvmeGenCmdSC { - NVME_SC_SUCCESS = 0x00, - NVME_SC_INVALID_OPCODE = 0x01, - NVME_SC_INVALID_FIELD = 0x02, - NVME_SC_COMMAND_ID_CONFLICT = 0x03, - NVME_SC_DATA_TRANSFER_ERROR = 0x04, - NVME_SC_ABORTED_POWER_LOSS = 0x05, - NVME_SC_INTERNAL_DEVICE_ERROR = 0x06, - NVME_SC_ABORTED_BY_REQUEST = 0x07, - NVME_SC_ABORTED_SQ_DELETION = 0x08, - NVME_SC_ABORTED_FAILED_FUSED = 0x09, - NVME_SC_ABORTED_MISSING_FUSED = 0x0a, - NVME_SC_INVALID_NAMESPACE_OR_FORMAT = 0x0b, - NVME_SC_COMMAND_SEQUENCE_ERROR = 0x0c, - NVME_SC_INVALID_SGL_SEG_DESCRIPTOR = 0x0d, - NVME_SC_INVALID_NUM_SGL_DESCIRPTORS = 0x0e, - NVME_SC_DATA_SGL_LENGTH_INVALID = 0x0f, - NVME_SC_METADATA_SGL_LENGTH_INVALID = 0x10, - NVME_SC_SGL_DESCRIPTOR_TYPE_INVALID = 0x11, - NVME_SC_INVALID_CONTROLLER_MEM_BUF = 0x12, - NVME_SC_INVALID_PRP_OFFSET = 0x13, - NVME_SC_ATOMIC_WRITE_UNIT_EXCEEDED = 0x14, - NVME_SC_OPERATION_DENIED = 0x15, - NVME_SC_INVALID_SGL_OFFSET = 0x16, - - NVME_SC_HOSTID_INCONSISTENT_FORMAT = 0x18, - NVME_SC_KEEP_ALIVE_EXPIRED = 0x19, - NVME_SC_KEEP_ALIVE_INVALID = 0x1a, - NVME_SC_ABORTED_PREEMPT = 0x1b, - NVME_SC_SANITIZE_FAILED = 0x1c, - NVME_SC_SANITIZE_IN_PROGRESS = 0x1d, - NVME_SC_SGL_DATA_BLOCK_GRANULARITY_INVALID = 0x1e, - NVME_SC_COMMAND_INVALID_IN_CMB = 0x1f, - NVME_SC_NAMESPACE_IS_WRITE_PROTECTED = 0x20, - NVME_SC_COMMAND_INTERRUPTED = 0x21, - NVME_SC_TRANSIENT_TRANSPORT_ERROR = 0x22, - - NVME_SC_LBA_OUT_OF_RANGE = 0x80, - NVME_SC_CAPACITY_EXCEEDED = 0x81, - NVME_SC_NAMESPACE_NOT_READY = 0x82, - NVME_SC_RESERVATION_CONFLICT = 0x83, - NVME_SC_FORMAT_IN_PROGRESS = 0x84, -}; - - -enum NvmeCmdSpecSC { - NVME_CSC_COMPLETION_QUEUE_INVALID = 0x00, - NVME_CSC_INVALID_QUEUE_IDENTIFIER = 0x01, - NVME_CSC_MAXIMUM_QUEUE_SIZE_EXCEEDED = 0x02, - NVME_CSC_ABORT_COMMAND_LIMIT_EXCEEDED = 0x03, - - NVME_CSC_ASYNC_EVENT_REQUEST_LIMIT_EXCEEDED = 0x05, - NVME_CSC_INVALID_FIRMWARE_SLOT = 0x06, - NVME_CSC_INVALID_FIRMWARE_IMAGE = 0x07, - NVME_CSC_INVALID_INTERRUPT_VECTOR = 0x08, - NVME_CSC_INVALID_LOG_PAGE = 0x09, - NVME_CSC_INVALID_FORMAT = 0x0a, - NVME_CSC_FIRMWARE_REQ_CONVENTIONAL_RESET = 0x0b, - NVME_CSC_INVALID_QUEUE_DELETION = 0x0c, - NVME_CSC_FEATURE_ID_NOT_SAVEABLE = 0x0d, - NVME_CSC_FEATURE_NOT_CHANGEABLE = 0x0e, - NVME_CSC_FEATURE_NOT_NAMESPACE_SPECIFIC = 0x0f, - NVME_CSC_FIRMWARE_REQ_NVM_RESET = 0x10, - NVME_CSC_FIRMWARE_REQ_RESET = 0x11, - NVME_CSC_FIRMWARE_REQ_MAX_TIME_VIOLATION = 0x12, - NVME_CSC_FIRMWARE_ACTIVATION_PROHIBITED = 0x13, - NVME_CSC_OVERLAPPING_RANGE = 0x14, - NVME_CSC_NAMESPACE_INSUFFICIENT_CAPACITY = 0x15, - NVME_CSC_NAMESPACE_ID_UNAVAILABLE = 0x16, - - NVME_CSC_NAMESPACE_ALREADY_ATTACHED = 0x18, - NVME_CSC_NAMESPACE_IS_PRIVATE = 0x19, - NVME_CSC_NAMESPACE_NOT_ATTACHED = 0x1a, - NVME_CSC_THINPROVISIONING_NOT_SUPPORTED = 0x1b, - NVME_CSC_CONTROLLER_LIST_INVALID = 0x1c, - NVME_CSC_DEVICE_SELF_TEST_IN_PROGRESS = 0x1d, - NVME_CSC_BOOT_PARTITION_WRITE_PROHIBITED = 0x1e, - NVME_CSC_INVALID_CTRLR_ID = 0x1f, - NVME_CSC_INVALID_SECONDARY_CTRLR_STATE = 0x20, - NVME_CSC_INVALID_NUM_CTRLR_RESOURCES = 0x21, - NVME_CSC_INVALID_RESOURCE_ID = 0x22, - - NVME_CSC_CONFLICTING_ATTRIBUTES = 0x80, - NVME_CSC_INVALID_PROTECTION_INFO = 0x81, - NVME_CSC_ATTEMPTED_WRITE_TO_RO_RANGE = 0x82, -}; - - -enum NvmeMediaErrSC { - NVME_MSC_WRITE_FAULTS = 0x80, - NVME_MSC_UNRECOVERED_READ_ERROR = 0x81, - NVME_MSC_GUARD_CHECK_ERROR = 0x82, - NVME_MSC_APPLICATION_TAG_CHECK_ERROR = 0x83, - NVME_MSC_REFERENCE_TAG_CHECK_ERROR = 0x84, - NVME_MSC_COMPARE_FAILURE = 0x85, - NVME_MSC_ACCESS_DENIED = 0x86, - NVME_MSC_DEALLOCATED_OR_UNWRITTEN_BLOCK = 0x87, -}; - -enum NvmeStatusCodes { - NVME_SUCCESS = 0x0000, - NVME_INVALID_OPCODE = 0x0001, - NVME_INVALID_FIELD = 0x0002, - NVME_CID_CONFLICT = 0x0003, - NVME_DATA_TRAS_ERROR = 0x0004, - NVME_POWER_LOSS_ABORT = 0x0005, - NVME_INTERNAL_DEV_ERROR = 0x0006, - NVME_CMD_ABORT_REQ = 0x0007, - NVME_CMD_ABORT_SQ_DEL = 0x0008, - NVME_CMD_ABORT_FAILED_FUSE = 0x0009, - NVME_CMD_ABORT_MISSING_FUSE = 0x000a, - NVME_INVALID_NSID = 0x000b, - NVME_CMD_SEQ_ERROR = 0x000c, - NVME_INVALID_SGL_SEG_DESCR = 0x000d, - NVME_INVALID_NUM_SGL_DESCRS = 0x000e, - NVME_DATA_SGL_LEN_INVALID = 0x000f, - NVME_MD_SGL_LEN_INVALID = 0x0010, - NVME_SGL_DESCR_TYPE_INVALID = 0x0011, - NVME_INVALID_USE_OF_CMB = 0x0012, - NVME_INVALID_PRP_OFFSET = 0x0013, - NVME_CMD_SET_CMB_REJECTED = 0x002b, - NVME_INVALID_CMD_SET = 0x002c, - NVME_LBA_RANGE = 0x0080, - NVME_CAP_EXCEEDED = 0x0081, - NVME_NS_NOT_READY = 0x0082, - NVME_NS_RESV_CONFLICT = 0x0083, - NVME_FORMAT_IN_PROGRESS = 0x0084, - NVME_INVALID_CQID = 0x0100, - NVME_INVALID_QID = 0x0101, - NVME_MAX_QSIZE_EXCEEDED = 0x0102, - NVME_ACL_EXCEEDED = 0x0103, - NVME_RESERVED = 0x0104, - NVME_AER_LIMIT_EXCEEDED = 0x0105, - NVME_INVALID_FW_SLOT = 0x0106, - NVME_INVALID_FW_IMAGE = 0x0107, - NVME_INVALID_IRQ_VECTOR = 0x0108, - NVME_INVALID_LOG_ID = 0x0109, - NVME_INVALID_FORMAT = 0x010a, - NVME_FW_REQ_RESET = 0x010b, - NVME_INVALID_QUEUE_DEL = 0x010c, - NVME_FID_NOT_SAVEABLE = 0x010d, - NVME_FEAT_NOT_CHANGEABLE = 0x010e, - NVME_FEAT_NOT_NS_SPEC = 0x010f, - NVME_FW_REQ_SUSYSTEM_RESET = 0x0110, - NVME_NS_ALREADY_ATTACHED = 0x0118, - NVME_NS_PRIVATE = 0x0119, - NVME_NS_NOT_ATTACHED = 0x011A, - NVME_NS_CTRL_LIST_INVALID = 0x011C, - NVME_CONFLICTING_ATTRS = 0x0180, - NVME_INVALID_PROT_INFO = 0x0181, - NVME_WRITE_TO_RO = 0x0182, - NVME_CMD_SIZE_LIMIT = 0x0183, - NVME_ZONE_BOUNDARY_ERROR = 0x01b8, - NVME_ZONE_FULL = 0x01b9, - NVME_ZONE_READ_ONLY = 0x01ba, - NVME_ZONE_OFFLINE = 0x01bb, - NVME_ZONE_INVALID_WRITE = 0x01bc, - NVME_ZONE_TOO_MANY_ACTIVE = 0x01bd, - NVME_ZONE_TOO_MANY_OPEN = 0x01be, - NVME_ZONE_INVAL_TRANSITION = 0x01bf, - NVME_WRITE_FAULT = 0x0280, - NVME_UNRECOVERED_READ = 0x0281, - NVME_E2E_GUARD_ERROR = 0x0282, - NVME_E2E_APP_ERROR = 0x0283, - NVME_E2E_REF_ERROR = 0x0284, - NVME_CMP_FAILURE = 0x0285, - NVME_ACCESS_DENIED = 0x0286, - NVME_DULB = 0x0287, - NVME_MORE = 0x2000, - NVME_DNR = 0x4000, - NVME_NO_COMPLETE = 0xffff, -}; - - -enum NvmeStatusCodeType { - NVME_SCT_GENERIC = 0x0, - NVME_SCT_COMMAND_SPECIFIC = 0x1, - NVME_SCT_MEDIA_ERROR = 0x2, - NVME_SCT_PATH = 0x3, - - NVME_SCT_VENDOR_SPECIFIC = 0x7, -}; - -#endif - diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_register_fifo.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_register_fifo.h deleted file mode 100644 index fe7ca27e7f31..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_register_fifo.h +++ /dev/null @@ -1,41 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ - -#ifndef __PS3_HTP_REGISTER_FIFO_H__ -#define __PS3_HTP_REGISTER_FIFO_H__ - -#include "hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h" -#include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h" -#include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h" -#include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h" - -#ifdef __cplusplus -extern "C" { -#endif - -union ps3RequestFifo { - unsigned char reserved0[HIL_REG0_PS3_REQUEST_QUEUE_SIZE]; - struct HilReg0Ps3RequestQueue request_fifo; -}; - -union ps3RegShare { - unsigned char reserved0[HIL_REG0_PS3_REGISTER_S_SIZE]; - struct HilReg0Ps3RegisterS share_reg; -}; - -union ps3RegExclusive { - unsigned char reserved0[HIL_REG0_PS3_REGISTER_F_SIZE]; - struct HilReg0Ps3RegisterF Excl_reg; -}; - -struct Ps3Fifo { - union ps3RegExclusive reg_f; - union ps3RequestFifo cmd_fifo; - union ps3RegShare reg_s; -}; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_trace_id.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_trace_id.h deleted file mode 100644 index d54d2688eb62..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_trace_id.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ - -#ifndef __PS3_HTP_TRACE_ID_H__ -#define __PS3_HTP_TRACE_ID_H__ - -#define TRACE_ID_CHIP_OUT_COUNT_MASK 0x000FFFFFFFFFFFFFLLU - -#define TRACE_ID_CHIP_OUT_CPUID_SHIFT 52 -#define TRACE_ID_CHIP_OUT_CPUID_MASK 0x7FFLLU - -static inline void traceIdCpuIdSet(unsigned long long *traceId, - unsigned short cpuId) -{ - *traceId &= ~(TRACE_ID_CHIP_OUT_CPUID_MASK - << TRACE_ID_CHIP_OUT_CPUID_SHIFT); - *traceId |= ((unsigned long long)cpuId & TRACE_ID_CHIP_OUT_CPUID_MASK) - << TRACE_ID_CHIP_OUT_CPUID_SHIFT; -} - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_common.h b/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_common.h index 85cd83201cfb..c49b562a8331 100644 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_common.h +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_common.h @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ #ifndef __PS3_MGR_EVT_COMMON_H__ #define __PS3_MGR_EVT_COMMON_H__ @@ -11,22 +9,18 @@ #define MGR_EVT_EXTEND_TYPE_START (17) -#define MGR_EVT_TYPE_BASE_LOCAL(sn) (sn < MGR_EVT_EXTEND_TYPE_START ? \ - (sn - 1) * MGR_EVT_TYPE_OFFSET : \ - MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1) \ - + MGR_EVT_TYPE_EXTEND_OFFSET * (sn - MGR_EVT_EXTEND_TYPE_START)) +#define MGR_EVT_TYPE_BASE_LOCAL(sn) (sn < MGR_EVT_EXTEND_TYPE_START ? (sn - 1) * MGR_EVT_TYPE_OFFSET : \ + MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1) \ + + MGR_EVT_TYPE_EXTEND_OFFSET * (sn - MGR_EVT_EXTEND_TYPE_START)) - - -#define MGR_EVENT_CODE_2_TYPE(code) \ - (code <= MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1) ? \ - ((code) / MGR_EVT_TYPE_OFFSET + 1) : \ - (code - MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1)) / \ - MGR_EVT_TYPE_EXTEND_OFFSET + MGR_EVT_EXTEND_TYPE_START) +#define MGR_EVENT_CODE_2_TYPE(code) (code <= MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1) ? \ + ((code) / MGR_EVT_TYPE_OFFSET + 1) : \ + (code - MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1)) / MGR_EVT_TYPE_EXTEND_OFFSET \ + + MGR_EVT_EXTEND_TYPE_START) #else -#define MGR_EVT_TYPE_BASE_LOCAL(sn) ((sn - 1) * MGR_EVT_TYPE_OFFSET) -#define MGR_EVENT_CODE_2_TYPE(code) ((code) / MGR_EVT_TYPE_OFFSET + 1) +#define MGR_EVT_TYPE_BASE_LOCAL(sn) ((sn - 1) * MGR_EVT_TYPE_OFFSET) +#define MGR_EVENT_CODE_2_TYPE(code) ((code) / MGR_EVT_TYPE_OFFSET + 1) #endif #define PS3_EVT_TYPE_OFFSET (30) @@ -37,50 +31,51 @@ #define PS3_EVT_CODE_OFFSET (0) #define PS3_MAKE_EVT_CODE(type, expose, batch, attr, level, code) \ - ((((type)&0b11) << PS3_EVT_TYPE_OFFSET) | \ - (((expose)&0b11) << PS3_EVT_EXPOSE_OFFSET) | \ - (((batch)&0b1) << PS3_EVT_BATCH_OFFSET) | \ - (((attr)&0x3F) << PS3_EVT_ATTR_OFFSET) | \ - (((level)&0xF) << PS3_EVT_LEVEL_OFFSET) | \ - ((code)&0xFFF) << PS3_EVT_CODE_OFFSET) + ((((type)&0b11) << PS3_EVT_TYPE_OFFSET) | (((expose)&0b11) << PS3_EVT_EXPOSE_OFFSET) | \ + (((batch)&0b1) << PS3_EVT_BATCH_OFFSET) | (((attr)&0x3F) << PS3_EVT_ATTR_OFFSET) | \ + (((level)&0xF) << PS3_EVT_LEVEL_OFFSET) | ((code)&0xFFF) << PS3_EVT_CODE_OFFSET) #define PS3_MK_EVT(type, expose, batch, attr, level, code) \ - (PS3_MAKE_EVT_CODE(type, expose, batch, attr, level, code)) + (PS3_MAKE_EVT_CODE(type, expose, batch, attr, level, code)) -#define PS3_EVT_TYPE(evtcode) ((evtcode >> PS3_EVT_TYPE_OFFSET) & 0b11) +#define PS3_EVT_TYPE(evtcode) ((evtcode >> PS3_EVT_TYPE_OFFSET) & 0b11) #define PS3_EVT_EXPOSE(evtcode) ((evtcode >> PS3_EVT_EXPOSE_OFFSET) & 0b11) #define PS3_EVT_IS_BATCH(evtcode) ((evtcode >> PS3_EVT_BATCH_OFFSET) & 0b1) -#define PS3_EVT_ATTR_EXTEND(evtcode) ((U8)((evtcode >> PS3_EVT_ATTR_OFFSET) & 0x3F)) -#define PS3_EVT_LEVEL(evtcode) ((evtcode >> PS3_EVT_LEVEL_OFFSET) & 0xF) -#define PS3_EVT_CODE(evtcode) (((unsigned int)evtcode >> PS3_EVT_CODE_OFFSET) & 0xFFF) - -enum Ps3EventType { - PS3_EVT_TYPE_UNKNOWN = 0b0000, - PS3_EVT_TYPE_RAIDHBA = 0b0001, - PS3_EVT_TYPE_EXPANDER = 0b0010, - PS3_EVT_TYPE_PCIESWITCH = 0b0011 -}; - -enum Ps3EventExpose { - PS3_EVT_EXP_UNKNOWN = 0b0000, - PS3_EVT_EXP_EXTERNAL = 0b0001, - PS3_EVT_EXP_INTERNAL = 0b0010, - PS3_EVT_EXP_MAX = 0b0011 -}; - -enum MgrEventLevel { - PS3_EVT_CLASS_UNKNOWN = 0b0000, - PS3_EVT_CLASS_DEBUG = 0b0011, - PS3_EVT_CLASS_PROCESS = 0b0101, - PS3_EVT_CLASS_INFO = 0b0001, - PS3_EVT_CLASS_WARNING = 0b0010, - PS3_EVT_CLASS_CRITICAL = 0b0100, - PS3_EVT_CLASS_FATAL = 0b1000, - PS3_EVT_CLASS_MAX -}; - -enum MgrEventIsBatch { - PS3_EVT_IS_BATCH_FALSE = 0b0, - PS3_EVT_IS_BATCH_TRUE = 0b1, -}; +#define PS3_EVT_ATTR_EXTEND(evtcode) ((U8)((evtcode >> PS3_EVT_ATTR_OFFSET) & 0x3F)) +#define PS3_EVT_LEVEL(evtcode) ((evtcode >> PS3_EVT_LEVEL_OFFSET) & 0xF) +#define PS3_EVT_CODE(evtcode) (((U32)evtcode >> PS3_EVT_CODE_OFFSET) & 0xFFF) + +typedef enum Ps3EventType +{ + PS3_EVT_TYPE_UNKNOWN = 0b0000, + PS3_EVT_TYPE_RAIDHBA = 0b0001, + PS3_EVT_TYPE_EXPANDER = 0b0010, + PS3_EVT_TYPE_PCIESWITCH = 0b0011, +}Ps3EventType_e; + +typedef enum Ps3EventExpose +{ + PS3_EVT_EXP_UNKNOWN = 0b0000, + PS3_EVT_EXP_EXTERNAL = 0b0001, + PS3_EVT_EXP_INTERNAL = 0b0010, + PS3_EVT_EXP_MAX = 0b0011, +}Ps3EventExpose_e; + +typedef enum MgrEventLevel +{ + PS3_EVT_CLASS_UNKNOWN = 0b0000, + PS3_EVT_CLASS_DEBUG = 0b0011, + PS3_EVT_CLASS_PROCESS = 0b0101, + PS3_EVT_CLASS_INFO = 0b0001, + PS3_EVT_CLASS_WARNING = 0b0010, + PS3_EVT_CLASS_CRITICAL = 0b0100, + PS3_EVT_CLASS_FATAL = 0b1000, + PS3_EVT_CLASS_MAX, +}MgrEventLevel_e; + +typedef enum MgrEventIsBatch +{ + PS3_EVT_IS_BATCH_FALSE = 0b0, + PS3_EVT_IS_BATCH_TRUE = 0b1, +}MgrEventIsBatch_e; #endif diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_base.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_base.c index b2d7641d51b0..579a92d2e1d9 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_base.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_base.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include #include #include @@ -40,17 +38,18 @@ #include "ps3_scsi_cmd_err.h" #include "ps3_drv_ver.h" #include "ps3_pcie_err_handle.h" +#include "ps3_err_inject.h" #include "ps3_r1x_write_lock.h" #include "ps3_watchdog.h" -#if defined PS3_HARDWARE_ASIC +#if defined PS3_HARDWARE_ASIC #include "ps3_pci.h" #endif #include "ps3_cli_debug.h" #include "ps3_recovery.h" -#include "ps3_kernel_version.h" + const char *const PS3_CHRDEV_NAME = "ps3stor-ioctl"; -#define PS3_PCI_DRIVER_NAME "ps3stor" -#define PS3_SCSI_HOST_NAME "ps3stor_scsi_host" +#define PS3_PCI_DRIVER_NAME "ps3stor" +#define PS3_SCSI_HOST_NAME "ps3stor_scsi_host" #define PS3_SCSI_DEFAULT_INIT_ID (-1) #define PS3_SCSI_DEFAULT_CMD_PER_LUN (256) @@ -60,37 +59,37 @@ const char *const PS3_CHRDEV_NAME = "ps3stor-ioctl"; #define PS3_BIOS_PARAM_MAX_SECTORS (63) #define PS3_BIOS_PARAM_DEV_CAPCITY_THRESHOLD_1G (0x200000) -#define IS_DMA64 (sizeof(dma_addr_t) == 8) +#define IS_DMA64 (sizeof(dma_addr_t) == 8) #define PS3_HOST_UUIID(_dev) (_dev->bus->number << 8 | _dev->devfn) -static const unsigned char DMA_MASK_BIT_44 = PCIE_DMA_HOST_ADDR_BIT_POS; -static const unsigned char DMA_MASK_BIT_52 = PCIE_DMA_HOST_ADDR_BIT_POS_VALID; -static const unsigned char DMA_MASK_BIT_32 = 32; -static const unsigned int PS3_REGISTER_BAR_INDEX = 0x02; +static const U8 DMA_MASK_BIT_44 = PCIE_DMA_HOST_ADDR_BIT_POS; +static const U8 DMA_MASK_BIT_52 = PCIE_DMA_HOST_ADDR_BIT_POS_VALID; +static const U8 DMA_MASK_BIT_32 = 32; +static const U32 PS3_REGISTER_BAR_INDEX = 0x02; static unsigned int ps3_mgmt_chrdev_major_no; #ifdef __KERNEL__ -#define PCI_DEVICE_SET(vend, dev, subven, subdev, cls, cls_mask) \ - .vendor = (vend), .device = (dev), .subvendor = (subven), \ - .subdevice = (subdev), .class = (cls), .class_mask = (cls_mask) +#define PCI_DEVICE_SET(vend, dev, subven, subdev, cls, cls_mask) \ + .vendor = (vend), .device = (dev), \ + .subvendor = (subven), .subdevice = (subdev),\ + .class = (cls), .class_mask = (cls_mask) #else -#define PCI_DEVICE_SET(vend, dev, subven, subdev, class, class_mask) \ - .vendor = (vend), .device = (dev), .subvendor = PCI_ANY_ID, \ - .subdevice = PCI_ANY_ID +#define PCI_DEVICE_SET(vend, dev, subven, subdev, class, class_mask) \ + .vendor = (vend), .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID #endif static struct pci_device_id ps3_pci_table[] = { - { PCI_DEVICE(PCI_VENDOR_ID_PS3_FPGA, PCI_DEVICE_ID_PS3_RAID_FPGA) }, - { PCI_DEVICE(PCI_VENDOR_ID_PS3_FPGA, PCI_DEVICE_ID_PS3_HBA) }, - { PCI_DEVICE(PCI_VENDOR_ID_PS3_ASIC, PCI_DEVICE_ID_PS3_RAID_FPGA) }, - { PCI_DEVICE(PCI_VENDOR_ID_PS3_ASIC, PCI_DEVICE_ID_PS3_HBA) }, - { PCI_DEVICE(PCI_VENDOR_ID_STARS, PCI_DEVICE_ID_STARS_IOC_2020_18i) }, - { PCI_DEVICE(PCI_VENDOR_ID_STARS, PCI_DEVICE_ID_STARS_ROC_2020_10i) }, - { PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_IOC_2020_18i) }, - { PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_ROC_2020_10i) }, - { PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_IOC_2213_16i) }, - { 0, 0, 0, 0 } -}; + {PCI_DEVICE(PCI_VENDOR_ID_PS3_FPGA, PCI_DEVICE_ID_PS3_RAID_FPGA)}, + {PCI_DEVICE(PCI_VENDOR_ID_PS3_FPGA, PCI_DEVICE_ID_PS3_HBA)}, + {PCI_DEVICE(PCI_VENDOR_ID_PS3_ASIC, PCI_DEVICE_ID_PS3_RAID_FPGA)}, + {PCI_DEVICE(PCI_VENDOR_ID_PS3_ASIC, PCI_DEVICE_ID_PS3_HBA)}, + {PCI_DEVICE(PCI_VENDOR_ID_STARS, PCI_DEVICE_ID_STARS_IOC_2020_18i)}, + {PCI_DEVICE(PCI_VENDOR_ID_STARS, PCI_DEVICE_ID_STARS_ROC_2020_10i)}, + {PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_IOC_2020_18i)}, + {PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_ROC_2020_10i)}, + {PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_IOC_2213_16i)}, + {0, 0, 0, 0}}; MODULE_DEVICE_TABLE(pci, ps3_pci_table); @@ -98,25 +97,26 @@ static int ps3_mgmt_open(struct inode *pinode, struct file *filep) { (void)pinode; (void)filep; - if (!capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) { return -EACCES; + } return PS3_SUCCESS; } static int ps3_bios_param(struct scsi_device *sdev, struct block_device *bdev, - sector_t capacity, int params[]) + sector_t capacity, int params[]) { int heads = PS3_BIOS_PARAM_DEFAULT_HEADER; int sectors = PS3_BIOS_PARAM_DEFAULT_SECTORS; sector_t cylinders = capacity; - unsigned long dummy = heads * sectors; + ULong dummy = heads * sectors; (void)sdev; (void)bdev; sector_div(cylinders, dummy); - if ((unsigned long)capacity >= PS3_BIOS_PARAM_DEV_CAPCITY_THRESHOLD_1G) { + if ((ULong)capacity >= PS3_BIOS_PARAM_DEV_CAPCITY_THRESHOLD_1G) { heads = PS3_BIOS_PARAM_MAX_HEADER; sectors = PS3_BIOS_PARAM_MAX_SECTORS; dummy = heads * sectors; @@ -135,14 +135,15 @@ static int ps3_bios_param(struct scsi_device *sdev, struct block_device *bdev, static MAP_QUEUES_RET_TYPE ps3_map_queues(struct Scsi_Host *shost) { struct ps3_instance *instance = NULL; - int qoff = 0; - int offset = 0; + S32 qoff = 0; + S32 offset = 0; struct blk_mq_queue_map *map = NULL; instance = (struct ps3_instance *)shost->hostdata; - if (shost->nr_hw_queues == 1) + if (shost->nr_hw_queues == 1) { goto l_out; + } offset = instance->irq_context.high_iops_msix_vectors; qoff = 0; @@ -150,9 +151,9 @@ static MAP_QUEUES_RET_TYPE ps3_map_queues(struct Scsi_Host *shost) map = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; map->nr_queues = instance->irq_context.valid_msix_vector_count - offset; map->queue_offset = 0; -#if defined(PS3_MAP_QUEUES_RET) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0)) (void)qoff; - return MAP_QUEUES_RET_VAL(blk_mq_pci_map_queues(map, instance->pdev, offset)); + MAP_QUEUES_RET_VAL(blk_mq_pci_map_queues(map, instance->pdev, offset)); #else blk_mq_pci_map_queues(map, instance->pdev, offset); qoff += map->nr_queues; @@ -165,16 +166,15 @@ static MAP_QUEUES_RET_TYPE ps3_map_queues(struct Scsi_Host *shost) } #endif l_out: - return MAP_QUEUES_RET_VAL(0); + MAP_QUEUES_RET_VAL(0); } #endif static ssize_t page_size_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - if (buf == NULL) { ret = 0; goto l_out; @@ -182,184 +182,169 @@ static ssize_t page_size_show(struct device *cdev, (void)cdev; (void)attr; - ret = snprintf(buf, PAGE_SIZE, "%ld\n", (unsigned long)PAGE_SIZE - 1); + ret = snprintf(buf, PAGE_SIZE, "%ld\n", (ULong)PAGE_SIZE - 1); l_out: return ret; } static inline ssize_t vd_io_outstanding_show(struct device *cdev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { return ps3_vd_io_outstanding_show(cdev, attr, buf); } static inline ssize_t io_outstanding_show(struct device *cdev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { return ps3_io_outstanding_show(cdev, attr, buf); } static inline ssize_t is_load_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_is_load_show(cdev, attr, buf); } static inline ssize_t dump_ioc_regs_show(struct device *cdev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { return ps3_dump_ioc_regs_show(cdev, attr, buf); } static inline ssize_t max_scsi_cmds_show(struct device *cdev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { return ps3_max_scsi_cmds_show(cdev, attr, buf); } static inline ssize_t event_subscribe_info_show(struct device *cdev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { return ps3_event_subscribe_info_show(cdev, attr, buf); } static inline ssize_t ioc_state_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_ioc_state_show(cdev, attr, buf); } static ssize_t log_level_store(struct device *cdev, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, const char *buf, size_t count) { return ps3_log_level_store(cdev, attr, buf, count); } static inline ssize_t log_level_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_log_level_show(cdev, attr, buf); } static inline ssize_t io_trace_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, const char *buf, size_t count) { return ps3_io_trace_switch_store(cdev, attr, buf, count); } static inline ssize_t io_trace_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_io_trace_switch_show(cdev, attr, buf); } static inline ssize_t dump_type_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_dump_type_show(cdev, attr, buf); } static inline ssize_t dump_type_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, const char *buf, size_t count) { return ps3_dump_type_store(cdev, attr, buf, count); } static inline ssize_t dump_dir_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_dump_dir_show(cdev, attr, buf); } static inline ssize_t dump_state_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_dump_state_show(cdev, attr, buf); } static inline ssize_t dump_state_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, const char *buf, size_t count) { return ps3_dump_state_store(cdev, attr, buf, count); } static inline ssize_t soc_dead_reset_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, const char *buf, size_t count) { return ps3_soc_dead_reset_store(cdev, attr, buf, count); } static inline ssize_t halt_support_cli_show(struct device *cdev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { return ps3_halt_support_cli_show(cdev, attr, buf); } static inline ssize_t halt_support_cli_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, const char *buf, size_t count) { return ps3_halt_support_cli_store(cdev, attr, buf, count); } static inline ssize_t qos_switch_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_qos_switch_show(cdev, attr, buf); } static ssize_t qos_switch_store(struct device *cdev, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, const char *buf, size_t count) { return ps3_qos_switch_store(cdev, attr, buf, count); } static inline ssize_t product_model_show(struct device *cdev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { return ps3_product_model_show(cdev, attr, buf); } -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else static inline ssize_t irq_prk_support_show(struct device *cdev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { return ps3_irq_prk_support_show(cdev, attr, buf); } static inline ssize_t irq_prk_support_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, const char *buf, size_t count) { return ps3_irq_prk_support_store(cdev, attr, buf, count); } #endif static inline ssize_t cli_ver_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { - ssize_t ret = 0; + ssize_t ret= 0; (void)cdev; (void)attr; - if (buf != NULL) + if (buf != NULL) { ret = snprintf(buf, PAGE_SIZE, "%d\n", PS3_IOCTL_VERSION); + } return ret; } @@ -383,14 +368,14 @@ static DEVICE_ATTR_RW(qos_switch); static DEVICE_ATTR_RO(product_model); static DEVICE_ATTR_RO(cli_ver); -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else static DEVICE_ATTR_RW(irq_prk_support); #endif -#if defined(PS3_HOST_ATTRS) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)) static struct attribute *ps3_host_attrs[] = { &dev_attr_page_size.attr, &dev_attr_vd_io_outstanding.attr, @@ -410,9 +395,9 @@ static struct attribute *ps3_host_attrs[] = { &dev_attr_qos_switch.attr, &dev_attr_product_model.attr, &dev_attr_cli_ver.attr, -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else &dev_attr_irq_prk_support.attr, #endif @@ -423,8 +408,10 @@ static const struct attribute_group ps3_host_attr_group = { .attrs = ps3_host_attrs }; -const struct attribute_group *ps3_host_groups[] = { &ps3_host_attr_group, - NULL }; +const struct attribute_group *ps3_host_groups[] = { + &ps3_host_attr_group, + NULL +}; #else static struct device_attribute *ps3_host_attrs[] = { &dev_attr_page_size, @@ -445,8 +432,8 @@ static struct device_attribute *ps3_host_attrs[] = { &dev_attr_qos_switch, &dev_attr_product_model, &dev_attr_cli_ver, -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else &dev_attr_irq_prk_support, @@ -473,28 +460,28 @@ static struct scsi_host_template ps3_scsi_host_template = { .map_queues = ps3_map_queues, #endif -#if defined(PS3_TRACK_QUEUE_DEPTH) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) .track_queue_depth = 1, #endif -#if defined(PS3_HOST_ATTRS) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)) .shost_groups = ps3_host_groups, #else .shost_attrs = ps3_host_attrs, #endif }; -static inline void ps3_set_product_model(struct ps3_instance *instance, - const unsigned short id) +static inline void ps3_set_product_model(struct ps3_instance * instance, const U16 id) { - if (PS3_DEVICE_IS_SWITCH(id)) + if (PS3_DEVICE_IS_SWITCH(id)) { instance->product_model = PS3_PSW_PRODUCT_MODEL; - else + } else { instance->product_model = PS3_PRODUCT_MODEL; + } + return; } -static struct ps3_instance *ps3_instance_create(struct pci_dev *pdev, - const struct pci_device_id *id) +static struct ps3_instance *ps3_instance_create(struct pci_dev *pdev, const struct pci_device_id *id) { struct Scsi_Host *host = NULL; struct ps3_instance *instance = NULL; @@ -505,7 +492,7 @@ static struct ps3_instance *ps3_instance_create(struct pci_dev *pdev, } host = scsi_host_alloc(&ps3_scsi_host_template, - sizeof(struct ps3_instance)); + sizeof(struct ps3_instance)); if (!host) { LOG_ERROR("pci_id[%u] scsi_host_alloc failed!\n", pdev->dev.id); @@ -524,7 +511,7 @@ static struct ps3_instance *ps3_instance_create(struct pci_dev *pdev, instance->state_machine.can_hostreset = PS3_FALSE; instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_CLEAN; instance->is_pcie_err_detected = PS3_FALSE; - mb(); /* in order to force CPU ordering */ + mb(); if (ps3_instance_add(instance) != PS3_SUCCESS) { scsi_remove_host(host); @@ -532,26 +519,29 @@ static struct ps3_instance *ps3_instance_create(struct pci_dev *pdev, instance = NULL; } - LOG_INFO("hno:%u scsi_host_alloc [unique_id:%d]!\n", PS3_HOST(instance), - host->unique_id); + LOG_INFO("hno:%u scsi_host_alloc [unique_id:%d]!\n", + PS3_HOST(instance), host->unique_id); return instance; } static inline void ps3_instance_put(struct ps3_instance *instance) { - if (ps3_instance_remove(instance) != PS3_SUCCESS) + if (ps3_instance_remove(instance) != PS3_SUCCESS) { LOG_ERROR("ps3_instance remove NOK\n"); + } + return; } -int ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance) +S32 ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance) { resource_size_t base_addr = 0; - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; ret = pci_enable_device_mem(pdev); + INJECT_START(PS3_ERR_IJ_FORCE_PCI_EN_MEM_FAILED, &ret) if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u pci id[%u] pci enable failed\n", - PS3_HOST(instance), pdev->dev.id); + PS3_HOST(instance), pdev->dev.id); goto l_pci_enable_device_mem_failed; } @@ -559,29 +549,36 @@ int ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance) instance->reg_bar = PS3_REGISTER_BAR_INDEX; ret = (pci_resource_flags(pdev, instance->reg_bar) & IORESOURCE_MEM); + INJECT_START(PS3_ERR_IJ_FORCE_PCI_RES_FLAGS_FAILED, &ret) if (!ret) { LOG_ERROR("hno:%u Bar %lu isnot IORESOURCE_MEM\n", - PS3_HOST(instance), instance->reg_bar); + PS3_HOST(instance), instance->reg_bar); goto l_bar_check_failed; } - ret = pci_request_selected_regions(pdev, 1 << instance->reg_bar, - "PS3 pci regions"); + ret = pci_request_selected_regions(pdev, 1<reg_bar, + "PS3 pci regions"); + INJECT_START(PS3_ERR_IJ_FORCE_PCI_REQ_REGION_FAILED, &ret) if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u IO memory region busy\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u IO memory region busy\n", + PS3_HOST(instance)); goto l_pci_request_selected_regions_failed; } -#if defined(PS3_SUPPORT_PCIE_REPORT) +#if ((defined(RHEL_MAJOR) && \ + ((RHEL_MAJOR == 8) || (RHEL_MAJOR == 9 && RHEL_MINOR < 4))) || \ + (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE <= KERNEL_VERSION(6, 5, 13))) pci_enable_pcie_error_reporting(pdev); #endif if (instance->ioc_adpter->reg_set) { instance->reg_set = - (struct Ps3Fifo __iomem *)instance->ioc_adpter->reg_set( - pdev, instance->reg_bar); + (Ps3Fifo_s __iomem *)instance->ioc_adpter->reg_set(pdev, + instance->reg_bar); } else { - instance->reg_set = (struct Ps3Fifo __iomem *)ioremap( - pci_resource_start(pdev, instance->reg_bar), - PS3_REGISTER_SET_SIZE); + instance->reg_set = + (Ps3Fifo_s __iomem *)ioremap( + pci_resource_start(pdev, instance->reg_bar), + PS3_REGISTER_SET_SIZE); } + INJECT_START(PS3_ERR_IJ_FORCE_PCI_IOREMAP_FAILED, &instance->reg_set) if (instance->reg_set == NULL) { LOG_ERROR("hno:%u ioremap failed\n", PS3_HOST(instance)); goto l_ioremap_failed; @@ -590,14 +587,15 @@ int ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance) } ps3_atomic_set(&instance->watchdog_reg_read_fail_count, 0); - LOG_INFO( - "reg_bar_idx = %lu, bar_base_paddr = 0x%llx, reg_set_vaddr = 0x%p\n", - instance->reg_bar, (unsigned long long)base_addr, instance->reg_set); + LOG_INFO("reg_bar_idx = %lu, bar_base_paddr = 0x%llx, reg_set_vaddr = 0x%p\n", instance->reg_bar, + (U64)base_addr, instance->reg_set); return PS3_SUCCESS; l_ioremap_failed: - pci_release_selected_regions(instance->pdev, 1 << instance->reg_bar); -#if defined(PS3_SUPPORT_PCIE_REPORT) + pci_release_selected_regions(instance->pdev, 1<reg_bar); +#if ((defined(RHEL_MAJOR) && \ + ((RHEL_MAJOR == 8) || (RHEL_MAJOR == 9 && RHEL_MINOR < 4))) || \ + (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE <= KERNEL_VERSION(6, 5, 13))) pci_disable_pcie_error_reporting(pdev); #endif l_pci_request_selected_regions_failed: @@ -615,20 +613,22 @@ static void ps3_pci_exit(struct ps3_instance *instance) } if (pci_is_enabled(instance->pdev)) { - pci_release_selected_regions(instance->pdev, - 1 << instance->reg_bar); -#if defined(PS3_SUPPORT_PCIE_REPORT) + pci_release_selected_regions(instance->pdev, 1<reg_bar); +#if ((defined(RHEL_MAJOR) && \ + ((RHEL_MAJOR == 8) || (RHEL_MAJOR == 9 && RHEL_MINOR < 4))) || \ + (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE <= KERNEL_VERSION(6, 5, 13))) pci_disable_pcie_error_reporting(instance->pdev); #endif pci_disable_device(instance->pdev); } + + return; } -static int ps3_scsi_init(struct ps3_instance *instance) +static S32 ps3_scsi_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct Scsi_Host *host = instance->host; - host->can_queue = instance->cmd_attr.cur_can_que; host->this_id = PS3_SCSI_DEFAULT_INIT_ID; host->sg_tablesize = instance->cmd_context.max_host_sge_count; @@ -638,7 +638,7 @@ static int ps3_scsi_init(struct ps3_instance *instance) host->max_id = instance->dev_context.max_dev_per_channel; host->max_lun = PS3_FRAME_LUN_BUFLEN; host->max_cmd_len = PS3_FRAME_CDB_BUFLEN; -#if defined(PS3_SUPPORT_BIO_MERGE) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) host->use_clustering = instance->use_clusting; #endif @@ -652,27 +652,28 @@ static int ps3_scsi_init(struct ps3_instance *instance) host->nr_hw_queues = 1; if ((instance->irq_context.valid_msix_vector_count > - instance->irq_context.high_iops_msix_vectors) && - ps3_tagset_enable_query() && (instance->smp_affinity_enable)) { + instance->irq_context.high_iops_msix_vectors) && + ps3_tagset_enable_query() && + (instance->smp_affinity_enable)) { host->host_tagset = 1; - host->nr_hw_queues = - instance->irq_context.valid_msix_vector_count - + host->nr_hw_queues = instance->irq_context.valid_msix_vector_count - instance->irq_context.high_iops_msix_vectors; } #endif -#if defined(PS3_CHANGE_QUEUE_DEPTH) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) ret = scsi_init_shared_tag_map(host, host->can_queue); if (ret) { LOG_ERROR("hno:%u Failed to shared tag from\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } #endif if (scsi_add_host(instance->host, &instance->pdev->dev)) { - LOG_ERROR("hno:%u Failed to add host\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u Failed to add host\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -683,61 +684,64 @@ static int ps3_scsi_init(struct ps3_instance *instance) return ret; } -static inline int __ps3_config_dma_mask32(struct ps3_instance *instance) +static inline S32 __ps3_config_dma_mask32(struct ps3_instance *instance) { if (dma_set_mask(&instance->pdev->dev, DMA_BIT_MASK(DMA_MASK_BIT_32)) || - dma_set_coherent_mask(&instance->pdev->dev, - DMA_BIT_MASK(DMA_MASK_BIT_32))) { + dma_set_coherent_mask(&instance->pdev->dev, + DMA_BIT_MASK(DMA_MASK_BIT_32))) { LOG_ERROR("hno:%u 32 dma mask set failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return -PS3_FAILED; + } else { + instance->dma_mask = DMA_MASK_BIT_32; + LOG_INFO("hno:%u 32 dma mask set\n", + PS3_HOST(instance)); } - instance->dma_mask = DMA_MASK_BIT_32; - LOG_INFO("hno:%u 32 dma mask set\n", PS3_HOST(instance)); + return PS3_SUCCESS; } -static inline unsigned char ps3_dma_mask_get(struct ps3_instance *instance) +static inline U8 ps3_dma_mask_get(struct ps3_instance *instance) { - return ((instance->dma_addr_bit_pos > DMA_MASK_BIT_52) ? - DMA_MASK_BIT_52 : - DMA_MASK_BIT_44); + return ((instance->dma_addr_bit_pos > DMA_MASK_BIT_52) ? DMA_MASK_BIT_52 : DMA_MASK_BIT_44); } -static inline int __ps3_config_dma_mask(struct ps3_instance *instance) +static inline S32 __ps3_config_dma_mask(struct ps3_instance *instance) { - unsigned char dma_mask = 0; + U8 dma_mask = 0; dma_mask = ps3_dma_mask_get(instance); if (dma_set_mask(&instance->pdev->dev, DMA_BIT_MASK(dma_mask)) || - dma_set_coherent_mask(&instance->pdev->dev, - DMA_BIT_MASK(dma_mask))) { + dma_set_coherent_mask(&instance->pdev->dev, + DMA_BIT_MASK(dma_mask))) { LOG_ERROR("hno:%u 62 dma mask set failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return __ps3_config_dma_mask32(instance); + } else { + instance->dma_mask = dma_mask; + LOG_INFO("hno:%u dma mask set %u\n", + PS3_HOST(instance), instance->dma_mask); } - instance->dma_mask = dma_mask; - LOG_INFO("hno:%u dma mask set %u\n", PS3_HOST(instance), instance->dma_mask); return PS3_SUCCESS; } -static int ps3_config_dma_mask(struct ps3_instance *instance) +static S32 ps3_config_dma_mask(struct ps3_instance *instance) { - int ret = -PS3_FAILED; - unsigned char is_dma64_support = PS3_FALSE; - - if (!ps3_ioc_mgr_is_dma64_support(instance, &is_dma64_support)) + S32 ret = -PS3_FAILED; + Bool is_dma64_support = PS3_FALSE; + if (!ps3_ioc_mgr_is_dma64_support(instance, &is_dma64_support)) { goto l_out; + } if (is_dma64_support) { if (IS_DMA64) { ret = __ps3_config_dma_mask(instance); } else { LOG_ERROR("hno:%u unsupport 32bit system\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } } else { LOG_ERROR("hno:%u soc unsupport 64bit dma\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } l_out: return ret; @@ -745,25 +749,27 @@ static int ps3_config_dma_mask(struct ps3_instance *instance) static inline void ps3_device_busy_threshold_cfg(struct ps3_instance *instance) { - int device_busy = 0; + S32 device_busy = 0; device_busy = ps3_device_busy_threshold_query(); - if (device_busy <= 0 || device_busy > instance->cmd_attr.cur_can_que) + if (device_busy <= 0 || + device_busy > instance->cmd_attr.cur_can_que) { instance->device_busy_threshold = PS3_DEVICE_IO_BUSY_THRESHOLD; - else + } else { instance->device_busy_threshold = device_busy; + } } static void ps3_cmd_attr_context_init(struct ps3_instance *instance) { - unsigned int cmd_qdepth = ps3_throttle_qdepth_query(); + U32 cmd_qdepth = ps3_throttle_qdepth_query(); instance->cmd_attr.cur_can_que = instance->cmd_context.max_scsi_cmd_count - instance->cmd_context.max_r1x_cmd_count; if ((cmd_qdepth != 0) && - cmd_qdepth <= (unsigned int)instance->cmd_attr.cur_can_que) { + cmd_qdepth <= (U32)instance->cmd_attr.cur_can_que) { instance->cmd_attr.throttle_que_depth = cmd_qdepth; } else { instance->cmd_attr.throttle_que_depth = @@ -776,50 +782,61 @@ static void ps3_cmd_attr_context_init(struct ps3_instance *instance) ps3_device_busy_threshold_cfg(instance); } -static int ps3_init_ioc_prepare(struct ps3_instance *instance) +static S32 ps3_init_ioc_prepare(struct ps3_instance *instance) { ps3_ioc_mgr_req_queue_lock_init(instance); instance->watchdog_context.is_stop = PS3_TRUE; ps3_atomic_set(&instance->watchdog_ref, 0); ps3_err_fault_context_init(instance); - if (!ps3_ioc_fw_version_get(instance)) + if (!ps3_ioc_fw_version_get(instance)) { goto l_get_reg_failed; + } if (!ps3_feature_support_reg_get(instance)) goto l_get_reg_failed; - if (ps3_ioc_init_cmd_context_init(instance) != PS3_SUCCESS) + if (ps3_ioc_init_cmd_context_init(instance) != PS3_SUCCESS) { goto l_ioc_init_failed; + } - if (ps3_ctrl_info_buf_alloc(instance) != PS3_SUCCESS) + if (ps3_ctrl_info_buf_alloc(instance) != PS3_SUCCESS) { goto l_ctrl_info_init_failed; + } - if (ps3_cmd_context_init(instance) != PS3_SUCCESS) + if (ps3_cmd_context_init(instance) != PS3_SUCCESS) { goto l_cmd_context_init_failed; + } ps3_cmd_attr_context_init(instance); - if (ps3_event_context_init(instance) != PS3_SUCCESS) + if (ps3_event_context_init(instance) != PS3_SUCCESS) { goto l_event_context_init_failed; + } - if (ps3_webSubscribe_context_init(instance) != PS3_SUCCESS) - goto l_web_context_init_failed; + if (ps3_webSubscribe_context_init(instance) != PS3_SUCCESS) { + goto l_web_context_init_failed; + } - if (ps3_cmd_statistics_init(instance) != PS3_SUCCESS) + if (ps3_cmd_statistics_init(instance) != PS3_SUCCESS) { goto l_cmd_stat_failed; + } - if (ps3_debug_mem_alloc(instance) != PS3_SUCCESS) + if (ps3_debug_mem_alloc(instance) != PS3_SUCCESS) { goto l_debug_mem_failed; + } - if (ps3_dump_init(instance) != PS3_SUCCESS) + if (ps3_dump_init(instance) != PS3_SUCCESS) { goto l_dump_init_failed; + } - if (ps3_drv_info_buf_alloc(instance) != PS3_SUCCESS) + if (ps3_drv_info_buf_alloc(instance) != PS3_SUCCESS) { goto l_drv_info_init_failed; + } - if (ps3_host_mem_info_buf_alloc(instance) != PS3_SUCCESS) + if (ps3_host_mem_info_buf_alloc(instance) != PS3_SUCCESS) { goto l_host_mem_init_failed; + } return PS3_SUCCESS; l_host_mem_init_failed: @@ -831,7 +848,7 @@ static int ps3_init_ioc_prepare(struct ps3_instance *instance) l_debug_mem_failed: ps3_cmd_statistics_exit(instance); l_cmd_stat_failed: - ps3_webSubscribe_context_exit(instance); + ps3_webSubscribe_context_exit(instance); l_web_context_init_failed: ps3_event_context_exit(instance); l_event_context_init_failed: @@ -851,7 +868,7 @@ static void ps3_init_ioc_prepare_exit(struct ps3_instance *instance) (void)ps3_debug_mem_free(instance); ps3_cmd_statistics_exit(instance); ps3_event_context_exit(instance); - ps3_webSubscribe_context_exit(instance); + ps3_webSubscribe_context_exit(instance); ps3_ctrl_info_buf_free(instance); ps3_ioc_init_cmd_context_exit(instance); ps3_cmd_context_exit(instance); @@ -863,23 +880,27 @@ static void ps3_init_ioc_prepare_exit(struct ps3_instance *instance) ps3_host_mem_info_buf_free(instance); } -static int ps3_init_ioc_complete(struct ps3_instance *instance) +static S32 ps3_init_ioc_complete(struct ps3_instance *instance) { - if (ps3_mgr_cmd_init(instance) != PS3_SUCCESS) + if (ps3_mgr_cmd_init(instance) != PS3_SUCCESS) { goto l_mgr_cmd_init_failed; + } - if (ps3_device_mgr_init(instance) != PS3_SUCCESS) + if (ps3_device_mgr_init(instance) != PS3_SUCCESS) { goto l_device_mgr_init_failed; + } - if (ps3_sas_device_mgr_init(instance) != PS3_SUCCESS) + if (ps3_sas_device_mgr_init(instance) != PS3_SUCCESS) { goto l_sas_device_mgr_init_failed; + } - if (ps3_qos_init(instance) != PS3_SUCCESS) + if (ps3_qos_init(instance) != PS3_SUCCESS) { goto l_qos_init_failed; + } return PS3_SUCCESS; l_qos_init_failed: - ps3_sas_device_mgr_exit(instance); + ps3_sas_device_mgr_exit(instance); l_sas_device_mgr_init_failed: ps3_device_mgr_exit(instance); l_device_mgr_init_failed: @@ -895,21 +916,27 @@ static void ps3_init_ioc_complete_exit(struct ps3_instance *instance) ps3_mgr_cmd_exit(instance); ps3_qos_exit(instance); + + return ; } -int ps3_pci_init_complete(struct ps3_instance *instance) +S32 ps3_pci_init_complete(struct ps3_instance *instance) { - if (ps3_config_dma_mask(instance) != PS3_SUCCESS) + if (ps3_config_dma_mask(instance) != PS3_SUCCESS) { goto l_failed; + } - if (ps3_irq_context_init(instance) != PS3_SUCCESS) + if (ps3_irq_context_init(instance) != PS3_SUCCESS) { goto l_failed; + } if (instance->ioc_adpter->irq_init) { - if (instance->ioc_adpter->irq_init(instance) != PS3_SUCCESS) + if (instance->ioc_adpter->irq_init(instance) != PS3_SUCCESS) { goto l_irqs_init_failed; + } } else { - if (ps3_irqs_init(instance) != PS3_SUCCESS) + if (ps3_irqs_init(instance) != PS3_SUCCESS) { goto l_irqs_init_failed; + } } return PS3_SUCCESS; @@ -919,21 +946,20 @@ int ps3_pci_init_complete(struct ps3_instance *instance) return -PS3_FAILED; } -static int ps3_wait_reg_access_done(struct ps3_instance *instance) +static S32 ps3_wait_reg_access_done(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int read_count = 0; - const unsigned int retry_max = 9000; + S32 ret = PS3_SUCCESS; + U32 read_count = 0; + const U32 retry_max = 9000; ps3_wait_scsi_cmd_done(instance, PS3_TRUE); ps3_wait_mgr_cmd_done(instance, PS3_TRUE); - while (ps3_atomic_read(&instance->reg_op_count) != 0) { + while (ps3_atomic_read(&instance->reg_op_count) != 0){ ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); - if (read_count++ > retry_max) { + if(read_count++ > retry_max){ LOG_INFO("hno:%u wait reg op over:%d ms, failed\n", - PS3_HOST(instance), - read_count * PS3_LOOP_TIME_INTERVAL_20MS); + PS3_HOST(instance), read_count*PS3_LOOP_TIME_INTERVAL_20MS); ret = -PS3_FAILED; goto l_out; } @@ -948,27 +974,26 @@ void ps3_pci_init_complete_exit(struct ps3_instance *instance) ps3_irqs_exit(instance); instance->is_pci_reset = PS3_TRUE; - mb(); /* in order to force CPU ordering */ + mb(); if (ps3_wait_reg_access_done(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u wait reg access done NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u wait reg access done NOK\n", PS3_HOST(instance)); return; } ps3_pci_exit(instance); if (!ps3_pci_err_recovery_get(instance) && - !instance->state_machine.is_suspend) { + !instance->state_machine.is_suspend) { pci_set_drvdata(instance->pdev, NULL); } ps3_irq_context_exit(instance); } -static unsigned char ps3_bit_pos_set(struct ps3_instance *instance) +static Bool ps3_bit_pos_set(struct ps3_instance *instance) { - unsigned char bit_pos = 0; - unsigned char ret = PS3_TRUE; + U8 bit_pos = 0; + Bool ret = PS3_TRUE; if (!ps3_ioc_atu_support_retry_read(instance, &bit_pos)) { ret = PS3_FALSE; @@ -982,62 +1007,72 @@ static unsigned char ps3_bit_pos_set(struct ps3_instance *instance) instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F0; else instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F1; + l_out: mb(); /* in order to force CPU ordering */ - LOG_WARN("hno:%u set bit pos %u\n", PS3_HOST(instance), - instance->dma_addr_bit_pos); + LOG_WARN("hno:%u set bit pos %u\n", + PS3_HOST(instance), instance->dma_addr_bit_pos); return ret; } -static int ps3_firmware_init(struct pci_dev *pdev, - struct ps3_instance *instance) +static S32 ps3_firmware_init(struct pci_dev *pdev, struct ps3_instance *instance) { - int ret; + S32 ret; - if (ps3_recovery_context_init(instance) != PS3_SUCCESS) + if (ps3_recovery_context_init(instance) != PS3_SUCCESS) { goto l_recovery_context_init_failed; + } - if (ps3_pci_init(pdev, instance) != PS3_SUCCESS) + if (ps3_pci_init(pdev, instance) != PS3_SUCCESS) { goto l_failed; + } - if (!ps3_ioc_recovery_count_get( - instance, - &instance->recovery_context->ioc_recovery_count)) { + if (!ps3_ioc_recovery_count_get(instance, + &instance->recovery_context->ioc_recovery_count)) { goto l_failed; } + INJECT_START(PS3_ERR_IJ_SET_IOC_IN_SECURITY, instance) if (instance->ioc_adpter->ioc_security_check && - instance->ioc_adpter->ioc_security_check(instance)) { - LOG_WARN("hno:%u:ioc is in security state\n", - PS3_HOST(instance)); + instance->ioc_adpter->ioc_security_check(instance)) { + LOG_WARN("hno:%u:ioc is in security state\n", PS3_HOST(instance)); goto l_failed; } - if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != - PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_READY, instance) + if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != PS3_SUCCESS) { goto l_failed; } atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_READY); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_A_READY, instance); if (!ps3_bit_pos_set(instance)) goto l_failed; - if (ps3_pci_init_complete(instance) != PS3_SUCCESS) + + if (ps3_pci_init_complete(instance) != PS3_SUCCESS) { goto l_failed; + } instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; pci_save_state(pdev); ret = ps3_init_ioc_prepare(instance); - if (ret != PS3_SUCCESS) + INJECT_START(PS3_ERR_IJ_FIRMWARE_INIT_FAIL, &ret) + if (ret != PS3_SUCCESS) { goto l_failed; + } - if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_INIT, instance) + if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) { goto l_failed; - atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_PRE_OPERATIONAL); + } + atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_PRE_OPERATIONAL); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_CTRL_INFO, instance) - if (ps3_ctrl_info_get(instance) != PS3_SUCCESS) + if (ps3_ctrl_info_get(instance) != PS3_SUCCESS) { goto l_failed; + } - if (ps3_init_ioc_complete(instance) != PS3_SUCCESS) + if (ps3_init_ioc_complete(instance) != PS3_SUCCESS) { goto l_failed; + } return PS3_SUCCESS; @@ -1054,6 +1089,7 @@ static void ps3_firmware_exit(struct ps3_instance *instance) ps3_pci_init_complete_exit(instance); ps3_init_ioc_complete_exit(instance); ps3_init_ioc_prepare_exit(instance); + return; } static void ps3_scsi_remove_host(struct ps3_instance *instance) @@ -1064,17 +1100,19 @@ static void ps3_scsi_remove_host(struct ps3_instance *instance) } else { scsi_remove_host(instance->host); } + return; } -static unsigned char ps3_cmd_context_empty(struct ps3_cmd_context *cmd_context) +static Bool ps3_cmd_context_empty(struct ps3_cmd_context *cmd_context) { - unsigned char ret = PS3_TRUE; - unsigned int i = 0; + Bool ret = PS3_TRUE; + U32 i = 0; for (i = 0; i < cmd_context->max_cmd_count; i++) { - if (cmd_context->cmd_buf[i]->cmd_state.state == - PS3_CMD_STATE_PROCESS) { + if (cmd_context->cmd_buf[i]->cmd_state.state == PS3_CMD_STATE_PROCESS) { ret = PS3_FALSE; + INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK, &ret) + INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_2, cmd_context) break; } } @@ -1085,50 +1123,54 @@ static unsigned char ps3_cmd_context_empty(struct ps3_cmd_context *cmd_context) static int ps3_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct ps3_instance *instance = NULL; - unsigned long flags = 0; - int ret; + ULong flags = 0; + S32 ret; +#ifdef PS3_SUPPORT_INJECT + U32 times = 180000; +#endif #ifdef PS3_HARDWARE_ASIC - unsigned short real_dev_id = 0; - unsigned int check_count = ps3_hba_check_time_query() * 10 + 1; + U16 real_dev_id = 0; + U32 check_count = ps3_hba_check_time_query() * 10 + 1; #endif - LOG_INFO("device[%d] %s\n", pdev->dev.id, __func__); + LOG_INFO("device[%d] ps3_probe\n", pdev->dev.id); if (ps3_available_func_id_query() >= PS3_FUNC_UNLIMITED) { - LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe start.\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe start.\n", ps3_get_pci_domain(pdev), + ps3_get_pci_bus(pdev), ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); } else { - if ((unsigned int)ps3_get_pci_function(pdev) != - ps3_available_func_id_query()) { - LOG2_WARN("Function %x not available\n", - ps3_get_pci_function(pdev)); + if ((U32)ps3_get_pci_function(pdev) != ps3_available_func_id_query()) { + LOG2_WARN("Function %x not available\n", ps3_get_pci_function(pdev)); goto l_func_id_error; } else { - LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe start.\n", - ps3_get_pci_domain(pdev), - ps3_get_pci_bus(pdev), ps3_get_pci_slot(pdev), - ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe start.\n", ps3_get_pci_domain(pdev), + ps3_get_pci_bus(pdev), ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); } } + INJECT_INIT() + INJECT_PROBE_ACTIVE() instance = ps3_instance_create(pdev, id); - if (instance == NULL) + if (instance == NULL) { goto l_ps3_instance_create_failed; + } #ifdef PS3_HARDWARE_ASIC - while (id->device == PCI_DEVICE_ID_PS3_RAID_FPGA && check_count > 0) { + while(id->device == PCI_DEVICE_ID_PS3_RAID_FPGA && + check_count > 0) { pci_read_config_word(pdev, PCI_DEVICE_ID, &real_dev_id); - LOG_INFO("get real device id is[0x%x]\n", real_dev_id); + LOG_INFO("get real device id is[0x%x] \n", real_dev_id); if (real_dev_id == PCI_DEVICE_ID_PS3_HBA || - real_dev_id == PCI_DEVICE_ID_STARS_IOC_2020_18i || - real_dev_id == PCI_DEVICE_ID_STARS_ROC_2020_10i) { + real_dev_id == PCI_DEVICE_ID_STARS_IOC_2020_18i || + real_dev_id == PCI_DEVICE_ID_STARS_ROC_2020_10i) { ((struct pci_device_id *)id)->device = real_dev_id; break; + } else { + check_count--; + ps3_msleep(100); } - check_count--; - ps3_msleep(100); + }; #endif ps3_ioc_adp_init(instance, id); @@ -1142,59 +1184,82 @@ static int ps3_probe(struct pci_dev *pdev, const struct pci_device_id *id) LOG_WARN("ps3_firmware_init fail:%d\n", ret); goto l_firmware_init_failed; } - ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_OPERATIONAL); + ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_OPERATIONAL); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_OPER, instance) instance->ioc_adpter->irq_enable(instance); ps3_dump_ctrl_set_int_ready(instance); ps3_ioctl_init(instance, PS3_MAX_IOCTL_CMDS); ps3_scsi_cmd_timeout_adjust(); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_SCSI_INIT, instance) ret = ps3_scsi_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_scsi_init_failed; + } instance->state_machine.is_load = PS3_TRUE; - mb(); /* in order to force CPU ordering */ + mb(); + INJECT_START(PS3_ERR_IJ_FORCE_F1_LOAD_START_HARD, instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_LOAD, instance) ret = ps3_watchdog_start(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_watch_dog_start_failed; + } + INJECT_START(PS3_ERR_IJ_F1_PROBE_FORCE_IOC_FAULT, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_HOST_START_HARD, instance) ret = ps3_device_mgr_data_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_dev_info_get_failed; + } ret = ps3_sas_device_data_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_expander_get_failed; + } + INJECT_START(PS3_ERR_IJ_FORCE_F1_SCAN_START_HARD, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_SCAN, instance) instance->state_machine.can_hostreset = PS3_TRUE; + INJECT_START(PS3_ERR_IJ_FORCE_F0_WATCHDOG_START_HARD, instance) ps3_scsi_scan_host(instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_A_SCAN, instance) + INJECT_START(PS3_ERR_IJ_SCSI_SCAN_HOST_DELAY, ×) + INJECT_START(PS3_ERR_IJ_FORCE_F1_A_SCAN_START_HARD, instance) + INJECT_START(PS3_ERR_IJ_PROBE_HOST_RESET, instance); instance->is_scan_host_finish = PS3_TRUE; + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_SCAN_FINISH, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_A_SCAN_FINISH_HARD, instance) ret = ps3_event_subscribe(instance); if (ret == -PS3_FAILED) { goto l_event_subscribe_failed; } else if (ret == -PS3_RECOVERED) { - LOG_INFO( - "device[%d] skip event/vd info subscribe due to recovery during probe\n", + LOG_INFO("device[%d] skip event/vd info subscribe due to recovery during probe\n", pdev->dev.id); goto l_event_subscribe_recovered; } + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_EVENT, instance) ret = ps3_dev_mgr_vd_info_subscribe(instance); if (ret != PS3_SUCCESS && ret != -PS3_RECOVERED) { LOG_INFO("device[%d] vd info subscribe failed, ret: %d\n", - pdev->dev.id, ret); + pdev->dev.id, ret); goto l_vd_info_subscribe_failed; } l_event_subscribe_recovered: + INJECT_START(PS3_ERR_IJ_WAIT_HARDRESET, instance) instance->is_probe_finish = PS3_TRUE; - mb(); /* in order to force CPU ordering */ - LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe end.\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + mb(); +#if 0 + if (ps3_watchdog_start(instance) != PS3_SUCCESS) { + goto l_watch_dog_start_failed; + } +#endif + LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); ps3_ioc_can_hardreset_set(instance, PS3_IOC_CAN_HARDRESET); return PS3_SUCCESS; @@ -1203,24 +1268,22 @@ static int ps3_probe(struct pci_dev *pdev, const struct pci_device_id *id) l_event_subscribe_failed: ps3_dev_mgr_vd_info_unsubscribe(instance); ps3_event_unsubscribe(instance); - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags); - ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); - ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); + instance->event_context.abort_eventcmd = 0; + instance->dev_context.abort_vdpending_cmd = 0; + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); ps3_sas_device_data_exit(instance); l_expander_get_failed: l_scsi_init_failed: instance->state_machine.is_load = PS3_FALSE; - mb(); /* in order to force CPU ordering */ + mb(); ps3_device_mgr_data_exit(instance); l_dev_info_get_failed: ps3_watchdog_stop(instance); l_watch_dog_start_failed: ps3_scsi_remove_host(instance); instance->state_machine.can_hostreset = PS3_FALSE; - mb(); /* in order to force CPU ordering */ + mb(); ps3_dump_work_stop(instance); ps3_recovery_context_exit(instance); instance->ioc_adpter->irq_disable(instance); @@ -1230,37 +1293,35 @@ static int ps3_probe(struct pci_dev *pdev, const struct pci_device_id *id) ps3_firmware_exit(instance); l_firmware_init_failed: instance->is_probe_failed = PS3_TRUE; - mb(); /* in order to force CPU ordering */ + mb(); ps3_instance_put(instance); scsi_host_put(instance->host); l_ps3_instance_create_failed: ps3_dma_dump_mapping(pdev); -l_func_id_error: - dev_warn(&pdev->dev, "PCI Device %04x:%02x:%02x:%x probe failed.\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + l_func_id_error: + LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe failed.\n", ps3_get_pci_domain(pdev), + ps3_get_pci_bus(pdev), ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); return -ENODEV; } -static int ps3_cancel_event_wk_in_unload(struct ps3_instance *instance) +static S32 ps3_cancel_event_wk_in_unload(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int cur_state = 0; - unsigned int ioc_state = 0; + S32 ret = PS3_SUCCESS; + U32 cur_state = 0; + U32 ioc_state = 0; cur_state = ps3_atomic_read(&instance->state_machine.state); ioc_state = instance->ioc_adpter->ioc_state_get(instance); - if ((ioc_state != PS3_FW_STATE_RUNNING) || - (cur_state != PS3_INSTANCE_STATE_OPERATIONAL)) { - LOG_WARN( - "hno:%u goto half hard reset, cur_state:%s,IOC state is %s!\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), - ps3_ioc_state_print(ioc_state)); + INJECT_START(PS3_ERR_IJ_IOC_NOT_RUNNING, &ioc_state) + if((ioc_state != PS3_FW_STATE_RUNNING) || + (cur_state != PS3_INSTANCE_STATE_OPERATIONAL)){ + LOG_WARN("hno:%u goto half hard reset, cur_state:%s,IOC state is %s!\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state),ps3_ioc_state_print(ioc_state)); ret = -PS3_FAILED; goto l_out; } - cancel_delayed_work_sync( - &instance->event_context.delay_work->event_work); + cancel_delayed_work_sync(&instance->event_context.delay_work->event_work); l_out: return ret; @@ -1268,34 +1329,38 @@ static int ps3_cancel_event_wk_in_unload(struct ps3_instance *instance) static void ps3_shutdown(struct pci_dev *pdev) { - struct ps3_instance *instance = - (struct ps3_instance *)pci_get_drvdata(pdev); + struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); if (instance == NULL) { - LOG_ERROR("device[%d] %s fail\n", pdev->dev.id, __func__); + LOG_ERROR("device[%d] ps3_shutdown fail\n", pdev->dev.id); return; } - LOG2_WARN("PCI Device %04x:%02x:%02x:%x shutdown start.\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x shutdown start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); instance->state_machine.is_load = PS3_FALSE; - mb(); /* in order to force CPU ordering */ + mb(); + INJECT_START(PS3_ERR_IJ_SHUTDOWN_HARDRESET, instance) ps3_recovery_cancel_work_sync(instance); if (instance->pci_err_handle_state == PS3_DEVICE_ERR_STATE_CLEAN) { while (!ps3_cmd_context_empty(&instance->cmd_context)) ps3_msleep(10000); + } - if (instance->is_half_hard_reset) + if (instance ->is_half_hard_reset) { goto l_reset_to_ready; + } - ps3_r1x_conflict_queue_clean_all( - instance, PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), - PS3_TRUE); + ps3_r1x_conflict_queue_clean_all(instance, + PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); ps3_qos_waitq_clear_all(instance, PS3_STATUS_HOST_NOT_FOUND); +#ifdef PS3_SUPPORT_INJECT + ps3_inject_clear(); +#endif - if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) + if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) { goto l_reset_to_ready; + } if (ps3_event_unsubscribe(instance) != PS3_SUCCESS) { LOG_ERROR("device[%d] event unsubscribe NOK.\n", pdev->dev.id); @@ -1307,26 +1372,25 @@ static void ps3_shutdown(struct pci_dev *pdev) goto l_reset_to_ready; } - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == - 1) { + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { ps3_wait_mgr_cmd_done(instance, PS3_TRUE); - if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { - LOG_ERROR("device[%d] web unsubscribe NOK.\n", - pdev->dev.id); - goto l_reset_to_ready; - } - } + if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { + LOG_ERROR("device[%d] web unsubscribe NOK.\n", pdev->dev.id); + goto l_reset_to_ready; + } + } instance->is_host_added = PS3_FALSE; ps3_watchdog_stop(instance); ps3_dump_exit(instance); - if (instance->is_half_hard_reset) + INJECT_START(PS3_ERR_IJ_HALF_HARD_RESET, &instance ->is_half_hard_reset) + if (instance ->is_half_hard_reset) { goto l_release_res; + } - if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_SHUTDOWN, - PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { + if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_SHUTDOWN, PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { LOG_ERROR("device[%d] unload failed.\n", pdev->dev.id); goto l_reset_to_ready; } @@ -1336,23 +1400,29 @@ static void ps3_shutdown(struct pci_dev *pdev) if (instance->is_host_added) { ps3_watchdog_stop(instance); ps3_dump_exit(instance); - if (instance->is_half_hard_reset) + if (instance ->is_half_hard_reset) { goto l_release_res; + } } - if (ps3_hard_reset_to_ready_with_doorbell(instance) != PS3_SUCCESS) - LOG_ERROR("device[%d] hard reset NOK.\n", PS3_HOST(instance)); + if (ps3_hard_reset_to_ready_with_doorbell(instance) != + PS3_SUCCESS) { + LOG_ERROR("device[%d] hard reset NOK.\n", + PS3_HOST(instance)); + } l_release_res: - while (atomic_read(&instance->cmd_statistics.io_outstanding) != 0) + while(atomic_read(&instance->cmd_statistics.io_outstanding) != 0) { ps3_msleep(3000); + } + INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, instance) instance->state_machine.can_hostreset = PS3_FALSE; ps3_check_and_wait_host_reset(instance); - if (!instance->is_half_hard_reset) { + if (!instance ->is_half_hard_reset) { instance->ioc_adpter->irq_disable(instance); ps3_irqs_sync(instance); } - ps3_recovery_destroy(instance); + ps3_recovery_destory(instance); ps3_instance_state_transfer_to_quit(instance); ps3_recovery_clean(instance); @@ -1361,67 +1431,80 @@ static void ps3_shutdown(struct pci_dev *pdev) ps3_firmware_exit(instance); ps3_instance_put(instance); - LOG2_WARN("PCI Device %04x:%02x:%02x:%x shutdown end.\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x shutdown end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + return; } void ps3_remove(struct pci_dev *pdev) { - struct ps3_instance *instance = - (struct ps3_instance *)pci_get_drvdata(pdev); + struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); if (instance == NULL) { - LOG_ERROR("device[%d] %s fail\n", pdev->dev.id, __func__); + LOG_ERROR("device[%d] ps3_remove fail\n", pdev->dev.id); return; } instance->state_machine.is_load = PS3_FALSE; - LOG2_WARN("PCI Device %04x:%02x:%02x:%x remove start\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); - mb(); /* in order to force CPU ordering */ + LOG2_WARN("PCI Device %04x:%02x:%02x:%x remove start\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + mb(); ps3_recovery_cancel_work_sync(instance); if (instance->pci_err_handle_state == PS3_DEVICE_ERR_STATE_CLEAN) { ps3_dump_exit(instance); while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) ps3_msleep(10); + while (!ps3_cmd_context_empty(&instance->cmd_context)) ps3_msleep(10000); + ps3_all_reply_fifo_complete(instance); ps3_cmd_force_stop(instance); - cancel_delayed_work_sync( - &instance->event_context.delay_work->event_work); + cancel_delayed_work_sync(&instance->event_context.delay_work->event_work); goto l_release_res; } - if (instance->is_half_hard_reset) + if (instance ->is_half_hard_reset) { goto l_reset_to_ready; - if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) + } + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_NOT_RUNNING, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_CANCEL_EVENT_WORK_FAIL_RESUME, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_CANCEL_EVENT_WORK_FAIL_RESUME, instance) + if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) { goto l_reset_to_ready; + } + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_EVENT_FAIL, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_EVENT_FAIL_RESUME, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_EVENT_FAIL_RESUME, instance) if (ps3_event_unsubscribe(instance) != PS3_SUCCESS) { LOG_ERROR("device[%d] event unsubscribe NOK.\n", pdev->dev.id); goto l_reset_to_ready; } + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_VDINFO_FAIL, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_VDINFO_FAIL_RESUME, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_VDINFO_FAIL_RESUME, instance) if (ps3_dev_mgr_vd_info_unsubscribe(instance) != PS3_SUCCESS) { LOG_ERROR("device[%d] vd unsubscribe NOK.\n", pdev->dev.id); goto l_reset_to_ready; } - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == - 1) { + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_WEB_FAIL, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_WEB_FAIL_RESUME, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_WEB_FAIL_RESUME, instance) + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { ps3_wait_mgr_cmd_done(instance, PS3_TRUE); - if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { - LOG_ERROR("device[%d] web unsubscribe NOK.\n", - pdev->dev.id); - goto l_reset_to_ready; - } - } + if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { + LOG_ERROR("device[%d] web unsubscribe NOK.\n", pdev->dev.id); + goto l_reset_to_ready; + } + } - ps3_r1x_conflict_queue_clean_all( - instance, PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), - PS3_TRUE); + ps3_r1x_conflict_queue_clean_all(instance, + PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); ps3_qos_waitq_clear_all(instance, PS3_STATUS_HOST_NOT_FOUND); +#ifdef PS3_SUPPORT_INJECT + ps3_inject_clear(); +#endif ps3_scsi_remove_host(instance); @@ -1430,10 +1513,14 @@ void ps3_remove(struct pci_dev *pdev) ps3_watchdog_stop(instance); ps3_dump_exit(instance); - if (instance->is_half_hard_reset) + INJECT_START(PS3_ERR_IJ_HALF_HARD_RESET, &instance ->is_half_hard_reset) + if (instance ->is_half_hard_reset) { goto l_release_res; - if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_REMOVE, - PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { + } + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_UNLOAD_FAIL, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_UNLOAD_FAIL_RESUME, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_UNLOAD_FAIL_RESUME, instance) + if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_REMOVE, PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { LOG_ERROR("device[%d] unload failed.\n", pdev->dev.id); goto l_reset_to_ready; } @@ -1443,28 +1530,36 @@ void ps3_remove(struct pci_dev *pdev) if (instance->is_host_added) { ps3_watchdog_stop(instance); ps3_dump_exit(instance); - if (instance->is_half_hard_reset) + if (instance ->is_half_hard_reset) { goto l_release_res; + } + } + if (ps3_hard_reset_to_ready_with_doorbell(instance) != + PS3_SUCCESS) { + LOG_ERROR("device[%d] hard reset NOK.\n", + PS3_HOST(instance)); } - if (ps3_hard_reset_to_ready_with_doorbell(instance) != PS3_SUCCESS) - LOG_ERROR("device[%d] hard reset NOK.\n", PS3_HOST(instance)); l_release_res: - while (atomic_read(&instance->cmd_statistics.io_outstanding) != 0) + while(atomic_read(&instance->cmd_statistics.io_outstanding) != 0) { ps3_msleep(3000); + } instance->state_machine.can_hostreset = PS3_FALSE; ps3_check_and_wait_host_reset(instance); + INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, instance) - ps3_instance_state_transfer_to_quit(instance); - ps3_recovery_destroy(instance); + ps3_instance_state_transfer_to_quit(instance); + ps3_recovery_destory(instance); - if (instance->is_host_added) + if (instance->is_host_added) { ps3_scsi_remove_host(instance); + } - while (ps3_atomic_read(&instance->host_reset_processing) > 0) + while(ps3_atomic_read(&instance->host_reset_processing) > 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); + } ps3_recovery_clean(instance); - if (!instance->is_half_hard_reset) { + if (!instance ->is_half_hard_reset) { instance->ioc_adpter->irq_disable(instance); ps3_irqs_sync(instance); } @@ -1475,49 +1570,55 @@ void ps3_remove(struct pci_dev *pdev) ps3_instance_put(instance); scsi_host_put(instance->host); ps3_dma_dump_mapping(pdev); - LOG2_WARN("PCI Device %04x:%02x:%02x:%x remove end\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x remove end\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + return; } #ifdef CONFIG_PM static int ps3_suspend(struct pci_dev *pdev, pm_message_t state) { - struct ps3_instance *instance = - (struct ps3_instance *)pci_get_drvdata(pdev); + struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; - unsigned char suspend_type = PS3_SUSPEND_TYPE_SLEEP; + U8 suspend_type = PS3_SUSPEND_TYPE_SLEEP; - (void)state; + (void) state; + INJECT_START(PS3_ERR_IJ_WAIT_PM_INSTANCE_NULL, &instance); if (instance == NULL) { LOG2_ERROR("device[%d] %s NOK\n", pdev->dev.id, __func__); return PS3_SUCCESS; } - LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s start.\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); instance->is_suspend = PS3_TRUE; - mb(); /* in order to force CPU ordering */ + mb(); instance->state_machine.is_suspend = PS3_TRUE; - mb(); /* in order to force CPU ordering */ + mb(); + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY_1, instance) ps3_recovery_cancel_work_sync(instance); if (instance->pci_err_handle_state == PS3_DEVICE_ERR_STATE_CLEAN) { while (!ps3_cmd_context_empty(&instance->cmd_context)) ps3_msleep(10000); + } - if (instance->is_half_hard_reset) + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET, instance) + if (instance ->is_half_hard_reset) { goto l_reset_to_ready; + } - ps3_r1x_conflict_queue_clean_all( - instance, PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), - PS3_TRUE); + ps3_r1x_conflict_queue_clean_all(instance, + PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); ps3_qos_waitq_clear_all(instance, PS3_STATUS_HOST_NOT_FOUND); +#ifdef PS3_SUPPORT_INJECT + ps3_inject_clear(); +#endif - if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) + if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) { goto l_reset_to_ready; + } if (ps3_event_unsubscribe(instance) != PS3_SUCCESS) { LOG_ERROR("device[%d] event unsubscribe NOK.\n", pdev->dev.id); @@ -1529,12 +1630,11 @@ static int ps3_suspend(struct pci_dev *pdev, pm_message_t state) goto l_reset_to_ready; } - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == - 1) { + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED, instance) + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { ps3_wait_mgr_cmd_done(instance, PS3_TRUE); if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { - LOG_ERROR("device[%d] web unsubscribe NOK.\n", - pdev->dev.id); + LOG_ERROR("device[%d] web unsubscribe NOK.\n", pdev->dev.id); goto l_reset_to_ready; } } @@ -1547,29 +1647,32 @@ static int ps3_suspend(struct pci_dev *pdev, pm_message_t state) ps3_watchdog_stop(instance); ps3_recovery_cancel_work_sync(instance); - if (instance->is_half_hard_reset) + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_2, instance) + if (instance ->is_half_hard_reset) { goto l_release_res; -#if defined(PS3_SUPPORT_FLUSH_SCHEDULED) + } +#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,6,0)) flush_scheduled_work(); #endif scsi_block_requests(instance->host); - if (state.event == PM_EVENT_FREEZE) + if (state.event == PM_EVENT_FREEZE) { suspend_type = PS3_SUSPEND_TYPE_HIBERNATE; + } LOG_INFO("event[%d] suspend_type[%d].\n", state.event, suspend_type); - if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_SUSPEND, - suspend_type) != PS3_SUCCESS) { + if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_SUSPEND, suspend_type) != PS3_SUCCESS) { LOG_ERROR("device[%d] unload NOK.\n", pdev->dev.id); if (ps3_hard_reset_to_ready_with_doorbell(instance) != - PS3_SUCCESS) { + PS3_SUCCESS) { LOG_ERROR("device[%d] hard reset NOK.\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } } goto l_release_res; l_reset_to_ready: - if (!instance->is_half_hard_reset) { + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_1, instance) + if (!instance ->is_half_hard_reset) { instance->ioc_adpter->irq_disable(instance); ps3_irqs_sync(instance); @@ -1578,11 +1681,15 @@ static int ps3_suspend(struct pci_dev *pdev, pm_message_t state) ps3_dump_work_stop(instance); ps3_watchdog_stop(instance); ps3_recovery_cancel_work_sync(instance); - if (instance->is_half_hard_reset) + if (instance ->is_half_hard_reset) { goto l_release_res; + } - if (ps3_hard_reset_to_ready_with_doorbell(instance) != PS3_SUCCESS) - LOG_ERROR("device[%d] hard reset NOK.\n", PS3_HOST(instance)); + if (ps3_hard_reset_to_ready_with_doorbell(instance) != + PS3_SUCCESS) { + LOG_ERROR("device[%d] hard reset NOK.\n", + PS3_HOST(instance)); + } if (instance->event_context.event_cmd != NULL) { cmd = instance->event_context.event_cmd; @@ -1593,109 +1700,104 @@ static int ps3_suspend(struct pci_dev *pdev, pm_message_t state) instance->event_context.event_abort_cmd = NULL; ps3_task_cmd_free(instance, abort_cmd); } - ps3_atomic_set(&instance->event_context.subwork, 0); + instance->event_context.subwork = 0; } ps3_dev_mgr_vd_info_clear(instance); - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == - 1) { + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { ps3_web_cmd_clear(instance); } -#if defined(PS3_SUPPORT_FLUSH_SCHEDULED) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,6,0)) flush_scheduled_work(); #endif scsi_block_requests(instance->host); l_release_res: + INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, instance) pci_set_drvdata(instance->pdev, instance); pci_save_state(pdev); - instance->is_half_hard_reset = PS3_FALSE; + instance ->is_half_hard_reset = PS3_FALSE; ps3_base_free_resources(instance); ps3_instance_put(instance); - LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s end.\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); instance->is_suspend = PS3_FALSE; return PS3_SUCCESS; } static int ps3_resume(struct pci_dev *pdev) { - int ret = PS3_SUCCESS; - struct ps3_instance *instance = - (struct ps3_instance *)pci_get_drvdata(pdev); + S32 ret = PS3_SUCCESS; + struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); + INJECT_START(PS3_ERR_IJ_WAIT_PM_INSTANCE_NULL, &instance); if (instance == NULL) { LOG2_ERROR("device[%d] %s NOK\n", pdev->dev.id, __func__); return PS3_SUCCESS; } - LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s start.\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); instance->is_resume = PS3_TRUE; - mb(); /* in order to force CPU ordering */ + mb(); ps3_recovery_cancel_work_sync(instance); pci_restore_state(pdev); instance->pdev = pdev; if (ps3_instance_add(instance) != PS3_SUCCESS) goto l_out; + + INJECT_START(PS3_ERR_IJ_WAIT_RESUME_FUNCID_INVALID, instance); if (ps3_available_func_id_query() < PS3_FUNC_UNLIMITED && - (unsigned int)ps3_get_pci_function(pdev) != ps3_available_func_id_query()) { - LOG2_WARN("Function %d not available\n", - ps3_get_pci_function(pdev)); + (U32)ps3_get_pci_function(pdev) != ps3_available_func_id_query()) { + LOG2_WARN("Function %d not available\n", ps3_get_pci_function(pdev)); goto l_out; } ret = ps3_base_init_resources(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u base init resources NOK, ret: %d\n", - PS3_HOST(instance), ret); + LOG_ERROR("hno:%u base init resources NOK, ret: %d\n", PS3_HOST(instance), ret); goto l_out; } instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; - if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != - PS3_SUCCESS) { + if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != PS3_SUCCESS) { goto l_out; } - ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_READY); + ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_READY); ps3_all_reply_fifo_init(instance); - if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) + if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) { goto l_out; + } - ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_PRE_OPERATIONAL); + ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_PRE_OPERATIONAL); instance->ioc_adpter->irq_enable(instance); - ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_OPERATIONAL); + ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_OPERATIONAL); instance->state_machine.is_load = PS3_TRUE; scsi_unblock_requests(instance->host); ps3_dump_ctrl_set_int_ready(instance); + INJECT_START(PS3_ERR_IJ_WAIT_RESUME_WAIT_RECOVERY, instance); ret = ps3_watchdog_start(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } - instance->event_req_info.eventTypeMapProcResult = - instance->event_req_info.eventTypeMap; + instance->event_req_info.eventTypeMapProcResult = instance->event_req_info.eventTypeMap; ret = ps3_event_subscribe(instance); if (ret == -PS3_FAILED) { goto l_out; } else if (ret == -PS3_RECOVERED) { - LOG_INFO( - "device[%d] skip event/vd info subscribe due to recovery during probe\n", + LOG_INFO("device[%d] skip event/vd info subscribe due to recovery during probe\n", pdev->dev.id); goto l_event_subscribe_recovered; } @@ -1703,24 +1805,23 @@ static int ps3_resume(struct pci_dev *pdev) ret = ps3_dev_mgr_vd_info_subscribe(instance); if (ret != PS3_SUCCESS && ret != -PS3_RECOVERED) { LOG_INFO("device[%d] vd info subscribe NOK, ret: %d\n", - pdev->dev.id, ret); + pdev->dev.id, ret); goto l_out; } - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == - 1) { + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { ret = ps3_web_subscribe(instance); - if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) + if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) { goto l_out; + } } l_event_subscribe_recovered: instance->state_machine.is_suspend = PS3_FALSE; instance->is_probe_finish = PS3_TRUE; instance->is_resume = PS3_FALSE; - LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s end.\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); ps3_ioc_can_hardreset_set(instance, PS3_IOC_CAN_HARDRESET); return PS3_SUCCESS; @@ -1731,9 +1832,8 @@ static int ps3_resume(struct pci_dev *pdev) ps3_instance_state_transfer_to_dead(instance); scsi_unblock_requests(instance->host); ps3_dma_dump_mapping(pdev); - LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s NOK.\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s NOK.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); return -ENODEV; } #endif @@ -1741,8 +1841,7 @@ static int ps3_resume(struct pci_dev *pdev) static ssize_t version_show(struct device_driver *dd, char *buf) { (void)dd; - return snprintf(buf, strlen(PS3_DRV_VERSION) + 2, "%s\n", - PS3_DRV_VERSION); + return snprintf(buf, strlen(PS3_DRV_VERSION) + 2, "%s\n", PS3_DRV_VERSION); } static DRIVER_ATTR_RO(version); @@ -1754,15 +1853,16 @@ static ssize_t release_date_show(struct device_driver *dd, char *buf) } static DRIVER_ATTR_RO(release_date); -static const struct file_operations ps3_mgmt_fops = { .owner = THIS_MODULE, - .unlocked_ioctl = - ps3_ioctl_fops, - .open = ps3_mgmt_open, - .release = NULL, - .llseek = noop_llseek, - .read = NULL, - .write = NULL, - .fasync = ps3_fasync }; +static const struct file_operations ps3_mgmt_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = ps3_ioctl_fops, + .open = ps3_mgmt_open, + .release = NULL, + .llseek = noop_llseek, + .read = NULL, + .write = NULL, + .fasync = ps3_fasync +}; static struct pci_driver ps3_pci_driver; static void init_pci_driver(struct pci_driver *drv) @@ -1776,41 +1876,48 @@ static void init_pci_driver(struct pci_driver *drv) drv->resume = ps3_resume; #endif drv->shutdown = ps3_shutdown; - if (ps3_aer_handle_support_query()) + if (ps3_aer_handle_support_query()) { ps3_pci_err_handler_init(drv); - else + } else { LOG_INFO("aer handle not supported\n"); + } + + return; } static int __init ps3stor_init(void) { int ret = PS3_SUCCESS; - - pr_warn("ps3stor driver init start, version[%s], commit_id[%s], build_time[%s], toolchain_id[%s]\n", - PS3_DRV_VERSION, PS3_DRV_COMMIT_ID, PS3_DRV_BUILD_TIME, - PS3_DRV_TOOLCHAIN_ID); + LOG2_WARN("ps3stor driver init start, version[%s], commit_id[%s], " + "build_time[%s], toolchain_id[%s]\n", + PS3_DRV_VERSION, PS3_DRV_COMMIT_ID, + PS3_DRV_BUILD_TIME, PS3_DRV_TOOLCHAIN_ID); ret = ps3_debug_init(); + INJECT_START(PS3_ERR_IJ_FORCE_DEBUG_INIT_FAIL, &ret); if (ret < 0) { - pr_err("ps3stor log init fail\n"); + printk(KERN_ERR "ps3stor log init fail\n"); goto l_debug_init_failed; } ps3_host_info_get(); ps3cmd_init(); ps3_mgmt_info_init(); - LOG_FILE_WARN("ps3stor driver ver[%s], commit_id[%s], build_time[%s], toolchain_id[%s]\n", - PS3_DRV_VERSION, PS3_DRV_COMMIT_ID, PS3_DRV_BUILD_TIME, - PS3_DRV_TOOLCHAIN_ID); + LOG_FILE_WARN("ps3stor driver version[%s], commit_id[%s]," + "build_time[%s], toolchain_id[%s]\n", + PS3_DRV_VERSION, PS3_DRV_COMMIT_ID, + PS3_DRV_BUILD_TIME, PS3_DRV_TOOLCHAIN_ID); ret = ps3_sas_attach_transport(); + INJECT_START(PS3_ERR_IJ_FORCE_TRANSPORT_INIT_FAIL, &ret); if (ret != PS3_SUCCESS) { - pr_err("ps3stor transport fail\n"); + printk(KERN_ERR "ps3stor transport fail\n"); ret = -ENODEV; goto l_sas_transport_failed; } ret = register_chrdev(0, PS3_CHRDEV_NAME, &ps3_mgmt_fops); + INJECT_START(PS3_ERR_IJ_FORCE_CHARDEV_INIT_FAIL, &ret); if (ret < 0) { LOG_ERROR("ps3stor: failed to open device node\n"); goto l_register_chrdev_failed; @@ -1819,18 +1926,23 @@ static int __init ps3stor_init(void) init_pci_driver(&ps3_pci_driver); ret = pci_register_driver(&ps3_pci_driver); + INJECT_START(PS3_ERR_IJ_FORCE_PCIDRV_INIT_FAIL, &ret); if (ret) { - LOG_ERROR("ps3stor: PCI hotplug registration failed\n"); + LOG_ERROR("ps3stor: PCI hotplug registration failed \n"); goto l_pci_register_driver_failed; } ret = driver_create_file(&ps3_pci_driver.driver, &driver_attr_version); - if (ret) + INJECT_START(PS3_ERR_IJ_FORCE_VERFILE_INIT_FAIL, &ret); + if (ret) { goto l_attr_ver_failed; + } ret = driver_create_file(&ps3_pci_driver.driver, - &driver_attr_release_date); - if (ret) + &driver_attr_release_date); + INJECT_START(PS3_ERR_IJ_FORCE_VERFILE2_INIT_FAIL, &ret); + if (ret) { goto l_attr_release_date_failed; + } ps3_trace_id_init(); ps3_version_verbose_fill(); @@ -1865,6 +1977,7 @@ static void __exit ps3stor_exit(void) ps3_debug_exit(); ps3cmd_exit(); ps3_mgmt_exit(); + return; } MODULE_INFO(private_version, PS3_PRIVATE_VERSION); diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.c index d013be2bb20c..666b3a412d8b 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include #include #include @@ -15,38 +13,44 @@ #include #include "ps3_cli.h" #include "ps3_instance_manager.h" -#include "ps3_kernel_version.h" #define PS3_CLI_STATIC_MINOR 26 #define PS3_CLI_DYNAMIC_MINOR MISC_DYNAMIC_MINOR -#define PS3_CLI_HASH_LEN 256 +#define PS3_CLI_HASH_LEN 256 struct ps3_cli_cmd_s { struct ps3_cli_cmd_s *next; char cmd[PS3_CLI_CMD_MAXLEN]; char help[PS3_CLI_HELP_LEN]; - void (*func)(int argc, char *argv[]); + ps3_cli_func_t func; }; static int misc_registered; -static atomic_t dev_opened; +static ps3_atomic32 dev_opened; static int cmd_ready; static char ps3_cli_input[PS3_CLI_INPUT_LEN]; static char ps3_cli_output[PS3_CLI_OUTLINE_LEN]; static char __user *read_buf; -static int read_buf_len; -static int read_buf_ptr; +static int read_buf_len; +static int read_buf_ptr; static struct ps3_cli_cmd_s *ps3_cli_cmd_head[PS3_CLI_HASH_LEN]; static struct mutex ps3_cli_mutex; +#if 0 +#define __pl() printk("func = %s, line = %d\n", __FUNCTION__, __LINE__) +#else #define __pl() +#endif -static inline int ps3_cli_minor_get(void) +static inline S32 ps3_cli_minor_get(void) { if (strstr(ps3_host_release_get(), "5.10.134-16.2.an8")) return PS3_CLI_DYNAMIC_MINOR; -#if defined(PS3_STATIC_MINOR) + +#if ((defined(RHEL_MAJOR) && \ + ((RHEL_MAJOR < 9) || (RHEL_MAJOR == 9 && RHEL_MINOR < 3))) || \ + (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0))) return PS3_CLI_STATIC_MINOR; #else return PS3_CLI_DYNAMIC_MINOR; @@ -54,12 +58,12 @@ static inline int ps3_cli_minor_get(void) } static ssize_t ps3_cli_write(struct file *fp, const char __user *buffer, - size_t nbytes, loff_t *ppos) + size_t nbytes, loff_t *ppos) { __pl(); (void)fp; (void)ppos; - if (nbytes > PS3_CLI_INPUT_LEN - 1) + if (nbytes>PS3_CLI_INPUT_LEN-1) return -EINVAL; if (copy_from_user(ps3_cli_input, buffer, nbytes)) @@ -73,10 +77,10 @@ static ssize_t ps3_cli_write(struct file *fp, const char __user *buffer, static u32 str_hash(const char *name) { u32 hash, hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9; - const signed char *scp = (const signed char *)name; + const signed char *scp = (const signed char*)name; while (*scp) { - hash = hash1 + (hash0 ^ (((int)*scp++) * 7152373)); + hash = hash1 + (hash0 ^ (((int) *scp++) * 7152373)); if (hash & 0x80000000) hash -= 0x7fffffff; @@ -88,10 +92,10 @@ static u32 str_hash(const char *name) static struct ps3_cli_cmd_s *ps3_cli_find_cmd(const char *cmd) { - u32 idx = str_hash(cmd) & (PS3_CLI_HASH_LEN - 1); + u32 idx = str_hash(cmd) & (PS3_CLI_HASH_LEN-1); struct ps3_cli_cmd_s *p; - for (p = ps3_cli_cmd_head[idx]; p; p = p->next) + for (p=ps3_cli_cmd_head[idx]; p; p=p->next) if (!strcmp(p->cmd, cmd)) return p; return NULL; @@ -108,15 +112,16 @@ int ps3stor_cli_printf(const char *fmt, ...) len = vsnprintf(ps3_cli_output, PS3_CLI_OUTLINE_LEN, fmt, args); va_end(args); - if (read_buf_ptr >= read_buf_len) + if (read_buf_ptr>=read_buf_len) { return read_buf_ptr; + } - n = read_buf_len - read_buf_ptr; - if (n > len) + n = read_buf_len-read_buf_ptr; + if (n>len) n = len; - ret = copy_to_user(read_buf + read_buf_ptr, ps3_cli_output, n); - if (ret < 0) { + ret = copy_to_user(read_buf+read_buf_ptr, ps3_cli_output, n); + if (ret<0) { pr_err("copy_to_user err=%d\n", ret); return -1; } @@ -129,19 +134,17 @@ int ps3stor_cli_printf(const char *fmt, ...) } EXPORT_SYMBOL(ps3stor_cli_printf); -int ps3stor_cli_register(void (*func)(int argc, char *argv[]), const char *cmd_str, - const char *help) +int ps3stor_cli_register(ps3_cli_func_t func, const char *cmd_str, const char *help) { - u32 idx = str_hash(cmd_str) & (PS3_CLI_HASH_LEN - 1); + u32 idx = str_hash(cmd_str) & (PS3_CLI_HASH_LEN-1); struct ps3_cli_cmd_s *cmd; int ret; __pl(); ret = mutex_lock_killable(&ps3_cli_mutex); - if (ret != 0) { - pr_err("%s(): mutex_lock_killable return err = %d\n", - __func__, ret); + if (ret!=0) { + pr_err("ps3stor_cli_register(): mutex_lock_killable return err = %d\n", ret); return ret; } cmd = ps3_cli_find_cmd(cmd_str); @@ -151,8 +154,9 @@ int ps3stor_cli_register(void (*func)(int argc, char *argv[]), const char *cmd_s return -EEXIST; } - cmd = kmalloc(sizeof(struct ps3_cli_cmd_s), GFP_KERNEL); - if (cmd == NULL) { + cmd = (struct ps3_cli_cmd_s *)kmalloc(sizeof(struct ps3_cli_cmd_s), GFP_KERNEL); + if (cmd==NULL) { + pr_err("out of memory\n"); mutex_unlock(&ps3_cli_mutex); return -ENOMEM; } @@ -176,11 +180,10 @@ EXPORT_SYMBOL(ps3stor_cli_register); static void ps3_parse_cmd(char *cmdline, int *argc, char *argv[]) { char *p = cmdline; - int i = 0, spc = 1; - - while (*p) { + int i=0, spc=1; + while(*p) { if (spc) { - if (*p != ' ') { + if (*p!=' ') { spc = 0; argv[i] = p; i++; @@ -188,7 +191,7 @@ static void ps3_parse_cmd(char *cmdline, int *argc, char *argv[]) *p = '\0'; } } else { - if (*p == ' ') { + if (*p==' ') { spc = 1; *p = '\0'; } else { @@ -199,8 +202,8 @@ static void ps3_parse_cmd(char *cmdline, int *argc, char *argv[]) *argc = i; } -static ssize_t ps3_cli_read(struct file *fp, char __user *buf, size_t nbytes, - loff_t *ppos) +static ssize_t ps3_cli_read(struct file *fp, char __user *buf, + size_t nbytes, loff_t *ppos) { struct ps3_cli_cmd_s *cmd; int argc; @@ -222,14 +225,14 @@ static ssize_t ps3_cli_read(struct file *fp, char __user *buf, size_t nbytes, ps3_parse_cmd(ps3_cli_input, &argc, argv); ret = mutex_lock_killable(&ps3_cli_mutex); - if (ret != 0) { - pr_err("ps3stor_cli_register(): mutex_lock_killable return err = %d\n", - ret); + if (ret!=0) { + pr_err("ps3stor_cli_register(): mutex_lock_killable return err = %d\n", ret); return ret; } - cmd = ps3_cli_find_cmd((const char *)argv[0]); - if (cmd != NULL) + cmd = ps3_cli_find_cmd((const char*)argv[0]); + if (cmd!=NULL) { cmd->func(argc, argv); + } mutex_unlock(&ps3_cli_mutex); __pl(); @@ -256,19 +259,21 @@ static int ps3_cli_release(struct inode *ip, struct file *fp) return 0; } -static const struct file_operations ps3_cli_fops = { .owner = NULL, - .unlocked_ioctl = NULL, - .open = ps3_cli_open, - .release = ps3_cli_release, - .llseek = NULL, - .read = ps3_cli_read, - .write = ps3_cli_write, - .fasync = NULL }; +static const struct file_operations ps3_cli_fops = { + .owner = NULL, + .unlocked_ioctl = NULL, + .open = ps3_cli_open, + .release = ps3_cli_release, + .llseek = NULL, + .read = ps3_cli_read, + .write = ps3_cli_write, + .fasync = NULL +}; static struct miscdevice ps3_cli_device = { .minor = PS3_CLI_STATIC_MINOR, - .name = "ps3stor_cli", - .fops = &ps3_cli_fops, + .name = "ps3stor_cli", + .fops = &ps3_cli_fops, }; static void ps3_cli_help(int argc, char *argv[]) @@ -278,10 +283,9 @@ static void ps3_cli_help(int argc, char *argv[]) (void)argc; (void)argv; __pl(); - for (i = 0; i < PS3_CLI_HASH_LEN; i++) { - for (cmd = ps3_cli_cmd_head[i]; cmd != NULL; cmd = cmd->next) { - ps3stor_cli_printf("%20s -- %s\n", cmd->cmd, - (const char *)cmd->help); + for (i=0; inext) { + ps3stor_cli_printf("%20s -- %s\n", cmd->cmd, (const char*)cmd->help); } } __pl(); @@ -291,8 +295,7 @@ static void ps3_free_cmds(void) { int i; struct ps3_cli_cmd_s *cmd; - - for (i = 0; i < PS3_CLI_HASH_LEN; i++) { + for (i=0; inext; @@ -318,8 +321,7 @@ int ps3cmd_init(void) return err; } misc_registered = 1; - ps3stor_cli_register(ps3_cli_help, "help", - "show this help information"); + ps3stor_cli_register(ps3_cli_help, "help", "show this help information"); return 0; } @@ -332,3 +334,4 @@ void ps3cmd_exit(void) misc_registered = 0; mutex_destroy(&ps3_cli_mutex); } + diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.h b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.h index ce4f2ef8ffb8..a8be3c57cf03 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.h +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.h @@ -1,17 +1,17 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_CLI_H_ #define _PS3_CLI_H_ -#define PS3_CLI_INPUT_LEN 2048 -#define PS3_CLI_OUTPUT_MAX (16 * 1024 * 1024) -#define PS3_CLI_OUTLINE_LEN 4096 -#define PS3_CLI_HELP_LEN 256 -#define PS3_CLI_CMD_MAXLEN 32 -#define PS3_MAX_ARGV 64 +#define PS3_CLI_INPUT_LEN 2048 +#define PS3_CLI_OUTPUT_MAX (16*1024*1024) +#define PS3_CLI_OUTLINE_LEN 4096 +#define PS3_CLI_HELP_LEN 256 +#define PS3_CLI_CMD_MAXLEN 32 +#define PS3_MAX_ARGV 64 + +typedef void (*ps3_cli_func_t)(int argc, char *argv[]); -int ps3stor_cli_register(void (*func)(int argc, char *argv[]), const char *cmd_str, - const char *help); +int ps3stor_cli_register(ps3_cli_func_t func, const char *cmd_str, const char *help); int ps3stor_cli_printf(const char *fmt, ...); diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.c index edcba3df38c4..ced3b05a4718 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include #include #include @@ -29,6 +27,7 @@ #include "ps3_irq.h" #include "ps3_cmd_complete.h" #include "ps3_qos.h" +#include "ps3_inject.h" static void ps3_cli_host_and_instance_ls(int argc, char *argv[]); static void ps3_cli_register_rw(int argc, char *argv[]); static void ps3_cli_register_dump(int argc, char *argv[]); @@ -42,7 +41,7 @@ static void ps3_cli_event_delay_set(int argc, char *argv[]); static void ps3_cli_crashdump_set(int argc, char *argv[]); static void ps3_cli_force_to_stop(int argc, char *argv[]); static void ps3_io_statis_dump_cli_cb(int argc, char *argv[]); -static void ps3_io_statis_clear_cli_cb(int argc, char *argv[]); +static void ps3_io_statis_clear_cli_cb(int argc, char *argv []); static void ps3_debug_mem_rw_cli_cb(int argc, char *argv[]); static void ps3_debug_mem_para_cli_cb(int argc, char *argv[]); static void ps3_scsi_device_lookup_cb(int argc, char *argv[]); @@ -60,215 +59,239 @@ static void ps3_cli_remove_host_force(int argc, char *argv[]); static void ps3_hardreset_cnt_clear_cli_cb(int argc, char *argv[]); static void ps3_hardreset_cnt_show_cli_cb(int argc, char *argv[]); static void ps3_cli_ramfs_test_set(int argc, char *argv[]); +static void ps3_cli_err_inject_active(int argc, char *argv[]); +static void ps3_cli_err_inject_clear(int argc, char *argv[]); static void ps3_no_wait_cli_cmd(int argc, char *argv[]); static void ps3_cli_qos_info(int argc, char *argv[]); -static void ps3_cli_special_log(int argc, char *argv[]); - -static unsigned char ps3_cli_wait_flag = PS3_FALSE; +static void ps3_cli_special_log(int argc, char *argv[]); + +static Bool ps3_cli_wait_flag = PS3_FALSE; +#ifdef PS3_SUPPORT_INJECT +static void ps3_show_inject_scsi_rw(int argc, char *argv[]); +static void ps3_show_inject_scsi_task(int argc, char *argv[]); +static void ps3_show_inject_mgr(int argc, char *argv[]); + +static void ps3_clear_all_inject(int argc, char *argv[]); +static void ps3_clear_inject_scsi_task(int argc, char *argv[]); +static void ps3_clear_inject_mgr(int argc, char *argv[]); + +static void ps3_clear_inject_scsi_rw(int argc, char *argv[]); +static void ps3_inject_scsi_task(int argc, char *argv[]); +static void ps3_inject_mgr(int argc, char *argv[]); +static void ps3_inject_scsi_rw(int argc, char *argv[]); +static void ps3_show_all_inject(int argc, char *argv[]); +static void ps3_clear_hit_cmd(int argc, char *argv[]); +#endif struct ps3_cli_debug_cmd { - void (*func)(int argc, char *argv[]); + ps3_cli_func_t func; const char *func_name; const char *help; }; static struct ps3_cli_debug_cmd g_ps3_cli_debug_cmd_table[] = { - { ps3_cli_host_and_instance_ls, "ls", - "ls option[host][instance][all]" }, - { ps3_cli_register_rw, "register_rw", - "register_rw host_no xxx(host num) name/offset xxx(name/offset) read/write xxx(value)" }, - { ps3_cli_register_dump, "register_dump", - "register_dump host_no xxx(host number)" }, - { ps3_cli_init_frame_dump, "init_frame_dump", - "init_frame_dump host_no xxx(host number)" }, - { ps3_cli_event_subscirbe_info_dump, "event_subscribe_dump", - "event_subscribe_dump host_no xxx(host number)" }, - { ps3_cli_event_delay_set, "event_delay_set", - "event_delay_set host_no xxx(host number) delay xxx(seconds)" }, - { ps3_cli_crashdump_set, "crashdump", - "crashdump host_no xxx(host number) wait xxx(seconds)" }, - { ps3_cli_dev_mgr_cli_base_dump, "dmbi", - "device manager base information: dmbi option[vd][pd][all]" }, - { ps3_cli_dev_mgr_cli_detail_dump, "dmdi", - "device manager detail information: dmdi " }, - { ps3_cli_reply_fifo_dump, "reply_fifo_dump", - "reply_fifo_dump host_no xxx(host number) isr_sn xxx(isr SN)\n" - "\t\toption[start_idx xxx default: last_reply_idx][count xxx default: 100]" }, - { ps3_cli_cmd_dump, "cmd_dump", - "cmd_dump host_no xxx(host number) cmd_frame_id xxx(cmd_frame_id)" }, - { ps3_io_statis_dump_cli_cb, "show", - "show io statis (detail|summary)" }, - { ps3_io_statis_clear_cli_cb, "clear", - "clear io statis " }, - { ps3_cli_force_to_stop, "force_to_stop", "force_to_stop" }, - { ps3_debug_mem_para_cli_cb, "debug_mem_para_dump", - "debug_mem_para_dump host_no xxx(host no)" }, - { ps3_debug_mem_rw_cli_cb, "debug_mem", - "debug_mem host_no (host no) entry_index(0--max entry cnt) dir(0/1 r/w) length(Bytes)" }, - { ps3_scsi_device_lookup_cb, "scsi_device_dump", - "scsi_device_dump host_no xxx(host number)" }, - { ps3_hard_reset_cb, "hard_reset", - "hard_reset host_no xxx(host number)" }, - { ps3_soc_halt_cb, "soc_halt", "soc_halt host_no xxx(host number)" }, - { ps3_cmd_stat_switch_store_cb, "cmd_stat_switch_store", - "cmd_stat_switch_store host_no xxx(host number) value xxx mask xxx\n" - "\t\t[bit0:OUTSTAND_SWITCH_OPEN, bit1:INC_SWITCH_OPEN,\n" - "\t\tbit2:LOG_SWITCH_OPEN, bit3:DEV_SWITCH_OPEN]" }, - { ps3_cmd_stat_switch_show_cb, "cmd_stat_switch_show", - "cmd_stat_switch_show host_no xxx" }, - { ps3_stat_total_show_cb, "cmd_stat_dump", - "cmd_stat_dump host_no xxx" }, - { ps3_stat_inc_show_cb, "inc_stat_dump", "inc_stat_dump host_no xxx" }, - { ps3_stat_buf_clr_cb, "cmd_stat_clear", "cmd_stat_clear host_no xxx" }, - { ps3_stat_interval_show_cb, "cmd_stat_interval_show", - "cmd_stat_interval_show host_no xxx" }, - { ps3_stat_interval_store_cb, "cmd_stat_interval_store", - "cmd_stat_interval_store host_no xxx interval xxx(ms)" }, - { ps3_reply_fifo_reset_cb, "ps3_all_reply_fifo_reset", - "ps3_all_reply_fifo_reset host_no xxx" }, - { ps3_cli_remove_host_force, "remove_host", - "remove one host and free resource: (host number)" }, - { ps3_hardreset_cnt_clear_cli_cb, "hardreset_cnt_clear", - "hardreset_cnt_clear host_no xxx(host number)" }, - { ps3_hardreset_cnt_show_cli_cb, "hardreset_cnt_show", - "hardreset_cnt_show host_no xxx(host number)" }, - { ps3_cli_ramfs_test_set, "ramfs_test_set", - "set or clear filesystem type to ramfs: (0: clear, 1: set)" }, - { ps3_no_wait_cli_cmd, "ps3_no_wait_cli_cmd", - "clean_wait_cli_cmd flag xxx" }, - { ps3_cli_qos_info, "qos_dump", - "qos_dump host_no xxx(host number) pd/vd xxx(id) | all" }, - { ps3_cli_special_log, "spe_log", - "spe_log host_no xxx(host number) set xxx(0/1)" }, + {ps3_cli_host_and_instance_ls, "ls", "ls option[host][instance][all]"}, + {ps3_cli_register_rw, "register_rw", + "register_rw host_no xxx(host number) name/offset xxx(reg name/offset) read/write xxx(reg value)"}, + {ps3_cli_register_dump, "register_dump", + "register_dump host_no xxx(host number)"}, + {ps3_cli_init_frame_dump, "init_frame_dump", + "init_frame_dump host_no xxx(host number)"}, + {ps3_cli_event_subscirbe_info_dump, + "event_subscribe_dump", + "event_subscribe_dump host_no xxx(host number)"}, + {ps3_cli_event_delay_set, + "event_delay_set", + "event_delay_set host_no xxx(host number) delay xxx(seconds)"}, + {ps3_cli_crashdump_set, + "crashdump", + "crashdump host_no xxx(host number) wait xxx(seconds)"}, + {ps3_cli_dev_mgr_cli_base_dump, "dmbi", + "device manager base infomation: dmbi option[vd][pd][all]"}, + {ps3_cli_dev_mgr_cli_detail_dump, "dmdi", + "device manager detail infomation: dmdi "}, + {ps3_cli_reply_fifo_dump, "reply_fifo_dump", + "reply_fifo_dump host_no xxx(host number) isr_sn xxx(isr SN) \ + option[start_idx xxx default: last_reply_idx][count xxx default: 100]"}, + {ps3_cli_cmd_dump, "cmd_dump", + "cmd_dump host_no xxx(host number) cmd_frame_id xxx(cmd_frame_id)"}, + {ps3_io_statis_dump_cli_cb, "show", + "show io statis (detail|summary)"}, + {ps3_io_statis_clear_cli_cb, "clear", + "clear io statis "}, + {ps3_cli_force_to_stop, "force_to_stop", "force_to_stop"}, + {ps3_debug_mem_para_cli_cb, "debug_mem_para_dump", + "debug_mem_para_dump host_no xxx(host no)"}, + {ps3_debug_mem_rw_cli_cb, "debug_mem", + "debug_mem host_no (host no) entry_index(0--max entry count) dir(0 read/1 write) length(Bytes)"}, + {ps3_scsi_device_lookup_cb, + "scsi_device_dump", "scsi_device_dump host_no xxx(host number)"}, + {ps3_hard_reset_cb, + "hard_reset", "hard_reset host_no xxx(host number)"}, + {ps3_soc_halt_cb, + "soc_halt", "soc_halt host_no xxx(host number)"}, + {ps3_cmd_stat_switch_store_cb, "cmd_stat_switch_store", + "cmd_stat_switch_store host_no xxx(host number) value xxx mask xxx" + "[bit0:OUTSTAND_SWITCH_OPEN, bit1:INC_SWITCH_OPEN," + " bit2:LOG_SWITCH_OPEN, bit3:DEV_SWITCH_OPEN]"}, + {ps3_cmd_stat_switch_show_cb, + "cmd_stat_switch_show", "cmd_stat_switch_show host_no xxx"}, + {ps3_stat_total_show_cb, "cmd_stat_dump", "cmd_stat_dump host_no xxx"}, + {ps3_stat_inc_show_cb, "inc_stat_dump", "inc_stat_dump host_no xxx"}, + {ps3_stat_buf_clr_cb, "cmd_stat_clear", "cmd_stat_clear host_no xxx"}, + {ps3_stat_interval_show_cb, "cmd_stat_interval_show", + "cmd_stat_interval_show host_no xxx"}, + {ps3_stat_interval_store_cb, "cmd_stat_interval_store", + "cmd_stat_interval_store host_no xxx interval xxx(ms)"}, + {ps3_reply_fifo_reset_cb, "ps3_all_reply_fifo_reset", + "ps3_all_reply_fifo_reset host_no xxx"}, + {ps3_cli_remove_host_force, "remove_host", + "remove one host and free resource: (host number)"}, + {ps3_hardreset_cnt_clear_cli_cb, "hardreset_cnt_clear", + "hardreset_cnt_clear host_no xxx(host number)"}, + {ps3_hardreset_cnt_show_cli_cb, "hardreset_cnt_show", + "hardreset_cnt_show host_no xxx(host number)"}, + {ps3_cli_ramfs_test_set, "ramfs_test_set", + "set or clear filesystem type to ramfs: (0: clear, 1: set)"}, + {ps3_cli_err_inject_active, "err_inject", + "err_inject err_type count"}, + {ps3_cli_err_inject_clear, "cli_err_clear", + ""}, + {ps3_no_wait_cli_cmd, "ps3_no_wait_cli_cmd", + "clean_wait_cli_cmd flag xxx"}, + {ps3_cli_qos_info, "qos_dump", + "qos_dump host_no xxx(host number) pd/vd xxx(id) | all"}, + {ps3_cli_special_log, "spe_log", + "spe_log host_no xxx(host number) set xxx(0/1)"}, +#ifdef PS3_SUPPORT_INJECT + {ps3_inject_scsi_rw, "inject_rw", + "host_no xxx(host number) dev xxx xxx(channel id) lba xxx len xxx xxx(1 timeout_force_reply/2 error_reply)\ +result xxx(scsi->result) sense xxx(resp_code-key-asc-ascq) times xxx"}, + {ps3_show_inject_scsi_rw, "show_inject_rw", + "host_no xxx(host number) dev xxx xxx(channel id) lba xxx len xxx xxx"}, + {ps3_clear_inject_scsi_rw, "clear_inject_rw", + "host_no xxx(host number) dev xxx xxx(channel id) lba xxx len xxx xxx"}, + {ps3_inject_scsi_task, "inject_scsi_task", + "host_no xxx(host number) dev xxx xxx(channel id) abort/reset (3 timeout/4 error_reply) times xxx"}, + {ps3_inject_mgr, "inject_mgr", + "host_no xxx(host number) cmd_type xxx cmd_sub_type xxx xxx (7 timeout/8 error_reply xxx (errType)) times xxx"}, + {ps3_show_inject_scsi_task, "show_inject_scsi_task", + "host_no xxx(host number) dev xxx xxx(channel id)"}, + {ps3_show_inject_mgr, "show_inject_mgr", + "host_no xxx(host number) cmd_type xxx cmd_sub_type xxx"}, + {ps3_clear_inject_scsi_task, "clear_inject_scsi_task", + "host_no xxx(host number) dev xxx xxx(channel id)"}, + {ps3_clear_inject_mgr, "clear_inject_mgr", + "host_no xxx(host number) cmd_type xxx cmd_sub_type xxx"}, + {ps3_clear_all_inject, "clear_inject_all", + "clear_inject_all"}, + {ps3_show_all_inject, "show_inject_all", + "show_inject_all"}, + {ps3_clear_hit_cmd, "ps3_clear_hit_cmd", + "ps3_clear_hit_cmd"}, +#endif }; #define DRIVER_REGISTER_DEBUG_SIMULATOR -#define REG_OFFSET(member) (offsetof(struct Ps3Fifo, member)) +#define REG_OFFSET(member) (offsetof(Ps3Fifo_s, member)) struct ps3_reg_dump_desc { const char *reg_name; - unsigned int reg_offset; - unsigned int reg_cnt; - unsigned char is_readable; + U32 reg_offset; + U32 reg_cnt; + Bool is_readable; }; static struct ps3_reg_dump_desc g_reg_table[] = { - { "ps3RequestQueue", PS3_REG_OFFSET_REQUEST_QUE, 1, PS3_TRUE }, - { "ps3Doorbell", PS3_REG_OFFSET_DOORBELL, 1, PS3_FALSE }, - { "ps3DoorbellIrqClear", PS3_REG_OFFSET_DOORBELL_IRQ_CLEAR, 1, - PS3_TRUE }, - { "ps3DoorbellIrqMask", PS3_REG_OFFSET_DOORBELL_IRQ_MASK, 1, PS3_TRUE }, - { "ps3IrqControl", PS3_REG_OFFSET_IRQ_CONTROL, 1, PS3_TRUE }, - { "ps3SoftresetKey", PS3_REG_OFFSET_SOFTRESET_KEY, 1, PS3_TRUE }, - { "ps3SoftresetState", PS3_REG_OFFSET_SOFTRESET_STATE, 1, PS3_TRUE }, - { "ps3Softreset", PS3_REG_OFFSET_SOFTRESET, 1, PS3_TRUE }, - { "ps3SoftresetIrqClear", PS3_REG_OFFSET_SOFTRESET_IRQ_CLEAR, 1, - PS3_TRUE }, - { "ps3SoftresetIrqMask", PS3_REG_OFFSET_SOFTRESET_IRQ_MASK, 1, - PS3_TRUE }, - { "ps3SoftresetKeyShiftRegLow", - PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_LOW, 1, PS3_TRUE }, - { "ps3SoftresetKeyShiftRegHigh", - PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_HIGH, 1, PS3_TRUE }, - { "ps3SoftresetTimeCnt", PS3_REG_OFFSET_SOFTRESET_TIME_CNT, 1, - PS3_TRUE }, - { "ps3SoftresetTimeOutEn", PS3_REG_OFFSET_SOFTRESET_TIME_OUT_CNT, 1, - PS3_TRUE }, - { "ps3HardresetKey", PS3_REG_OFFSET_HARDRESET_KEY, 1, PS3_TRUE }, - { "ps3HardresetState", PS3_REG_OFFSET_HARDRESET_STATE, 1, PS3_TRUE }, - { "ps3Hardreset", PS3_REG_OFFSET_HARDRESET, 1, PS3_TRUE }, - { "ps3HardresetKeyShiftRegLow", - PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_LOW, 1, PS3_TRUE }, - { "ps3HardresetKeyShiftRegHigh", - PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_HIGH, 1, PS3_TRUE }, - { "ps3HardresetTimeCnt", PS3_REG_OFFSET_HARDRESET_TIME_CNT, 1, - PS3_TRUE }, - { "ps3HardresetTimeOutEn", PS3_REG_OFFSET_HARDRESET_TIME_OUT_CNT, 1, - PS3_TRUE }, - { "ps3KeyGapCfg", PS3_REG_OFFSET_KEY_GAP_CFG, 1, PS3_TRUE }, - { "ps3HardresetIrqClear", PS3_REG_OFFSET_HARDRESET_IRQ_CLEAR, 1, - PS3_TRUE }, - { "ps3HardresetIrqMask", PS3_REG_OFFSET_HARDRESET_IRQ_MASK, 1, - PS3_TRUE }, - { "ps3SocFwState", PS3_REG_OFFSET_SOC_FW_STATE, 1, PS3_TRUE }, - { "ps3MaxFwCmd", PS3_REG_OFFSET_MAX_FW_CMD, 1, PS3_TRUE }, - { "ps3MaxChainSize", PS3_REG_OFFSET_MAX_CHAIN_SIZE, 1, PS3_TRUE }, - { "ps3MaxVdInfoSize", PS3_REG_OFFSET_MAX_VD_INFO_SIZE, 1, PS3_TRUE }, - { "ps3MaxNvmePageSize", PS3_REG_OFFSET_MAX_NVME_PAGE_SIZE, 1, - PS3_TRUE }, - { "ps3FeatureSupport", PS3_REG_OFFSET_FEATURE_SUPPORT, 1, PS3_TRUE }, - { "ps3FirmwareVersion", PS3_REG_OFFSET_FIRMWARE_VERSION, 1, PS3_TRUE }, - { "ps3MaxReplyque", PS3_REG_OFFSET_REPLY_QUE, 1, PS3_TRUE }, - { "ps3HardwareVersion", PS3_REG_OFFSET_HARDWARE_VERSION, 1, PS3_TRUE }, - { "ps3MgrQueueDepth", PS3_REG_OFFSET_MGR_QUEUE_DEPTH, 1, PS3_TRUE }, - { "ps3CmdQueueDepth", PS3_REG_OFFSET_CMD_QUEUE_DEPTH, 1, PS3_TRUE }, - { "ps3TfifoDepth", PS3_REG_OFFSET_TFIFO_DEPTH, 1, PS3_TRUE }, - { "ps3MaxSecR1xCmds", PS3_REG_OFFSET_MAX_SEC_R1X_CMDS, 1, PS3_TRUE }, - { "ps3HilAdvice2directCnt0", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT0, 1, - PS3_TRUE }, - { "ps3HilAdvice2directCnt1", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT1, 1, - PS3_TRUE }, - { "ps3HilAdvice2directCnt2", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT2, 1, - PS3_TRUE }, - { "ps3HilAdvice2directCnt3", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT3, 1, - PS3_TRUE }, - { "ps3HilAdvice2directCntAll", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT_ALL, - 1, PS3_TRUE }, - { "ps3IrqStatusRpt", PS3_REG_OFFSET_IRQ_STATUS_RPT, 1, PS3_TRUE }, - { "ps3DumpCtrl", PS3_REG_OFFSET_DUMP_CTRL, 1, PS3_FALSE }, - { "ps3DumpCtrlIrqClear", PS3_REG_OFFSET_DUMP_CTRl_IRQ_CLEAR, 1, - PS3_TRUE }, - { "ps3DumpCtrlIrqMask", PS3_REG_OFFSET_DUMP_CTRl_IRQ_MASK, 1, - PS3_TRUE }, - { "ps3DumpStatus", PS3_REG_OFFSET_DUMP_STATUS, 1, PS3_TRUE }, - { "ps3DumpDataSize", PS3_REG_OFFSET_DUMP_DATA_SIZE, 1, PS3_TRUE }, - { "ps3CmdTrigger", PS3_REG_OFFSET_CMD_TRIGGER, 1, PS3_TRUE }, - { "ps3CmdTriggerIrqClear", PS3_REG_OFFSET_CMD_TRIGGER_IRQ_CLEAR, 1, - PS3_TRUE }, - { "ps3CmdTriggerIrqMask", PS3_REG_OFFSET_CMD_TRIGGER_IRQ_MASK, 1, - PS3_TRUE }, - { "ps3RegCmdState", PS3_REG_OFFSET_REG_CMD_STATE, 1, PS3_TRUE }, - { "ps3SoftresetCounter", PS3_REG_OFFSET_SOFTRESET_COUNTER, 1, - PS3_TRUE }, - { "ps3Debug0", PS3_REG_OFFSET_DEBUG0, 1, PS3_TRUE }, - { "ps3Debug0IrqClear", PS3_REG_OFFSET_DEBUG0_IRQ_CLEAR, 1, PS3_TRUE }, - { "ps3Debug0IrqMask", PS3_REG_OFFSET_DEBUG0_IRQ_MASK, 1, PS3_TRUE }, - { "ps3Debug1", PS3_REG_OFFSET_DEBUG1, 1, PS3_TRUE }, - { "ps3Debug1IrqClear", PS3_REG_OFFSET_DEBUG1_IRQ_CLEAR, 1, PS3_TRUE }, - { "ps3Debug1IrqMask", PS3_REG_OFFSET_DEBUG1_IRQ_MASK, 1, PS3_TRUE }, - { "ps3Debug2", PS3_REG_OFFSET_DEBUG2, 1, PS3_TRUE }, - { "ps3Debug2IrqClear", PS3_REG_OFFSET_DEBUG2_IRQ_CLEAR, 1, PS3_TRUE }, - { "ps3Debug2IrqMask", PS3_REG_OFFSET_DEBUG2_IRQ_MASK, 1, PS3_TRUE }, - { "ps3Debug3", PS3_REG_OFFSET_DEBUG3, 1, PS3_TRUE }, - { "ps3Debug3IrqClear", PS3_REG_OFFSET_DEBUG3_IRQ_CLEAR, 1, PS3_TRUE }, - { "ps3Debug3IrqMask", PS3_REG_OFFSET_DEBUG3_IRQ_MASK, 1, PS3_TRUE }, - { "ps3Debug4", PS3_REG_OFFSET_DEBUG4, 1, PS3_TRUE }, - { "ps3Debug4IrqMask", PS3_REG_OFFSET_DEBUG4_IRQ_CLEAR, 1, PS3_TRUE }, - { "ps3Debug4IrqMask", PS3_REG_OFFSET_DEBUG4_IRQ_MASK, 1, PS3_TRUE }, - { "ps3Debug5", PS3_REG_OFFSET_DEBUG5, 1, PS3_TRUE }, - { "ps3Debug6", PS3_REG_OFFSET_DEBUG6, 1, PS3_TRUE }, - { "ps3Debug7", PS3_REG_OFFSET_DEBUG7, 1, PS3_TRUE }, - { "ps3Debug8", PS3_REG_OFFSET_DEBUG8, 1, PS3_TRUE }, - { "ps3Debug9", PS3_REG_OFFSET_DEBUG9, 1, PS3_TRUE }, - { "ps3Debug10", PS3_REG_OFFSET_DEBUG10, 1, PS3_TRUE }, - { "ps3Debug11", PS3_REG_OFFSET_DEBUG11, 1, PS3_TRUE }, - { "ps3Debug12", PS3_REG_OFFSET_DEBUG12, 1, PS3_TRUE }, - { "ps3SessioncmdAddr", PS3_REG_SESSION_ADDR, 1, PS3_TRUE }, - { "ps3SessioncmdAddrIrqClear", PS3_REG_SESSION_ADDR_IRQ_CLEAR, 1, - PS3_TRUE }, - { "ps3SessioncmdAddrIrqMask", PS3_REG_SESSION_ADDR_IRQ_MASK, 1, - PS3_TRUE }, + {"ps3RequestQueue", PS3_REG_OFFSET_REQUEST_QUE, 1, PS3_TRUE}, + {"ps3Doorbell", PS3_REG_OFFSET_DOORBELL, 1, PS3_FALSE}, + {"ps3DoorbellIrqClear", PS3_REG_OFFSET_DOORBELL_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3DoorbellIrqMask", PS3_REG_OFFSET_DOORBELL_IRQ_MASK, 1, PS3_TRUE}, + {"ps3IrqControl", PS3_REG_OFFSET_IRQ_CONTROL, 1, PS3_TRUE}, + {"ps3SoftresetKey", PS3_REG_OFFSET_SOFTRESET_KEY, 1, PS3_TRUE}, + {"ps3SoftresetState", PS3_REG_OFFSET_SOFTRESET_STATE, 1, PS3_TRUE}, + {"ps3Softreset", PS3_REG_OFFSET_SOFTRESET, 1, PS3_TRUE}, + {"ps3SoftresetIrqClear", PS3_REG_OFFSET_SOFTRESET_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3SoftresetIrqMask", PS3_REG_OFFSET_SOFTRESET_IRQ_MASK, 1, PS3_TRUE}, + {"ps3SoftresetKeyShiftRegLow", PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_LOW, 1, PS3_TRUE}, + {"ps3SoftresetKeyShiftRegHigh", PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_HIGH, 1, PS3_TRUE}, + {"ps3SoftresetTimeCnt", PS3_REG_OFFSET_SOFTRESET_TIME_CNT, 1, PS3_TRUE}, + {"ps3SoftresetTimeOutEn", PS3_REG_OFFSET_SOFTRESET_TIME_OUT_CNT, 1, PS3_TRUE}, + {"ps3HardresetKey", PS3_REG_OFFSET_HARDRESET_KEY, 1, PS3_TRUE}, + {"ps3HardresetState", PS3_REG_OFFSET_HARDRESET_STATE, 1, PS3_TRUE}, + {"ps3Hardreset", PS3_REG_OFFSET_HARDRESET, 1, PS3_TRUE}, + {"ps3HardresetKeyShiftRegLow", PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_LOW, 1, PS3_TRUE}, + {"ps3HardresetKeyShiftRegHigh", PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_HIGH, 1, PS3_TRUE}, + {"ps3HardresetTimeCnt", PS3_REG_OFFSET_HARDRESET_TIME_CNT, 1, PS3_TRUE}, + {"ps3HardresetTimeOutEn", PS3_REG_OFFSET_HARDRESET_TIME_OUT_CNT, 1, PS3_TRUE}, + {"ps3KeyGapCfg", PS3_REG_OFFSET_KEY_GAP_CFG, 1, PS3_TRUE}, + {"ps3HardresetIrqClear", PS3_REG_OFFSET_HARDRESET_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3HardresetIrqMask", PS3_REG_OFFSET_HARDRESET_IRQ_MASK, 1, PS3_TRUE}, + {"ps3SocFwState", PS3_REG_OFFSET_SOC_FW_STATE, 1, PS3_TRUE}, + {"ps3MaxFwCmd", PS3_REG_OFFSET_MAX_FW_CMD, 1, PS3_TRUE}, + {"ps3MaxChainSize", PS3_REG_OFFSET_MAX_CHAIN_SIZE, 1, PS3_TRUE}, + {"ps3MaxVdInfoSize", PS3_REG_OFFSET_MAX_VD_INFO_SIZE, 1, PS3_TRUE}, + {"ps3MaxNvmePageSize", PS3_REG_OFFSET_MAX_NVME_PAGE_SIZE, 1, PS3_TRUE}, + {"ps3FeatureSupport", PS3_REG_OFFSET_FEATURE_SUPPORT, 1, PS3_TRUE}, + {"ps3FirmwareVersion", PS3_REG_OFFSET_FIRMWARE_VERSION, 1, PS3_TRUE}, + {"ps3MaxReplyque", PS3_REG_OFFSET_REPLY_QUE, 1, PS3_TRUE}, + {"ps3HardwareVersion", PS3_REG_OFFSET_HARDWARE_VERSION, 1, PS3_TRUE}, + {"ps3MgrQueueDepth", PS3_REG_OFFSET_MGR_QUEUE_DEPTH, 1, PS3_TRUE}, + {"ps3CmdQueueDepth", PS3_REG_OFFSET_CMD_QUEUE_DEPTH, 1, PS3_TRUE}, + {"ps3TfifoDepth", PS3_REG_OFFSET_TFIFO_DEPTH, 1, PS3_TRUE}, + {"ps3MaxSecR1xCmds", PS3_REG_OFFSET_MAX_SEC_R1X_CMDS, 1, PS3_TRUE}, + {"ps3HilAdvice2directCnt0", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT0, 1, PS3_TRUE}, + {"ps3HilAdvice2directCnt1", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT1, 1, PS3_TRUE}, + {"ps3HilAdvice2directCnt2", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT2, 1, PS3_TRUE}, + {"ps3HilAdvice2directCnt3", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT3, 1, PS3_TRUE}, + {"ps3HilAdvice2directCntAll", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT_ALL, 1, PS3_TRUE}, + {"ps3IrqStatusRpt", PS3_REG_OFFSET_IRQ_STATUS_RPT, 1, PS3_TRUE}, + {"ps3DumpCtrl", PS3_REG_OFFSET_DUMP_CTRL, 1, PS3_FALSE}, + {"ps3DumpCtrlIrqClear", PS3_REG_OFFSET_DUMP_CTRl_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3DumpCtrlIrqMask", PS3_REG_OFFSET_DUMP_CTRl_IRQ_MASK, 1, PS3_TRUE}, + {"ps3DumpStatus", PS3_REG_OFFSET_DUMP_STATUS, 1, PS3_TRUE}, + {"ps3DumpDataSize", PS3_REG_OFFSET_DUMP_DATA_SIZE, 1, PS3_TRUE}, + {"ps3CmdTrigger", PS3_REG_OFFSET_CMD_TRIGGER, 1, PS3_TRUE}, + {"ps3CmdTriggerIrqClear", PS3_REG_OFFSET_CMD_TRIGGER_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3CmdTriggerIrqMask", PS3_REG_OFFSET_CMD_TRIGGER_IRQ_MASK, 1, PS3_TRUE}, + {"ps3RegCmdState", PS3_REG_OFFSET_REG_CMD_STATE, 1, PS3_TRUE}, + {"ps3SoftresetCounter", PS3_REG_OFFSET_SOFTRESET_COUNTER, 1, PS3_TRUE}, + {"ps3Debug0", PS3_REG_OFFSET_DEBUG0, 1, PS3_TRUE}, + {"ps3Debug0IrqClear", PS3_REG_OFFSET_DEBUG0_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3Debug0IrqMask", PS3_REG_OFFSET_DEBUG0_IRQ_MASK, 1, PS3_TRUE}, + {"ps3Debug1", PS3_REG_OFFSET_DEBUG1, 1, PS3_TRUE}, + {"ps3Debug1IrqClear", PS3_REG_OFFSET_DEBUG1_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3Debug1IrqMask", PS3_REG_OFFSET_DEBUG1_IRQ_MASK, 1, PS3_TRUE}, + {"ps3Debug2", PS3_REG_OFFSET_DEBUG2, 1, PS3_TRUE}, + {"ps3Debug2IrqClear", PS3_REG_OFFSET_DEBUG2_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3Debug2IrqMask", PS3_REG_OFFSET_DEBUG2_IRQ_MASK, 1, PS3_TRUE}, + {"ps3Debug3", PS3_REG_OFFSET_DEBUG3, 1, PS3_TRUE}, + {"ps3Debug3IrqClear", PS3_REG_OFFSET_DEBUG3_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3Debug3IrqMask", PS3_REG_OFFSET_DEBUG3_IRQ_MASK, 1, PS3_TRUE}, + {"ps3Debug4", PS3_REG_OFFSET_DEBUG4, 1, PS3_TRUE}, + {"ps3Debug4IrqMask", PS3_REG_OFFSET_DEBUG4_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3Debug4IrqMask", PS3_REG_OFFSET_DEBUG4_IRQ_MASK, 1, PS3_TRUE}, + {"ps3Debug5", PS3_REG_OFFSET_DEBUG5, 1, PS3_TRUE}, + {"ps3Debug6", PS3_REG_OFFSET_DEBUG6, 1, PS3_TRUE}, + {"ps3Debug7", PS3_REG_OFFSET_DEBUG7, 1, PS3_TRUE}, + {"ps3Debug8", PS3_REG_OFFSET_DEBUG8, 1, PS3_TRUE}, + {"ps3Debug9", PS3_REG_OFFSET_DEBUG9, 1, PS3_TRUE}, + {"ps3Debug10", PS3_REG_OFFSET_DEBUG10, 1, PS3_TRUE}, + {"ps3Debug11", PS3_REG_OFFSET_DEBUG11, 1, PS3_TRUE}, + {"ps3Debug12", PS3_REG_OFFSET_DEBUG12, 1, PS3_TRUE}, + {"ps3SessioncmdAddr", PS3_REG_SESSION_ADDR, 1, PS3_TRUE}, + {"ps3SessioncmdAddrIrqClear", PS3_REG_SESSION_ADDR_IRQ_CLEAR, 1, PS3_TRUE}, + {"ps3SessioncmdAddrIrqMask", PS3_REG_SESSION_ADDR_IRQ_MASK, 1, PS3_TRUE}, }; static void ps3_cli_register_dump(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - unsigned short host_no = 0; - int ret = 0; + U16 host_no = 0; + S32 ret = 0; - buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { - ps3stor_cli_printf( - "malloc buf failed for register dump cli!\n"); + ps3stor_cli_printf("malloc buf failed for register dump cli!\n"); goto l_malloc_failed; } @@ -284,15 +307,14 @@ static void ps3_cli_register_dump(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse host_no for register dump cmd!\n"); + ps3stor_cli_printf("Can not parse host_no for register dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf( - "Invalid host_no %d for register dump cmd!\n", host_no); + ps3stor_cli_printf("Invalid host_no %d for register dump cmd!\n", + host_no); goto l_out; } @@ -316,12 +338,11 @@ static void ps3_cli_init_frame_dump(int argc, char *argv[]) struct ps3_instance *instance = NULL; struct ps3_cmd_context *cmd_context = NULL; struct PS3InitReqFrame *init_frame_msg = NULL; - unsigned short host_no = 0; - int ret = 0; + U16 host_no = 0; + S32 ret = 0; if (argc < 3) { - ps3stor_cli_printf( - "Too few args for init_frame_dump cli cmd!\n"); + ps3stor_cli_printf("Too few args for init_frame_dump cli cmd!\n"); goto l_out; } @@ -332,15 +353,13 @@ static void ps3_cli_init_frame_dump(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse host_no for init_frame_dump cmd!\n"); + ps3stor_cli_printf("Can not parse host_no for init_frame_dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf( - "Invalid host_no %d for init_frame_dump cmd!\n", + ps3stor_cli_printf("Invalid host_no %d for init_frame_dump cmd!\n", host_no); goto l_out; } @@ -355,7 +374,7 @@ static void ps3_cli_init_frame_dump(int argc, char *argv[]) ps3stor_cli_printf("init frame:\n"); ps3stor_cli_printf("reqHead.cmdType:\t%u\n", - init_frame_msg->reqHead.cmdType); + init_frame_msg->reqHead.cmdType); ps3stor_cli_printf("length:\t%u\n", init_frame_msg->length); ps3stor_cli_printf("operater:\t%u\n", init_frame_msg->operater); ps3stor_cli_printf("pageSize:\t%u\n", init_frame_msg->pageSize); @@ -363,30 +382,25 @@ static void ps3_cli_init_frame_dump(int argc, char *argv[]) ps3stor_cli_printf("msixVector:\t%u\n", init_frame_msg->msixVector); ps3stor_cli_printf("timeStamp:\t%llu\n", init_frame_msg->timeStamp); ps3stor_cli_printf("reqFrameBufBaseAddr:\t0x%llx\n", - init_frame_msg->reqFrameBufBaseAddr); + init_frame_msg->reqFrameBufBaseAddr); ps3stor_cli_printf("replyFifoDescBaseAddr:\t0x%llx\n", - init_frame_msg->replyFifoDescBaseAddr); + init_frame_msg->replyFifoDescBaseAddr); ps3stor_cli_printf("respFrameBaseAddr:\t0x%llx\n", - init_frame_msg->respFrameBaseAddr); - ps3stor_cli_printf("eventTypeMap:\t0x%08x\n", - init_frame_msg->eventTypeMap); - ps3stor_cli_printf("reqFrameMaxNum:\t%u\n", - init_frame_msg->reqFrameMaxNum); + init_frame_msg->respFrameBaseAddr); + ps3stor_cli_printf("eventTypeMap:\t0x%08x\n", init_frame_msg->eventTypeMap); + ps3stor_cli_printf("reqFrameMaxNum:\t%u\n", init_frame_msg->reqFrameMaxNum); ps3stor_cli_printf("respFrameMaxNum:\t%u\n", - init_frame_msg->respFrameMaxNum); + init_frame_msg->respFrameMaxNum); ps3stor_cli_printf("bufSizePerRespFrame:\t%u\n", - init_frame_msg->bufSizePerRespFrame); - ps3stor_cli_printf("hilMode:\t%u\n", init_frame_msg->hilMode); + init_frame_msg->bufSizePerRespFrame); + ps3stor_cli_printf("hilMode:\t%u\n", + init_frame_msg->hilMode); ps3stor_cli_printf("systemInfoBufAddr:\t0x%llx\n", - init_frame_msg->systemInfoBufAddr); - ps3stor_cli_printf("debugMemAddr:\t0x%llx\n", - init_frame_msg->debugMemArrayAddr); - ps3stor_cli_printf("debugMemSize:\t%u\n", - init_frame_msg->debugMemArrayNum); - ps3stor_cli_printf("filterTableAddr:\t0x%llx\n", - init_frame_msg->filterTableAddr); - ps3stor_cli_printf("filterTableLen:\t%u\n", - init_frame_msg->filterTableLen); + init_frame_msg->systemInfoBufAddr); + ps3stor_cli_printf("debugMemAddr:\t0x%llx\n", init_frame_msg->debugMemArrayAddr); + ps3stor_cli_printf("debugMemSize:\t%u\n", init_frame_msg->debugMemArrayNum); + ps3stor_cli_printf("filterTableAddr:\t0x%llx\n", init_frame_msg->filterTableAddr); + ps3stor_cli_printf("filterTableLen:\t%u\n", init_frame_msg->filterTableLen); ps3stor_cli_printf("respStatus:\t0x%08x\n", init_frame_msg->respStatus); @@ -394,10 +408,10 @@ static void ps3_cli_init_frame_dump(int argc, char *argv[]) return; } -static int ps3_register_offset_lookup(const char *reg_name_string, - unsigned int *reg_offset) +static S32 ps3_register_offset_lookup(const char *reg_name_string, + U32 *reg_offset) { - unsigned int idx = 0; + U32 idx = 0; struct ps3_reg_dump_desc *reg_desc = NULL; for (idx = 0; idx < ARRAY_SIZE(g_reg_table); idx++) { @@ -405,7 +419,7 @@ static int ps3_register_offset_lookup(const char *reg_name_string, if (reg_desc->reg_cnt != 1) { LOG_DEBUG("Reg %s is not a single register!\n", - reg_desc->reg_name); + reg_desc->reg_name); continue; } @@ -418,51 +432,49 @@ static int ps3_register_offset_lookup(const char *reg_name_string, return -PS3_FAILED; } -static void ps3_register_read_write(struct ps3_instance *instance, int argc, - char *argv[]) +static void ps3_register_read_write(struct ps3_instance *instance, + int argc, char *argv[]) { const char *reg_name_offset_string = argv[3]; const char *reg_loc_string = argv[4]; const char *state_ops_string = argv[5]; - unsigned int reg_value = 0; - unsigned int reg_offset = 0; - int ret = 0; - unsigned long long value; + U32 reg_value = 0; + U32 reg_offset = 0; + S32 ret = 0; + U64 value; - if (strcmp(reg_name_offset_string, "offset") == 0) + if (strcmp(reg_name_offset_string, "offset") == 0) { ret = kstrtouint(reg_loc_string, 0, ®_offset); - else + } else { ret = ps3_register_offset_lookup(reg_loc_string, ®_offset); + } if (ret != PS3_SUCCESS) { ps3stor_cli_printf("Reg %s not supported to read and write!\n", - reg_loc_string); + reg_loc_string); goto l_out; } if (strcmp(state_ops_string, "read") == 0) { - PS3_IOC_REG_READ_OFFSET_WITCH_CHECK(instance, reg_offset, - value); + PS3_IOC_REG_READ_OFFSET_WITCH_CHECK(instance, reg_offset, value); ps3stor_cli_printf("0x%llx\n", value); } else if (strcmp(state_ops_string, "write") == 0) { if (argc < 7) { ps3stor_cli_printf("No reg value for %s write cmd!\n", - reg_loc_string); + reg_loc_string); goto l_out; } ret = kstrtouint(argv[6], 0, ®_value); if (ret != 0) { - ps3stor_cli_printf( - "Invalid reg value for %s write cmd!\n", + ps3stor_cli_printf("Invalid reg value for %s write cmd!\n", reg_loc_string); goto l_out; } - PS3_IOC_REG_WRITE_OFFSET_WITH_CHECK(instance, reg_offset, - (unsigned long long)reg_value); + PS3_IOC_REG_WRITE_OFFSET_WITH_CHECK(instance, reg_offset, (U64)reg_value); ps3stor_cli_printf("Write 0x%x to %s!\n", reg_value, - reg_loc_string); + reg_loc_string); } else { ps3stor_cli_printf("Invalid ops for %s cmd!\n", reg_loc_string); } @@ -474,8 +486,8 @@ static void ps3_register_read_write(struct ps3_instance *instance, int argc, static void ps3_cli_register_rw(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - int ret = 0; + U16 host_no = 0; + S32 ret = 0; if (argc < 6) { ps3stor_cli_printf("Too few args for register cli cmd!\n"); @@ -489,15 +501,14 @@ static void ps3_cli_register_rw(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse host_no for register cli cmd!\n"); + ps3stor_cli_printf("Can not parse host_no for register cli cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { ps3stor_cli_printf("Invalid host_no %d for register cli cmd!\n", - host_no); + host_no); goto l_out; } @@ -510,112 +521,98 @@ ssize_t ps3_ioc_reg_dump(struct ps3_instance *instance, char *buf) { ssize_t len = 0; ssize_t total_len = PAGE_SIZE; - unsigned int idx = 0; - unsigned long long value = 0; + U32 idx = 0; + U64 value = 0; struct ps3_reg_dump_desc *reg_desc = NULL; for (idx = 0; idx < ARRAY_SIZE(g_reg_table); idx++) { reg_desc = &g_reg_table[idx]; #ifndef DRIVER_REGISTER_DEBUG_SIMULATOR - if (!reg_desc->is_readable) + if (!reg_desc->is_readable) { continue; + } #endif - if (reg_desc->reg_cnt > 1) + if (reg_desc->reg_cnt > 1) { continue; + } - PS3_IOC_REG_READ_OFFSET_WITCH_CHECK( - instance, reg_desc->reg_offset, value); + PS3_IOC_REG_READ_OFFSET_WITCH_CHECK(instance, reg_desc->reg_offset, value); len += snprintf(buf + len, total_len - len, "%s:\t0x%08llx\n", - reg_desc->reg_name, value); + reg_desc->reg_name, value); } return len; } -static void ps3_dev_mgr_print_vd(struct PS3VDEntry *p_entry, unsigned char is_detail) +static void ps3_dev_mgr_print_vd(struct PS3VDEntry *p_entry, Bool is_detail) { - unsigned char i = 0; - unsigned char j = 0; - - ps3stor_cli_printf( - "vd channel, id, virtDiskId: [%u:%u:%u], magicNum:%#x\n", + U8 i = 0; + U8 j = 0; + ps3stor_cli_printf("vd channel, id, virtDiskId: [%u:%u:%u], magicNum:%#x\n", PS3_CHANNEL(&p_entry->diskPos), PS3_TARGET(&p_entry->diskPos), PS3_VDID(&p_entry->diskPos), p_entry->diskPos.diskMagicNum); ps3stor_cli_printf("vd dev_type: PS3_DEV_TYPE_VD\n"); ps3stor_cli_printf("vd isHidden: %s\n", - (p_entry->isHidden) ? "true" : "false"); + (p_entry->isHidden) ? "true" : "false"); ps3stor_cli_printf("vd accessPolicy: %s\n", - ps3_get_vd_access_plolicy_str( - (enum VDAccessPolicy)p_entry->accessPolicy)); + ps3_get_vd_access_plolicy_str((VDAccessPolicy_e)p_entry->accessPolicy)); ps3stor_cli_printf("vd diskGrpId: %u\n", p_entry->diskGrpId); - if (!is_detail) + if (!is_detail) { return; + } ps3stor_cli_printf("vd sectorSize: %u\n", p_entry->sectorSize); - ps3stor_cli_printf("vd stripeDataSize: %u\n", - p_entry->stripeDataSize); + ps3stor_cli_printf("vd stripeDataSize: %u\n", p_entry->stripeDataSize); ps3stor_cli_printf("vd physDrvCnt: %u\n", p_entry->physDrvCnt); ps3stor_cli_printf("vd stripSize: %u\n", p_entry->stripSize); ps3stor_cli_printf("vd isDirectEnable: %s\n", - (p_entry->isDirectEnable) ? "true" : "false"); + (p_entry->isDirectEnable) ? "true" : "false"); ps3stor_cli_printf("vd isNvme: %s\n", - (p_entry->isNvme) ? "true" : "false"); + (p_entry->isNvme) ? "true" : "false"); ps3stor_cli_printf("vd isSsd: %s\n", - (p_entry->isSsd) ? "true" : "false"); + (p_entry->isSsd) ? "true" : "false"); ps3stor_cli_printf("vd isWriteDirectEnable: %s\n", - (p_entry->isWriteDirectEnable) ? "true" : "false"); + (p_entry->isWriteDirectEnable) ? "true" : "false"); ps3stor_cli_printf("vd raidLevel: %u\n", p_entry->raidLevel); ps3stor_cli_printf("vd spanCount: %u\n", p_entry->spanCount); ps3stor_cli_printf("vd diskState: %u\n", p_entry->diskState); ps3stor_cli_printf("vd startLBA: %llu\n", p_entry->startLBA); ps3stor_cli_printf("vd extentSize: %llu\n", p_entry->extentSize); - ps3stor_cli_printf("vd isTaskMgmtEnable: %u\n", - p_entry->isTaskMgmtEnable); - ps3stor_cli_printf("vd taskAbortTimeout: %u\n", - p_entry->taskAbortTimeout); - ps3stor_cli_printf("vd taskResetTimeout: %u\n", - p_entry->taskResetTimeout); + ps3stor_cli_printf("vd isTaskMgmtEnable: %u\n", p_entry->isTaskMgmtEnable); + ps3stor_cli_printf("vd taskAbortTimeout: %u\n", p_entry->taskAbortTimeout); + ps3stor_cli_printf("vd taskResetTimeout: %u\n", p_entry->taskResetTimeout); ps3stor_cli_printf("vd mapBlock: %llu\n", p_entry->mapBlock); ps3stor_cli_printf("vd mapBlockVer: %u\n", p_entry->mapBlockVer); ps3stor_cli_printf("vd maxIOSize: %u\n", p_entry->maxIOSize); ps3stor_cli_printf("vd devQueDepth: %u\n", p_entry->devQueDepth); - ps3stor_cli_printf("vd dmaAddrAlignShift: %u\n", - p_entry->dmaAddrAlignShift); - ps3stor_cli_printf("vd dmaLenAlignShift: %u\n", - p_entry->dmaLenAlignShift); + ps3stor_cli_printf("vd dmaAddrAlignShift: %u\n", p_entry->dmaAddrAlignShift); + ps3stor_cli_printf("vd dmaLenAlignShift: %u\n", p_entry->dmaLenAlignShift); ps3stor_cli_printf("vd capacity(sector): %llu\n", p_entry->capacity); ps3stor_cli_printf("vd bdev_bdi_cap: %u\n", p_entry->bdev_bdi_cap); ps3stor_cli_printf("vd umapBlkDescCnt: %u\n", p_entry->umapBlkDescCnt); ps3stor_cli_printf("vd umapNumblk: %u\n", p_entry->umapNumblk); ps3stor_cli_printf("vd virtDiskSeq: %llu\n", p_entry->virtDiskSeq); ps3stor_cli_printf("vd normalQuota:%u directQuota:%u\n", - p_entry->normalQuota, p_entry->directQuota); + p_entry->normalQuota, p_entry->directQuota); ps3stor_cli_printf("vd dev_busy_scale: %u\n", p_entry->dev_busy_scale); for (i = 0; i < p_entry->spanCount; i++) { ps3stor_cli_printf(" span[%u].spanStripeDataSize: %u\n", i, - p_entry->span[i].spanStripeDataSize); + p_entry->span[i].spanStripeDataSize); ps3stor_cli_printf(" span[%u].spanState: %u\n", i, - p_entry->span[i].spanState); + p_entry->span[i].spanState); ps3stor_cli_printf(" span[%u].spanPdNum: %u\n", i, - p_entry->span[i].spanPdNum); + p_entry->span[i].spanPdNum); for (j = 0; j < p_entry->span[i].spanPdNum; j++) { ps3stor_cli_printf( " span[%u].extent[%u] - member pd:[%u:%u:%u]\n", i, j, - p_entry->span[i] - .extent[j] - .phyDiskID.ps3Dev.softChan, - p_entry->span[i] - .extent[j] - .phyDiskID.ps3Dev.devID, - p_entry->span[i] - .extent[j] - .phyDiskID.ps3Dev.phyDiskID); - ps3stor_cli_printf( - " span[%u].extent[%u].state: %u\n", i, j, + p_entry->span[i].extent[j].phyDiskID.ps3Dev.softChan, + p_entry->span[i].extent[j].phyDiskID.ps3Dev.devID, + p_entry->span[i].extent[j].phyDiskID.ps3Dev.phyDiskID); + ps3stor_cli_printf(" span[%u].extent[%u].state: %u\n", i, j, p_entry->span[i].extent[j].state); } } @@ -623,101 +620,90 @@ static void ps3_dev_mgr_print_vd(struct PS3VDEntry *p_entry, unsigned char is_de static void ps3_dev_mgr_show_base_vd(struct ps3_instance *instance) { - unsigned short i = 0; - unsigned short j = 0; - unsigned char chan_id = 0; + U16 i = 0; + U16 j = 0; + U8 chan_id = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_channel *vd_chan = p_dev_ctx->channel_vd; - unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_table = &p_dev_ctx->vd_table[vd_table_idx]; + U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_table = + &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_entries = p_dev_ctx->vd_entries_array[vd_table_idx]; - unsigned short vd_idx = PS3_INVALID_DEV_ID; - unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; + U16 vd_idx = PS3_INVALID_DEV_ID; + U16 virtDiskIdx = PS3_INVALID_DEV_ID; - ps3stor_cli_printf( - "\n===========start print VD base information=========\n"); + ps3stor_cli_printf("\n===========start print VD base infomation=========\n"); for (i = 0; i < p_dev_ctx->vd_channel_count; i++) { chan_id = vd_chan[i].channel; for (j = 0; j < vd_chan[i].max_dev_num; j++) { vd_idx = p_table->vd_idxs[chan_id][j]; - virtDiskIdx = get_offset_of_vdid( - PS3_VDID_OFFSET(instance), vd_idx); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), vd_idx); if (vd_idx != PS3_INVALID_DEV_ID) { - ps3_dev_mgr_print_vd(&p_entries[virtDiskIdx], - PS3_FALSE); + ps3_dev_mgr_print_vd(&p_entries[virtDiskIdx], PS3_FALSE); } } } - ps3stor_cli_printf( - "\n============end print VD base information==========\n"); + ps3stor_cli_printf("\n============end print VD base infomation==========\n"); } -static void ps3_dev_mgr_print_pd(struct ps3_pd_entry *p_entry, unsigned char is_detail, - unsigned char is_raid) +static void ps3_dev_mgr_print_pd(struct ps3_pd_entry *p_entry, Bool is_detail, Bool is_raid) { - ps3stor_cli_printf( - "pd channel, id, pdFlatId: [%u:%u:%u], magicNum: %#x\n", + ps3stor_cli_printf("pd channel, id, pdFlatId: [%u:%u:%u], magicNum: %#x\n", PS3_CHANNEL(&p_entry->disk_pos), PS3_TARGET(&p_entry->disk_pos), PS3_PDID(&p_entry->disk_pos), p_entry->disk_pos.diskMagicNum); ps3stor_cli_printf("pd state: %s\n", - getDeviceStateName((enum DeviceState)p_entry->state)); + getDeviceStateName((DeviceState_e)p_entry->state)); ps3stor_cli_printf("pd dev_type: %s\n", - namePS3DevType((enum PS3DevType)p_entry->dev_type)); + namePS3DevType((enum PS3DevType)p_entry->dev_type)); ps3stor_cli_printf("pd config_flag: %s\n", - getPdStateName((enum MicPdState)p_entry->config_flag, - is_raid)); - ps3stor_cli_printf("pd pd_flags: 0x%02x\n", - p_entry->pd_flags); - ps3stor_cli_printf("pd support_ncq: %d\n", - p_entry->support_ncq); + getPdStateName((MicPdState_e)p_entry->config_flag, is_raid)); + ps3stor_cli_printf("pd pd_flags: 0x%02x\n", p_entry->pd_flags); + ps3stor_cli_printf("pd support_ncq: %d\n", p_entry->support_ncq); if (is_detail) { ps3stor_cli_printf("pd RWCT: %u\n", - p_entry->RWCT); + p_entry->RWCT); ps3stor_cli_printf("pd scsi_interface_type: %u\n", - p_entry->scsi_interface_type); + p_entry->scsi_interface_type); ps3stor_cli_printf("pd task_abort_timeout: %u\n", - p_entry->task_abort_timeout); + p_entry->task_abort_timeout); ps3stor_cli_printf("pd task_reset_timeout: %u\n", - p_entry->task_reset_timeout); + p_entry->task_reset_timeout); ps3stor_cli_printf("pd max_io_size: %u\n", - p_entry->max_io_size); + p_entry->max_io_size); ps3stor_cli_printf("pd is_direct_disable: %s\n", - (p_entry->is_direct_disable) ? "true" : - "false"); + (p_entry->is_direct_disable) ? "true" : "false"); ps3stor_cli_printf("pd dev_queue_depth: %u\n", - p_entry->dev_queue_depth); + p_entry->dev_queue_depth); ps3stor_cli_printf("pd sector_size: %u\n", - p_entry->sector_size); + p_entry->sector_size); ps3stor_cli_printf("pd encl_id: %u\n", - p_entry->encl_id); + p_entry->encl_id); ps3stor_cli_printf("pd phy_id: %u\n", - p_entry->phy_id); + p_entry->phy_id); ps3stor_cli_printf("pd dma_addr_alignment: %u\n", - p_entry->dma_addr_alignment); + p_entry->dma_addr_alignment); ps3stor_cli_printf("pd dma_len_alignment: %u\n", - p_entry->dma_len_alignment); + p_entry->dma_len_alignment); ps3stor_cli_printf("pd protect: %u\n", - p_entry->protect); + p_entry->protect); ps3stor_cli_printf("qos pd quota:normal[%u] direct[%u]\n", - p_entry->normal_quota, - p_entry->direct_quota); + p_entry->normal_quota, p_entry->direct_quota); } } static void ps3_dev_mgr_show_base_pd(struct ps3_instance *instance) { - unsigned short i = 0; - unsigned short j = 0; - unsigned char chan_id = 0; + U16 i = 0; + U16 j = 0; + U8 chan_id = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_channel *pd_chan = p_dev_ctx->channel_pd; struct ps3_pd_table *p_table = &p_dev_ctx->pd_table; - unsigned short pd_idx = PS3_INVALID_DEV_ID; + U16 pd_idx = PS3_INVALID_DEV_ID; - ps3stor_cli_printf( - "\n===========start print PD base information=========\n"); + ps3stor_cli_printf("\n===========start print PD base infomation=========\n"); for (i = 0; i < p_dev_ctx->pd_channel_count; i++) { chan_id = pd_chan[i].channel; for (j = 0; j < pd_chan[i].max_dev_num; j++) { @@ -729,14 +715,13 @@ static void ps3_dev_mgr_show_base_pd(struct ps3_instance *instance) } } } - ps3stor_cli_printf( - "\n============end print PD base information==========\n"); + ps3stor_cli_printf("\n============end print PD base infomation==========\n"); } static void ps3_cli_dev_mgr_cli_base_dump(int argc, char *argv[]) { - int ret = 0; - unsigned short host_no = 0; + S32 ret = 0; + U16 host_no = 0; struct ps3_instance *instance = NULL; if (argc < 3) { @@ -746,8 +731,7 @@ static void ps3_cli_dev_mgr_cli_base_dump(int argc, char *argv[]) ret = kstrtou16(argv[1], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse host_no \"%s\" for dmbi cmd!\n", + ps3stor_cli_printf("Can not parse host_no \"%s\" for dmbi cmd!\n", argv[1]); goto l_out; } @@ -755,7 +739,7 @@ static void ps3_cli_dev_mgr_cli_base_dump(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { ps3stor_cli_printf("Invalid host_no %d for dmbi cmd!\n", - host_no); + host_no); goto l_out; } @@ -771,78 +755,72 @@ static void ps3_cli_dev_mgr_cli_base_dump(int argc, char *argv[]) goto l_out; } else { ps3stor_cli_printf("Invalid subtype \"%s\" for dmbi cmd!\n", - argv[2]); + argv[2]); } l_out: return; } static void ps3_dev_mgr_show_detail_info(struct ps3_instance *instance, - unsigned short channel, unsigned short id) + U16 channel, U16 id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_pd_table *p_pd_table = &p_dev_ctx->pd_table; - unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_vd_table = &p_dev_ctx->vd_table[vd_table_idx]; + U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_vd_table = + &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; - unsigned short disk_idx = 0; - unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; + U16 disk_idx = 0; + U16 virtDiskIdx = PS3_INVALID_DEV_ID; if (PS3_IS_VD_CHANNEL(instance, channel)) { if (p_vd_table->vd_idxs[channel] == NULL) { - ps3stor_cli_printf( - "==error==invalid channel parameter: %d\n", + ps3stor_cli_printf("==error==invalid channel parameter: %d\n", channel); goto l_out; } if (id >= p_dev_ctx->max_dev_in_channel[channel]) { - ps3stor_cli_printf( - "==error==invalid id parameter: %d\n", id); + ps3stor_cli_printf("==error==invalid id parameter: %d\n", + id); goto l_out; } disk_idx = p_vd_table->vd_idxs[channel][id]; - virtDiskIdx = - get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_idx); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_idx); if (virtDiskIdx == PS3_INVALID_DEV_ID) { ps3stor_cli_printf("==warn==vd is not exist: [%u:%u]\n", - channel, id); + channel, id); goto l_out; } - ps3stor_cli_printf( - "\n===========start print VD detail information=========\n"); + ps3stor_cli_printf("\n===========start print VD detail infomation=========\n"); ps3_dev_mgr_print_vd(&p_vd_array[virtDiskIdx], PS3_DRV_TRUE); - ps3stor_cli_printf( - "\n============end print VD detail information==========\n"); + ps3stor_cli_printf("\n============end print VD detail infomation==========\n"); } else { if (p_pd_table->pd_idxs[channel] == NULL) { - ps3stor_cli_printf( - "==error==invalid channel parameter: %d\n", + ps3stor_cli_printf("==error==invalid channel parameter: %d\n", channel); goto l_out; } if (id >= p_dev_ctx->max_dev_in_channel[channel]) { - ps3stor_cli_printf( - "==error==invalid id parameter: %d\n", id); + ps3stor_cli_printf("==error==invalid id parameter: %d\n", + id); goto l_out; } disk_idx = p_pd_table->pd_idxs[channel][id]; if (disk_idx == PS3_INVALID_DEV_ID) { ps3stor_cli_printf("==warn==pd is not exist: [%u:%u]\n", - channel, id); + channel, id); goto l_out; } - ps3stor_cli_printf( - "\n===========start print PD detail information=========\n"); + ps3stor_cli_printf("\n===========start print PD detail infomation=========\n"); ps3_dev_mgr_print_pd(&p_dev_ctx->pd_entries_array[disk_idx], - PS3_DRV_TRUE, instance->is_raid); - ps3stor_cli_printf( - "\n============end print PD detail information==========\n"); + PS3_DRV_TRUE, instance->is_raid); + ps3stor_cli_printf("\n============end print PD detail infomation==========\n"); } l_out: return; @@ -850,10 +828,10 @@ static void ps3_dev_mgr_show_detail_info(struct ps3_instance *instance, static void ps3_cli_dev_mgr_cli_detail_dump(int argc, char *argv[]) { - int ret = 0; - unsigned short host_no = 0; - unsigned short channel = 0; - unsigned short id = 0; + S32 ret = 0; + U16 host_no = 0; + U16 channel = 0; + U16 id = 0; struct ps3_instance *instance = NULL; if (argc < 4) { @@ -863,8 +841,7 @@ static void ps3_cli_dev_mgr_cli_detail_dump(int argc, char *argv[]) ret = kstrtou16(argv[1], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse host_no \"%s\" for dmdi cmd!\n", + ps3stor_cli_printf("Can not parse host_no \"%s\" for dmdi cmd!\n", argv[1]); goto l_out; } @@ -872,21 +849,20 @@ static void ps3_cli_dev_mgr_cli_detail_dump(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { ps3stor_cli_printf("Invalid host_no %d for dmdi cmd!\n", - host_no); + host_no); goto l_out; } ret = kstrtou16(argv[2], 0, &channel); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse chanel \"%s\" for dmdi cmd!\n", argv[2]); + ps3stor_cli_printf("Can not parse chanel \"%s\" for dmdi cmd!\n", + argv[2]); goto l_out; } ret = kstrtou16(argv[3], 0, &id); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse targetId \"%s\" for dmdi cmd!\n", + ps3stor_cli_printf("Can not parse targetId \"%s\" for dmdi cmd!\n", argv[3]); goto l_out; } @@ -900,19 +876,17 @@ static void ps3_cli_event_subscirbe_info_dump(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - unsigned short host_no = 0; - int ret = 0; + U16 host_no = 0; + S32 ret = 0; - buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { - ps3stor_cli_printf( - "malloc buf failed for event subscribe info cli!\n"); + ps3stor_cli_printf("malloc buf failed for event subscribe info cli!\n"); goto l_malloc_failed; } if (argc < 3) { - ps3stor_cli_printf( - "Too few args for event_subscribe_dump cli cmd!\n"); + ps3stor_cli_printf("Too few args for event_subscribe_dump cli cmd!\n"); goto l_out; } @@ -923,15 +897,13 @@ static void ps3_cli_event_subscirbe_info_dump(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse host_no for event_subscribe_dump cmd!\n"); + ps3stor_cli_printf("Can not parse host_no for event_subscribe_dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf( - "Invalid host_no %d for event_subscribe_dump cmd!\n", + ps3stor_cli_printf("Invalid host_no %d for event_subscribe_dump cmd!\n", host_no); goto l_out; } @@ -948,13 +920,12 @@ static void ps3_cli_event_subscirbe_info_dump(int argc, char *argv[]) static void ps3_cli_event_delay_set(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - unsigned int delay_seconds = 0; - int ret = 0; + U16 host_no = 0; + U32 delay_seconds = 0; + S32 ret = 0; if (argc < 3) { - ps3stor_cli_printf( - "Too few args for event_subscribe_dump cli cmd!\n"); + ps3stor_cli_printf("Too few args for event_subscribe_dump cli cmd!\n"); goto l_out; } @@ -965,15 +936,13 @@ static void ps3_cli_event_delay_set(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse host_no for event_subscribe_dump cmd!\n"); + ps3stor_cli_printf("Can not parse host_no for event_subscribe_dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf( - "Invalid host_no %d for event_subscribe_dump cmd!\n", + ps3stor_cli_printf("Invalid host_no %d for event_subscribe_dump cmd!\n", host_no); goto l_out; } @@ -981,18 +950,15 @@ static void ps3_cli_event_delay_set(int argc, char *argv[]) if (strcmp(argv[3], "delay") == 0) { ret = kstrtouint(argv[4], 0, &delay_seconds); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse delay seconds for event delay cmd!\n"); + ps3stor_cli_printf("Can not parse delay seconds for event delay cmd!\n"); goto l_out; } ret = ps3_event_delay_set(instance, delay_seconds); if (ret != 0) { - ps3stor_cli_printf( - "Unable to config event delay ret %d\n", ret); + ps3stor_cli_printf("Unable to config event delay ret %d\n", ret); goto l_out; } else { - ps3stor_cli_printf("Config event delay %d success\n", - delay_seconds); + ps3stor_cli_printf("Config event delay %d success\n", delay_seconds); } } @@ -1003,9 +969,9 @@ static void ps3_cli_event_delay_set(int argc, char *argv[]) static void ps3_cli_crashdump_set(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - unsigned int delay_seconds = 0; - int ret = 0; + U16 host_no = 0; + U32 delay_seconds = 0; + S32 ret = 0; if (argc < 3) { ps3stor_cli_printf("Too few args for crashdump cli cmd!\n"); @@ -1019,15 +985,13 @@ static void ps3_cli_crashdump_set(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse host_no for event_subscribe_dump cmd!\n"); + ps3stor_cli_printf("Can not parse host_no for event_subscribe_dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf( - "Invalid host_no %d for event_subscribe_dump cmd!\n", + ps3stor_cli_printf("Invalid host_no %d for event_subscribe_dump cmd!\n", host_no); goto l_out; } @@ -1035,8 +999,7 @@ static void ps3_cli_crashdump_set(int argc, char *argv[]) if (strcmp(argv[3], "wait") == 0) { ret = kstrtouint(argv[4], 0, &delay_seconds); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse delay seconds for event delay cmd!\n"); + ps3stor_cli_printf("Can not parse delay seconds for event delay cmd!\n"); goto l_out; } @@ -1049,65 +1012,42 @@ static void ps3_cli_crashdump_set(int argc, char *argv[]) } instance->dump_context.dump_dma_wait_times = delay_seconds; - ps3stor_cli_printf("set crashdump dma wait times %d success\n", - delay_seconds); + ps3stor_cli_printf("set crashdump dma wait times %d success\n", delay_seconds); } l_out: return; } -int ps3_dump_context_show(const char *prefix, struct ps3_instance *instance) +S32 ps3_dump_context_show(const char *prefix, struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_dump_context *ctxt = &instance->dump_context; - ps3stor_cli_printf("%sdump_type : %d\n", prefix, - ctxt->dump_type); - ps3stor_cli_printf("%sdump_state : %d\n", prefix, - ctxt->dump_state); - ps3stor_cli_printf("%sdump_work_status : %d\n", prefix, - ctxt->dump_work_status); - ps3stor_cli_printf("%sdump_env : %d\n", prefix, - ctxt->dump_env); - ps3stor_cli_printf("%sdump_dma_vaddr : %p\n", prefix, - ctxt->dump_dma_buf); - ps3stor_cli_printf("%sdump_dma_paddr : %llx\n", prefix, - ctxt->dump_dma_addr); - ps3stor_cli_printf("%sdump_dma_buff_size : %#x\n", prefix, - PS3_DUMP_DMA_BUF_SIZE); - ps3stor_cli_printf("%sdump_dma_wait_times : %#x\n", prefix, - ctxt->dump_dma_wait_times); - ps3stor_cli_printf("%sdump_data_size : %llu\n", prefix, - ctxt->dump_data_size); - ps3stor_cli_printf("%sdump_data_size_copyed: %llu\n", prefix, - ctxt->copyed_data_size); - ps3stor_cli_printf("%sdump_dir : %s\n", prefix, - ctxt->dump_dir); - ps3stor_cli_printf("%sdump_file : %s\n", prefix, - ctxt->dump_out_file.filename); - ps3stor_cli_printf("%sdump_file_type : %d\n", prefix, - ctxt->dump_out_file.type); - ps3stor_cli_printf("%sdump_file_size : %llu\n", prefix, - ctxt->dump_out_file.file_size); - ps3stor_cli_printf("%sdump_file_write_cnt : %llu\n", prefix, - ctxt->dump_out_file.file_w_cnt); - ps3stor_cli_printf("%sdump_file_status : %d\n", prefix, - ctxt->dump_out_file.file_status); - ps3stor_cli_printf("%sdump_file_fp : %p\n", prefix, - ctxt->dump_out_file.fp); + ps3stor_cli_printf("%sdump_type : %d \n", prefix, ctxt->dump_type); + ps3stor_cli_printf("%sdump_state : %d \n", prefix,ctxt->dump_state); + ps3stor_cli_printf("%sdump_work_status : %d \n", prefix,ctxt->dump_work_status); + ps3stor_cli_printf("%sdump_env : %d \n", prefix,ctxt->dump_env); + ps3stor_cli_printf("%sdump_dma_vaddr : %p \n", prefix, ctxt->dump_dma_buf); + ps3stor_cli_printf("%sdump_dma_paddr : %llx \n", prefix, ctxt->dump_dma_addr); + ps3stor_cli_printf("%sdump_dma_buff_size : %#x \n", prefix, PS3_DUMP_DMA_BUF_SIZE); + ps3stor_cli_printf("%sdump_dma_wait_times : %#x \n", prefix, ctxt->dump_dma_wait_times); + ps3stor_cli_printf("%sdump_data_size : %llu \n", prefix,ctxt->dump_data_size); + ps3stor_cli_printf("%sdump_data_size_copyed: %llu \n", prefix, ctxt->copyed_data_size); + ps3stor_cli_printf("%sdump_dir : %s \n", prefix,ctxt->dump_dir); + ps3stor_cli_printf("%sdump_file : %s \n", prefix,ctxt->dump_out_file.filename); + ps3stor_cli_printf("%sdump_file_type : %d \n", prefix,ctxt->dump_out_file.type); + ps3stor_cli_printf("%sdump_file_size : %llu\n", prefix,ctxt->dump_out_file.file_size); + ps3stor_cli_printf("%sdump_file_write_cnt : %llu\n", prefix,ctxt->dump_out_file.file_w_cnt); + ps3stor_cli_printf("%sdump_file_status : %d\n", prefix,ctxt->dump_out_file.file_status); + ps3stor_cli_printf("%sdump_file_fp : %p\n", prefix,ctxt->dump_out_file.fp); if (ctxt->dump_pending_cmd) { - ps3stor_cli_printf( - "%sdump_pending_cmd : [trace_id:0x%llx][CFID:%d]\n", - prefix, ctxt->dump_pending_cmd->trace_id, - ctxt->dump_pending_cmd->cmd_word.cmdFrameID); - } - ps3stor_cli_printf("%sdump_notify_reg_times: %d\n", prefix, - ctxt->dump_pending_send_times); - ps3stor_cli_printf("%sdump_type_times : %d\n", prefix, - ctxt->dump_type_times); - ps3stor_cli_printf("%sdump_state_times : %d\n", prefix, - ctxt->dump_state_times); + ps3stor_cli_printf("%sdump_pending_cmd : [trace_id:0x%llx][CFID:%d]\n", prefix, + ctxt->dump_pending_cmd->trace_id, ctxt->dump_pending_cmd->cmd_word.cmdFrameID); + } + ps3stor_cli_printf("%sdump_notify_reg_times: %d\n", prefix,ctxt->dump_pending_send_times); + ps3stor_cli_printf("%sdump_type_times : %d\n", prefix,ctxt->dump_type_times); + ps3stor_cli_printf("%sdump_state_times : %d\n", prefix,ctxt->dump_state_times); return ret; } @@ -1117,15 +1057,12 @@ static void ps3_host_info_detail_dump(void) struct ps3_instance *instance = NULL; struct list_head *pitem = NULL; struct Scsi_Host *phost = NULL; - list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { instance = list_entry(pitem, struct ps3_instance, list_item); phost = instance->host; - ps3stor_cli_printf("host_no:%d scsi_host detail info\n", - phost->host_no); + ps3stor_cli_printf("host_no:%d scsi_host detail info\n", phost->host_no); ps3stor_cli_printf(" host_failed %d\n", phost->host_failed); - ps3stor_cli_printf(" host_eh_scheduled %d\n", - phost->host_eh_scheduled); + ps3stor_cli_printf(" host_eh_scheduled %d\n", phost->host_eh_scheduled); ps3stor_cli_printf(" host_no %d\n", phost->host_no); ps3stor_cli_printf(" eh_deadline %d\n", phost->eh_deadline); ps3stor_cli_printf(" last_reset %ul\n", phost->last_reset); @@ -1136,15 +1073,13 @@ static void ps3_host_info_detail_dump(void) ps3stor_cli_printf(" max_cmd_len %d\n", phost->max_cmd_len); ps3stor_cli_printf(" can_queue %d\n", phost->can_queue); ps3stor_cli_printf(" cmd_per_lun %d\n", phost->cmd_per_lun); - ps3stor_cli_printf(" sg_tablesize %d\n", - phost->sg_tablesize); - ps3stor_cli_printf(" sg_prot_tablesize %d\n", - phost->sg_prot_tablesize); + ps3stor_cli_printf(" sg_tablesize %d\n", phost->sg_tablesize); + ps3stor_cli_printf(" sg_prot_tablesize %d\n", phost->sg_prot_tablesize); ps3stor_cli_printf(" max_sectors %d\n", phost->max_sectors); - ps3stor_cli_printf(" dma_boundary 0x%x\n", - phost->dma_boundary); + ps3stor_cli_printf(" dma_boundary 0x%x\n", phost->dma_boundary); - switch (phost->shost_state) { + switch (phost->shost_state) + { case SHOST_CREATED: ps3stor_cli_printf(" shost_state SHOST_CREATED\n"); break; @@ -1161,12 +1096,10 @@ static void ps3_host_info_detail_dump(void) ps3stor_cli_printf(" shost_state SHOST_RECOVERY\n"); break; case SHOST_CANCEL_RECOVERY: - ps3stor_cli_printf( - " shost_state SHOST_CANCEL_RECOVERY\n"); + ps3stor_cli_printf(" shost_state SHOST_CANCEL_RECOVERY\n"); break; case SHOST_DEL_RECOVERY: - ps3stor_cli_printf( - " shost_state SHOST_DEL_RECOVERY\n"); + ps3stor_cli_printf(" shost_state SHOST_DEL_RECOVERY\n"); break; default: break; @@ -1176,115 +1109,109 @@ static void ps3_host_info_detail_dump(void) } static void ps3_cmd_context_detail_dump(const char *format_space, - struct ps3_cmd_context *cmd_context) -{ - unsigned int i = 0; - - ps3stor_cli_printf("%smax_cmd_count:%d\n", format_space, - cmd_context->max_cmd_count); - ps3stor_cli_printf("%smax_scsi_cmd_count:%d\n", format_space, - cmd_context->max_scsi_cmd_count); - ps3stor_cli_printf("%smax_mgr_cmd_count:%d\n", format_space, - cmd_context->max_mgr_cmd_count); - ps3stor_cli_printf("%sreq_frame_buf_phys:0x%llx\n", format_space, - cmd_context->req_frame_buf_phys); - ps3stor_cli_printf("%sresponse_frame_buf_phys:0x%llx\n", format_space, - cmd_context->response_frame_buf_phys); - ps3stor_cli_printf("%sinit_frame_buf_phys:0x%llx\n", format_space, - cmd_context->init_frame_buf_phys); - ps3stor_cli_printf("%sinit_frame_sys_info_phys:0x%llx\n", format_space, - cmd_context->init_frame_sys_info_phys); - ps3stor_cli_printf("%s sgl_mode_support: %u\n", format_space, - cmd_context->sgl_mode_support); - - if (cmd_context->cmd_buf == NULL) + struct ps3_cmd_context *cmd_context) +{ + U32 i = 0; + ps3stor_cli_printf("%smax_cmd_count:%d\n", + format_space, cmd_context->max_cmd_count); + ps3stor_cli_printf("%smax_scsi_cmd_count:%d\n", + format_space, cmd_context->max_scsi_cmd_count); + ps3stor_cli_printf("%smax_mgr_cmd_count:%d\n", + format_space, cmd_context->max_mgr_cmd_count); + ps3stor_cli_printf("%sreq_frame_buf_phys:0x%llx\n", + format_space, cmd_context->req_frame_buf_phys); + ps3stor_cli_printf("%sresponse_frame_buf_phys:0x%llx\n", + format_space, cmd_context->response_frame_buf_phys); + ps3stor_cli_printf("%sinit_frame_buf_phys:0x%llx\n", + format_space, cmd_context->init_frame_buf_phys); + ps3stor_cli_printf("%sinit_frame_sys_info_phys:0x%llx\n", + format_space, cmd_context->init_frame_sys_info_phys); + ps3stor_cli_printf("%s sgl_mode_support: %u\n", + format_space, cmd_context->sgl_mode_support); + + if (cmd_context->cmd_buf == NULL) { goto l_out; + } for (i = cmd_context->max_scsi_cmd_count; - i < cmd_context->max_cmd_count; i++) { - if (cmd_context->cmd_buf[i]->cmd_state.state == - PS3_CMD_STATE_INIT) { + i < cmd_context->max_cmd_count; i++) { + if (cmd_context->cmd_buf[i]->cmd_state.state == PS3_CMD_STATE_INIT) { continue; } - ps3stor_cli_printf( - "%s pending cmd mgr : [trace_id:0x%llx][CFID:%d][type:%d][isrSN:%d][%s]\n", - format_space, cmd_context->cmd_buf[i]->trace_id, + ps3stor_cli_printf("%s pending cmd mgr : [trace_id:0x%llx][CFID:%d][type:%d]" + "[isrSN:%d][%s]\n", + format_space, + cmd_context->cmd_buf[i]->trace_id, cmd_context->cmd_buf[i]->cmd_word.cmdFrameID, cmd_context->cmd_buf[i]->cmd_word.type, cmd_context->cmd_buf[i]->cmd_word.isrSN, - namePS3CmdState( - cmd_context->cmd_buf[i]->cmd_state.state)); + namePS3CmdState(cmd_context->cmd_buf[i]->cmd_state.state)); } for (i = 0; i < cmd_context->max_scsi_cmd_count; i++) { - if (cmd_context->cmd_buf[i]->cmd_state.state == - PS3_CMD_STATE_INIT) { + if (cmd_context->cmd_buf[i]->cmd_state.state == PS3_CMD_STATE_INIT) { continue; } - ps3stor_cli_printf( - "%s pending cmd scsi: [trace_id:0x%llx][CFID:%d][type:%d][isrSN:%d][%s]\n", - format_space, cmd_context->cmd_buf[i]->trace_id, + ps3stor_cli_printf("%s pending cmd scsi: [trace_id:0x%llx][CFID:%d][type:%d]" + "[isrSN:%d][%s]\n", + format_space, + cmd_context->cmd_buf[i]->trace_id, cmd_context->cmd_buf[i]->cmd_word.cmdFrameID, cmd_context->cmd_buf[i]->cmd_word.type, cmd_context->cmd_buf[i]->cmd_word.isrSN, - namePS3CmdState( - cmd_context->cmd_buf[i]->cmd_state.state)); + namePS3CmdState(cmd_context->cmd_buf[i]->cmd_state.state)); } l_out: ps3stor_cli_printf("\n"); } static void ps3_irq_context_detail_dump(const char *format_space, - struct ps3_irq_context *irq_context) -{ - unsigned int i = 0; - - ps3stor_cli_printf("%sreply_fifo_depth:%d\n", format_space, - irq_context->reply_fifo_depth); - ps3stor_cli_printf("%svalid_msix_vector_count:%d\n", format_space, - irq_context->valid_msix_vector_count); - ps3stor_cli_printf("%shigh_iops_msix_vectors:%d\n", format_space, - irq_context->high_iops_msix_vectors); - ps3stor_cli_printf("%sreply_fifo_desc_buf_phys:0x%llx\n", format_space, - irq_context->reply_fifo_desc_buf_phys); + struct ps3_irq_context *irq_context) +{ + U32 i = 0; + + ps3stor_cli_printf("%sreply_fifo_depth:%d\n", + format_space, irq_context->reply_fifo_depth); + ps3stor_cli_printf("%svalid_msix_vector_count:%d\n", + format_space, irq_context->valid_msix_vector_count); + ps3stor_cli_printf("%shigh_iops_msix_vectors:%d\n", + format_space, irq_context->high_iops_msix_vectors); + ps3stor_cli_printf("%sreply_fifo_desc_buf_phys:0x%llx\n", + format_space, irq_context->reply_fifo_desc_buf_phys); for (i = 0; i < irq_context->valid_msix_vector_count; i++) { - ps3stor_cli_printf( - "%sreply_fifo_phys_base_addr_buf[%d]:0x%llx\n", + ps3stor_cli_printf("%sreply_fifo_phys_base_addr_buf[%d]:0x%llx\n", format_space, i, irq_context->reply_fifo_phys_base_addr_buf[i]); } - for (i = 0; (int)i < irq_context->cpu_msix_table_sz - 1; i++) { - if (irq_context->cpu_msix_table == NULL) + for (i = 0; (S32)i < irq_context->cpu_msix_table_sz - 1; i++) { + if (irq_context->cpu_msix_table == NULL) { break; + } ps3stor_cli_printf("%scpu_msix_table[%d]:0x%llx\n", - format_space, i, - irq_context->cpu_msix_table[i]); - } - - ps3stor_cli_printf("%shigh_iops_io_count:%d\n", format_space, - irq_context->high_iops_io_count.counter); - ps3stor_cli_printf("%sis_enable_interrupts:%s\n", format_space, - irq_context->is_enable_interrupts ? "PS3_TRUE" : - "PS3_FALSE"); - ps3stor_cli_printf("%sis_support_balance:%s\n", format_space, - irq_context->is_support_balance ? "PS3_TRUE" : - "PS3_FALSE"); - ps3stor_cli_printf("%sis_balance_current_perf_mode:%s\n", format_space, - irq_context->is_balance_current_perf_mode ? - "PS3_TRUE" : - "PS3_FALSE"); + format_space, i, irq_context->cpu_msix_table[i]); + } + + ps3stor_cli_printf("%shigh_iops_io_count:%d\n", + format_space, irq_context->high_iops_io_count.counter); + ps3stor_cli_printf("%sis_enable_interrupts:%s\n", + format_space, + irq_context->is_enable_interrupts ? "PS3_TRUE" : "PS3_FALSE"); + ps3stor_cli_printf("%sis_support_balance:%s\n", + format_space, + irq_context->is_support_balance ? "PS3_TRUE" : "PS3_FALSE"); + ps3stor_cli_printf("%sis_balance_current_perf_mode:%s\n", + format_space, + irq_context->is_balance_current_perf_mode ? + "PS3_TRUE" : "PS3_FALSE"); switch (irq_context->pci_irq_type) { case PS3_PCI_IRQ_LEGACY: - ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_LEGACY\n", - format_space); - break; + ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_LEGACY\n", format_space); + break; case PS3_PCI_IRQ_MSI: - ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_MSI\n", - format_space); - break; + ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_MSI\n", format_space); + break; case PS3_PCI_IRQ_MSIX: - ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_MSIX\n", - format_space); - break; + ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_MSIX\n", format_space); + break; default: break; } @@ -1292,147 +1219,135 @@ static void ps3_irq_context_detail_dump(const char *format_space, } static void ps3_dev_context_detail_dump(const char *format_space, - struct ps3_dev_context *dev_context) -{ - ps3stor_cli_printf("%svd_table_idx:%d\n", format_space, - dev_context->vd_table_idx); - ps3stor_cli_printf("%spd_channel_count:%d\n", format_space, - dev_context->pd_channel_count); - ps3stor_cli_printf("%svd_channel_count:%d\n", format_space, - dev_context->vd_channel_count); - ps3stor_cli_printf("%stotal_vd_count:%d\n", format_space, - dev_context->total_vd_count); - ps3stor_cli_printf("%stotal_pd_count:%d\n", format_space, - dev_context->total_pd_count); - ps3stor_cli_printf("%smax_dev_per_channel:%d\n", format_space, - dev_context->max_dev_per_channel); - ps3stor_cli_printf("%spd_list_buf_phys:0x%llx\n", format_space, - dev_context->pd_list_buf_phys); - ps3stor_cli_printf("%svd_list_buf_phys:0x%llx\n", format_space, - dev_context->vd_list_buf_phys); - ps3stor_cli_printf("%spd_info_buf_phys:0x%llx\n", format_space, - dev_context->pd_info_buf_phys); - ps3stor_cli_printf("%svd_info_buf_phys_sync:0x%llx\n", format_space, - dev_context->vd_info_buf_phys_sync); - ps3stor_cli_printf("%svd_info_buf_phys_async:0x%llx\n", format_space, - dev_context->vd_info_buf_phys_async); + struct ps3_dev_context *dev_context) +{ + ps3stor_cli_printf("%svd_table_idx:%d\n", format_space, dev_context->vd_table_idx); + ps3stor_cli_printf("%spd_channel_count:%d\n", + format_space, dev_context->pd_channel_count); + ps3stor_cli_printf("%svd_channel_count:%d\n", + format_space, dev_context->vd_channel_count); + ps3stor_cli_printf("%stotal_vd_count:%d\n", + format_space, dev_context->total_vd_count); + ps3stor_cli_printf("%stotal_pd_count:%d\n", + format_space, dev_context->total_pd_count); + ps3stor_cli_printf("%smax_dev_per_channel:%d\n", + format_space, dev_context->max_dev_per_channel); + ps3stor_cli_printf("%spd_list_buf_phys:0x%llx\n", + format_space, dev_context->pd_list_buf_phys); + ps3stor_cli_printf("%svd_list_buf_phys:0x%llx\n", + format_space, dev_context->vd_list_buf_phys); + ps3stor_cli_printf("%spd_info_buf_phys:0x%llx\n", + format_space, dev_context->pd_info_buf_phys); + ps3stor_cli_printf("%svd_info_buf_phys_sync:0x%llx\n", + format_space, dev_context->vd_info_buf_phys_sync); + ps3stor_cli_printf("%svd_info_buf_phys_async:0x%llx\n", + format_space, dev_context->vd_info_buf_phys_async); ps3stor_cli_printf("\n"); } -static void -ps3_event_context_detail_dump(const char *format_space, - struct ps3_event_context *event_context) +static void ps3_event_context_detail_dump(const char *format_space, + struct ps3_event_context *event_context) { if (event_context->delay_work) { - ps3stor_cli_printf("%sevent_delay:%d\n", format_space, - event_context->delay_work->event_delay); + ps3stor_cli_printf("%sevent_delay:%d\n", + format_space, event_context->delay_work->event_delay); } ps3stor_cli_printf("\n"); } -static void -ps3_fault_context_detail_dump(const char *format_space, - struct ps3_fault_context *fault_context) +static void ps3_fault_context_detail_dump(const char *format_space, + struct ps3_fault_context *fault_context) { - ps3stor_cli_printf("%sioc_busy:%d\n", format_space, - fault_context->ioc_busy); - ps3stor_cli_printf("%slast_time:%d\n", format_space, - fault_context->last_time); + ps3stor_cli_printf("%sioc_busy:%d\n", + format_space, fault_context->ioc_busy); + ps3stor_cli_printf("%slast_time:%d\n", + format_space, fault_context->last_time); ps3stor_cli_printf("\n"); } static void ps3_ioc_ctrl_info_detail_dump(const char *format_space, - struct PS3IocCtrlInfo *ctrl_info) + struct PS3IocCtrlInfo *ctrl_info) { size_t i = 0; - - ps3stor_cli_printf("%smaxVdCount:%d\n", format_space, - ctrl_info->maxVdCount); - ps3stor_cli_printf("%smaxPdCount:%d\n", format_space, - ctrl_info->maxPdCount); - ps3stor_cli_printf("%smaxSectors:%d\n", format_space, - ctrl_info->maxSectors); - ps3stor_cli_printf("%sPS3IocCtrlProp.enableSnapshot:%s\n", format_space, - ctrl_info->properties.enableSnapshot ? "PS3_TRUE" : - "PS3_FALSE"); + ps3stor_cli_printf("%smaxVdCount:%d\n", + format_space, ctrl_info->maxVdCount); + ps3stor_cli_printf("%smaxPdCount:%d\n", + format_space, ctrl_info->maxPdCount); + ps3stor_cli_printf("%smaxSectors:%d\n", + format_space, ctrl_info->maxSectors); + ps3stor_cli_printf("%sPS3IocCtrlProp.enableSnapshot:%s\n", + format_space, + ctrl_info->properties.enableSnapshot ? "PS3_TRUE" : "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlProp.enableSoftReset:%s\n", - format_space, - ctrl_info->properties.enableSoftReset ? "PS3_TRUE" : - "PS3_FALSE"); + format_space, + ctrl_info->properties.enableSoftReset ? + "PS3_TRUE" : "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportUnevenSpans:%s\n", - format_space, - ctrl_info->capabilities.supportUnevenSpans ? - "PS3_TRUE" : - "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportUnevenSpans ? + "PS3_TRUE" : "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportJbodSecure:%s\n", - format_space, - ctrl_info->capabilities.supportJbodSecure ? - "PS3_TRUE" : - "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportJbodSecure ? + "PS3_TRUE" : "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportNvmePassthru:%s\n", - format_space, - ctrl_info->capabilities.supportNvmePassthru ? - "PS3_TRUE" : - "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportNvmePassthru ? + "PS3_TRUE" : "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportDirectCmd:%s\n", - format_space, - ctrl_info->capabilities.supportDirectCmd ? - "PS3_TRUE" : - "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportDirectCmd ? + "PS3_TRUE" : "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportSataDirectCmd:%s\n", - format_space, - ctrl_info->capabilities.supportSataDirectCmd ? - "PS3_TRUE" : - "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportSataDirectCmd ? + "PS3_TRUE" : "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportSataNcq:%s\n", - format_space, - ctrl_info->capabilities.supportSataNcq ? - "PS3_TRUE" : - "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportSataNcq ? + "PS3_TRUE" : "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportAcceleration:%s\n", - format_space, - ctrl_info->capabilities.supportAcceleration ? - "PS3_TRUE" : - "PS3_FALSE"); - ps3stor_cli_printf("%sscsiTaskAbortTimeout:%d\n", format_space, - ctrl_info->scsiTaskAbortTimeout); - ps3stor_cli_printf("%sscsiTaskResetTimeout:%d\n", format_space, - ctrl_info->scsiTaskResetTimeout); - ps3stor_cli_printf("%siocPerfMode:%d\n", format_space, - ctrl_info->iocPerfMode); - ps3stor_cli_printf("%svdQueueNum:%d\n", format_space, - ctrl_info->vdQueueNum); - ps3stor_cli_printf("%scancelTimeOut:%d\n", format_space, - ctrl_info->cancelTimeOut); - ps3stor_cli_printf("%schannelInfo channelNum:%d\n", format_space, - ctrl_info->channelInfo.channelNum); + format_space, + ctrl_info->capabilities.supportAcceleration ? + "PS3_TRUE" : "PS3_FALSE"); + ps3stor_cli_printf("%sscsiTaskAbortTimeout:%d\n", + format_space, ctrl_info->scsiTaskAbortTimeout); + ps3stor_cli_printf("%sscsiTaskResetTimeout:%d\n", + format_space, ctrl_info->scsiTaskResetTimeout); + ps3stor_cli_printf("%siocPerfMode:%d\n", + format_space, ctrl_info->iocPerfMode); + ps3stor_cli_printf("%svdQueueNum:%d\n", + format_space, ctrl_info->vdQueueNum); + ps3stor_cli_printf("%scancelTimeOut:%d\n", + format_space, ctrl_info->cancelTimeOut); + ps3stor_cli_printf("%schannelInfo channelNum:%d\n", + format_space, ctrl_info->channelInfo.channelNum); for (i = 0; i < ctrl_info->channelInfo.channelNum; i++) { - ps3stor_cli_printf( - "%s channels[%d].channelType:%d\n", format_space, i, + ps3stor_cli_printf("%s channels[%d].channelType:%d\n", + format_space, i, ctrl_info->channelInfo.channels[i].channelType); - ps3stor_cli_printf( - "%s channels[%d].maxDevNum:%d\n", format_space, i, + ps3stor_cli_printf("%s channels[%d].maxDevNum:%d\n", + format_space, i, ctrl_info->channelInfo.channels[i].maxDevNum); } ps3stor_cli_printf("\n"); } -static void -ps3_cmd_attr_context_detail_dump(const char *format_space, - struct ps3_cmd_attr_context *cmd_attr) +static void ps3_cmd_attr_context_detail_dump(const char *format_space, + struct ps3_cmd_attr_context *cmd_attr) { - ps3stor_cli_printf("%sthrottle_que_depth:%d\n", format_space, - cmd_attr->throttle_que_depth); - ps3stor_cli_printf("%scur_can_que:%d\n", format_space, - cmd_attr->cur_can_que); - ps3stor_cli_printf("%svd_io_threshold:%d\n", format_space, - cmd_attr->vd_io_threshold); - ps3stor_cli_printf("%sis_support_direct_cmd:%s\n", format_space, - cmd_attr->is_support_direct_cmd ? "PS3_TRUE" : - "PS3_FALSE"); - ps3stor_cli_printf("%snvme_page_size:%d\n", format_space, - cmd_attr->nvme_page_size); + ps3stor_cli_printf("%sthrottle_que_depth:%d\n", + format_space, cmd_attr->throttle_que_depth); + ps3stor_cli_printf("%scur_can_que:%d\n", + format_space, cmd_attr->cur_can_que); + ps3stor_cli_printf("%svd_io_threshold:%d\n", + format_space, cmd_attr->vd_io_threshold); + ps3stor_cli_printf("%sis_support_direct_cmd:%s\n", + format_space, cmd_attr->is_support_direct_cmd ? + "PS3_TRUE" : "PS3_FALSE"); + ps3stor_cli_printf("%snvme_page_size:%d\n", + format_space, cmd_attr->nvme_page_size); ps3stor_cli_printf("\n"); } @@ -1442,25 +1357,18 @@ static void ps3_instance_info_detail_dump(void) struct ps3_instance *instance = NULL; struct list_head *pitem = NULL; struct Scsi_Host *phost = NULL; - int instance_state = 0; - + S32 instance_state = 0; list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { instance = list_entry(pitem, struct ps3_instance, list_item); phost = instance->host; instance_state = atomic_read(&instance->state_machine.state); - ps3stor_cli_printf("host_no:%d instance detail info\n", - phost->host_no); - ps3stor_cli_printf(" %s\n", - namePS3InstanceState(instance_state)); + ps3stor_cli_printf("host_no:%d instance detail info\n", phost->host_no); + ps3stor_cli_printf(" %s\n", namePS3InstanceState(instance_state)); ps3stor_cli_printf(" reg_bar:0x%x\n", instance->reg_bar); ps3stor_cli_printf(" is_load:%s\n", - instance->state_machine.is_load ? - "PS3_TRUE" : - "PS3_FALSE"); + instance->state_machine.is_load ? "PS3_TRUE" : "PS3_FALSE"); ps3stor_cli_printf(" is_support_sync_cache:%s\n", - instance->is_support_sync_cache ? - "PS3_TRUE" : - "PS3_FALSE"); + instance->is_support_sync_cache ? "PS3_TRUE" : "PS3_FALSE"); ps3stor_cli_printf(" ps3_cmd_context detail info dump\n"); ps3_cmd_context_detail_dump(" ", &instance->cmd_context); @@ -1472,20 +1380,18 @@ static void ps3_instance_info_detail_dump(void) ps3_dev_context_detail_dump(" ", &instance->dev_context); ps3stor_cli_printf(" ps3_event_context detail info dump\n"); - ps3_event_context_detail_dump(" ", - &instance->event_context); + ps3_event_context_detail_dump(" ", &instance->event_context); ps3stor_cli_printf(" ps3_fault_context detail info dump\n"); - ps3_fault_context_detail_dump(" ", - &instance->fault_context); + ps3_fault_context_detail_dump(" ", &instance->fault_context); ps3stor_cli_printf(" PS3IocCtrlInfo detail info dump\n"); - ps3_ioc_ctrl_info_detail_dump(" ", &instance->ctrl_info); + ps3_ioc_ctrl_info_detail_dump(" ", + &instance->ctrl_info); - ps3stor_cli_printf( - " ps3_cmd_attr_context detail info dump\n"); + ps3stor_cli_printf(" ps3_cmd_attr_context detail info dump\n"); ps3_cmd_attr_context_detail_dump(" ", - &instance->cmd_attr); + &instance->cmd_attr); ps3stor_cli_printf(" ps3_dump_context detail info dump\n"); ps3_dump_context_show(" ", instance); @@ -1496,7 +1402,7 @@ static void ps3_cli_host_and_instance_ls(int argc, char *argv[]) { if (argc < 2) { ps3stor_cli_printf("ls host/instance/all\n"); - return; + return ; } ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); @@ -1518,74 +1424,76 @@ static void ps3_cli_host_and_instance_ls(int argc, char *argv[]) l_out: ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); + return ; } -static ssize_t ps3_reply_fifo_dump(struct ps3_instance *instance, unsigned short isr_sn, - char *buf, ssize_t total_len, unsigned short index, - unsigned short count) +static ssize_t ps3_reply_fifo_dump(struct ps3_instance *instance, U16 isr_sn, + char *buf, ssize_t total_len, U16 index, U16 count) { ssize_t len = 0; struct PS3ReplyWord *fifo = NULL; - unsigned int i = 0; + U32 i = 0; struct ps3_irq *irq = NULL; - unsigned short start_idx = 0; - unsigned short once_print_cnt = 0; - unsigned short cnt = 0; + U16 start_idx = 0; + U16 once_print_cnt = 0; + U16 cnt = 0; if (isr_sn >= instance->irq_context.valid_msix_vector_count) { - ps3stor_cli_printf( - "invalid isr_sn %d (max:%d)\n", isr_sn, + ps3stor_cli_printf("invalid isr_sn %d (max:%d)\n", isr_sn, instance->irq_context.valid_msix_vector_count - 1); return PS3_FAILED; } irq = instance->irq_context.irqs + isr_sn; - if (irq == NULL) + if (irq == NULL) { goto l_out; + } len += snprintf(buf + len, total_len - len, "irq_name: %s\n", - irq->name); + irq->name); len += snprintf(buf + len, total_len - len, "irqNo: %d\n", - irq->irqNo); + irq->irqNo); len += snprintf(buf + len, total_len - len, "isrSN: %d\n", - irq->isrSN); + irq->isrSN); len += snprintf(buf + len, total_len - len, "last_reply_idx: %d\n", - irq->last_reply_idx); + irq->last_reply_idx); len += snprintf(buf + len, total_len - len, "irq_poll_th: %d\n", - irq->irq_poll_sched_threshold); + irq->irq_poll_sched_threshold); len += snprintf(buf + len, total_len - len, "is_sched_irq_poll: %d\n", - irq->is_sched_irq_poll); + irq->is_sched_irq_poll); len += snprintf(buf + len, total_len - len, "is_enable_irq: %d\n", - irq->is_enable_irq); + irq->is_enable_irq); - if (index == 0) + if(index == 0) { start_idx = irq->last_reply_idx; - else + } else { start_idx = index; + } - if (count == 0) + if(count == 0){ once_print_cnt = 100; - else + } else { once_print_cnt = count; + } - while (cnt < once_print_cnt) { - if (i == instance->irq_context.reply_fifo_depth) + while(cnt < once_print_cnt) { + if(i == instance->irq_context.reply_fifo_depth) { i = 0; - else + } else { i = start_idx; - for (; i < instance->irq_context.reply_fifo_depth; ++i, ++cnt) { + } + for ( ; i < instance->irq_context.reply_fifo_depth; ++i, ++cnt) { if (total_len - len < 100) { ps3stor_cli_printf(buf); memset(buf, 0, total_len); len = 0; } fifo = irq->reply_fifo_virt_base_addr + i; - len += snprintf( - buf + len, total_len - len, + len += snprintf(buf + len, total_len - len, "reply_word:index[%u], replyFlags[0x%x], CFID[0x%x], mode[%d], retType[%d] diskType[%d]\n", - i, fifo->retStatus, fifo->cmdFrameID, - fifo->mode, fifo->retType, fifo->diskType); - if (cnt >= once_print_cnt) + i, fifo->retStatus, fifo->cmdFrameID, fifo->mode, fifo->retType, fifo->diskType); + if(cnt >= once_print_cnt) { break; + } } } ps3stor_cli_printf(buf); @@ -1594,10 +1502,8 @@ static ssize_t ps3_reply_fifo_dump(struct ps3_instance *instance, unsigned short LOG_DEBUG("reply fifo[%d]", irq->isrSN); while (i < instance->irq_context.reply_fifo_depth) { fifo = irq->reply_fifo_virt_base_addr + i; - LOG_DEBUG( - "reply_word:index[%u], replyFlags[0x%x], CFID[0x%x] mode[%d] retType[%d] diskType[%d]\n", - i, fifo->retStatus, fifo->cmdFrameID, fifo->mode, - fifo->retType, fifo->diskType); + LOG_DEBUG("reply_word:index[%u], replyFlags[0x%x], CFID[0x%x] mode[%d] retType[%d] diskType[%d]\n", + i, fifo->retStatus, fifo->cmdFrameID, fifo->mode, fifo->retType, fifo->diskType); ++i; } @@ -1609,13 +1515,13 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - unsigned short host_no = 0; - unsigned short isr_sn = 0; - int ret = 0; - unsigned short start_idx = 0; - unsigned short count = 0; + U16 host_no = 0; + U16 isr_sn = 0; + S32 ret = 0; + U16 start_idx = 0; + U16 count = 0; - buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; @@ -1650,7 +1556,7 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) if (isr_sn >= PS3_MAX_REPLY_QUE_COUNT) { ps3stor_cli_printf("Invalid isr_sn %d, max isr_sn %d!\n", - isr_sn, PS3_MAX_REPLY_QUE_COUNT); + isr_sn, PS3_MAX_REPLY_QUE_COUNT); goto l_out; } @@ -1660,12 +1566,11 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) goto l_out; } - if (argc == 7) { + if(argc == 7) { if (strcmp(argv[5], "start_idx") == 0) { ret = kstrtou16(argv[6], 0, &start_idx); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse start_idx!\n"); + ps3stor_cli_printf("Can not parse start_idx!\n"); goto l_out; } } else if (strcmp(argv[5], "count") == 0) { @@ -1679,8 +1584,7 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) if (strcmp(argv[5], "start_idx") == 0) { ret = kstrtou16(argv[6], 0, &start_idx); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse start_idx!\n"); + ps3stor_cli_printf("Can not parse start_idx!\n"); goto l_out; } } @@ -1693,8 +1597,7 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) } } - (void)ps3_reply_fifo_dump(instance, isr_sn, buf, PAGE_SIZE, start_idx, - count); + (void)ps3_reply_fifo_dump(instance, isr_sn, buf, PAGE_SIZE, start_idx, count); l_out: kfree(buf); @@ -1702,176 +1605,172 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) return; } -static ssize_t ps3_req_head_dump(struct PS3ReqFrameHead *head, char *buf, - ssize_t total_len, size_t len) +static ssize_t ps3_req_head_dump(struct PS3ReqFrameHead *head, + char *buf, ssize_t total_len, size_t len) { - len += snprintf(buf + len, total_len - len, "cmdType: %d\n", - head->cmdType); - len += snprintf(buf + len, total_len - len, "cmdSubType: %d\n", - head->cmdSubType); - len += snprintf(buf + len, total_len - len, "cmdFrameID: %d\n", - head->cmdFrameID); - len += snprintf(buf + len, total_len - len, "control: 0x%x\n", - head->control); len += snprintf(buf + len, total_len - len, - "noReplyWord: 0x%x\n", head->noReplyWord); - len += snprintf(buf + len, total_len - len, "dataFormat: 0x%x\n", - head->dataFormat); + "cmdType: %d\n", head->cmdType); + len += snprintf(buf + len, total_len - len, + "cmdSubType: %d\n", head->cmdSubType); + len += snprintf(buf + len, total_len - len, + "cmdFrameID: %d\n", head->cmdFrameID); len += snprintf(buf + len, total_len - len, - "reqFrameFormat: 0x%x\n", head->reqFrameFormat); + "control: 0x%x\n", head->control); len += snprintf(buf + len, total_len - len, - "mapBlockVer: 0x%x\n", head->mapBlockVer); - len += snprintf(buf + len, total_len - len, "isWrite: 0x%x\n", - head->isWrite); - len += snprintf(buf + len, total_len - len, "devID: 0x%x\n", - head->devID.diskID); - len += snprintf(buf + len, total_len - len, "traceID: %lld\n", - head->traceID); + "noReplyWord: 0x%x\n", head->noReplyWord); + len += snprintf(buf + len, total_len - len, + "dataFormat: 0x%x\n", head->dataFormat); + len += snprintf(buf + len, total_len - len, + "reqFrameFormat: 0x%x\n", head->reqFrameFormat); + len += snprintf(buf + len, total_len - len, + "mapBlockVer: 0x%x\n", head->mapBlockVer); + len += snprintf(buf + len, total_len - len, + "isWrite: 0x%x\n", head->isWrite); + len += snprintf(buf + len, total_len - len, + "devID: 0x%x\n", head->devID.diskID); + len += snprintf(buf + len, total_len - len, + "traceID: %lld\n", head->traceID); return len; } -static ssize_t ps3_mgr_req_frame_dump(struct ps3_cmd *cmd, char *buf, - ssize_t total_len, size_t len) +static ssize_t ps3_mgr_req_frame_dump(struct ps3_cmd *cmd, + char *buf, ssize_t total_len, size_t len) { - struct PS3MgrReqFrame *mgr_req = (struct PS3MgrReqFrame *)cmd->req_frame; - + PS3MgrReqFrame_s *mgr_req = (PS3MgrReqFrame_s*)cmd->req_frame; if (mgr_req->reqHead.cmdType == PS3_CMD_MANAGEMENT || - mgr_req->reqHead.cmdType == PS3_CMD_IOCTL) { - len = ps3_req_head_dump(&mgr_req->reqHead, buf, total_len, len); + mgr_req->reqHead.cmdType == PS3_CMD_IOCTL) { + len = ps3_req_head_dump(&mgr_req->reqHead, buf, + total_len, len); len += snprintf(buf + len, total_len - len, - "sgeCount: %d\n", mgr_req->sgeCount); + "sgeCount: %d\n", mgr_req->sgeCount); len += snprintf(buf + len, total_len - len, - "sgeOffset: %d\n", mgr_req->sgeOffset); + "sgeOffset: %d\n", mgr_req->sgeOffset); len += snprintf(buf + len, total_len - len, - "syncFlag: %d\n", mgr_req->syncFlag); + "syncFlag: %d\n", mgr_req->syncFlag); len += snprintf(buf + len, total_len - len, - "timeout: %d\n", mgr_req->timeout); + "timeout: %d\n", mgr_req->timeout); len += snprintf(buf + len, total_len - len, - "abortFlag: %d\n", mgr_req->abortFlag); + "abortFlag: %d\n", mgr_req->abortFlag); len += snprintf(buf + len, total_len - len, - "pendingFlag: %d\n", mgr_req->pendingFlag); - } else if (mgr_req->reqHead.cmdType == PS3_CMD_SCSI_TASK_MANAGEMENT) { - struct PS3MgrTaskReqFrame *task_req = - (struct PS3MgrTaskReqFrame *)cmd->req_frame; - len = ps3_req_head_dump(&task_req->reqHead, buf, total_len, - len); + "pendingFlag: %d\n", mgr_req->pendingFlag); + } else if (mgr_req->reqHead.cmdType == PS3_CMD_SCSI_TASK_MANAGEMENT){ + PS3MgrTaskReqFrame_s *task_req = + (PS3MgrTaskReqFrame_s*)cmd->req_frame; + len = ps3_req_head_dump(&task_req->reqHead, buf, + total_len, len); len += snprintf(buf + len, total_len - len, - "taskID: %d\n", task_req->taskID); + "taskID: %d\n", task_req->taskID); len += snprintf(buf + len, total_len - len, - "abortedCmdType: %d\n", - task_req->abortedCmdType); + "abortedCmdType: %d\n", task_req->abortedCmdType); } else { - struct PS3FrontEndReqFrame *fe_req = - (struct PS3FrontEndReqFrame *)cmd->req_frame; - len = ps3_req_head_dump(&fe_req->reqHead, buf, total_len, len); + PS3FrontEndReqFrame_s *fe_req = + (PS3FrontEndReqFrame_s*)cmd->req_frame; + len = ps3_req_head_dump(&fe_req->reqHead, buf, + total_len, len); len += snprintf(buf + len, total_len - len, - "sgeCount: %d\n", fe_req->sgeCount); + "sgeCount: %d\n", fe_req->sgeCount); } return len; } -static ssize_t ps3_req_frame_dump(struct ps3_cmd *cmd, char *buf, - ssize_t total_len, size_t len) +static ssize_t ps3_req_frame_dump(struct ps3_cmd *cmd, + char *buf, ssize_t total_len, size_t len) { if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { - if (cmd->req_frame->mgrReq.reqHead.reqFrameFormat == - PS3_REQFRAME_FORMAT_FRONTEND) { - struct PS3FrontEndReqFrame *fe_req = - (struct PS3FrontEndReqFrame *)cmd->req_frame; + if (cmd->req_frame->mgrReq.reqHead.reqFrameFormat == PS3_REQFRAME_FORMAT_FRONTEND) { + PS3FrontEndReqFrame_s *fe_req = + (PS3FrontEndReqFrame_s*)cmd->req_frame; len = ps3_req_head_dump(&fe_req->reqHead, buf, - total_len, len); + total_len, len); len += snprintf(buf + len, total_len - len, - "dataXferLen: %d\n", - fe_req->dataXferLen); + "dataXferLen: %d\n", fe_req->dataXferLen); len += snprintf(buf + len, total_len - len, - "sgeCount: %d\n", - fe_req->sgeCount); + "sgeCount: %d\n", fe_req->sgeCount); } else { - struct PS3HwReqFrame *hw_req = - (struct PS3HwReqFrame *)cmd->req_frame; + PS3HwReqFrame_s *hw_req = + (PS3HwReqFrame_s*)cmd->req_frame; len += snprintf(buf + len, total_len - len, - "traceID: %llu\n", - hw_req->reqHead.traceID); + "traceID: %llu\n", hw_req->reqHead.traceID); len += snprintf(buf + len, total_len - len, - "vlba: 0x%llx\n", - hw_req->softwareZone.virtDiskLba); + "vlba: 0x%llx\n", + hw_req->softwareZone.virtDiskLba); len += snprintf(buf + len, total_len - len, - "numBlocks: %u\n", - hw_req->softwareZone.numBlocks); + "numBlocks: 0x%u\n", + hw_req->softwareZone.numBlocks); len += snprintf(buf + len, total_len - len, - "opcode: %u\n", - hw_req->softwareZone.opcode); + "opcode: 0x%u\n", + hw_req->softwareZone.opcode); len += snprintf(buf + len, total_len - len, - "sglOffset: %u\n", - hw_req->softwareZone.sglOffset); + "sglOffset: 0x%u\n", + hw_req->softwareZone.sglOffset); len += snprintf(buf + len, total_len - len, - "sglFormat: %u\n", - hw_req->softwareZone.sglFormat); + "sglFormat: 0x%u\n", + hw_req->softwareZone.sglFormat); len += snprintf(buf + len, total_len - len, - "isResendCmd: %u\n", - hw_req->softwareZone.isResendCmd); + "isResendCmd: 0x%u\n", + hw_req->softwareZone.isResendCmd); len += snprintf(buf + len, total_len - len, - "subOpcode: %u\n", - hw_req->softwareZone.subOpcode); + "subOpcode: 0x%u\n", + hw_req->softwareZone.subOpcode); len += snprintf(buf + len, total_len - len, - "sgeCount: %u\n", - hw_req->softwareZone.sgeCount); + "sgeCount: 0x%u\n", + hw_req->softwareZone.sgeCount); } - } else if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { - len = ps3_mgr_req_frame_dump(cmd, buf, total_len, len); + } else if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR){ + len = ps3_mgr_req_frame_dump(cmd, buf, total_len, len); } else { len += snprintf(buf + len, total_len - len, - "req frame is null\n"); + "req frame is null\n"); } return len; } -static ssize_t ps3_cmd_dump(struct ps3_instance *instance, unsigned short CFID, char *buf, - ssize_t total_len) +static ssize_t ps3_cmd_dump(struct ps3_instance *instance, U16 CFID, + char *buf, ssize_t total_len) { ssize_t len = 0; struct ps3_cmd *cmd = NULL; - cmd = (struct ps3_cmd *)instance->cmd_context.cmd_buf[CFID]; - if (cmd == NULL) + cmd = (struct ps3_cmd*)instance->cmd_context.cmd_buf[CFID]; + if (cmd == NULL) { goto l_out; + } len += snprintf(buf + len, total_len - len, "----dump ps3_cmd----\n"); len += snprintf(buf + len, total_len - len, "cmdFrameID: %d\n", - CFID); + CFID); len += snprintf(buf + len, total_len - len, "trace_id: %lld\n", - cmd->trace_id); + cmd->trace_id); len += snprintf(buf + len, total_len - len, "no_reply_word: %d\n", - cmd->no_reply_word); + cmd->no_reply_word); len += snprintf(buf + len, total_len - len, "is_retry_cmd: %d\n", - cmd->io_attr.is_retry_cmd); + cmd->io_attr.is_retry_cmd); len += snprintf(buf + len, total_len - len, "direct_flag: %d\n", - cmd->io_attr.direct_flag); + cmd->io_attr.direct_flag); len += snprintf(buf + len, total_len - len, "dev_type: %s\n", - namePS3DevType((enum PS3DevType)cmd->io_attr.dev_type)); + namePS3DevType((enum PS3DevType)cmd->io_attr.dev_type)); len += snprintf(buf + len, total_len - len, "rw_flag: %d\n", - cmd->io_attr.rw_flag); + cmd->io_attr.rw_flag); len += snprintf(buf + len, total_len - len, "------cmd_word------\n"); len += snprintf(buf + len, total_len - len, "type: %d\n", - cmd->cmd_word.type); + cmd->cmd_word.type); len += snprintf(buf + len, total_len - len, "direct: %d\n", - cmd->cmd_word.direct); + cmd->cmd_word.direct); len += snprintf(buf + len, total_len - len, "isrSN: %d\n", - cmd->cmd_word.isrSN); + cmd->cmd_word.isrSN); len += snprintf(buf + len, total_len - len, "phyDiskID: %d\n", - cmd->cmd_word.phyDiskID); + cmd->cmd_word.phyDiskID); len += snprintf(buf + len, total_len - len, "queID: %d\n", - cmd->cmd_word.qMask); + cmd->cmd_word.qMask); len += snprintf(buf + len, total_len - len, "cmdFrameID: %d\n", - cmd->cmd_word.cmdFrameID); + cmd->cmd_word.cmdFrameID); len += snprintf(buf + len, total_len - len, "virtDiskID: %d\n", - cmd->cmd_word.virtDiskID); + cmd->cmd_word.virtDiskID); len += snprintf(buf + len, total_len - len, "------req_frame------\n"); if (cmd->cmd_word.cmdFrameID == 0) { - len += snprintf(buf + len, total_len - len, - "--cmd is null--\n"); + len += snprintf(buf + len, total_len - len, "--cmd is null--\n"); goto l_out; } @@ -1885,11 +1784,11 @@ static void ps3_cli_cmd_dump(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - unsigned short host_no = 0; - unsigned short cmdFrameID = 0; - int ret = 0; + U16 host_no = 0; + U16 cmdFrameID = 0; + S32 ret = 0; - buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; @@ -1930,8 +1829,7 @@ static void ps3_cli_cmd_dump(int argc, char *argv[]) if (cmdFrameID >= instance->cmd_context.max_cmd_count) { ps3stor_cli_printf("Invalid cmd_frame_id %d, max id %d!\n", - cmdFrameID, - instance->cmd_context.max_cmd_count); + cmdFrameID, instance->cmd_context.max_cmd_count); goto l_out; } @@ -1945,11 +1843,11 @@ static void ps3_cli_cmd_dump(int argc, char *argv[]) } static ssize_t ps3_io_statis_to_str(struct ps3_dev_io_statis *disk_io_statis, - char *buf, ssize_t total_len) + char *buf, ssize_t total_len) { ssize_t len = 0; - const unsigned int temp_array_len = 256; - char temp[256] = { 0 }; + const U32 temp_array_len = 256; + char temp[256] = {0}; ssize_t temp_len = 0; (void)disk_io_statis; @@ -1957,139 +1855,129 @@ static ssize_t ps3_io_statis_to_str(struct ps3_dev_io_statis *disk_io_statis, memset(temp, 0, temp_array_len); temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readSendCnt", - (unsigned long long)atomic64_read(&disk_io_statis->read_send_cnt)); - if ((len + temp_len) > total_len) + (U64)atomic64_read(&disk_io_statis->read_send_cnt)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", - "readSendCnt", - (unsigned long long)atomic64_read(&disk_io_statis->read_send_cnt)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readSendCnt", + (U64)atomic64_read(&disk_io_statis->read_send_cnt)); memset(temp, 0, temp_array_len); - temp_len = - snprintf(temp, temp_array_len, "%-20s:%llu\n", "readSendOkCnt", - (unsigned long long)atomic64_read(&disk_io_statis->read_send_ok_cnt)); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readSendOkCnt", + (U64)atomic64_read(&disk_io_statis->read_send_ok_cnt)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", - "readSendOkCnt", - (unsigned long long)atomic64_read(&disk_io_statis->read_send_ok_cnt)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readSendOkCnt", + (U64)atomic64_read(&disk_io_statis->read_send_ok_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf( - temp, temp_array_len, "%-20s:%llu\n", "readOutStandCnt", - (unsigned long long)atomic64_read(&disk_io_statis->read_send_wait_cnt)); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readOutStandCnt", + (U64)atomic64_read(&disk_io_statis->read_send_wait_cnt)); + if ((len + temp_len) > total_len) { goto l_out; - - len += snprintf( - buf + len, total_len - len, "%-20s:%llu\n", "readOutStandCnt", - (unsigned long long)atomic64_read(&disk_io_statis->read_send_wait_cnt)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readOutStandCnt", + (U64)atomic64_read(&disk_io_statis->read_send_wait_cnt)); memset(temp, 0, temp_array_len); temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readRecvCnt", - (unsigned long long)atomic64_read(&disk_io_statis->read_recv_cnt)); - if ((len + temp_len) > total_len) + (U64)atomic64_read(&disk_io_statis->read_recv_cnt)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", - "readRecvCnt", - (unsigned long long)atomic64_read(&disk_io_statis->read_recv_cnt)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readRecvCnt", + (U64)atomic64_read(&disk_io_statis->read_recv_cnt)); memset(temp, 0, temp_array_len); - temp_len = - snprintf(temp, temp_array_len, "%-20s:%llu\n", "readRecvOkCnt", - (unsigned long long)atomic64_read(&disk_io_statis->read_recv_ok_cnt)); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readRecvOkCnt", + (U64)atomic64_read(&disk_io_statis->read_recv_ok_cnt)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", - "readRecvOkCnt", - (unsigned long long)atomic64_read(&disk_io_statis->read_recv_ok_cnt)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readRecvOkCnt", + (U64)atomic64_read(&disk_io_statis->read_recv_ok_cnt)); memset(temp, 0, temp_array_len); temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readOkBytes", - (unsigned long long)atomic64_read(&disk_io_statis->read_ok_bytes)); - if ((len + temp_len) > total_len) + (U64)atomic64_read(&disk_io_statis->read_ok_bytes)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", - "readOkBytes", - (unsigned long long)atomic64_read(&disk_io_statis->read_ok_bytes)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readOkBytes", + (U64)atomic64_read(&disk_io_statis->read_ok_bytes)); memset(temp, 0, temp_array_len); - temp_len = - snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeSendCnt", - (unsigned long long)atomic64_read(&disk_io_statis->write_send_cnt)); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeSendCnt", + (U64)atomic64_read(&disk_io_statis->write_send_cnt)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", - "writeSendCnt", - (unsigned long long)atomic64_read(&disk_io_statis->write_send_cnt)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "writeSendCnt", + (U64)atomic64_read(&disk_io_statis->write_send_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf( - temp, temp_array_len, "%-20s:%llu\n", "writeSendOkCnt", - (unsigned long long)atomic64_read(&disk_io_statis->write_send_ok_cnt)); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeSendOkCnt", + (U64)atomic64_read(&disk_io_statis->write_send_ok_cnt)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", - "writeSendOkCnt", - (unsigned long long)atomic64_read(&disk_io_statis->write_send_ok_cnt)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "writeSendOkCnt", + (U64)atomic64_read(&disk_io_statis->write_send_ok_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf( - temp, temp_array_len, "%-20s:%llu\n", "writeOutStandCnt", - (unsigned long long)atomic64_read(&disk_io_statis->write_send_wait_cnt)); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeOutStandCnt", + (U64)atomic64_read(&disk_io_statis->write_send_wait_cnt)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf( - buf + len, total_len - len, "%-20s:%llu\n", "writeOutStandCnt", - (unsigned long long)atomic64_read(&disk_io_statis->write_send_wait_cnt)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "writeOutStandCnt", + (U64)atomic64_read(&disk_io_statis->write_send_wait_cnt)); memset(temp, 0, temp_array_len); - temp_len = - snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeRecvCnt", - (unsigned long long)atomic64_read(&disk_io_statis->write_recv_cnt)); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeRecvCnt", + (U64)atomic64_read(&disk_io_statis->write_recv_cnt)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", - "writeRecvCnt", - (unsigned long long)atomic64_read(&disk_io_statis->write_recv_cnt)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "writeRecvCnt", + (U64)atomic64_read(&disk_io_statis->write_recv_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf( - temp, temp_array_len, "%-20s:%llu\n", "writeRecvOkCnt", - (unsigned long long)atomic64_read(&disk_io_statis->write_recv_ok_cnt)); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeRecvOkCnt", + (U64)atomic64_read(&disk_io_statis->write_recv_ok_cnt)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", - "writeRecvOkCnt", - (unsigned long long)atomic64_read(&disk_io_statis->write_recv_ok_cnt)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "writeRecvOkCnt", + (U64)atomic64_read(&disk_io_statis->write_recv_ok_cnt)); memset(temp, 0, temp_array_len); - temp_len = - snprintf(temp, temp_array_len, "%-20s:%llu\n\n", "writeOkBytes", - (unsigned long long)atomic64_read(&disk_io_statis->write_ok_bytes)); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n\n", "writeOkBytes", + (U64)atomic64_read(&disk_io_statis->write_ok_bytes)); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n\n", - "writeOkBytes", - (unsigned long long)atomic64_read(&disk_io_statis->write_ok_bytes)); + } + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n\n", "writeOkBytes", + (U64)atomic64_read(&disk_io_statis->write_ok_bytes)); l_out: return len; } static ssize_t ps3_io_statis_detail_dump(struct ps3_instance *instance, - char *buf, ssize_t total_len) + char *buf, ssize_t total_len) { ssize_t len = 0; struct scsi_device *sdev = NULL; struct ps3_scsi_priv_data *scsi_priv = NULL; struct ps3_dev_io_statis disk_io_statis; - unsigned int i = 0; - const unsigned int temp_array_len = 256; - char temp[256] = { 0 }; + U32 i = 0; + const U32 temp_array_len = 256; + char temp[256] = {0}; ssize_t temp_len = 0; - unsigned char dev_type = 0; + U8 dev_type = 0; if (!instance || !buf || total_len <= 0) { ps3stor_cli_printf("invalid parameters"); @@ -2097,19 +1985,18 @@ static ssize_t ps3_io_statis_detail_dump(struct ps3_instance *instance, } memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%s\n", - "disk io statistics detail:"); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%s\n", "disk io statistics detail:"); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%s\n", - "disk io statistics detail:"); + } + len += snprintf(buf + len, total_len - len, "%s\n", "disk io statistics detail:"); list_for_each_entry(sdev, &instance->host->__devices, siblings) { if (scsi_device_get(sdev)) continue; ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - scsi_priv = (struct ps3_scsi_priv_data *)sdev->hostdata; + scsi_priv = (struct ps3_scsi_priv_data*)sdev->hostdata; if (scsi_priv == NULL) { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); scsi_device_put(sdev); @@ -2117,49 +2004,43 @@ static ssize_t ps3_io_statis_detail_dump(struct ps3_instance *instance, } memset(&disk_io_statis, 0, sizeof(struct ps3_dev_io_statis)); - memcpy(&disk_io_statis, &scsi_priv->statis, - sizeof(struct ps3_dev_io_statis)); + memcpy(&disk_io_statis, &scsi_priv->statis, sizeof(struct ps3_dev_io_statis)); dev_type = scsi_priv->dev_type; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "index", - i); + temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "index", i); if ((len + temp_len) > total_len) { scsi_device_put(sdev); goto l_out; } - len += snprintf(buf + len, total_len - len, "%-20s:%d\n", - "index", i); + len += snprintf(buf + len, total_len - len, "%-20s:%d\n", "index", i); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:[%d,%d]\n", - "diskId", sdev->channel, sdev->id); + temp_len = snprintf(temp, temp_array_len, "%-20s:[%d,%d]\n", "diskId", + sdev->channel, sdev->id); if ((len + temp_len) > total_len) { scsi_device_put(sdev); goto l_out; } - len += snprintf(buf + len, total_len - len, "%-20s:[%d,%d]\n", - "diskId", sdev->channel, sdev->id); + len += snprintf(buf + len, total_len - len, "%-20s:[%d,%d]\n", "diskId", + sdev->channel, sdev->id); memset(temp, 0, temp_array_len); - temp_len = - snprintf(temp, temp_array_len, "%-20s:%s\n", "diskType", - (dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); + temp_len = snprintf(temp, temp_array_len, "%-20s:%s\n", "diskType", + (dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); if ((len + temp_len) > total_len) { scsi_device_put(sdev); goto l_out; } - len += snprintf(buf + len, total_len - len, "%-20s:%s\n", - "diskType", - (dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); + len += snprintf(buf + len, total_len - len, "%-20s:%s\n", "diskType", + (dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); if (len >= total_len) { scsi_device_put(sdev); break; } - len += ps3_io_statis_to_str(&disk_io_statis, buf + len, - total_len - len); + len += ps3_io_statis_to_str(&disk_io_statis, buf + len, total_len - len); scsi_device_put(sdev); i++; @@ -2170,37 +2051,38 @@ static ssize_t ps3_io_statis_detail_dump(struct ps3_instance *instance, } static void ps3_io_statis_clear_by_target(struct ps3_instance *instance, - unsigned int channel, unsigned int target) + U32 channel, U32 target) { struct scsi_device *sdev = NULL; if (!instance) { ps3stor_cli_printf("invalid parameters"); - return; + return ; } sdev = scsi_device_lookup(instance->host, channel, target, 0); - if (sdev) { - if (sdev->channel == channel && sdev->id == target) + if (sdev){ + if (sdev->channel == channel && sdev->id == target) { ps3_io_statis_clear(sdev); + } scsi_device_put(sdev); } } static ssize_t ps3_io_statis_summary_dump(struct ps3_instance *instance, - char *buf, ssize_t total_len) + char *buf, ssize_t total_len) { ssize_t len = 0; struct scsi_device *sdev = NULL; struct ps3_scsi_priv_data *scsi_priv = NULL; struct ps3_dev_io_statis disk_io_statis; struct ps3_dev_io_statis disk_io_statis_total; - unsigned int pd_cnt = 0, vd_cnt = 0; - const unsigned int temp_array_len = 256; - char temp[256] = { 0 }; + U32 pd_cnt = 0, vd_cnt = 0; + const U32 temp_array_len = 256; + char temp[256] = {0}; ssize_t temp_len = 0; - unsigned char dev_type = 0; + U8 dev_type = 0; if (!instance || !buf || total_len <= 0) { ps3stor_cli_printf("invalid parameters"); @@ -2213,134 +2095,113 @@ static ssize_t ps3_io_statis_summary_dump(struct ps3_instance *instance, continue; ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - scsi_priv = (struct ps3_scsi_priv_data *)sdev->hostdata; + scsi_priv = (struct ps3_scsi_priv_data*)sdev->hostdata; if (scsi_priv == NULL) { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); scsi_device_put(sdev); continue; } memset(&disk_io_statis, 0, sizeof(struct ps3_dev_io_statis)); - memcpy(&disk_io_statis, &scsi_priv->statis, - sizeof(struct ps3_dev_io_statis)); + memcpy(&disk_io_statis, &scsi_priv->statis, sizeof(struct ps3_dev_io_statis)); dev_type = scsi_priv->dev_type; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); - atomic64_add(atomic64_read(&disk_io_statis.read_send_cnt), - &disk_io_statis_total.read_send_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_send_ok_cnt), - &disk_io_statis_total.read_send_ok_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_send_err_cnt), - &disk_io_statis_total.read_send_err_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_send_cnt), &disk_io_statis_total.read_send_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_send_ok_cnt), &disk_io_statis_total.read_send_ok_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_send_err_cnt), &disk_io_statis_total.read_send_err_cnt); atomic64_add(atomic64_read(&disk_io_statis.read_send_wait_cnt), - &disk_io_statis_total.read_send_wait_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_recv_cnt), - &disk_io_statis_total.read_recv_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_recv_err_cnt), - &disk_io_statis_total.read_recv_err_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_recv_ok_cnt), - &disk_io_statis_total.read_recv_ok_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_ok_bytes), - &disk_io_statis_total.read_ok_bytes); - - atomic64_add(atomic64_read(&disk_io_statis.write_send_cnt), - &disk_io_statis_total.write_send_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_send_ok_cnt), - &disk_io_statis_total.write_send_ok_cnt); + &disk_io_statis_total.read_send_wait_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_recv_cnt), &disk_io_statis_total.read_recv_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_recv_err_cnt), &disk_io_statis_total.read_recv_err_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_recv_ok_cnt), &disk_io_statis_total.read_recv_ok_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_ok_bytes), &disk_io_statis_total.read_ok_bytes); + + atomic64_add(atomic64_read(&disk_io_statis.write_send_cnt), &disk_io_statis_total.write_send_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_send_ok_cnt), &disk_io_statis_total.write_send_ok_cnt); atomic64_add(atomic64_read(&disk_io_statis.write_send_err_cnt), - &disk_io_statis_total.write_send_err_cnt); + &disk_io_statis_total.write_send_err_cnt); atomic64_add(atomic64_read(&disk_io_statis.write_send_wait_cnt), - &disk_io_statis_total.write_send_wait_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_recv_cnt), - &disk_io_statis_total.write_recv_cnt); + &disk_io_statis_total.write_send_wait_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_recv_cnt), &disk_io_statis_total.write_recv_cnt); atomic64_add(atomic64_read(&disk_io_statis.write_recv_err_cnt), - &disk_io_statis_total.write_recv_err_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_recv_ok_cnt), - &disk_io_statis_total.write_recv_ok_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_ok_bytes), - &disk_io_statis_total.write_ok_bytes); + &disk_io_statis_total.write_recv_err_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_recv_ok_cnt), &disk_io_statis_total.write_recv_ok_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_ok_bytes), &disk_io_statis_total.write_ok_bytes); - if (dev_type == PS3_DEV_TYPE_VD) + if (dev_type == PS3_DEV_TYPE_VD) { vd_cnt++; - else + } else { pd_cnt++; + } scsi_device_put(sdev); } - memcpy(&disk_io_statis, &disk_io_statis_total, - sizeof(struct ps3_dev_io_statis)); + memcpy(&disk_io_statis, &disk_io_statis_total, sizeof(struct ps3_dev_io_statis)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%s\n", - "disk io statistics summary:"); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%s\n", "disk io statistics summary:"); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%s\n", - "disk io statistics summary:"); + } + len += snprintf(buf + len, total_len - len, "%s\n", "disk io statistics summary:"); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "VD count", - vd_cnt); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "VD count", vd_cnt); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%d\n", "VD count", - vd_cnt); + } + len += snprintf(buf + len, total_len - len, "%-20s:%d\n", "VD count", vd_cnt); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "PD count", - pd_cnt); - if ((len + temp_len) > total_len) + temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "PD count", pd_cnt); + if ((len + temp_len) > total_len) { goto l_out; - len += snprintf(buf + len, total_len - len, "%-20s:%d\n", "PD count", - pd_cnt); + } + len += snprintf(buf + len, total_len - len, "%-20s:%d\n", "PD count", pd_cnt); - if (len >= total_len) + if (len >= total_len) { goto l_out; + } len += ps3_io_statis_to_str(&disk_io_statis, buf, total_len - len); l_out: return len; } -void ps3_io_statis_dump_cli_cb_test(unsigned char detail) +void ps3_io_statis_dump_cli_cb_test(U8 detail) { struct ps3_instance *instance = NULL; struct list_head *pitem = NULL; char *buf = NULL; - buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; } if (detail) { - list_for_each(pitem, - &ps3_mgmt_info_get()->instance_list_head) { - instance = list_entry(pitem, struct ps3_instance, - list_item); + list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { + instance = list_entry(pitem, struct ps3_instance, list_item); if (instance) { - (void)ps3_io_statis_detail_dump(instance, buf, - PAGE_SIZE); + (void)ps3_io_statis_detail_dump(instance, buf, PAGE_SIZE); break; } } } else { - list_for_each(pitem, - &ps3_mgmt_info_get()->instance_list_head) { - instance = list_entry(pitem, struct ps3_instance, - list_item); + list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { + instance = list_entry(pitem, struct ps3_instance, list_item); if (instance) { - (void)ps3_io_statis_summary_dump(instance, buf, - PAGE_SIZE); + (void)ps3_io_statis_summary_dump(instance, buf, PAGE_SIZE); break; } } } ps3stor_cli_printf(buf); - LOG_DEBUG("buf = %s\n", buf); + LOG_DEBUG("buf = %s\n",buf); kfree(buf); buf = NULL; @@ -2355,7 +2216,7 @@ static void ps3_io_statis_dump_cli_cb(int argc, char *argv[]) struct list_head *pitem = NULL; char *buf = NULL; - buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; @@ -2382,31 +2243,25 @@ static void ps3_io_statis_dump_cli_cb(int argc, char *argv[]) } if (strcmp(argv[3], "detail") == 0) { - list_for_each(pitem, - &ps3_mgmt_info_get()->instance_list_head) { - instance = list_entry(pitem, struct ps3_instance, - list_item); + list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { + instance = list_entry(pitem, struct ps3_instance, list_item); if (instance) { - (void)ps3_io_statis_detail_dump(instance, buf, - PAGE_SIZE); + (void)ps3_io_statis_detail_dump(instance, buf, PAGE_SIZE); break; } } } else { - list_for_each(pitem, - &ps3_mgmt_info_get()->instance_list_head) { - instance = list_entry(pitem, struct ps3_instance, - list_item); + list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { + instance = list_entry(pitem, struct ps3_instance, list_item); if (instance) { - (void)ps3_io_statis_summary_dump(instance, buf, - PAGE_SIZE); + (void)ps3_io_statis_summary_dump(instance, buf, PAGE_SIZE); break; } } } ps3stor_cli_printf(buf); - LOG_INFO("buf: %s\n", buf); + LOG_INFO("buf: %s\n", buf); l_out: kfree(buf); @@ -2420,8 +2275,8 @@ static void ps3_io_statis_clear_cli_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; struct list_head *pitem = NULL; - unsigned int channel = 0, target = 0; - int ret = 0; + U32 channel = 0, target = 0; + S32 ret = 0; if (argc < 5) { ps3stor_cli_printf("Too few args, must input 5 args!\n"); @@ -2457,10 +2312,8 @@ static void ps3_io_statis_clear_cli_cb(int argc, char *argv[]) list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { instance = list_entry(pitem, struct ps3_instance, list_item); if (instance) { - ps3_io_statis_clear_by_target(instance, channel, - target); - ps3stor_cli_printf( - "clear host %d channel %d target %d io statistics\n", + ps3_io_statis_clear_by_target(instance, channel, target); + ps3stor_cli_printf("clear host %d channel %d target %d io statistics\n", instance->host->host_no, channel, target); break; } @@ -2469,8 +2322,8 @@ static void ps3_io_statis_clear_cli_cb(int argc, char *argv[]) l_out: return; } -static ssize_t ps3_hardreset_cnt_show(struct ps3_instance *instance, char *buf, - ssize_t total_len) +static ssize_t ps3_hardreset_cnt_show(struct ps3_instance *instance, + char *buf, ssize_t total_len) { ssize_t len = 0; @@ -2480,25 +2333,24 @@ static ssize_t ps3_hardreset_cnt_show(struct ps3_instance *instance, char *buf, } len += snprintf(buf + len, total_len - len, "%s:%u\n", "hard reset cnt", - instance->recovery_context->hardreset_count); + instance->recovery_context->hardreset_count); l_out: return len; } -static ssize_t ps3_hardreset_cnt_clear(struct ps3_instance *instance, char *buf, - ssize_t total_len) +static ssize_t ps3_hardreset_cnt_clear(struct ps3_instance *instance, + char *buf, ssize_t total_len) { ssize_t len = 0; - if (!instance || !buf || total_len <= 0) { ps3stor_cli_printf("invalid parameters"); goto l_out; } instance->recovery_context->hardreset_count = 0; - len += snprintf(buf + len, total_len - len, "%s:%u\n", "hard reset cnt", - instance->recovery_context->hardreset_count); + len += snprintf(buf + len, total_len - len, "%s:%u\n", + "hard reset cnt",instance->recovery_context->hardreset_count); l_out: return len; } @@ -2507,10 +2359,10 @@ static void ps3_hardreset_cnt_show_cli_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - unsigned short host_no = 0; - int ret = 0; + U16 host_no = 0; + S32 ret = 0; - buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; @@ -2528,21 +2380,20 @@ static void ps3_hardreset_cnt_show_cli_cb(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse host_no for register dump cmd!\n"); + ps3stor_cli_printf("Can not parse host_no for register dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf( - "Invalid host_no %d for register dump cmd!\n", host_no); + ps3stor_cli_printf("Invalid host_no %d for register dump cmd!\n", + host_no); goto l_out; } (void)ps3_hardreset_cnt_show(instance, buf, PAGE_SIZE); ps3stor_cli_printf(buf); - LOG_INFO("buf: %s\n", buf); + LOG_INFO("buf: %s\n", buf); l_out: kfree(buf); @@ -2556,10 +2407,9 @@ static void ps3_hardreset_cnt_clear_cli_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - unsigned short host_no = 0; - int ret = 0; - - buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + U16 host_no = 0; + S32 ret = 0; + buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; @@ -2577,20 +2427,19 @@ static void ps3_hardreset_cnt_clear_cli_cb(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf( - "Can not parse host_no for register dump cmd!\n"); + ps3stor_cli_printf("Can not parse host_no for register dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf( - "Invalid host_no %d for register dump cmd!\n", host_no); + ps3stor_cli_printf("Invalid host_no %d for register dump cmd!\n", + host_no); goto l_out; } (void)ps3_hardreset_cnt_clear(instance, buf, PAGE_SIZE); ps3stor_cli_printf(buf); - LOG_INFO("buf: %s\n", buf); + LOG_INFO("buf: %s\n", buf); l_out: kfree(buf); @@ -2598,6 +2447,7 @@ static void ps3_hardreset_cnt_clear_cli_cb(int argc, char *argv[]) l_malloc_failed: return; + } static void ps3_cli_stop_all_instance(void) @@ -2607,39 +2457,35 @@ static void ps3_cli_stop_all_instance(void) struct ps3_cmd *cmd = NULL; struct scsi_cmnd *s_cmd = NULL; struct ps3_scsi_priv_data *data = NULL; - unsigned int index = 0; - + U32 index = 0; list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { instance = list_entry(pitem, struct ps3_instance, list_item); - if (instance == NULL) + if (instance == NULL) { continue; + } ps3_instance_state_transfer_to_dead(instance); instance->ioc_adpter->irq_disable(instance); ps3_irqs_sync(instance); - ps3_r1x_conflict_queue_clean_all( - instance, PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), - PS3_TRUE); - for (index = 0; - index < instance->cmd_context.max_scsi_cmd_count; - index++) { + ps3_r1x_conflict_queue_clean_all(instance, + PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); +#ifdef PS3_SUPPORT_INJECT + ps3_inject_clear(); +#endif + for (index = 0; index < instance->cmd_context.max_scsi_cmd_count; index++) { cmd = instance->cmd_context.cmd_buf[index]; if (cmd->scmd != NULL) { PS3_IO_OUTSTAND_DEC(instance, cmd->scmd); PS3_VD_OUTSTAND_DEC(instance, cmd->scmd); PS3_IO_BACK_ERR_INC(instance, cmd->scmd); PS3_DEV_BUSY_DEC(cmd->scmd); - cmd->scmd->result = - ((int)PS3_SCSI_RESULT_HOST_STATUS( - DID_NO_CONNECT)); + cmd->scmd->result = ((S32)PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT)); s_cmd = cmd->scmd; ps3_scsi_dma_unmap(cmd); - data = (struct ps3_scsi_priv_data *) - cmd->scmd->device->hostdata; - if (likely(data != NULL)) { - ps3_r1x_write_unlock(&data->lock_mgr, - cmd); + data = (struct ps3_scsi_priv_data *)cmd->scmd->device->hostdata; + if(likely(data != NULL)){ + ps3_r1x_write_unlock(&data->lock_mgr, cmd); } ps3_scsi_cmd_free(cmd); SCMD_IO_DONE(s_cmd); @@ -2647,29 +2493,23 @@ static void ps3_cli_stop_all_instance(void) } for (index = instance->cmd_context.max_scsi_cmd_count; - index < instance->cmd_context.max_cmd_count; index++) { + index < instance->cmd_context.max_cmd_count; index++) { cmd = instance->cmd_context.cmd_buf[index]; - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == - PS3_CMD_WORD_NO_REPLY_WORD) { - cmd->resp_frame->normalRespFrame.respStatus = - PS3_STATUS_DEVICE_NOT_FOUND; + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NO_REPLY_WORD) { + cmd->resp_frame->normalRespFrame.respStatus = PS3_STATUS_DEVICE_NOT_FOUND; } else if (cmd->cmd_receive_cb != NULL) { - cmd->resp_frame->normalRespFrame.respStatus = - PS3_STATUS_DEVICE_NOT_FOUND; - cmd->cmd_receive_cb(cmd, - PS3_REPLY_WORD_FLAG_FAIL); + cmd->resp_frame->normalRespFrame.respStatus = PS3_STATUS_DEVICE_NOT_FOUND; + cmd->cmd_receive_cb(cmd, PS3_REPLY_WORD_FLAG_FAIL); } } - cancel_delayed_work_sync( - &instance->event_context.delay_work->event_work); + cancel_delayed_work_sync(&instance->event_context.delay_work->event_work); ps3_watchdog_stop(instance); instance->ioc_adpter->irq_enable(instance); ps3_irqpolls_enable(instance); - ps3stor_cli_printf("host_no:%d instance stopped!\n", - instance->host->host_no); + ps3stor_cli_printf("host_no:%d instance stopped!\n", instance->host->host_no); } } @@ -2686,66 +2526,58 @@ static void ps3_cli_force_to_stop(int argc, char *argv[]) ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); } -static void ps3_debug_mem_dump(struct ps3_instance *ins, unsigned short entry, unsigned int len) +static void ps3_debug_mem_dump(struct ps3_instance *ins, U16 entry, U32 len) { - unsigned int i = 0; - const unsigned int once_dump_len = 1024; + U32 i = 0; + const U32 once_dump_len = 1024; char buf[256] = { 0 }; - for (; i < ins->debug_context.debug_mem_vaddr[entry].debugMemSize; - ++i) { - if (ins->debug_context.debug_mem_vaddr[entry].debugMemAddr == - 0 || - len == 0) { + for (; i < ins->debug_context.debug_mem_vaddr[entry].debugMemSize; ++i) { + if (ins->debug_context.debug_mem_vaddr[entry].debugMemAddr == 0 || len == 0) { break; } memset(buf, '\0', sizeof(buf)); if (len <= once_dump_len) { - (void)snprintf(buf, sizeof(buf), - "base addr[0x%llx] len[%u]\n", - ins->debug_context.debug_mem_vaddr[entry] - .debugMemAddr + - i * once_dump_len, - len); - DATA_DUMP(((unsigned char *)(ins->debug_context - .debug_mem_vaddr[entry] - .debugMemAddr + - i * once_dump_len)), - len, buf); + (void)snprintf(buf, sizeof(buf),"base addr[0x%llx] len[%u]\n", + ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + + i * once_dump_len, len); + DATA_DUMP(((U8*)(ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + i * once_dump_len)), + len, buf); break; + } else { + len -= once_dump_len; + (void)snprintf(buf, sizeof(buf),"base addr[0x%llx] len[%u]\n", + ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + + i * once_dump_len, once_dump_len); + DATA_DUMP(((U8*)(ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + i * once_dump_len)), + once_dump_len, buf); } - len -= once_dump_len; - (void)snprintf(buf, sizeof(buf), - "base addr[0x%llx] len[%u]\n", - ins->debug_context.debug_mem_vaddr[entry] - .debugMemAddr + i * once_dump_len, once_dump_len); - DATA_DUMP(((unsigned char *)(ins->debug_context.debug_mem_vaddr[entry] - .debugMemAddr + i * once_dump_len)), once_dump_len, buf); } + return; } -static void ps3_debug_mem_write(struct ps3_instance *ins, unsigned short entry, unsigned int len) +static void ps3_debug_mem_write(struct ps3_instance *ins, U16 entry, U32 len) { - const unsigned char l_value = 0x55; - const unsigned char h_value = 0xaa; - unsigned int i = 0; - struct Ps3DebugMemEntry *debug_mem_entry = NULL; + const U8 l_value = 0x55; + const U8 h_value = 0xaa; + U32 i = 0; - debug_mem_entry = &ins->debug_context.debug_mem_vaddr[entry]; - for (i = 0; i < len; i += 2) { - *((unsigned char *)(uintptr_t)debug_mem_entry->debugMemAddr + i) = l_value; - *((unsigned char *)(uintptr_t)debug_mem_entry->debugMemAddr + i + 1) = h_value; + for (i = 0; i < len; i+=2) { + *((U8*)ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + i) = l_value; + *((U8*)ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + i + 1) = h_value; } + + return; } static void ps3_debug_mem_rw_cli_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - unsigned short entry = 0; - unsigned short dir = 0; - unsigned int len = 0; - int ret = 0; + U16 host_no = 0; + U16 entry = 0; + U16 dir = 0; + U32 len = 0; + S32 ret = 0; if (argc < 9) { ps3stor_cli_printf("Too few args, must input 9 args!\n"); @@ -2779,8 +2611,7 @@ static void ps3_debug_mem_rw_cli_cb(int argc, char *argv[]) } if (instance->debug_context.debug_mem_array_num == 0) { - ps3stor_cli_printf("host_no %d not support debug mem!\n", - host_no); + ps3stor_cli_printf("host_no %d not support debug mem!\n", host_no); goto l_out; } @@ -2812,13 +2643,9 @@ static void ps3_debug_mem_rw_cli_cb(int argc, char *argv[]) ps3stor_cli_printf("Can not parse entry!\n"); goto l_out; } - if (len > (instance->debug_context.debug_mem_vaddr[entry].debugMemSize * - 1024)) { + if (len > (instance->debug_context.debug_mem_vaddr[entry].debugMemSize * 1024)) { ps3stor_cli_printf("len over mem [%u], max[%u]!\n", len, - instance->debug_context - .debug_mem_vaddr[entry] - .debugMemSize * - 1024); + instance->debug_context.debug_mem_vaddr[entry].debugMemSize * 1024); goto l_out; } @@ -2834,16 +2661,14 @@ static void ps3_debug_mem_rw_cli_cb(int argc, char *argv[]) static void ps3_debug_mem_para_dump(struct ps3_instance *instance) { struct ps3_debug_context *cxt = &instance->debug_context; - unsigned int i = 0; - - ps3stor_cli_printf("debug mem array num %u\n", - cxt->debug_mem_array_num); - if (cxt->debug_mem_array_num == 0) + U32 i = 0; + ps3stor_cli_printf("debug mem array num %u\n", cxt->debug_mem_array_num); + if (cxt->debug_mem_array_num == 0) { goto l_out; + } for (; i < cxt->debug_mem_array_num; ++i) { - ps3stor_cli_printf( - "entry[%u] vaddr[0x%llx] dma[0x%llx] max_size[%u]KB\n", + ps3stor_cli_printf("entry[%u] vaddr[0x%llx] dma[0x%llx] max_size[%u]KB\n", i, cxt->debug_mem_vaddr[i].debugMemAddr, cxt->debug_mem_buf[i].debugMemAddr, cxt->debug_mem_buf[i].debugMemSize); @@ -2855,8 +2680,8 @@ static void ps3_debug_mem_para_dump(struct ps3_instance *instance) static void ps3_debug_mem_para_cli_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - int ret = 0; + U16 host_no = 0; + S32 ret = 0; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -2880,8 +2705,7 @@ static void ps3_debug_mem_para_cli_cb(int argc, char *argv[]) } if (instance->debug_context.debug_mem_array_num == 0) { - ps3stor_cli_printf("host_no %d not support debug mem!\n", - host_no); + ps3stor_cli_printf("host_no %d not support debug mem!\n", host_no); goto l_out; } @@ -2894,18 +2718,19 @@ static void ps3_debug_mem_para_cli_cb(int argc, char *argv[]) static void ps3_scsi_device_loop_dump(struct ps3_instance *instance) { struct scsi_device *sdev = NULL; - unsigned long flags = 0; + ULong flags = 0; struct Scsi_Host *shost = instance->host; - if (instance->host == NULL) + if (instance->host == NULL) { goto l_out; + } spin_lock_irqsave(shost->host_lock, flags); list_for_each_entry(sdev, &shost->__devices, siblings) { - if (sdev == NULL) + if (sdev == NULL) { continue; - ps3stor_cli_printf( - "channel[%u], id[%u], lun[%llu], state[%d]!\n", + } + ps3stor_cli_printf("channel[%u], id[%u], lun[%llu], state[%d]!\n", sdev->channel, sdev->id, sdev->lun, sdev->sdev_state); } spin_unlock_irqrestore(shost->host_lock, flags); @@ -2917,8 +2742,8 @@ static void ps3_scsi_device_loop_dump(struct ps3_instance *instance) static void ps3_scsi_device_lookup_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - int ret = 0; + U16 host_no = 0; + S32 ret = 0; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -2950,8 +2775,8 @@ static void ps3_scsi_device_lookup_cb(int argc, char *argv[]) static void ps3_hard_reset_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - int ret = 0; + U16 host_no = 0; + S32 ret = 0; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -2975,24 +2800,26 @@ static void ps3_hard_reset_cb(int argc, char *argv[]) } ps3stor_cli_printf("hno:%u entry hard reset !\n", host_no); - LOG_INFO("hno:%u entry hard reset!\n", PS3_HOST(instance)); + LOG_INFO("hno:%u entry hard reset!\n", + PS3_HOST(instance)); - LOG_WARN("hno:%u cli call recovery request!\n", PS3_HOST(instance)); - if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) || - (!ps3_hard_reset_enable_query())) { - LOG_WARN( - "hno:%u soc feature unsupport Hard reset! need to be offline!\n", + LOG_WARN("hno:%u cli call recovery request!\n", + PS3_HOST(instance)); + if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) + || (!ps3_hard_reset_enable_query())) { + LOG_WARN("hno:%u soc feature unsupport Hard reset! need to be offline!\n", PS3_HOST(instance)); goto l_out; } if (ps3_need_block_hard_reset_request(instance)) { LOG_WARN("hno:%u can not start hard reset\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ps3_hard_recovery_request_with_retry(instance); - LOG_WARN("hno:%u cli call recovery request!\n", PS3_HOST(instance)); + LOG_WARN("hno:%u cli call recovery request!\n", + PS3_HOST(instance)); l_out: return; @@ -3001,8 +2828,8 @@ static void ps3_hard_reset_cb(int argc, char *argv[]) static void ps3_soc_halt_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - int ret = 0; + U16 host_no = 0; + S32 ret = 0; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3027,11 +2854,11 @@ static void ps3_soc_halt_cb(int argc, char *argv[]) if (PS3_IOC_STATE_HALT_SUPPORT(instance)) { LOG_WARN("hno:%u cli call trans to halt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_instance_state_transfer_to_dead(instance); instance->ioc_adpter->ioc_force_to_halt(instance); LOG_WARN("hno:%u cli call trans to halt end!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } else { ps3stor_cli_printf("host does not support HALT!\n", host_no); } @@ -3040,12 +2867,12 @@ static void ps3_soc_halt_cb(int argc, char *argv[]) return; } -static void ps3_cmd_stat_switch_store - (unsigned short host_no, unsigned short switch_flag, unsigned short mask) +static void ps3_cmd_stat_switch_store(U16 host_no, + U16 switch_flag, U16 mask) { struct ps3_instance *instance = ps3_instance_lookup(host_no); struct ps3_cmd_stat_wrokq_context *ctx = NULL; - unsigned char is_inc_switch_open = PS3_FALSE; + Bool is_inc_switch_open = PS3_FALSE; if (instance == NULL) { ps3stor_cli_printf("invalid host_no %u\n", host_no); @@ -3053,39 +2880,37 @@ static void ps3_cmd_stat_switch_store } if ((instance->cmd_statistics.cmd_stat_switch & mask) == - (switch_flag & mask)) { + (switch_flag & mask)) { ps3stor_cli_printf("switch_flag no change 0x%x\n", - instance->cmd_statistics.cmd_stat_switch); + instance->cmd_statistics.cmd_stat_switch); goto l_out; } is_inc_switch_open = ps3_stat_inc_switch_is_open(instance); - instance->cmd_statistics.cmd_stat_switch &= (~mask); - instance->cmd_statistics.cmd_stat_switch |= (switch_flag & mask); + instance->cmd_statistics.cmd_stat_switch &= (~mask) ; + instance->cmd_statistics.cmd_stat_switch |= (switch_flag & mask) ; ctx = &instance->cmd_statistics.stat_workq; if ((ctx->stat_queue != NULL) && (!ctx->is_stop) && - ps3_stat_inc_switch_is_open(instance) && !is_inc_switch_open) { + ps3_stat_inc_switch_is_open(instance) && !is_inc_switch_open) { ps3stor_cli_printf("schedule delay work\n"); - queue_delayed_work( - ctx->stat_queue, &ctx->stat_work, - msecs_to_jiffies( - instance->cmd_statistics.stat_interval)); + queue_delayed_work(ctx->stat_queue, &ctx->stat_work, + msecs_to_jiffies(instance->cmd_statistics.stat_interval)); } ps3stor_cli_printf("stat switch value is 0x%x\n", - instance->cmd_statistics.cmd_stat_switch); + instance->cmd_statistics.cmd_stat_switch); l_out: return; } static void ps3_cmd_stat_switch_store_cb(int argc, char *argv[]) { - unsigned short host_no = 0; - unsigned short switch_flag = 0; - unsigned short mask = 0; - int ret = PS3_SUCCESS; + U16 host_no = 0; + U16 switch_flag = 0; + U16 mask = 0; + S32 ret = PS3_SUCCESS; if (argc < 7) { ps3stor_cli_printf("Too few args, must input 7 args!\n"); @@ -3131,19 +2956,18 @@ static void ps3_cmd_stat_switch_store_cb(int argc, char *argv[]) return; } -static inline void ps3_cmd_stat_switch_show(unsigned short host_no) +static inline void ps3_cmd_stat_switch_show(U16 host_no) { struct ps3_instance *instance = ps3_instance_lookup(host_no); - if (instance == NULL) { ps3stor_cli_printf("invalid host_no %u\n", host_no); goto l_out; } - ps3stor_cli_printf("[bit0:OUTSTAND_SWITCH_OPEN, bit1:INC_SWITCH_OPEN\n" - "bit2:LOG_SWITCH_OPEN, bit3:DEV_SWITCH_OPEN]\n"); + ps3stor_cli_printf("[bit0:OUTSTAND_SWITCH_OPEN, bit1:INC_SWITCH_OPEN," + "bit2:LOG_SWITCH_OPEN, bit3:DEV_SWITCH_OPEN]\n"); ps3stor_cli_printf("stat switch value is 0x%x\n", - instance->cmd_statistics.cmd_stat_switch); + instance->cmd_statistics.cmd_stat_switch); l_out: return; @@ -3151,8 +2975,8 @@ static inline void ps3_cmd_stat_switch_show(unsigned short host_no) static void ps3_cmd_stat_switch_show_cb(int argc, char *argv[]) { - unsigned short host_no = 0; - int ret = PS3_SUCCESS; + U16 host_no = 0; + S32 ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3175,36 +2999,34 @@ static void ps3_cmd_stat_switch_show_cb(int argc, char *argv[]) return; } -static void ps3_stat_total_dump(struct ps3_instance *instance, char *buf, - int total_len) +static void ps3_stat_total_dump(struct ps3_instance *instance, + char *buf, S32 total_len) { - int len = 0; - const unsigned int temp_array_len = total_len; - char *tmp_buf = NULL; - int temp_len = 0; + S32 len = 0; + const U32 temp_array_len = total_len; + S8 *tmp_buf = NULL; + S32 temp_len = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - unsigned short i = 0; + U16 i = 0; len += snprintf(buf + len, total_len - len, - "----host[%u] total cmd statistics show begin----\n", - PS3_HOST(instance)); - len += snprintf( - buf + len, total_len - len, "----cmd_outstandin:%u----\n", + "----host[%u] total cmd statistics show begin----\n", PS3_HOST(instance)); + len += snprintf(buf + len, total_len - len, + "----cmd_outstandin:%u----\n", ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); - len += snprintf( - buf + len, total_len - len, + len += snprintf(buf + len, total_len - len, "%-25s %-15s %-15s %-15s %-15s %-20s %-20s %-20s\n", - " ", "start", "back_good", "back_err", "not_back", "avg(us)", - "max(us)", "min(us)"); + " ", "start", "back_good", "back_err", "not_back", "avg(us)", "max(us)", "min(us)"); - tmp_buf = kzalloc(temp_array_len, GFP_KERNEL); - if (tmp_buf == NULL) + tmp_buf = (S8 *)kzalloc(temp_array_len, GFP_KERNEL); + if (tmp_buf == NULL) { goto l_out; + } for (; i < PS3_QOS_PD_PRO; ++i) { - temp_len = snprintf( - tmp_buf, temp_array_len, - "%-25s %-15llu %-15llu %-15llu %-15llu %-20llu %-20llu %-20llu\n", + temp_len = snprintf(tmp_buf, temp_array_len, + "%-25s %-15llu %-15llu %-15llu %-15llu " + "%-20llu %-20llu %-20llu\n", ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), ctx->total_stat.stat[i].start, ctx->total_stat.stat[i].back_good, @@ -3220,9 +3042,9 @@ static void ps3_stat_total_dump(struct ps3_instance *instance, char *buf, memset(tmp_buf, 0, temp_array_len); - len += snprintf( - buf + len, total_len - len, - "%-25s %-15llu %-15llu %-15llu %-15llu %-20llu %-20llu %-20llu\n", + len += snprintf(buf + len, total_len - len, + "%-25s %-15llu %-15llu %-15llu %-15llu " + "%-20llu %-20llu %-20llu\n", ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), ctx->total_stat.stat[i].start, ctx->total_stat.stat[i].back_good, @@ -3234,29 +3056,28 @@ static void ps3_stat_total_dump(struct ps3_instance *instance, char *buf, } temp_len = snprintf(tmp_buf, temp_array_len, - "----host[%u] cmd statistics show end----\n", - PS3_HOST(instance)); + "----host[%u] cmd statistics show end----\n", PS3_HOST(instance)); if ((len + temp_len) > total_len) { ps3stor_cli_printf("print over!\n"); goto l_out; } len += snprintf(buf + len, total_len - len, - "----host[%u] cmd statistics show end----\n", - PS3_HOST(instance)); + "----host[%u] cmd statistics show end----\n", PS3_HOST(instance)); l_out: if (tmp_buf != NULL) { - kfree((void *)tmp_buf); + kfree((void*)tmp_buf); tmp_buf = NULL; } + return; } static void ps3_stat_total_show_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - char *buf = NULL; - unsigned short host_no = 0; - int ret = PS3_SUCCESS; + S8 *buf = NULL; + U16 host_no = 0; + S32 ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3280,7 +3101,7 @@ static void ps3_stat_total_show_cb(int argc, char *argv[]) goto l_out; } - buf = kzalloc(PAGE_SIZE * 2, GFP_KERNEL); + buf = (S8 *)kzalloc(PAGE_SIZE * 2, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_out; @@ -3294,35 +3115,34 @@ static void ps3_stat_total_show_cb(int argc, char *argv[]) kfree(buf); buf = NULL; } + return; } -static void ps3_stat_inc_dump(struct ps3_instance *instance, char *buf, - int total_len) +static void ps3_stat_inc_dump(struct ps3_instance *instance, + char *buf, S32 total_len) { - int len = 0; - const unsigned int temp_array_len = PAGE_SIZE; - char *tmp_buf = NULL; - int temp_len = 0; + S32 len = 0; + const U32 temp_array_len = PAGE_SIZE; + S8 *tmp_buf = NULL; + S32 temp_len = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - unsigned short i = 0; + U16 i = 0; len += snprintf(buf + len, total_len - len, - "----host[%u] inc cmd statistics show begin----\n", - PS3_HOST(instance)); - len += snprintf( - buf + len, total_len - len, + "----host[%u] inc cmd statistics show begin----\n", PS3_HOST(instance)); + len += snprintf(buf + len, total_len - len, "%-25s %-15s %-15s %-15s %-15s %-20s %-20s %-20s\n", - " ", "start", "back_good", "back_err", "not_back", "avg(us)", - "max(us)", "min(us)"); + " ", "start", "back_good", "back_err", "not_back", "avg(us)", "max(us)", "min(us)"); - tmp_buf = kzalloc(temp_array_len, GFP_KERNEL); - if (tmp_buf == NULL) + tmp_buf = (S8 *)kzalloc(temp_array_len, GFP_KERNEL); + if (tmp_buf == NULL) { goto l_out; + } for (; i < PS3_QOS_PD_PRO; ++i) { - temp_len = snprintf( - tmp_buf, temp_array_len, - "%-25s %-15llu %-15llu %-15llu %-15llu %-20llu %-20llu %-20llu\n", + temp_len = snprintf(tmp_buf, temp_array_len, + "%-25s %-15llu %-15llu %-15llu %-15llu " + "%-20llu %-20llu %-20llu\n", ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), ctx->inc_stat.stat[i].start, ctx->inc_stat.stat[i].back_good, @@ -3338,9 +3158,9 @@ static void ps3_stat_inc_dump(struct ps3_instance *instance, char *buf, memset(tmp_buf, 0, temp_array_len); - len += snprintf( - buf + len, total_len - len, - "%-25s %-15llu %-15llu %-15llu %-15llu %-20llu %-20llu %-20llu\n", + len += snprintf(buf + len, total_len - len, + "%-25s %-15llu %-15llu %-15llu %-15llu " + "%-20llu %-20llu %-20llu\n", ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), ctx->inc_stat.stat[i].start, ctx->inc_stat.stat[i].back_good, @@ -3352,29 +3172,28 @@ static void ps3_stat_inc_dump(struct ps3_instance *instance, char *buf, } temp_len = snprintf(tmp_buf, temp_array_len, - "----host[%u] cmd statistics show end----\n", - PS3_HOST(instance)); + "----host[%u] cmd statistics show end----\n", PS3_HOST(instance)); if ((len + temp_len) > total_len) { ps3stor_cli_printf("print over!\n"); goto l_out; } len += snprintf(buf + len, total_len - len, - "----host[%u] cmd statistics show end----\n", - PS3_HOST(instance)); + "----host[%u] cmd statistics show end----\n", PS3_HOST(instance)); l_out: if (tmp_buf != NULL) { - kfree((void *)tmp_buf); + kfree((void*)tmp_buf); tmp_buf = NULL; } + return; } static void ps3_stat_inc_show_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - char *buf = NULL; - unsigned short host_no = 0; - int ret = PS3_SUCCESS; + S8 *buf = NULL; + U16 host_no = 0; + S32 ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3398,7 +3217,7 @@ static void ps3_stat_inc_show_cb(int argc, char *argv[]) goto l_out; } - buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = (S8 *)kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_out; @@ -3412,13 +3231,14 @@ static void ps3_stat_inc_show_cb(int argc, char *argv[]) kfree(buf); buf = NULL; } + return; } static void ps3_stat_buf_clr_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - int ret = PS3_SUCCESS; + U16 host_no = 0; + S32 ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3452,8 +3272,8 @@ static void ps3_stat_buf_clr_cb(int argc, char *argv[]) static void ps3_stat_interval_show_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - int ret = PS3_SUCCESS; + U16 host_no = 0; + S32 ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3478,7 +3298,7 @@ static void ps3_stat_interval_show_cb(int argc, char *argv[]) } ps3stor_cli_printf("cmd stat interval is %u ms\n", - instance->cmd_statistics.stat_interval); + instance->cmd_statistics.stat_interval); l_out: return; @@ -3487,9 +3307,9 @@ static void ps3_stat_interval_show_cb(int argc, char *argv[]) static void ps3_stat_interval_store_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - unsigned int interval = 0; - int ret = PS3_SUCCESS; + U16 host_no = 0; + U32 interval = 0; + S32 ret = PS3_SUCCESS; if (argc < 5) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3532,7 +3352,7 @@ static void ps3_stat_interval_store_cb(int argc, char *argv[]) instance->cmd_statistics.stat_interval = interval; ps3stor_cli_printf("cmd stat interval is %u ms\n", - instance->cmd_statistics.stat_interval); + instance->cmd_statistics.stat_interval); l_out: return; @@ -3541,8 +3361,8 @@ static void ps3_stat_interval_store_cb(int argc, char *argv[]) static void ps3_reply_fifo_reset_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - int ret = PS3_SUCCESS; + U16 host_no = 0; + S32 ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3577,8 +3397,8 @@ static void ps3_reply_fifo_reset_cb(int argc, char *argv[]) static void ps3_cli_remove_host_force(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - int ret = PS3_SUCCESS; + U16 host_no = 0; + S32 ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3611,8 +3431,8 @@ static void ps3_cli_remove_host_force(int argc, char *argv[]) static void ps3_cli_ramfs_test_set(int argc, char *argv[]) { - unsigned short ramfs_enable = 0; - int ret = PS3_SUCCESS; + U16 ramfs_enable = 0; + S32 ret = PS3_SUCCESS; if (argc < 2) { ps3stor_cli_printf("Too few args, must input 2 args!\n"); @@ -3625,22 +3445,60 @@ static void ps3_cli_ramfs_test_set(int argc, char *argv[]) goto l_out; } - ps3_ramfs_test_store((int)ramfs_enable); + ps3_ramfs_test_store((S32)ramfs_enable); ps3stor_cli_printf("set ramfs test enable to %d\n", ramfs_enable); l_out: return; } -unsigned char ps3_get_wait_cli_flag(void) +static void ps3_cli_err_inject_active(int argc, char *argv[]) +{ + U32 err_inject_type = 0; + U32 count; + S32 ret = PS3_SUCCESS; + + if (argc < 3) { + ps3stor_cli_printf("Too few args, must input 3 args!\n"); + goto l_out; + } + + ret = kstrtouint(argv[1], 0, &err_inject_type); + if (ret != 0) { + ps3stor_cli_printf("Can not parse err_inject_type!\n"); + goto l_out; + } + + ret = kstrtouint(argv[2], 0, &count); + if (ret != 0) { + ps3stor_cli_printf("Can not parse count!\n"); + goto l_out; + } + + if ((err_inject_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) && + (err_inject_type < PS3_ERR_IJ_MAX_COUNT)) { + INJECT_ACTIVE(err_inject_type, count) + ps3stor_cli_printf("active %u count %u\n", err_inject_type, count); + } +l_out: + return; +} +static void ps3_cli_err_inject_clear(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + INJECT_EXIT() +} + +Bool ps3_get_wait_cli_flag(void) { return ps3_cli_wait_flag; } static void ps3_no_wait_cli_cmd(int argc, char *argv[]) { - unsigned short wait_cli_flag = PS3_FALSE; - int ret = PS3_SUCCESS; + U16 wait_cli_flag = PS3_FALSE; + S32 ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3654,31 +3512,32 @@ static void ps3_no_wait_cli_cmd(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &wait_cli_flag); if (ret != 0) { - ps3stor_cli_printf("Can not parse wait_cli_flag!\n", argv[3]); + ps3stor_cli_printf("Can not parse wait_cli_flag!\n", + argv[3]); goto l_out; } - if (wait_cli_flag) + if (wait_cli_flag) { ps3_cli_wait_flag = PS3_TRUE; - else + } else { ps3_cli_wait_flag = PS3_FALSE; + } ps3stor_cli_printf("ps3 no wait cli flag %d\n", ps3_cli_wait_flag); l_out: return; } -static void ps3_qos_show_pd(struct ps3_instance *instance, unsigned short disk_id) +static void ps3_qos_show_pd(struct ps3_instance *instance, U16 disk_id) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct qos_wait_queue *waitq = NULL; - unsigned short i = 0; - - if (disk_id > 0 && disk_id <= instance->qos_context.max_pd_count) { + U16 i = 0; + if (disk_id > 0 && + disk_id <= instance->qos_context.max_pd_count) { ps3stor_cli_printf("qos pd[%u] info\n", disk_id); qos_pd_mgr = &instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; - ps3stor_cli_printf( - "-----valid[%u] vid[%u] used_quota[%u] quota[%u] total_waited_cmd[%u]\n", + ps3stor_cli_printf("-----valid[%u] vid[%u] used_quota[%u] quota[%u] total_waited_cmd[%u]\n", ps3_atomic_read(&qos_pd_mgr->valid), qos_pd_mgr->vd_id, ps3_atomic_read(&qos_pd_mgr->pd_used_quota), qos_pd_mgr->pd_quota, qos_pd_mgr->total_wait_cmd_cnt); @@ -3686,8 +3545,7 @@ static void ps3_qos_show_pd(struct ps3_instance *instance, unsigned short disk_i for (i = 1; i < qos_pd_mgr->waitq_cnt; i++) { waitq = &qos_pd_mgr->waitqs[i]; if (waitq->count > 0) { - ps3stor_cli_printf( - " vid[%u] waitq_cnt[%u]\n", + ps3stor_cli_printf(" vid[%u] waitq_cnt[%u]\n", waitq->id, waitq->count); } } @@ -3695,10 +3553,9 @@ static void ps3_qos_show_pd(struct ps3_instance *instance, unsigned short disk_i if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { waitq = &qos_pd_mgr->waitqs[0]; - ps3stor_cli_printf( - " direct_used_quota[%u] direct_quota[%u] waitq_cnt[%u]\n", - ps3_atomic_read(&qos_pd_mgr->direct_used_quota), - qos_pd_mgr->direct_quota, waitq->count); + ps3stor_cli_printf(" direct_used_quota[%u] direct_quota[%u] waitq_cnt[%u]\n", + ps3_atomic_read(&qos_pd_mgr->direct_used_quota), + qos_pd_mgr->direct_quota, waitq->count); } } else { @@ -3706,33 +3563,26 @@ static void ps3_qos_show_pd(struct ps3_instance *instance, unsigned short disk_i } } -static void ps3_qos_show_vd(struct ps3_instance *instance, unsigned short disk_id) +static void ps3_qos_show_vd(struct ps3_instance *instance, U16 disk_id) { - unsigned char i = 0; + U8 i = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_cq_context *qos_cq_ctx = &instance->qos_context.cq_ctx; struct ps3_qos_softq_mgr *qos_softq_mgr = NULL; - if (disk_id > 0 && disk_id <= instance->qos_context.max_vd_count) { ps3stor_cli_printf("qos vd[%u] info\n", disk_id); if (instance->qos_context.vd_ctx.qos_vd_mgrs) { - qos_vd_mgr = &instance->qos_context.vd_ctx - .qos_vd_mgrs[disk_id]; - ps3stor_cli_printf( - "-----valid[%u] quota[%u] quota_waitq[%u] exclusive[%u]\n", - qos_vd_mgr->valid, - ps3_atomic_read(&qos_vd_mgr->vd_quota), - qos_vd_mgr->vd_quota_wait_q.count, - ps3_atomic_read( - &qos_vd_mgr->exclusive_cmd_cnt)); + qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[disk_id]; + ps3stor_cli_printf("-----valid[%u] quota[%u] quota_waitq[%u] exclusive[%u]\n", + qos_vd_mgr->valid, ps3_atomic_read(&qos_vd_mgr->vd_quota), + qos_vd_mgr->vd_quota_wait_q.count, ps3_atomic_read(&qos_vd_mgr->exclusive_cmd_cnt)); } if (qos_cq_ctx->cmdqs) { for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { qos_softq_mgr = &qos_cq_ctx->cmdqs[i]; - ps3stor_cli_printf( - "-----cmdq[%u] waitq_cnt[%u]\n", i, - qos_softq_mgr->waitqs[disk_id].count); + ps3stor_cli_printf("-----cmdq[%u] waitq_cnt[%u]\n", + i, qos_softq_mgr->waitqs[disk_id].count); } } } else { @@ -3740,122 +3590,113 @@ static void ps3_qos_show_vd(struct ps3_instance *instance, unsigned short disk_i } } -static void ps3_qos_stat_dump(struct ps3_instance *instance, char *buf, - int total_len) +static void ps3_qos_stat_dump(struct ps3_instance *instance, + char *buf, S32 total_len) { - int len = 0; - struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; - struct ps3_qos_pd_context *qos_pd_ctx = &instance->qos_context.pd_ctx; - struct ps3_qos_vd_context *qos_vd_ctx = &instance->qos_context.vd_ctx; + S32 len = 0; + struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; + struct ps3_qos_pd_context *qos_pd_ctx = &instance->qos_context.pd_ctx; + struct ps3_qos_vd_context *qos_vd_ctx = &instance->qos_context.vd_ctx; struct ps3_qos_cq_context *qos_cq_ctx = &instance->qos_context.cq_ctx; struct ps3_qos_softq_mgr *qos_softq_mgr = NULL; - struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - struct qos_wait_queue *cmd_waitq = NULL; - unsigned short i = 0; + struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; + struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; + struct qos_wait_queue *cmd_waitq = NULL; + U16 i = 0; - len += snprintf( - buf + len, total_len - len, - "----host[%u] qos cmd statistics show begin switch[%u] total_qos_cmd[%llu]\n", - PS3_HOST(instance), instance->qos_context.qos_switch, + len += snprintf(buf + len, total_len - len, + "----host[%u] qos cmd statistics show begin switch[%u] " + "total_qos_cmd[%llu]\n", + PS3_HOST(instance), instance->qos_context.qos_switch, ps3_atomic64_read(&instance->cmd_statistics.cmd_qos_total)); if (qos_tg_ctx->vd_cmd_waitqs) { len += snprintf(buf + len, total_len - len, - "tag: share[%u] mgr[%u]\n", - ps3_atomic_read(&qos_tg_ctx->share_free_cnt), - ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt)); - - if (qos_tg_ctx->mgr_cmd_wait_q.count > 0) { - len += snprintf(buf + len, total_len - len, - "mgr cmd waitq count[%u]\n", - qos_tg_ctx->mgr_cmd_wait_q.count); - if (len >= total_len) - goto l_out; - } + "tag: share[%u] mgr[%u]\n", ps3_atomic_read(&qos_tg_ctx->share_free_cnt), + ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt)); + + if (qos_tg_ctx ->mgr_cmd_wait_q.count > 0) { + len += snprintf(buf + len, total_len - len, + "mgr cmd waitq count[%u]\n", + qos_tg_ctx->mgr_cmd_wait_q.count); + if (len >= total_len) { + goto l_out; + } + } for (i = 1; i <= instance->qos_context.max_vd_count; i++) { - cmd_waitq = &qos_tg_ctx->vd_cmd_waitqs[i]; - if (cmd_waitq->count) { - len += snprintf(buf + len, total_len - len, - "vd[%u] cmd waitq_count[%u]\n", - i, cmd_waitq->count); - if (len >= total_len) - goto l_out; - } - } + cmd_waitq = &qos_tg_ctx ->vd_cmd_waitqs[i]; + if (cmd_waitq->count) { + len += snprintf(buf + len, total_len - len, + "vd[%u] cmd waitq_count[%u]\n", i, cmd_waitq->count); + if (len >= total_len) { + goto l_out; + } + } + } } if (qos_cq_ctx->cmdqs) { qos_softq_mgr = &qos_cq_ctx->mgrq; len += snprintf(buf + len, total_len - len, - "mgrq: free[%u] waitq_count[%u]\n", - ps3_atomic_read(&qos_softq_mgr->free_cnt), - qos_softq_mgr->total_wait_cmd_cnt); - if (len >= total_len) - goto l_out; + "mgrq: free[%u] waitq_count[%u]\n", ps3_atomic_read(&qos_softq_mgr->free_cnt), + qos_softq_mgr->total_wait_cmd_cnt); + if (len >= total_len) { + goto l_out; + } for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { qos_softq_mgr = &qos_cq_ctx->cmdqs[i]; - len += snprintf( - buf + len, total_len - len, - "cmdq[%u]: free[%u] waitq_count[%u]\n", i, - ps3_atomic_read(&qos_softq_mgr->free_cnt), + len += snprintf(buf + len, total_len - len, + "cmdq[%u]: free[%u] waitq_count[%u]\n", i, ps3_atomic_read(&qos_softq_mgr->free_cnt), qos_softq_mgr->total_wait_cmd_cnt); - if (len >= total_len) - goto l_out; + if (len >= total_len) { + goto l_out; + } } } if (qos_pd_ctx->qos_pd_mgrs) { - for (i = 1; i <= instance->qos_context.max_pd_count; i++) { - qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[i]; - if (qos_pd_mgr->total_wait_cmd_cnt) { - len += snprintf( - buf + len, total_len - len, + for (i = 1; i <= instance->qos_context.max_pd_count; i++) { + qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[i]; + if (qos_pd_mgr->total_wait_cmd_cnt) { + len += snprintf(buf + len, total_len - len, "pid[%u] vid[%u] valid[%u] used_quota[%u] waitq_count[%u]\n", - qos_pd_mgr->disk_id, qos_pd_mgr->vd_id, - ps3_atomic_read(&qos_pd_mgr->valid), - ps3_atomic_read( - &qos_pd_mgr->pd_used_quota), - qos_pd_mgr->total_wait_cmd_cnt); - if (len >= total_len) - goto l_out; - } + qos_pd_mgr->disk_id, qos_pd_mgr->vd_id, ps3_atomic_read(&qos_pd_mgr->valid), + ps3_atomic_read(&qos_pd_mgr->pd_used_quota),qos_pd_mgr->total_wait_cmd_cnt); + if (len >= total_len) { + goto l_out; + } + } if (qos_pd_mgr->total_waited_direct_cmd) { - len += snprintf( - buf + len, total_len - len, + len += snprintf(buf + len, total_len - len, "pid[%u] valid[%u] direct_used_quota[%u] waitq_count[%u]\n", - qos_pd_mgr->disk_id, qos_pd_mgr->vd_id, - ps3_atomic_read( - &qos_pd_mgr->direct_used_quota), + qos_pd_mgr->disk_id, qos_pd_mgr->vd_id, ps3_atomic_read(&qos_pd_mgr->direct_used_quota), qos_pd_mgr->total_waited_direct_cmd); - if (len >= total_len) - goto l_out; + if (len >= total_len) { + goto l_out; + } } - } + } } if (qos_vd_ctx->qos_vd_mgrs) { - for (i = 1; i <= instance->qos_context.max_vd_count; i++) { - qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[i]; - if (qos_vd_mgr->vd_quota_wait_q.count) { - len += snprintf( - buf + len, total_len - len, - "vid[%u] quota[%u] waitq_count[%u]\n", - i, - ps3_atomic_read(&qos_vd_mgr->vd_quota), - qos_vd_mgr->vd_quota_wait_q.count); - if (len >= total_len) - goto l_out; - } - } - } - - len += snprintf(buf + len, total_len - len, - "----host[%u] qos cmd statistics show end----\n", - PS3_HOST(instance)); + for (i = 1; i <= instance->qos_context.max_vd_count; i++) { + qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[i]; + if (qos_vd_mgr->vd_quota_wait_q.count) { + len += snprintf(buf + len, total_len - len, + "vid[%u] quota[%u] waitq_count[%u]\n", + i, ps3_atomic_read(&qos_vd_mgr->vd_quota),qos_vd_mgr->vd_quota_wait_q.count); + if (len >= total_len) { + goto l_out; + } + } + } + } + + len += snprintf(buf + len, total_len - len, + "----host[%u] qos cmd statistics show end----\n", PS3_HOST(instance)); l_out: return; } @@ -3863,32 +3704,30 @@ static void ps3_qos_stat_dump(struct ps3_instance *instance, char *buf, static void ps3_qos_show_delay(struct ps3_instance *instance) { struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - unsigned short i = 0; + U16 i = 0; - ps3stor_cli_printf("----host[%u] qos delay show begin----\n", - PS3_HOST(instance)); - ps3stor_cli_printf("%-25s %-20s %-20s %-20s\n", " ", "avg(us)", - "max(us)", "min(us)"); + ps3stor_cli_printf("----host[%u] qos delay show begin----\n", PS3_HOST(instance)); + ps3stor_cli_printf("%-25s %-20s %-20s %-20s\n", + " ", "avg(us)", "max(us)", "min(us)"); for (i = PS3_QOS_PD_PRO; i < PS3_CMD_STAT_COUNT; i++) { - ps3stor_cli_printf( - "%-25s %-20llu %-20llu %-20llu\n", + ps3stor_cli_printf("%-25s %-20llu %-20llu %-20llu\n", ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), ctx->total_stat.stat[i].lagency.avg, ctx->total_stat.stat[i].lagency.max_lagency, ctx->total_stat.stat[i].lagency.min_lagency); } - ps3stor_cli_printf("----host[%u] qos delay show end----\n", - PS3_HOST(instance)); + ps3stor_cli_printf("----host[%u] qos delay show end----\n", PS3_HOST(instance)); + return; } static void ps3_cli_qos_info(int argc, char *argv[]) { - struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - unsigned short disk_id = 0; - char *buf = NULL; - int ret = 0; + struct ps3_instance *instance = NULL; + U16 host_no = 0; + U16 disk_id = 0; + S8 *buf = NULL; + S32 ret = 0; if (argc < 4) { ps3stor_cli_printf("Too few args, must input 4 args!\n"); @@ -3912,10 +3751,10 @@ static void ps3_cli_qos_info(int argc, char *argv[]) goto l_out; } - if (!instance->qos_context.inited) { - ps3stor_cli_printf("qos not support host_no %u !\n", host_no); + if (!instance->qos_context.inited) { + ps3stor_cli_printf("qos not support host_no %u !\n", host_no); goto l_out; - } + } if (strcmp(argv[3], "pd") == 0) { if (argc < 5) { @@ -3944,7 +3783,7 @@ static void ps3_cli_qos_info(int argc, char *argv[]) ps3_qos_show_vd(instance, disk_id); goto l_out; } else if (strcmp(argv[3], "all") == 0) { - buf = kzalloc(PAGE_SIZE * 2, GFP_KERNEL); + buf = (S8 *)kzalloc(PAGE_SIZE * 2, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_out; @@ -3956,18 +3795,20 @@ static void ps3_cli_qos_info(int argc, char *argv[]) ps3_qos_show_delay(instance); } l_out: - if (buf != NULL) { + if (buf != NULL) { kfree(buf); buf = NULL; } + + return; } -static void ps3_cli_special_log(int argc, char *argv[]) +static void ps3_cli_special_log(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - unsigned short host_no = 0; - unsigned short print_switch = 0; - int ret = 0; + U16 host_no = 0; + U16 print_switch = 0; + S32 ret = 0; if (argc < 5) { ps3stor_cli_printf("Too few args, must input 5 args!\n"); @@ -4000,25 +3841,1495 @@ static void ps3_cli_special_log(int argc, char *argv[]) instance->is_print_special_log = (print_switch > 0 ? 1 : 0); ps3stor_cli_printf("set print_special_log=%u\n", - instance->is_print_special_log); + instance->is_print_special_log); } l_out: return; } +#ifdef PS3_SUPPORT_INJECT +struct inject_cmds_t * ps3_inject_scsi_rw_exist(struct inject_cmds_t *this_pitem) +{ + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + Bool is_find = PS3_FALSE; + + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->scsi_rw_list)) { + goto l_out; + } + + list_for_each_entry(pitem, &p_inject_list->scsi_rw_list, list) { + if ((this_pitem->item.scsi_cmd.host_no == pitem->item.scsi_cmd.host_no) && + (this_pitem->item.scsi_cmd.channel == pitem->item.scsi_cmd.channel) && + (this_pitem->item.scsi_cmd.id == pitem->item.scsi_cmd.id)) { + if (((this_pitem->item.scsi_cmd.lba >= pitem->item.scsi_cmd.lba) && + (this_pitem->item.scsi_cmd.lba <= pitem->item.scsi_cmd.lba + pitem->item.scsi_cmd.len)) || + ((this_pitem->item.scsi_cmd.lba + this_pitem->item.scsi_cmd.len >= pitem->item.scsi_cmd.lba) && + (this_pitem->item.scsi_cmd.lba + this_pitem->item.scsi_cmd.len <= + pitem->item.scsi_cmd.lba + pitem->item.scsi_cmd.len))) { + ps3stor_cli_printf("inject [%u:%u:%u] lba[0x%llx], len[0x%x], is exist!\n", + pitem->item.scsi_cmd.host_no, pitem->item.scsi_cmd.channel, + pitem->item.scsi_cmd.id, pitem->item.scsi_cmd.lba, + pitem->item.scsi_cmd.len); + is_find = PS3_TRUE; + break; + } + } + } +l_out: + if(!is_find) { + pitem = NULL; + } + ps3_mutex_unlock(&p_inject_list->lock); + return pitem; +} -void ps3_cli_debug_init(void) +struct inject_cmds_t * ps3_inject_scsi_task_exist(struct inject_cmds_t *this_pitem) { - int ret = 0; - struct ps3_cli_debug_cmd *cmd = NULL; - unsigned int table_index = 0; - unsigned int table_size = ARRAY_SIZE(g_ps3_cli_debug_cmd_table); + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + Bool is_find = PS3_FALSE; - for (table_index = 0; table_index < table_size; table_index++) { - cmd = &g_ps3_cli_debug_cmd_table[table_index]; - ret = ps3stor_cli_register(cmd->func, cmd->func_name, - cmd->help); - if (ret) - pr_err("cli register failed:%s:%d\n", cmd->func_name, ret); + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->scsi_task_list)) { + goto l_out; + } + + list_for_each_entry(pitem, &p_inject_list->scsi_task_list, list) { + if ((this_pitem->item.scsi_task_cmd.host_no == pitem->item.scsi_task_cmd.host_no) && + (this_pitem->item.scsi_task_cmd.channel == pitem->item.scsi_task_cmd.channel) && + (this_pitem->item.scsi_task_cmd.id == pitem->item.scsi_task_cmd.id)) { + if (this_pitem->item.scsi_task_cmd.cmd_type == pitem->item.scsi_task_cmd.cmd_type && + this_pitem->item.scsi_task_cmd.cmd_sub_type == pitem->item.scsi_task_cmd.cmd_sub_type) { + is_find = PS3_TRUE; + break; + } + } + } +l_out: + if(!is_find) { + pitem = NULL; + } + ps3_mutex_unlock(&p_inject_list->lock); + return pitem; +} +struct inject_cmds_t * ps3_inject_mgr_exist(struct inject_cmds_t *this_pitem) +{ + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + Bool is_find = PS3_FALSE; + + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->mgr_list)) { + goto l_out; + } + + list_for_each_entry(pitem, &p_inject_list->mgr_list, list) { + if ((this_pitem->item.mgr_cmd.host_no == pitem->item.mgr_cmd.host_no) && + (this_pitem->item.mgr_cmd.cmd_type == pitem->item.mgr_cmd.cmd_type) && + (this_pitem->item.mgr_cmd.cmd_sub_type == pitem->item.mgr_cmd.cmd_sub_type)) { + is_find = PS3_TRUE; + } + } +l_out: + if(!is_find) { + pitem = NULL; + } + ps3_mutex_unlock(&p_inject_list->lock); + return pitem; +} + +void ps3_show_inject_scsi_rw_item(struct inject_cmds_t *pitem) +{ + struct inject_cmds_t *pitem1 = NULL; + PS3Inject_s *p_inject_list = get_inject(); + + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->scsi_rw_list)) { + ps3stor_cli_printf("rw inject list is empty!\n"); + ps3_mutex_unlock(&p_inject_list->lock); + goto l_out; + } + ps3_mutex_unlock(&p_inject_list->lock); + + if ((pitem1 = ps3_inject_scsi_rw_exist(pitem)) == NULL){ + ps3stor_cli_printf("rw inject type is noexist!\n"); + goto l_out; + } + ps3stor_cli_printf("inject_rw host_no %u channel %u id %u lba 0x%llx len 0x%u type %u, time %u!\n", + pitem1->item.scsi_cmd.host_no, pitem1->item.scsi_cmd.channel, + pitem1->item.scsi_cmd.id, pitem1->item.scsi_cmd.lba, + pitem1->item.scsi_cmd.len, pitem1->item.scsi_cmd.dealType, + pitem1->item.scsi_cmd.inject_count); + +l_out: + return; +} + +void ps3_show_inject_all_scsi_rw(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + + (void)argc; + (void)argv; + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->scsi_rw_list)) { + ps3stor_cli_printf("rw inject list is empty!\n"); + goto l_out; + } + + list_for_each_entry(pitem, &p_inject_list->scsi_rw_list, list) { + ps3stor_cli_printf("inject_rw host_no %u channel %u id %u lba 0x%llx len 0x%u!\n", + pitem->item.scsi_cmd.host_no, pitem->item.scsi_cmd.channel, + pitem->item.scsi_cmd.id, pitem->item.scsi_cmd.lba, + pitem->item.scsi_cmd.len); + } + +l_out: + ps3_mutex_unlock(&p_inject_list->lock); + return; +} +void ps3_show_inject_scsi_task_item(struct inject_cmds_t *pitem) +{ + struct inject_cmds_t *pitem1; + PS3Inject_s *p_inject_list = get_inject(); + + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->scsi_task_list)) { + ps3stor_cli_printf("task inject list is empty!\n"); + ps3_mutex_unlock(&p_inject_list->lock); + goto l_out; + } + ps3_mutex_unlock(&p_inject_list->lock); + + if ((pitem1 = ps3_inject_scsi_task_exist(pitem)) == NULL){ + ps3stor_cli_printf("task inject type is noexist!\n"); + goto l_out; + } + ps3stor_cli_printf("inject_rw host_no %u channel %u id %u cmdtype" + " 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", + pitem1->item.scsi_task_cmd.host_no, pitem1->item.scsi_task_cmd.channel, + pitem1->item.scsi_task_cmd.id, pitem1->item.scsi_task_cmd.cmd_type, + pitem1->item.scsi_task_cmd.cmd_sub_type, pitem1->item.scsi_task_cmd.dealType, + pitem1->item.scsi_task_cmd.inject_count); + +l_out: + return; +} +void ps3_show_inject_mgr_item(struct inject_cmds_t *pitem) +{ + struct inject_cmds_t *pitem1; + PS3Inject_s *p_inject_list = get_inject(); + + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->mgr_list)) { + ps3_mutex_unlock(&p_inject_list->lock); + goto l_out; + } + ps3_mutex_unlock(&p_inject_list->lock); + + if ((pitem1 = ps3_inject_mgr_exist(pitem)) == NULL){ + ps3stor_cli_printf("mgr type is noexist!\n"); + goto l_out; + } + ps3stor_cli_printf("inject_mgr host_no %u cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", + pitem1->item.mgr_cmd.host_no, pitem1->item.mgr_cmd.cmd_type, + pitem1->item.mgr_cmd.cmd_sub_type, pitem1->item.mgr_cmd.dealType, + pitem1->item.mgr_cmd.inject_count); + +l_out: + return; +} + +void ps3_show_inject_all_scsi_task(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + + (void)argc; + (void)argv; + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->scsi_task_list)) { + ps3stor_cli_printf("task inject list is empty!\n"); + goto l_out; + } + + list_for_each_entry(pitem, &p_inject_list->scsi_task_list, list) { + ps3stor_cli_printf("inject_task host_no %u channel %u id %u" + " cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", + pitem->item.scsi_task_cmd.host_no, pitem->item.scsi_task_cmd.channel, + pitem->item.scsi_task_cmd.id, pitem->item.scsi_task_cmd.cmd_type, + pitem->item.scsi_task_cmd.cmd_sub_type,pitem->item.scsi_task_cmd.dealType, + pitem->item.scsi_task_cmd.inject_count); + } + +l_out: + ps3_mutex_unlock(&p_inject_list->lock); + return; +} +void ps3_show_inject_all_mgr(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + + (void)argc; + (void)argv; + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_inject_list->mgr_list)) { + goto l_out; + } + + list_for_each_entry(pitem, &p_inject_list->mgr_list, list) { + ps3stor_cli_printf("inject_task host_no %u cmdtype 0x%u " + "cmdSubtype 0x%u dealType 0x%u times %u!\n", + pitem->item.mgr_cmd.host_no, pitem->item.mgr_cmd.cmd_type, + pitem->item.mgr_cmd.cmd_sub_type,pitem->item.mgr_cmd.dealType, + pitem->item.mgr_cmd.inject_count); + } + +l_out: + ps3_mutex_unlock(&p_inject_list->lock); + return; +} + +void ps3_clear_all_inject_scsi_rw(void) +{ + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + struct inject_cmds_t *pitem_next = NULL; + + ps3_mutex_lock(&p_inject_list->lock); + + if (list_empty(&p_inject_list->scsi_rw_list)) { + goto l_out; + } + + list_for_each_entry_safe(pitem, pitem_next, &p_inject_list->scsi_rw_list, list) { + list_del(&pitem->list); + kfree(pitem); + } + +l_out: + ps3_mutex_unlock(&p_inject_list->lock); + return; +} +void ps3_clear_all_inject_scsi_task(void) +{ + struct inject_cmds_t *pitem = NULL; + struct inject_cmds_t *pitem_next = NULL; + PS3Inject_s *p_inject_list = get_inject(); + + ps3_mutex_lock(&p_inject_list->lock); + + if (list_empty(&p_inject_list->scsi_task_list)) { + goto l_out; + } + + list_for_each_entry_safe(pitem, pitem_next, &p_inject_list->scsi_task_list, list) { + list_del(&pitem->list); + kfree(pitem); + } + +l_out: + ps3_mutex_unlock(&p_inject_list->lock); + return; +} +void ps3_clear_all_inject_mgr(void) +{ + struct inject_cmds_t *pitem = NULL; + struct inject_cmds_t *pitem_next = NULL; + PS3Inject_s *p_inject_list = get_inject(); + + ps3_mutex_lock(&p_inject_list->lock); + + if (list_empty(&p_inject_list->mgr_list)) { + goto l_out; + } + + list_for_each_entry_safe(pitem, pitem_next, &p_inject_list->mgr_list, list) { + list_del(&pitem->list); + kfree(pitem); + } + +l_out: + ps3_mutex_unlock(&p_inject_list->lock); + return; +} + +void ps3_del_inject_scsi_rw(struct inject_cmds_t *pitem) +{ + struct inject_cmds_t *pitem1; + PS3Inject_s *p_inject_list = get_inject(); + + if ((pitem1 = ps3_inject_scsi_rw_exist(pitem)) == NULL){ + ps3stor_cli_printf("rw inject type is noexist!\n"); + goto l_err; + } + ps3_mutex_lock(&p_inject_list->lock); + ps3stor_cli_printf("del inject_rw host_no %u channel %u id %u lba 0x%llx len 0x%u type %u, time %u!\n", + pitem1->item.scsi_cmd.host_no, pitem1->item.scsi_cmd.channel, + pitem1->item.scsi_cmd.id, pitem1->item.scsi_cmd.lba, + pitem1->item.scsi_cmd.len, pitem1->item.scsi_cmd.dealType, + pitem1->item.scsi_cmd.inject_count); + list_del(&pitem1->list); + ps3_mutex_unlock(&p_inject_list->lock); + kfree(pitem1); + +l_err: + kfree(pitem); + return; +} +void ps3_del_inject_scsi_task(struct inject_cmds_t *pitem) +{ + struct inject_cmds_t *pitem1; + PS3Inject_s *p_inject_list = get_inject(); + + if ((pitem1 = ps3_inject_scsi_task_exist(pitem)) == NULL){ + ps3stor_cli_printf("task inject type is noexist!\n"); + goto l_err; + } + ps3_mutex_lock(&p_inject_list->lock); + ps3stor_cli_printf("del inject_task host_no %u channel %u id %u" + " cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", + pitem1->item.scsi_task_cmd.host_no, pitem1->item.scsi_task_cmd.channel, + pitem1->item.scsi_task_cmd.id, pitem1->item.scsi_task_cmd.cmd_type, + pitem1->item.scsi_task_cmd.cmd_sub_type, pitem1->item.scsi_task_cmd.dealType, + pitem1->item.scsi_task_cmd.inject_count); + list_del(&pitem1->list); + ps3_mutex_unlock(&p_inject_list->lock); + kfree(pitem1); + +l_err: + kfree(pitem); + return; +} +void ps3_del_inject_mgr(struct inject_cmds_t *pitem) +{ + struct inject_cmds_t *pitem1; + PS3Inject_s *p_inject_list = get_inject(); + + if ((pitem1 = ps3_inject_mgr_exist(pitem)) == NULL){ + ps3stor_cli_printf("mgr inject type is noexist!\n"); + goto l_err; + } + ps3_mutex_lock(&p_inject_list->lock); + ps3stor_cli_printf("del inject_mgr host_no %u cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", + pitem1->item.mgr_cmd.host_no, pitem1->item.mgr_cmd.cmd_type, + pitem1->item.mgr_cmd.cmd_sub_type,pitem1->item.mgr_cmd.dealType, + pitem1->item.mgr_cmd.inject_count); + list_del(&pitem1->list); + ps3_mutex_unlock(&p_inject_list->lock); + kfree(pitem1); + +l_err: + kfree(pitem); + return; +} + +S32 ps3_add_inject_scsi_rw(struct inject_cmds_t *pitem) +{ + S32 iRet = PS3_SUCCESS; + PS3Inject_s *p_inject_list = get_inject(); + + if (ps3_inject_scsi_rw_exist(pitem) != NULL){ + ps3stor_cli_printf("rw inject type is exist!\n"); + iRet = -PS3_FAILED; + goto l_err; + } + ps3_mutex_lock(&p_inject_list->lock); + ps3stor_cli_printf("inject_rw host_no %u channel %u id %u lba 0x%llx len 0x%u type %u, time %u!\n", + pitem->item.scsi_cmd.host_no, pitem->item.scsi_cmd.channel, + pitem->item.scsi_cmd.id, pitem->item.scsi_cmd.lba, + pitem->item.scsi_cmd.len, pitem->item.scsi_cmd.dealType, + pitem->item.scsi_cmd.inject_count); + list_add_tail(&pitem->list, &p_inject_list->scsi_rw_list); + ps3_mutex_unlock(&p_inject_list->lock); + goto l_out; + +l_err: + kfree(pitem); +l_out: + return iRet; +} +S32 ps3_add_inject_scsi_task(struct inject_cmds_t *pitem) +{ + S32 iRet = PS3_SUCCESS; + PS3Inject_s *p_inject_list = get_inject(); + + if (ps3_inject_scsi_task_exist(pitem) != NULL){ + ps3stor_cli_printf("task inject type is exist!\n"); + iRet = -PS3_FAILED; + goto l_err; + } + ps3_mutex_lock(&p_inject_list->lock); + ps3stor_cli_printf("inject_task host_no %u channel %u id %u " + "cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", + pitem->item.scsi_task_cmd.host_no, pitem->item.scsi_task_cmd.channel, + pitem->item.scsi_task_cmd.id, pitem->item.scsi_task_cmd.cmd_type, + pitem->item.scsi_task_cmd.cmd_sub_type, pitem->item.scsi_task_cmd.dealType, + pitem->item.scsi_task_cmd.inject_count); + list_add_tail(&pitem->list, &p_inject_list->scsi_task_list); + ps3_mutex_unlock(&p_inject_list->lock); + goto l_out; + +l_err: + kfree(pitem); +l_out: + return iRet; +} +S32 ps3_add_inject_mgr(struct inject_cmds_t *pitem) +{ + S32 iRet = PS3_SUCCESS; + PS3Inject_s *p_inject_list = get_inject(); + + if (ps3_inject_mgr_exist(pitem) != NULL){ + ps3stor_cli_printf("mgr inject type is exist!\n"); + iRet = -PS3_FAILED; + goto l_err; + } + ps3_mutex_lock(&p_inject_list->lock); + ps3stor_cli_printf("inject_task host_no %u cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", + pitem->item.mgr_cmd.host_no, pitem->item.mgr_cmd.cmd_type, + pitem->item.mgr_cmd.cmd_sub_type, pitem->item.mgr_cmd.dealType, + pitem->item.mgr_cmd.inject_count); + list_add_tail(&pitem->list, &p_inject_list->mgr_list); + ps3_mutex_unlock(&p_inject_list->lock); + goto l_out; + +l_err: + kfree(pitem); +l_out: + return iRet; +} + +static void ps3_inject_scsi_rw(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + U32 host_no; + U32 id; + U32 channel; + U64 lba; + U32 len; + S32 ret; + U32 result; + U32 sense_info; + struct scsi_device *sdev; + U32 times; + U32 dealType; + struct ps3_instance *instance; + + if (argc < 13) { + ps3stor_cli_printf("Too few args for enject!\n"); + return; + } + + pitem = (struct inject_cmds_t*)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) { + return; + } + + if (strcmp(argv[1], "host_no") != 0) { + ps3stor_cli_printf("host_no is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[2], 0, &host_no); + if (ret != 0) { + ps3stor_cli_printf("Can not parse host_no !\n"); + goto l_err; + } + + instance = ps3_instance_lookup(host_no); + if (instance == NULL) { + ps3stor_cli_printf("Invalid host_no %d invalid !\n", + host_no); + goto l_err; + } + pitem->item.scsi_cmd.host_no = host_no; + + if (strcmp(argv[3], "dev") != 0) { + ps3stor_cli_printf("dev is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[4], 0, &channel); + if (ret != 0) { + ps3stor_cli_printf("Can not parse channel!\n"); + goto l_err; + } + + ret = kstrtouint(argv[5], 0, &id); + if (ret != 0) { + ps3stor_cli_printf("Can not parse id!\n"); + goto l_err; + } + sdev = ps3_scsi_device_lookup(instance, channel, id, 0); + if (sdev == NULL) { + ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", + host_no, channel, id); + goto l_err; + } + pitem->item.scsi_cmd.channel = channel; + pitem->item.scsi_cmd.id = id; + pitem->item.scsi_cmd.device = sdev; + if (strcmp(argv[6], "lba") != 0) { + ps3stor_cli_printf("lba is needed!\n"); + goto l_err; + } + + ret = kstrtou64(argv[7], 0, &lba); + if (ret != 0) { + ps3stor_cli_printf("Can not parse lba!\n"); + goto l_err; + } + pitem->item.scsi_cmd.lba = lba; + + if (strcmp(argv[8], "len") != 0) { + ps3stor_cli_printf("len is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[9], 0, &len); + if (ret != 0) { + ps3stor_cli_printf("Can not parse len!\n"); + goto l_err; + } + pitem->item.scsi_cmd.len = len; + + ret = kstrtouint(argv[10], 0, &dealType); + if (ret != 0) { + ps3stor_cli_printf("Can not parse dealType!\n"); + goto l_err; + } + if (dealType != PS3_SCSI_CMD_TIMEOUT_FORCE_REPLY + && dealType != PS3_SCSI_CMD_ERROR) { + ps3stor_cli_printf("err type is invalid!\n"); + goto l_err; + } + + pitem->item.scsi_cmd.dealType = dealType; + switch (pitem->item.scsi_cmd.dealType) + { + case PS3_SCSI_CMD_TIMEOUT_FORCE_REPLY: + if (strcmp(argv[11], "times") != 0) { + ps3stor_cli_printf("times is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[12], 0, ×); + if (ret != 0) { + ps3stor_cli_printf("Can not parse times!\n"); + goto l_err; + } + pitem->item.scsi_cmd.inject_count = times; + break; + case PS3_SCSI_CMD_ERROR: + if (strcmp(argv[11], "result") != 0) { + ps3stor_cli_printf("result is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[12], 0, &result); + if (ret != 0) { + ps3stor_cli_printf("Can not parse result!\n"); + goto l_err; + } + pitem->item.scsi_cmd.cmdDeal.errReply.result = result; + + if (strcmp(argv[13], "sense") != 0) { + ps3stor_cli_printf("sense is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[14], 0, &sense_info); + if (ret != 0) { + ps3stor_cli_printf("Can not parse sense!\n"); + goto l_err; + } + pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.resp_code = sense_info & 0xf; + pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.sense_key = sense_info >> 8 & 0xf; + pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.asc = sense_info >> 16 & 0xf; + pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.ascq = sense_info >> 24 & 0xf; + + if (strcmp(argv[15], "times") != 0) { + ps3stor_cli_printf("times is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[16], 0, ×); + if (ret != 0) { + ps3stor_cli_printf("Can not parse times!\n"); + goto l_err; + } + pitem->item.scsi_cmd.inject_count = times; + break; + default: + ps3stor_cli_printf("handle type is invalid!\n"); + goto l_err; + break; + } + ps3_add_inject_scsi_rw(pitem); + goto l_out; + +l_err: + kfree(pitem); +l_out: + return; +} +static void ps3_inject_scsi_task(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + U32 host_no; + U32 id; + U32 channel; + S32 ret; + struct scsi_device *sdev; + U32 times; + U32 dealType; + struct ps3_instance *instance; + + if (argc < 10) { + ps3stor_cli_printf("Too few args for enject!\n"); + return; + } + + pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) { + return; + } + + if (strcmp(argv[1], "host_no") != 0) { + ps3stor_cli_printf("host_no is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[2], 0, &host_no); + if (ret != 0) { + ps3stor_cli_printf("Can not parse host_no !\n"); + goto l_err; + } + + instance = ps3_instance_lookup(host_no); + if (instance == NULL) { + ps3stor_cli_printf("Invalid host_no %d invalid !\n", + host_no); + goto l_err; + } + pitem->item.scsi_task_cmd.host_no = host_no; + + if (strcmp(argv[3], "dev") != 0) { + ps3stor_cli_printf("dev is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[4], 0, &channel); + if (ret != 0) { + ps3stor_cli_printf("Can not parse channel!\n"); + goto l_err; + } + + ret = kstrtouint(argv[5], 0, &id); + if (ret != 0) { + ps3stor_cli_printf("Can not parse id!\n"); + goto l_err; + } + sdev = ps3_scsi_device_lookup(instance, channel, id, 0); + if (sdev == NULL) { + ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", + host_no, channel, id); + goto l_err; + } + pitem->item.scsi_task_cmd.channel = channel; + pitem->item.scsi_task_cmd.id = id; + + if (strcmp(argv[6], "abort") == 0) { + pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_ABORT; + } else if (strcmp(argv[6], "reset") == 0) { + pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_RESET; + } else { + ps3stor_cli_printf("type is invalid!\n"); + goto l_err; + } + + ret = kstrtouint(argv[7], 0, &dealType); + if (ret != 0) { + ps3stor_cli_printf("Can not parse dealType!\n"); + goto l_err; + } + if (dealType != PS3_SCSI_TASK_CMD_TIMEOUT && dealType != PS3_SCSI_TASK_CMD_ERROE && + dealType != PS3_SCSI_TASK_CMD_NORMAL) { + ps3stor_cli_printf("deal type is invalid!\n"); + goto l_err; + } + pitem->item.scsi_task_cmd.dealType = dealType; + + if (strcmp(argv[8], "times") != 0) { + ps3stor_cli_printf("times is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[9], 0, ×); + if (ret != 0) { + ps3stor_cli_printf("Can not parse times!\n"); + goto l_err; + } + pitem->item.scsi_task_cmd.inject_count = times; + + ps3_add_inject_scsi_task(pitem); + goto l_out; + +l_err: + kfree(pitem); +l_out: + return; +} +static void ps3_inject_mgr(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + U32 host_no; + U8 cmd_type; + U8 cmd_sub_type; + S32 ret; + U32 times; + U32 dealType; + U32 errType; + struct ps3_instance *instance; + + if (argc < 10) { + ps3stor_cli_printf("Too few args for enject!\n"); + return; + } + + pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) { + return; + } + + if (strcmp(argv[1], "host_no") != 0) { + ps3stor_cli_printf("host_no is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[2], 0, &host_no); + if (ret != 0) { + ps3stor_cli_printf("Can not parse host_no !\n"); + goto l_err; + } + + instance = ps3_instance_lookup(host_no); + if (instance == NULL) { + ps3stor_cli_printf("Invalid host_no %d invalid !\n", + host_no); + goto l_err; + } + pitem->item.scsi_task_cmd.host_no = host_no; + + if (strcmp(argv[3], "cmd_type") != 0) { + ps3stor_cli_printf("cmd_type is needed!\n"); + goto l_err; + } + + ret = kstrtou8(argv[4], 0, &cmd_type); + if (ret != 0) { + ps3stor_cli_printf("Can not parse cmd_type!\n"); + goto l_err; + } + pitem->item.mgr_cmd.cmd_type = cmd_type; + + if (strcmp(argv[5], "cmd_sub_type") != 0) { + ps3stor_cli_printf("cmd_sub_type is needed!\n"); + goto l_err; + } + + ret = kstrtou8(argv[6], 0, &cmd_sub_type); + if (ret != 0) { + ps3stor_cli_printf("Can not parse cmd_sub_type!\n"); + goto l_err; + } + pitem->item.mgr_cmd.cmd_sub_type = cmd_sub_type; + + ret = kstrtouint(argv[7], 0, &dealType); + if (ret != 0) { + ps3stor_cli_printf("Can not parse dealType!\n"); + goto l_err; + } + + if (dealType == PS3_MGR_CMD_TIMEOUT) { + if (strcmp(argv[8], "times") != 0) { + ps3stor_cli_printf("times is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[9], 0, ×); + if (ret != 0) { + ps3stor_cli_printf("Can not parse times!\n"); + goto l_err; + } + } else if (dealType == PS3_MGR_CMD_ERROE) { + ret = kstrtouint(argv[8], 0, &errType); + if (ret != 0) { + ps3stor_cli_printf("Can not parse errType!\n"); + goto l_err; + } + pitem->item.mgr_cmd.errType = errType; + if (strcmp(argv[9], "times") != 0) { + ps3stor_cli_printf("times is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[10], 0, ×); + if (ret != 0) { + ps3stor_cli_printf("Can not parse times!\n"); + goto l_err; + } + } else { + ps3stor_cli_printf("deal type is invalid!\n"); + goto l_err; + } + + pitem->item.mgr_cmd.dealType = dealType; + pitem->item.mgr_cmd.inject_count = times; + + ps3_add_inject_mgr(pitem); + goto l_out; + +l_err: + kfree(pitem); +l_out: + return; +} + +static void ps3_clear_inject_scsi_rw(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + + U32 host_no; + U32 id; + U32 channel; + U64 lba; + U32 len; + S32 ret; + struct scsi_device *sdev; + struct ps3_instance *instance; + + if (argc < 10) { + ps3stor_cli_printf("Too few args for enject!\n"); + return; + } + + pitem = (struct inject_cmds_t*)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) { + return; + } + + if (strcmp(argv[1], "host_no") != 0) { + ps3stor_cli_printf("host_no is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[2], 0, &host_no); + if (ret != 0) { + ps3stor_cli_printf("Can not parse host_no !\n"); + goto l_err; + } + + instance = ps3_instance_lookup(host_no); + if (instance == NULL) { + ps3stor_cli_printf("Invalid host_no %d invalid !\n", + host_no); + goto l_err; + } + pitem->item.scsi_cmd.host_no = host_no; + + if (strcmp(argv[3], "dev") != 0) { + ps3stor_cli_printf("dev is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[4], 0, &channel); + if (ret != 0) { + ps3stor_cli_printf("Can not parse channel!\n"); + goto l_err; + } + + ret = kstrtouint(argv[5], 0, &id); + if (ret != 0) { + ps3stor_cli_printf("Can not parse id!\n"); + goto l_err; + } + sdev = ps3_scsi_device_lookup(instance, channel, id, 0); + if (sdev == NULL) { + ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", + host_no, channel, id); + goto l_err; + } + pitem->item.scsi_cmd.channel = channel; + pitem->item.scsi_cmd.id = id; + pitem->item.scsi_cmd.device = sdev; + if (strcmp(argv[6], "lba") != 0) { + ps3stor_cli_printf("lba is needed!\n"); + goto l_err; + } + + ret = kstrtou64(argv[7], 0, &lba); + if (ret != 0) { + ps3stor_cli_printf("Can not parse lba!\n"); + goto l_err; + } + pitem->item.scsi_cmd.lba = lba; + + if (strcmp(argv[8], "len") != 0) { + ps3stor_cli_printf("len is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[9], 0, &len); + if (ret != 0) { + ps3stor_cli_printf("Can not parse len!\n"); + goto l_err; + } + pitem->item.scsi_cmd.len = len; + + ps3_del_inject_scsi_rw(pitem); + return; + +l_err: + kfree(pitem); + return; +} +static void ps3_clear_inject_scsi_task(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + + U32 host_no; + U32 id; + U32 channel; + S32 ret; + struct scsi_device *sdev; + struct ps3_instance *instance; + + if (argc < 7) { + ps3stor_cli_printf("Too few args for enject!\n"); + return; + } + + pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) { + return; + } + + if (strcmp(argv[1], "host_no") != 0) { + ps3stor_cli_printf("host_no is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[2], 0, &host_no); + if (ret != 0) { + ps3stor_cli_printf("Can not parse host_no !\n"); + goto l_err; + } + + instance = ps3_instance_lookup(host_no); + if (instance == NULL) { + ps3stor_cli_printf("Invalid host_no %d invalid !\n", + host_no); + goto l_err; + } + pitem->item.scsi_task_cmd.host_no = host_no; + + if (strcmp(argv[3], "dev") != 0) { + ps3stor_cli_printf("dev is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[4], 0, &channel); + if (ret != 0) { + ps3stor_cli_printf("Can not parse channel!\n"); + goto l_err; + } + + ret = kstrtouint(argv[5], 0, &id); + if (ret != 0) { + ps3stor_cli_printf("Can not parse id!\n"); + goto l_err; + } + sdev = ps3_scsi_device_lookup(instance, channel, id, 0); + if (sdev == NULL) { + ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", + host_no, channel, id); + goto l_err; + } + pitem->item.scsi_task_cmd.channel = channel; + pitem->item.scsi_task_cmd.id = id; + + if (strcmp(argv[6], "abort") == 0) { + pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_ABORT; + } else if (strcmp(argv[6], "reset") == 0) { + pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_RESET; + } else { + ps3stor_cli_printf("type is invalid!\n"); + goto l_err; + } + ps3_del_inject_scsi_task(pitem); + return; + +l_err: + kfree(pitem); + return; +} + +static void ps3_clear_inject_mgr(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + U32 host_no; + U32 cmd_type; + U32 cmd_sub_type; + S32 ret; + struct ps3_instance *instance; + + if (argc < 7) { + ps3stor_cli_printf("Too few args for enject!\n"); + return; + } + + pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) { + return; + } + + if (strcmp(argv[1], "host_no") != 0) { + ps3stor_cli_printf("host_no is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[2], 0, &host_no); + if (ret != 0) { + ps3stor_cli_printf("Can not parse host_no !\n"); + goto l_err; + } + + instance = ps3_instance_lookup(host_no); + if (instance == NULL) { + ps3stor_cli_printf("Invalid host_no %d invalid !\n", + host_no); + goto l_err; + } + pitem->item.mgr_cmd.host_no = host_no; + + if (strcmp(argv[3], "cmd_type") != 0){ + ps3stor_cli_printf("cmd_type is invalid!\n"); + goto l_err; + } + + ret = kstrtouint(argv[4], 0, &cmd_type); + if (ret != 0) { + ps3stor_cli_printf("Can not parse cmd_type !\n"); + goto l_err; + } + pitem->item.mgr_cmd.cmd_type = cmd_type; + + if (strcmp(argv[5], "cmd_sub_type") != 0){ + ps3stor_cli_printf("cmd_sub_type is invalid!\n"); + goto l_err; + } + + ret = kstrtouint(argv[6], 0, &cmd_sub_type); + if (ret != 0) { + ps3stor_cli_printf("Can not parse cmd_type !\n"); + goto l_err; + } + pitem->item.mgr_cmd.cmd_sub_type = cmd_sub_type; + + ps3_del_inject_mgr(pitem); + return; + +l_err: + kfree(pitem); + return; +} + +static void ps3_clear_all_inject(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + ps3_clear_all_inject_scsi_rw(); + ps3_clear_all_inject_scsi_task(); + ps3_clear_all_inject_mgr(); +} + +static void ps3_show_inject_scsi_rw(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + + U32 host_no; + U32 id; + U32 channel; + U64 lba; + U32 len; + S32 ret; + struct scsi_device *sdev; + struct ps3_instance *instance; + + if (argc < 10) { + ps3stor_cli_printf("Too few args for enject!\n"); + return; + } + + pitem = (struct inject_cmds_t*)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) { + return; + } + + if (strcmp(argv[1], "host_no") != 0) { + ps3stor_cli_printf("host_no is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[2], 0, &host_no); + if (ret != 0) { + ps3stor_cli_printf("Can not parse host_no !\n"); + goto l_err; + } + + instance = ps3_instance_lookup(host_no); + if (instance == NULL) { + ps3stor_cli_printf("Invalid host_no %d invalid !\n", + host_no); + goto l_err; + } + pitem->item.scsi_cmd.host_no = host_no; + + if (strcmp(argv[3], "dev") != 0) { + ps3stor_cli_printf("dev is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[4], 0, &channel); + if (ret != 0) { + ps3stor_cli_printf("Can not parse channel!\n"); + goto l_err; + } + + ret = kstrtouint(argv[5], 0, &id); + if (ret != 0) { + ps3stor_cli_printf("Can not parse id!\n"); + goto l_err; + } + sdev = ps3_scsi_device_lookup(instance, channel, id, 0); + if (sdev == NULL) { + ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", + host_no, channel, id); + goto l_err; + } + pitem->item.scsi_cmd.channel = channel; + pitem->item.scsi_cmd.id = id; + if (strcmp(argv[6], "lba") != 0) { + ps3stor_cli_printf("lba is needed!\n"); + goto l_err; + } + + ret = kstrtou64(argv[7], 0, &lba); + if (ret != 0) { + ps3stor_cli_printf("Can not parse lba!\n"); + goto l_err; + } + pitem->item.scsi_cmd.lba = lba; + + if (strcmp(argv[8], "len") != 0) { + ps3stor_cli_printf("len is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[9], 0, &len); + if (ret != 0) { + ps3stor_cli_printf("Can not parse len!\n"); + goto l_err; + } + pitem->item.scsi_cmd.len = len; + ps3_show_inject_scsi_rw_item(pitem); + return; + +l_err: + kfree(pitem); + return; +} +static void ps3_show_inject_scsi_task(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + + U32 host_no; + U32 id; + U32 channel; + S32 ret; + struct scsi_device *sdev; + struct ps3_instance *instance; + + if (argc < 7) { + ps3stor_cli_printf("Too few args for enject!\n"); + return; + } + + pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) { + return; + } + + if (strcmp(argv[1], "host_no") != 0) { + ps3stor_cli_printf("host_no is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[2], 0, &host_no); + if (ret != 0) { + ps3stor_cli_printf("Can not parse host_no !\n"); + goto l_err; + } + + instance = ps3_instance_lookup(host_no); + if (instance == NULL) { + ps3stor_cli_printf("Invalid host_no %d invalid !\n", + host_no); + goto l_err; + } + pitem->item.scsi_task_cmd.host_no = host_no; + + if (strcmp(argv[3], "dev") != 0) { + ps3stor_cli_printf("dev is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[4], 0, &channel); + if (ret != 0) { + ps3stor_cli_printf("Can not parse channel!\n"); + goto l_err; + } + + ret = kstrtouint(argv[5], 0, &id); + if (ret != 0) { + ps3stor_cli_printf("Can not parse id!\n"); + goto l_err; + } + sdev = ps3_scsi_device_lookup(instance, channel, id, 0); + if (sdev == NULL) { + ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", + host_no, channel, id); + goto l_err; + } + pitem->item.scsi_task_cmd.channel = channel; + pitem->item.scsi_task_cmd.id = id; + + if (strcmp(argv[6], "abort") == 0) { + pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_ABORT; + } else if (strcmp(argv[6], "reset") == 0) { + pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_RESET; + } else { + ps3stor_cli_printf("type is invalid!\n"); + goto l_err; + } + ps3_show_inject_scsi_task_item(pitem); + return; + +l_err: + kfree(pitem); + return; +} +static void ps3_show_inject_mgr(int argc, char *argv[]) +{ + struct inject_cmds_t *pitem = NULL; + + U32 host_no; + U32 cmd_type; + U32 cmd_sub_type; + S32 ret; + struct ps3_instance *instance; + + if (argc < 7) { + ps3stor_cli_printf("Too few args for enject!\n"); + return; + } + + pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) { + return; + } + + if (strcmp(argv[1], "host_no") != 0) { + ps3stor_cli_printf("host_no is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[2], 0, &host_no); + if (ret != 0) { + ps3stor_cli_printf("Can not parse host_no !\n"); + goto l_err; + } + + instance = ps3_instance_lookup(host_no); + if (instance == NULL) { + ps3stor_cli_printf("Invalid host_no %d invalid !\n", + host_no); + goto l_err; + } + pitem->item.scsi_task_cmd.host_no = host_no; + + if (strcmp(argv[3], "cmd_type") != 0) { + ps3stor_cli_printf("dev is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[4], 0, &cmd_type); + if (ret != 0) { + ps3stor_cli_printf("Can not parse cmd_type!\n"); + goto l_err; + } + pitem->item.mgr_cmd.cmd_type = cmd_type; + + if (strcmp(argv[5], "cmd_sub_type") != 0) { + ps3stor_cli_printf("cmd_sub_type is needed!\n"); + goto l_err; + } + + ret = kstrtouint(argv[6], 0, &cmd_sub_type); + if (ret != 0) { + ps3stor_cli_printf("Can not parse cmd_sub_type!\n"); + goto l_err; + } + + ps3_show_inject_mgr_item(pitem); + return; + +l_err: + kfree(pitem); + return; +} +static void ps3_show_all_inject(int argc, char *argv[]) +{ + ps3_show_inject_all_scsi_rw(argc, argv); + ps3_show_inject_all_scsi_task(argc, argv); + ps3_show_inject_all_mgr(argc, argv); + return; +} + +void ps3_scsi_task_cmd_clear_all(void) +{ + struct inject_hit_cmds_t *p_cmd = NULL; + struct inject_hit_cmds_t *p_cmd_next = NULL; + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + PS3HitCmd_s * p_hit_inject = get_hit_inject(); + + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_hit_inject->scsi_task_list)) { + LOG_DEBUG("task inject list is empty!\n"); + goto l_out; + } + + list_for_each_entry_safe(p_cmd, p_cmd_next, &p_hit_inject->scsi_task_list, list) { + list_del(&p_cmd->list); + kfree(p_cmd); + } + + if(pitem->item.scsi_task_cmd.inject_count == 0) { + ps3_delete_scsi_task_inject(pitem); + } + +l_out: + ps3_mutex_unlock(&p_inject_list->lock); + return ; +} + +void ps3_mgr_cmd_clear_all(void) +{ + struct inject_hit_cmds_t *p_cmd = NULL; + struct inject_hit_cmds_t *p_cmd_next = NULL; + struct inject_cmds_t *pitem = NULL; + PS3Inject_s *p_inject_list = get_inject(); + PS3HitCmd_s * p_hit_inject = get_hit_inject(); + + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_hit_inject->mgr_list)) { + LOG_DEBUG("mgr inject list is empty!\n"); + goto l_out; + } + + list_for_each_entry_safe(p_cmd, p_cmd_next, &p_hit_inject->mgr_list, list) { + list_del(&p_cmd->list); + kfree(p_cmd); + } + + if(pitem->item.mgr_cmd.inject_count == 0) { + ps3_delete_mgr_inject(pitem); + } + +l_out: + ps3_mutex_unlock(&p_inject_list->lock); + return ; +} +void ps3_scsi_rw_cmd_clear_all(void) +{ + struct inject_hit_cmds_t *p_cmd = NULL; + struct inject_hit_cmds_t *p_cmd_next = NULL; + PS3Inject_s *p_inject_list = get_inject(); + PS3HitCmd_s * p_hit_inject = get_hit_inject(); + + ps3_mutex_lock(&p_inject_list->lock); + if (list_empty(&p_hit_inject->scsi_rw_list)) { + LOG_DEBUG("rw inject cmd list is empty!\n"); + goto l_out; + } + + list_for_each_entry_safe(p_cmd, p_cmd_next, &p_hit_inject->scsi_rw_list, list) { + list_del(&p_cmd->list); + ps3_scsi_dma_unmap(p_cmd->cmd); + ps3_scsi_cmd_free(p_cmd->cmd); + kfree(p_cmd); + } + +l_out: + ps3_mutex_unlock(&p_inject_list->lock); + return ; +} + +static void ps3_clear_hit_cmd(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + ps3_scsi_rw_cmd_clear_all(); + ps3_scsi_task_cmd_clear_all(); + ps3_mgr_cmd_clear_all(); +} +void ps3_inject_clear(void) +{ + ps3_scsi_rw_cmd_clear_all(); + ps3_scsi_task_cmd_clear_all(); + ps3_mgr_cmd_clear_all(); + + ps3_clear_all_inject_scsi_rw(); + ps3_clear_all_inject_scsi_task(); + ps3_clear_all_inject_mgr(); +} +#endif + +void ps3_cli_debug_init(void) +{ + int ret = 0; + struct ps3_cli_debug_cmd *cmd = NULL; + U32 table_index = 0; + U32 table_size = ARRAY_SIZE(g_ps3_cli_debug_cmd_table); + for (table_index = 0; table_index < table_size; table_index++) { + cmd = &g_ps3_cli_debug_cmd_table[table_index]; + ret = ps3stor_cli_register(cmd->func, cmd->func_name, cmd->help); + if (ret) { + printk("cli register failed:%s:%d\n", cmd->func_name, ret); + } } + INJECT_INIT() } diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.h b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.h index 9b52a395e33a..63b362c25d38 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.h +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_CLI_DEBUG_H_ #define _PS3_CLI_DEBUG_H_ #include "ps3_instance_manager.h" @@ -8,7 +7,12 @@ ssize_t ps3_ioc_reg_dump(struct ps3_instance *instance, char *buf); void ps3_cli_debug_init(void); -void ps3_io_statis_dump_cli_cb_test(unsigned char detail); +void ps3_io_statis_dump_cli_cb_test(U8 detail); + +Bool ps3_get_wait_cli_flag(void); +#ifdef PS3_SUPPORT_INJECT -unsigned char ps3_get_wait_cli_flag(void); +void ps3_inject_clear(void); #endif +#endif + diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.c index 0161826bdad6..383c5ee3f106 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include #include #include @@ -23,7 +21,7 @@ #include "ps3_driver_log.h" #include "ps3_module_para.h" -#include "ps3_kernel_version.h" +S32 g_ramfs_test_enable = 0; #if defined DRIVER_DEBUG && defined __KERNEL__ @@ -34,98 +32,98 @@ #define DRV_LOG_FILE_SIZE_MIN_MB 10 #define DRV_LOG_FILE_SIZE_MAX_MB 200 -struct ps3_debug g_ps3_debug; -char g_log_path_str[LOG_PATH_LEN] = { 0 }; -char g_log_path_bin[LOG_PATH_LEN] = { 0 }; +ps3_debug_t g_ps3_debug; +char g_log_path_str[LOG_PATH_LEN] = {0}; +char g_log_path_bin[LOG_PATH_LEN] = {0}; static inline int time_for_log(char *buff, int buf_len) { -#if defined(PS3_DUMP_TIME_32) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) struct timeval tv; struct tm td; do_gettimeofday(&tv); - time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); + time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest*60, &td); return snprintf(buff, buf_len, "[%04ld-%02d-%02d;%02d:%02d:%02d.%ld]", - td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, - td.tm_hour, td.tm_min, td.tm_sec, tv.tv_usec); + td.tm_year + 1900, + td.tm_mon + 1, td.tm_mday, td.tm_hour, + td.tm_min, td.tm_sec, tv.tv_usec); #else struct timespec64 tv; struct tm td; - ktime_get_real_ts64(&tv); - time64_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); + time64_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest*60, &td); return snprintf(buff, buf_len, "[%04ld-%02d-%02d;%02d:%02d:%02d.%ld]", - td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, - td.tm_hour, td.tm_min, td.tm_sec, tv.tv_nsec * 1000); + td.tm_year + 1900, + td.tm_mon + 1, td.tm_mday, td.tm_hour, + td.tm_min, td.tm_sec, tv.tv_nsec*1000); #endif } static inline int time_for_file_name(char *buff, int buf_len) { -#if defined(PS3_DUMP_TIME_32) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) struct timeval tv; struct tm td; do_gettimeofday(&tv); - time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); + time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest*60, &td); #else struct timespec64 tv; struct tm td; - ktime_get_real_ts64(&tv); - time64_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); + time64_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest*60, &td); #endif return snprintf(buff, buf_len, "%04ld-%02d-%02d_%02d:%02d:%02d", - td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, - td.tm_hour, td.tm_min, td.tm_sec); + td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, + td.tm_hour, td.tm_min, td.tm_sec); } static inline char *ps3_stack_top(void) { -#if defined(PS3_THREAD_INFO) - unsigned long *ptr = (unsigned long *)(current->thread_info + 1); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) + ULong *ptr = (ULong*)(current->thread_info + 1); #else - unsigned long *ptr = (unsigned long *)(task_thread_info(current) + 1); + ULong *ptr = (ULong*)(task_thread_info(current) + 1 ); #endif - return (char *)(ptr + 1); + return (char*)(ptr + 1); } -static inline struct ps3_thread_local *ps3_thread_local_get(struct ps3_thread_key *key) +static inline ps3_thread_local_t *ps3_thread_local_get(ps3_thread_key_t * key) { - return (struct ps3_thread_local *)(ps3_stack_top() + key->offset); + return (ps3_thread_local_t*)(ps3_stack_top() + key->offset); } -void ps3_thread_key_create(int size, struct ps3_thread_key *key) +void ps3_thread_key_create(int size, ps3_thread_key_t *key) { key->offset = g_ps3_debug.key_offset; - g_ps3_debug.key_offset += sizeof(struct ps3_thread_local) + size; + g_ps3_debug.key_offset += sizeof(ps3_thread_local_t) + size; } -void *ps3_thread_get_specific(struct ps3_thread_key *key) +void *ps3_thread_get_specific(ps3_thread_key_t *key) { - struct ps3_thread_local *local = ps3_thread_local_get(key); - + ps3_thread_local_t *local = ps3_thread_local_get(key); if (local->magic != DEBUG_TRACE_MAGIC) + { return NULL; - return (void *)local->data; + } + return (void*)local->data; } -void ps3_thread_clear_specific(struct ps3_thread_key *key) +void ps3_thread_clear_specific(ps3_thread_key_t *key) { - struct ps3_thread_local *local = ps3_thread_local_get(key); - + ps3_thread_local_t *local = ps3_thread_local_get(key); local->magic = 0; } int ps3_filter_file_add(char *name) { - struct debug_file *file = NULL; + debug_file_t *file = NULL; - file = kmalloc(sizeof(struct debug_file), GFP_ATOMIC); - if (!file) { - ps3_print(PRINT_ERR, "kmalloc size %lu failed\n", PAGE_SIZE); + file = (debug_file_t*)kmalloc(sizeof(debug_file_t), GFP_ATOMIC); + if (!file){ + ps3_print(KERN_ERR,"kmalloc size %lu failed\n", PAGE_SIZE); return -ENOMEM; } strncpy(file->name, name, sizeof(file->name)); @@ -137,26 +135,26 @@ int ps3_filter_file_add(char *name) void ps3_filter_file_del(char *filename) { - struct debug_file *file = NULL; + debug_file_t *file = NULL; - list_for_each_entry_rcu(file, &g_ps3_debug.filter_file, list) { - if (!strcmp(file->name, filename)) { + list_for_each_entry_rcu(file, &g_ps3_debug.filter_file, list){ + if(!strcmp(file->name, filename)){ list_del_rcu(&file->list); synchronize_rcu(); kfree(file); return; } } + return; } #ifndef PS3_CFG_RELEASE static inline int ps3_filter_file_print(const char *filename) { - struct debug_file *file; - + debug_file_t *file; rcu_read_lock(); - list_for_each_entry_rcu(file, &g_ps3_debug.filter_file, list) { - if (!strcmp(file->name, filename)) { + list_for_each_entry_rcu(file, &g_ps3_debug.filter_file, list){ + if(!strcmp(file->name, filename)){ rcu_read_unlock(); return 1; } @@ -168,26 +166,30 @@ static inline int ps3_filter_file_print(const char *filename) #endif void ps3_filter_file_clear(void) { - struct debug_file *file = NULL; - - do { - file = list_first_or_null_rcu(&g_ps3_debug.filter_file, - struct debug_file, list); - if (file) { + debug_file_t *file = NULL; + + do{ + file = list_first_or_null_rcu( + &g_ps3_debug.filter_file, + debug_file_t, + list); + if (file){ list_del_rcu(&file->list); synchronize_rcu(); kfree(file); } - } while (file); + }while(file); + + return; } int ps3_filter_func_add(char *name) { - struct debug_func *func = NULL; + debug_func_t *func = NULL; - func = kmalloc(sizeof(struct debug_func), GFP_ATOMIC); - if (!func) { - ps3_print(PRINT_ERR, "kmalloc size %lu failed\n", PAGE_SIZE); + func = (debug_func_t *)kmalloc(sizeof(debug_func_t), GFP_ATOMIC); + if (!func){ + ps3_print(KERN_ERR,"kmalloc size %lu failed\n", PAGE_SIZE); return -ENOMEM; } strncpy(func->name, name, sizeof(func->name)); @@ -199,31 +201,36 @@ int ps3_filter_func_add(char *name) void ps3_filter_func_del(char *name) { - struct debug_func *func = NULL; + debug_func_t *func = NULL; - list_for_each_entry_rcu(func, &g_ps3_debug.filter_func, list) { - if (!strcmp(func->name, name)) { + list_for_each_entry_rcu(func, &g_ps3_debug.filter_func, list){ + if(!strcmp(func->name, name)){ list_del_rcu(&func->list); synchronize_rcu(); kfree(func); return; } } + return; } void ps3_filter_func_clear(void) { - struct debug_func *func = NULL; - - do { - func = list_first_or_null_rcu(&g_ps3_debug.filter_func, - struct debug_func, list); - if (func) { + debug_func_t *func = NULL; + + do{ + func = list_first_or_null_rcu( + &g_ps3_debug.filter_func, + debug_func_t, + list); + if (func){ list_del_rcu(&func->list); synchronize_rcu(); kfree(func); } - } while (func); + }while(func); + + return; } void ps3_level_set(int level) @@ -231,14 +238,14 @@ void ps3_level_set(int level) g_ps3_debug.level = level; } -int ps3_level_get(void) +S32 ps3_level_get(void) { - return (int)g_ps3_debug.level; + return (S32)g_ps3_debug.level; } -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) static void ps3_file_close(struct file **file) { @@ -246,10 +253,10 @@ static void ps3_file_close(struct file **file) *file = NULL; } -static int ps3_file_open(struct ps3_log *log, struct file **pp_file) +static int ps3_file_open(ps3_log_t *log, struct file **pp_file) { struct file *file; - int flags_new = O_CREAT | O_RDWR | O_APPEND | O_LARGEFILE; + int flags_new = O_CREAT | O_RDWR | O_APPEND | O_LARGEFILE; int flags_rewrite = O_CREAT | O_RDWR | O_LARGEFILE | O_TRUNC; int err = 0; int len = 0; @@ -261,12 +268,11 @@ static int ps3_file_open(struct ps3_log *log, struct file **pp_file) if (log->file_num == 0) { time_for_file_name(filename + len, FILE_NAME_SIZE - len); } else { - snprintf(filename + len, FILE_NAME_SIZE - len, "%04d", - log->index++); + snprintf(filename + len, FILE_NAME_SIZE - len, "%04d", log->index++); log->index = log->index % log->file_num; } - if (log->file_num == 1 && log->file != NULL) { + if(log->file_num == 1 && log->file != NULL) { ps3_file_close(&log->file); log->file_pos = 0; } @@ -280,38 +286,36 @@ static int ps3_file_open(struct ps3_log *log, struct file **pp_file) file = filp_open(filename, flags_rewrite, 0666); if (IS_ERR(file)) { err = (int)PTR_ERR(file); - if (err == -ENOENT) + if (err == -ENOENT) { file = filp_open(filename, flags_new, 0666); + } } } if (IS_ERR(file)) { err = (int)PTR_ERR(file); if (printk_timed_ratelimit(&j, PS3_LOG_LIMIT_INTERVAL_MSEC)) { - ps3_print(PRINT_INFO, "open file:%s failed[errno:%d]\n", - filename, err); + ps3_print(KERN_INFO,"open file:%s failed[errno:%d]\n", filename, err); } goto l_out; } - if (!ps3_fs_requires_dev(file)) { -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + if (!ps3_fs_requires_dev(file)) { +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) if (printk_timed_ratelimit(&j, PS3_LOG_LIMIT_INTERVAL_MSEC)) { - ps3_print( - PRINT_INFO, - "unexpected filesystem, superblock flags: 0x%x\n", - file->f_inode->i_sb->s_type->fs_flags); + ps3_print(KERN_INFO, "unexpected filesystem, superblock flags: 0x%x\n", + file->f_inode->i_sb->s_type->fs_flags); } #endif - ps3_file_close(&file); - err = -EINVAL; - goto l_out; - } + ps3_file_close(&file); + err = -EINVAL; + goto l_out; + } mapping_set_gfp_mask(file->f_path.dentry->d_inode->i_mapping, GFP_NOFS); - ps3_print(PRINT_INFO, "redirect file %s\n", filename); + ps3_print(KERN_INFO,"redirect file %s\n", filename); *pp_file = file; @@ -322,32 +326,35 @@ static int ps3_file_open(struct ps3_log *log, struct file **pp_file) static void ps3_file_sync(struct file *file) { struct address_space *mapping; - void *journal; + void *journal; int ret = 0; int err; (void)ret; (void)err; - if (!file || !file->f_op || !file->f_op->fsync) + if( !file || !file->f_op || !file->f_op->fsync ){ goto l_end; + } - journal = current->journal_info; + journal = current->journal_info; current->journal_info = NULL; mapping = file->f_mapping; ret = filemap_fdatawrite(mapping); -#if defined(PS3_FILEMAP_WAIT) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) mutex_lock(&mapping->host->i_mutex); err = file->f_op->fsync(file, file->f_path.dentry, 1); - if (!ret) + if( !ret ){ ret = err; + } mutex_unlock(&mapping->host->i_mutex); err = filemap_fdatawait(mapping); - if (!ret) + if( !ret ){ ret = err; + } #else err = file->f_op->fsync(file, 0, file->f_mapping->host->i_size, 1); @@ -364,17 +371,17 @@ static int ps3_file_write(struct file *file, char *buf, int len) int ret = 0; void *journal; -#if defined(PS3_SUPPORT_FS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) mm_segment_t old_fs; #endif -#if defined(PS3_KERNEL_WRITE_GET_DS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) old_fs = get_fs(); set_fs(get_ds()); -#elif defined(PS3_KERNEL_WRITE) +#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) old_fs = get_fs(); set_fs(KERNEL_DS); -#elif defined(PS3_VFS_WRITE) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) #else old_fs = force_uaccess_begin(); #endif @@ -382,33 +389,34 @@ static int ps3_file_write(struct file *file, char *buf, int len) journal = current->journal_info; current->journal_info = NULL; - if (!file) { + if (!file){ return 0; } - do { -#if defined(PS3_KERNEL_WRITE_FILE_OP) + do{ +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,9,0) ret = file->f_op->write(file, buf, len, &file->f_pos); -#elif defined(PS3_KERNEL_WRITE_FILE_VFS) +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0) ret = vfs_write(file, buf, len, &file->f_pos); #else ret = kernel_write(file, buf, len, &file->f_pos); #endif - } while (ret == -EINTR); + }while( ret == -EINTR ); if (ret >= 0) { -#if defined(PS3_FSNOTIFY_FILE) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0) fsnotify_modify(file); -#elif defined(PS3_FSNOTIFY_FILE_PATH) - if (file->f_path.dentry) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) + if ( file->f_path.dentry) { fsnotify_modify(file->f_path.dentry); + } #endif } current->journal_info = journal; -#if defined(PS3_SET_FS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) set_fs(old_fs); -#elif defined(PS3_FORCE_UACCESS) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) #else force_uaccess_end(old_fs); #endif @@ -416,38 +424,38 @@ static int ps3_file_write(struct file *file, char *buf, int len) return ret; } -static void ps3_klog_in(struct ps3_log *log, char *buf, const int len) +static void ps3_klog_in(ps3_log_t *log, char *buf, const int len) { int begin = 0; - int end = 0; + int end = 0; int free_size; - unsigned long flags; + ULong flags; static unsigned long j; spin_lock_irqsave(&log->lock, flags); if (log->head > log->tail) { if (printk_timed_ratelimit(&j, PS3_LOG_LIMIT_INTERVAL_MSEC)) { - ps3_print(PRINT_INFO, - "FAILURE: log head exceeds log tail\n"); + ps3_print(KERN_INFO,"FAILURE: log head exceeds log tail\n"); PS3_BUG_NO_SYNC(); } } free_size = log->buf_size - (log->tail - log->head); - if (free_size <= len) { + if (free_size <= len){ log->is_drop = 1; spin_unlock_irqrestore(&log->lock, flags); return; } begin = log->tail % log->buf_size; - end = (log->tail + len) % log->buf_size; + end = (log->tail + len) % log->buf_size; - if (begin < end) { + if (begin < end){ memcpy(log->buf + begin, buf, len); - } else { + } + else{ memcpy(log->buf + begin, buf, log->buf_size - begin); memcpy(log->buf, buf + log->buf_size - begin, end); } @@ -455,9 +463,11 @@ static void ps3_klog_in(struct ps3_log *log, char *buf, const int len) log->tail = log->tail + len; spin_unlock_irqrestore(&log->lock, flags); + + return; } -static void ps3_klog_out(struct ps3_log *log) +static void ps3_klog_out(ps3_log_t *log) { int len = 0; int rc = 0; @@ -474,61 +484,69 @@ static void ps3_klog_out(struct ps3_log *log) if (log->file == NULL) { rc = ps3_file_open(log, &log->file); - if (log->file != NULL) + if (log->file != NULL) { log->file_pos = 0; - else + } else { return; + } } do { - tail = log->tail; + tail = log->tail; begin = log->head % log->buf_size; - end = tail % log->buf_size; + end = tail % log->buf_size; len = 0; rc = 0; schedule_count_th++; - if (schedule_count_th >= max_loop) { + if ((schedule_count_th >= max_loop)) { schedule_count_th = 0; schedule_timeout_interruptible(PS3_KLOG_OUT_WAIT); } if (log->is_drop) { - rc = ps3_file_write(log->file, DEBUG_DROP_LOG_STRING, - strlen(DEBUG_DROP_LOG_STRING)); - if (rc < 0) + rc = ps3_file_write( + log->file, + DEBUG_DROP_LOG_STRING, + strlen(DEBUG_DROP_LOG_STRING)); + if (rc < 0) { break; + } log->is_drop = 0; } if (begin < end) { - rc = ps3_file_write(log->file, log->buf + begin, - end - begin); - if (rc > 0) + rc = ps3_file_write( + log->file, + log->buf + begin, + end - begin); + if (rc > 0) { len += rc; - } else if (begin > end) { - rc = ps3_file_write(log->file, log->buf + begin, - log->buf_size - begin); + } + } else if(begin > end) { + rc = ps3_file_write( + log->file, + log->buf + begin, + log->buf_size - begin); if (rc > 0) { len += rc; rc = ps3_file_write(log->file, log->buf, end); - if (rc > 0) + if (rc > 0) { len += rc; + } } } log->head += len; log->file_pos += len; - LOG_BUG_ON(log->head > log->tail, - "FAILURE: log head exceeds log tail\n"); - } while (log->head != log->tail && rc > 0); + LOG_BUG_ON(log->head > log->tail, "FAILURE: log head exceeds log tail\n"); + }while (log->head != log->tail && rc > 0); if (rc < 0) { if (printk_timed_ratelimit(&j, PS3_LOG_LIMIT_INTERVAL_MSEC)) { - ps3_print(PRINT_INFO, "write file %s error %d\n", - log->file_path, rc); + ps3_print(KERN_INFO,"write file %s error %d\n", log->file_path, rc); } - return; + return ; } #ifdef DRIVER_SWITCH_FILE @@ -541,31 +559,37 @@ static void ps3_klog_out(struct ps3_log *log) } } #endif + return ; } static int ps3_klog_flush(void *arg) { int i; - while (!kthread_should_stop()) { + while (!kthread_should_stop()){ schedule_timeout_interruptible(PS3_KLOG_OUT_WAIT); - for (i = 0; i < ARRAY_SIZE(g_ps3_debug.log); i++) + for (i = 0; i < ARRAY_SIZE(g_ps3_debug.log); i++){ ps3_klog_out(&g_ps3_debug.log[i]); + } } return 0; } -static int ps3_klog_init(struct ps3_log *log, long long buf_size, char *file_path, - long long file_size, unsigned int file_num) +static int ps3_klog_init( + ps3_log_t *log, + long long buf_size, + char *file_path, + long long file_size, + U32 file_num) { int rc = 0; memset(log, 0, sizeof(*log)); spin_lock_init(&log->lock); - log->buf = vmalloc(buf_size + PAGE_SIZE); - if (!log->buf) { + log->buf = (char*)vmalloc(buf_size+PAGE_SIZE); + if (!log->buf){ rc = -ENOMEM; goto l_end; } @@ -573,125 +597,146 @@ static int ps3_klog_init(struct ps3_log *log, long long buf_size, char *file_pat log->file = NULL; log->head = 0; log->tail = 0; - log->buf_size = buf_size; + log->buf_size = buf_size; log->file_path = file_path; - log->file_pos = 0; + log->file_pos = 0; log->file_size = file_size; - log->file_num = file_num; - log->index = 0; + log->file_num = file_num; + log->index = 0; l_end: return rc; } -static void ps3_klog_exit(struct ps3_log *log) +static void ps3_klog_exit(ps3_log_t *log) { - if (log->buf) + if (log->buf) { vfree(log->buf); - if (log->file) + } + if (log->file) { ps3_file_close(&log->file); + } } static inline char *ps3_file_name_locale(char *file) { char *p_slash = strrchr(file, '/'); - - return (p_slash == NULL) ? file : (p_slash + 1); + return (p_slash == NULL)?file:(p_slash+1); } -void ps3_log_string(enum debug_level level, const char *file, int line, - const char *fmt, ...) +void ps3_log_string( + debug_level_e level, + const char *file, + int line, + const char *fmt,...) { - struct ps3_ctxt *ctxt = NULL; + ps3_ctxt_t *ctxt = NULL; char *buf = NULL; int len = 0; - unsigned long flags = 0; + ULong flags = 0; va_list args; - if (level > g_ps3_debug.level) { + if (level > g_ps3_debug.level){ #ifndef PS3_CFG_RELEASE - if (!ps3_filter_file_print(file)) + if (!ps3_filter_file_print(file)){ return; + } #else return; #endif } - if (!in_interrupt()) + if (!in_interrupt()){ local_irq_save(flags); + } ctxt = per_cpu_ptr(g_ps3_debug.ctxt, get_cpu()); put_cpu(); - buf = ctxt->buff; + buf = ctxt->buff; - len = snprintf(buf, PAGE_SIZE, "%s", ps3_debug_level_name(level)); - len += time_for_log(buf + len, PAGE_SIZE - len); - len += snprintf(buf + len, PAGE_SIZE - len, - "[%d][%d]%s:%4d:", raw_smp_processor_id(), current->pid, - ps3_file_name_locale((char *)file), line); + len = snprintf(buf, PAGE_SIZE, "%s", ps3_debug_level_name(level)); + len += time_for_log(buf+len, PAGE_SIZE - len); + len += snprintf(buf+len, PAGE_SIZE - len, "[%d][%d]%s:%4d:", + raw_smp_processor_id(), current->pid, + ps3_file_name_locale((char*)file), line); va_start(args, fmt); - len += vsnprintf(buf + len, PAGE_SIZE - len, fmt, args); + len += vsnprintf( + buf + len, + PAGE_SIZE - len, + fmt, + args); va_end(args); - if (!in_interrupt()) + + if (!in_interrupt()){ local_irq_restore(flags); + } if (ps3_log_tty_query()) { if (buf[0] == 'I' || buf[0] == 'W') { - printk_ratelimited(KERN_WARNING "%s", - buf + LOG_INFO_PREFIX_LEN); + printk_ratelimited(KERN_WARNING"%s", buf + LOG_INFO_PREFIX_LEN); } else if (buf[0] == 'E') { - printk_ratelimited(KERN_WARNING "%s", - buf + LOG_ERROR_PREFIX_LEN); + printk_ratelimited(KERN_WARNING"%s", buf + LOG_ERROR_PREFIX_LEN); } } ps3_klog_in(&g_ps3_debug.log[DEBUG_TYPE_STRING], buf, len); wake_up_process(g_ps3_debug.task); + + return; } -void ps3_log_binary(const char *file, int line, char *ptr, int size, char *str) +void ps3_log_binary( + const char *file, + int line, + char *ptr, + int size, + char *str) { #define LINE_TOTAL 16 - struct ps3_ctxt *ctxt = NULL; + ps3_ctxt_t *ctxt = NULL; char *buf = NULL; int len = 0; int i; - unsigned long flags = 0; + ULong flags = 0; - if (!in_interrupt()) + if (!in_interrupt()){ local_irq_save(flags); + } ctxt = per_cpu_ptr(g_ps3_debug.ctxt, get_cpu()); put_cpu(); - buf = ctxt->buff; + buf = ctxt->buff; - len += time_for_log(buf + len, PAGE_SIZE - len); - len += snprintf(buf + len, PAGE_SIZE - len, "[%d]%s:%d, size:%d, ", - current->pid, ps3_file_name_locale((char *)file), line, - size); + len += time_for_log(buf+len, PAGE_SIZE - len); + len += snprintf(buf+len, PAGE_SIZE - len, "[%d]%s:%d, size:%d, ", + current->pid, ps3_file_name_locale((char*)file), + line, size); - len += snprintf(buf + len, PAGE_SIZE - len, "%s", str); + len+=snprintf(buf + len, PAGE_SIZE - len, "%s",str); - for (i = 0; i < size; i++) { - if (i % LINE_TOTAL == 0) + for(i = 0; i < size; i++){ + if (i % LINE_TOTAL == 0){ len += snprintf(buf + len, PAGE_SIZE - len, "%08x ", i); + } len += snprintf(buf + len, PAGE_SIZE - len, "%02hhx", ptr[i]); - if ((i % LINE_TOTAL) == (LINE_TOTAL - 1) || i == (size - 1)) + if ((i % LINE_TOTAL) == (LINE_TOTAL - 1) || i == (size - 1)){ len += snprintf(buf + len, PAGE_SIZE - len, "\n"); - else if ((i % LINE_TOTAL) == (LINE_TOTAL / 2 - 1)) + } else if ((i % LINE_TOTAL) == (LINE_TOTAL/2 - 1)){ len += snprintf(buf + len, PAGE_SIZE - len, " "); - else + } else{ len += snprintf(buf + len, PAGE_SIZE - len, " "); + } } - if (!in_interrupt()) + if (!in_interrupt()){ local_irq_restore(flags); + } ps3_klog_in(&g_ps3_debug.log[DEBUG_TYPE_BINARY], buf, len); @@ -707,27 +752,27 @@ void ps3_log_sync(void) int ps3_debug_init(void) { struct task_struct *task = NULL; - struct ps3_ctxt *ctxt = NULL; + ps3_ctxt_t *ctxt = NULL; int rc = 0; int i; int nid; - unsigned int file_num = 0; - unsigned int log_path_len = 0; - unsigned int input_log_space = ps3_log_space_size_query(); - unsigned int input_log_file_size = ps3_log_file_size_query(); - unsigned int log_file_size = 0; - char *log_path_p = NULL; - struct ps3_log *log_bin = &g_ps3_debug.log[DEBUG_TYPE_BINARY]; - struct ps3_log *log_str = &g_ps3_debug.log[DEBUG_TYPE_STRING]; + U32 file_num = 0; + U32 log_path_len = 0; + U32 input_log_space = ps3_log_space_size_query(); + U32 input_log_file_size = ps3_log_file_size_query(); + unsigned int log_file_size = 0; + char *log_path_p = NULL; + ps3_log_t *log_bin = &g_ps3_debug.log[DEBUG_TYPE_BINARY]; + ps3_log_t *log_str = &g_ps3_debug.log[DEBUG_TYPE_STRING]; INIT_LIST_HEAD(&g_ps3_debug.filter_file); INIT_LIST_HEAD(&g_ps3_debug.filter_func); g_ps3_debug.level = ps3_log_level_query(); - g_ps3_debug.ctxt = alloc_percpu(struct ps3_ctxt); + g_ps3_debug.ctxt = alloc_percpu(ps3_ctxt_t); if (!g_ps3_debug.ctxt) { rc = -ENOMEM; - ps3_print(PRINT_ERR, "alloc percpu failed\n"); + ps3_print(KERN_ERR,"alloc percpu failed\n"); goto l_end; } @@ -738,13 +783,12 @@ int ps3_debug_init(void) for_each_possible_cpu(i) { ctxt = per_cpu_ptr(g_ps3_debug.ctxt, i); - nid = cpu_to_node(i); + nid = cpu_to_node(i); ctxt->page = alloc_pages_node(nid, GFP_ATOMIC, 0); if (!ctxt->page) { rc = -ENOMEM; - ps3_print(PRINT_ERR, "kmalloc size %lu failed\n", - PAGE_SIZE); + ps3_print(KERN_ERR,"kmalloc size %lu failed\n", PAGE_SIZE); goto l_free_cpu_buff; } ctxt->buff = kmap(ctxt->page); @@ -754,22 +798,18 @@ int ps3_debug_init(void) log_path_len = strlen(log_path_p); if (log_path_p != NULL && log_path_p[0] == '/') { if (log_path_p[log_path_len - 1] == '/') { - snprintf(g_log_path_str, LOG_PATH_LEN, "%s%s.", - log_path_p, LOG_FILE_PREFIX); - snprintf(g_log_path_bin, LOG_PATH_LEN, "%s%s.", - log_path_p, BINARY_FILE_PREFIX); + snprintf(g_log_path_str, LOG_PATH_LEN, "%s%s.", log_path_p, LOG_FILE_PREFIX); + snprintf(g_log_path_bin, LOG_PATH_LEN, "%s%s.", log_path_p, BINARY_FILE_PREFIX); } else { - snprintf(g_log_path_str, LOG_PATH_LEN, "%s/%s.", - log_path_p, LOG_FILE_PREFIX); - snprintf(g_log_path_bin, LOG_PATH_LEN, "%s/%s.", - log_path_p, BINARY_FILE_PREFIX); + snprintf(g_log_path_str, LOG_PATH_LEN, "%s/%s.", log_path_p, LOG_FILE_PREFIX); + snprintf(g_log_path_bin, LOG_PATH_LEN, "%s/%s.", log_path_p, BINARY_FILE_PREFIX); } } else { snprintf(g_log_path_str, LOG_PATH_LEN, "%s.", LOG_FILE_PATH); snprintf(g_log_path_bin, LOG_PATH_LEN, "%s.", BINARY_FILE_PATH); } if (input_log_file_size < DRV_LOG_FILE_SIZE_MIN_MB || - input_log_file_size > DRV_LOG_FILE_SIZE_MAX_MB) { + input_log_file_size > DRV_LOG_FILE_SIZE_MAX_MB) { ps3_log_file_size_modify(LOG_FILE_SIZE >> MEGABYTE); input_log_file_size = LOG_FILE_SIZE >> MEGABYTE; } @@ -782,36 +822,44 @@ int ps3_debug_init(void) if (input_log_space) { file_num = input_log_space / input_log_file_size; if (file_num == 0) { - ps3_print(PRINT_ERR, "filenum shouldnot be 0\n"); + ps3_print(KERN_ERR,"filenum shouldnot be 0\n"); PS3_BUG(); } } else { file_num = 0; } - rc = ps3_klog_init(log_str, LOG_BUF_SIZE, g_log_path_str, log_file_size, - file_num); - if (rc < 0) + rc = ps3_klog_init( + log_str, + LOG_BUF_SIZE, + g_log_path_str, + log_file_size, + file_num); + if (rc < 0) { goto l_free_cpu_buff; + } - rc = ps3_klog_init(log_bin, BIN_BUF_SIZE, g_log_path_bin, - BINARY_FILE_SIZE, 0); - if (rc < 0) + rc = ps3_klog_init( + log_bin, + BIN_BUF_SIZE, + g_log_path_bin, + BINARY_FILE_SIZE, + 0); + if (rc < 0) { goto l_free_string; + } task = kthread_create(ps3_klog_flush, NULL, "ps3_klog_flush"); if (IS_ERR(task)) { rc = (int)PTR_ERR(task); - ps3_print(PRINT_ERR, "Create kernel thread, err: %d\n", rc); + ps3_print(KERN_ERR,"Create kernel thread, err: %d\n", rc); goto l_free_binary; } wake_up_process(task); g_ps3_debug.task = task; rc = 0; - ps3_print(PRINT_INFO, - "PS3 debug init logpath[%s] strlogsize[%dM] filenum[%d]\n", - g_log_path_str, (log_file_size >> MEGABYTE), - log_str->file_num); + ps3_print(KERN_INFO,"PS3 debug init logpath[%s] strlogsize[%dM] filenum[%d]\n", + g_log_path_str, (log_file_size >> MEGABYTE), log_str->file_num); l_end: return rc; @@ -836,15 +884,17 @@ int ps3_debug_init(void) void ps3_debug_exit(void) { int i = 0; - struct ps3_ctxt *ctxt; + ps3_ctxt_t *ctxt; - if (g_ps3_debug.task == NULL) + if (g_ps3_debug.task == NULL) { return; + } kthread_stop(g_ps3_debug.task); - for (i = 0; i < ARRAY_SIZE(g_ps3_debug.log); i++) + for (i = 0; i < ARRAY_SIZE(g_ps3_debug.log); i++) { ps3_klog_exit(&g_ps3_debug.log[i]); + } if (g_ps3_debug.ctxt) { for_each_possible_cpu(i) { @@ -877,47 +927,105 @@ void ps3_debug_exit(void) #endif +#if 0 + +struct task_struct *g_ps3_task[8]; +static int ps3_log_test(void *arg) +{ + int i = 0; + int dump[16] = {}; + while(!kthread_should_stop()){ + for(i = 0; i < 1024; i++) { + LOG_WARN("hello world,%d\n",i); + DATA_DUMP(dump, sizeof(dump), "123\n"); + } + schedule_timeout_interruptible(8*HZ); + } + return 0; +} + +static int __init ps3_init(void) +{ + int rc = 0; + int i = 0; + int dump[16] = {}; + rc = ps3_debug_init(); + if (rc < 0){ + return rc; + } + + for (i = 0; i < 8; i++){ + LOG_WARN("hello world,%d\n",i); + DATA_DUMP(dump, sizeof(dump), "123\n"); + } + + for (i = 0; i < 8; i++){ + g_ps3_task[i] = kthread_create(ps3_log_test, NULL, "ps3_log_test"); + wake_up_process(g_ps3_task[i]); + } + return 0; +} + +static void __exit ps3_exit(void) +{ + int i; + for (i = 0; i < 8; i++){ + kthread_stop(g_ps3_task[i]); + } + ps3_debug_exit(); +} + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("ps3@starsmicrosystem.com"); +MODULE_DESCRIPTION("Stars PS3 Driver"); + +module_init(ps3_init); +module_exit(ps3_exit); + +#endif + #else -int g_ps3_log_level = LEVEL_INFO; +S32 g_ps3_log_level = LEVEL_INFO; -void ps3_thread_key_create(int size, struct ps3_thread_key *key) +void ps3_thread_key_create(int size, ps3_thread_key_t *key) { - (void)size; - (void)key; + size = size; + key = key; } -void *ps3_thread_get_specific(struct ps3_thread_key *key) +void *ps3_thread_get_specific(ps3_thread_key_t *key) { + key = key; return key; } -void ps3_thread_clear_specific(struct ps3_thread_key *key) +void ps3_thread_clear_specific(ps3_thread_key_t *key) { - (void)key; + key = key; } -int ps3_filter_file_add(char *name) +int ps3_filter_file_add(char *name) { - (void)name; + name = name; return 0; } void ps3_filter_file_del(char *name) { - (void)name; + name = name; } void ps3_filter_file_clear(void) { } -int ps3_filter_func_add(char *name) +int ps3_filter_func_add(char *name) { - (void)name; + name = name; return 0; } void ps3_filter_func_del(char *name) { - (void)name; + name = name; } void ps3_filter_func_clear(void) { @@ -927,7 +1035,7 @@ void ps3_level_set(int level) g_ps3_log_level = level; } -int ps3_level_get(void) +S32 ps3_level_get(void) { return g_ps3_log_level; } @@ -948,13 +1056,3 @@ void ps3_debug_exit(void) #endif -static int g_ramfs_test_enable; -int ps3_ramfs_test_query(void) -{ - return g_ramfs_test_enable; -} - -void ps3_ramfs_test_store(int val) -{ - g_ramfs_test_enable = val; -} diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.h b/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.h index 9bff9441e346..28636cb6f4a9 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.h +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.h @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ #ifndef _PS3_DRIVER_LOG_H_ #define _PS3_DRIVER_LOG_H_ @@ -9,180 +7,141 @@ #include #include "ps3_htp_def.h" -#include "ps3_platform_utils.h" #ifdef __cplusplus -extern "C" { +extern "C"{ #endif -#define PS3_HOST(ins) ((ins)->host->host_no) +#define PS3_HOST(ins) (ins)->host->host_no #define DRIVER_DEBUG -#define LOG_INFO_PREFIX_LEN 32 -#define LOG_ERROR_PREFIX_LEN 33 -#define MEGABYTE 20 +#define LOG_INFO_PREFIX_LEN 32 +#define LOG_ERROR_PREFIX_LEN 33 +#define MEGABYTE 20 -enum debug_level { +typedef enum { LEVEL_ERROR, LEVEL_WARN, LEVEL_INFO, LEVEL_DEBUG, -}; +}debug_level_e; -static inline const char *ps3_debug_level_name(enum debug_level lv) +static inline const S8 *ps3_debug_level_name(debug_level_e lv) { - static const char * const level[] = { + static const S8 *level[] = { [LEVEL_ERROR] = "ERROR", - [LEVEL_WARN] = "WARN", - [LEVEL_INFO] = "INFO", + [LEVEL_WARN] = "WARN", + [LEVEL_INFO] = "INFO", [LEVEL_DEBUG] = "DBG", }; return level[lv]; } -int ps3_level_get(void); +S32 ps3_level_get(void); #define PS3_LOG_LIMIT_INTERVAL_MSEC (24 * 60 * 60 * 1000) #ifdef __KERNEL__ -#define PRINT_DEBUG LEVEL_DEBUG -#define PRINT_INFO LEVEL_INFO -#define PRINT_WARN LEVEL_WARN -#define PRINT_ERR LEVEL_ERROR - -#define ps3_print(level, fmt, ...) \ - do { \ - if (level == LEVEL_DEBUG) { \ - pr_debug("[PS3STOR]%s():%d;" fmt, \ - __func__, __LINE__, ##__VA_ARGS__); \ - } else if (level == LEVEL_INFO) { \ - pr_info("[PS3STOR]%s():%d;" fmt, \ - __func__, __LINE__, ##__VA_ARGS__); \ - } else if (level == LEVEL_WARN) { \ - pr_warn("[PS3STOR]%s():%d;" fmt, \ - __func__, __LINE__, ##__VA_ARGS__); \ - } else if (level == LEVEL_ERROR) { \ - pr_err("[PS3STOR]%s():%d;" fmt, \ - __func__, __LINE__, ##__VA_ARGS__); \ - } \ - } while (0) - -#define ps3_printk(level, fmt, ...) \ - do { \ - if (level <= ps3_level_get()) { \ - if (level == LEVEL_DEBUG) { \ - pr_debug("[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - } else if (level == LEVEL_INFO) { \ - pr_info("[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - } else if (level == LEVEL_WARN) { \ - pr_warn("[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - } else if (level == LEVEL_ERROR) { \ - pr_err("[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - } \ - } \ - } while (0) - -#define ps3_printk_ratelimited(level, fmt, ...) \ - do { \ - if (level <= ps3_level_get()) { \ - if (level == LEVEL_INFO) { \ - printk_ratelimited(KERN_INFO \ - "[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, \ - ##__VA_ARGS__); \ - } else if (level == LEVEL_WARN) { \ - printk_ratelimited(KERN_WARNING \ - "[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, \ - ##__VA_ARGS__); \ - } else if (level == LEVEL_ERROR) { \ - printk_ratelimited(KERN_ERR \ - "[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, \ - ##__VA_ARGS__); \ - } \ - } \ - } while (0) +#define PRINT_DEBUG KERN_DEBUG +#define PRINT_INFO KERN_INFO +#define PRINT_WARN KERN_WARNING +#define PRINT_ERR KERN_ERR + +#define ps3_print(level,fmt,...) \ + printk(level"[PS3STOR]%s():%d;" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__) + +#define ps3_printk(level,fmt,...) do { \ + if (level <= ps3_level_get()) { \ + if (level == LEVEL_DEBUG) { \ + printk(KERN_DEBUG "[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + } else if (level == LEVEL_INFO) { \ + printk(KERN_INFO "[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + } else if (level == LEVEL_WARN) { \ + printk(KERN_WARNING "[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + }else if (level == LEVEL_ERROR) { \ + printk(KERN_ERR "[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + } \ + } \ +} while(0) + +#define ps3_printk_ratelimited(level,fmt,...) do { \ + if (level <= ps3_level_get()) { \ + if (level == LEVEL_INFO) { \ + pr_info_ratelimited(KERN_INFO "[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + } else if (level == LEVEL_WARN) { \ + printk_ratelimited(KERN_WARNING "[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + }else if (level == LEVEL_ERROR) { \ + printk_ratelimited(KERN_ERR "[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + } \ + } \ +} while(0) #else -#define PRINT_DEBUG LEVEL_DEBUG -#define PRINT_INFO LEVEL_INFO -#define PRINT_WARN LEVEL_WARN -#define PRINT_ERR LEVEL_ERROR +#define PRINT_DEBUG LEVEL_DEBUG +#define PRINT_INFO LEVEL_INFO +#define PRINT_WARN LEVEL_WARN +#define PRINT_ERR LEVEL_ERROR #include #include #include #define __percpu -static inline unsigned long long get_now_ms(void) -{ +static inline U64 get_now_ms() { struct timeval tv; - unsigned long long timestamp = 0; - + U64 timestamp = 0; gettimeofday(&tv, NULL); - timestamp = tv.tv_sec * 1000 + tv.tv_usec / 1000; + timestamp = tv.tv_sec * 1000 + tv.tv_usec/1000; return timestamp; } -#define filename_printf(x) (strrchr((x), '/') ? strrchr((x), '/') + 1 : (x)) - -#define ps3_print(lock_chk, level, fmt, ...) \ - do { \ - if (level != LEVEL_DEBUG && lock_chk) { \ - EXPECT_EQ(ps3_get_irq_spin_lock_count(), 0); \ - } \ - if (level <= ps3_level_get()) { \ - if (level == LEVEL_DEBUG) { \ - printf("DEBUG:%llu:%s:%s():%d:[%lu];" fmt, \ - get_now_ms(), \ - filename_printf(__FILE__), \ - __func__, __LINE__, pthread_self(), \ - ##__VA_ARGS__); \ - } else if (level == LEVEL_INFO) { \ - printf("INFO:%llu:%s:%s():%d:[%lu];" fmt, \ - get_now_ms(), \ - filename_printf(__FILE__), \ - __func__, __LINE__, pthread_self(), \ - ##__VA_ARGS__); \ - } else if (level == LEVEL_WARN) { \ - printf("WARN:%llu:%s:%s():%d:[%lu];" fmt, \ - get_now_ms(), \ - filename_printf(__FILE__), \ - __func__, __LINE__, pthread_self(), \ - ##__VA_ARGS__); \ - } else if (level == LEVEL_ERROR) { \ - printf("ERROR:%llu:%s:%s():%d:[%lu];" fmt, \ - get_now_ms(), \ - filename_printf(__FILE__), \ - __func__, __LINE__, pthread_self(), \ - ##__VA_ARGS__); \ - } \ - } \ - } while (0) +#define filename_printf(x) strrchr((x),'/')?strrchr((x),'/')+1:(x) + +#define ps3_print(lock_chk, level, fmt, ...) do { \ + if (level != LEVEL_DEBUG && lock_chk) { \ + EXPECT_EQ(ps3_get_irq_spin_lock_count(), 0); \ + } \ + if (level <= ps3_level_get()) { \ + if (level == LEVEL_DEBUG) { \ + printf("DEBUG:%llu:%s:%s():%d:[%lu];" fmt, get_now_ms(), filename_printf(__FILE__), \ + __FUNCTION__, __LINE__, pthread_self(), ##__VA_ARGS__); \ + } else if (level == LEVEL_INFO) { \ + printf("INFO:%llu:%s:%s():%d:[%lu];" fmt, get_now_ms(), filename_printf(__FILE__), \ + __FUNCTION__, __LINE__, pthread_self(), ##__VA_ARGS__); \ + } else if (level == LEVEL_WARN) { \ + printf("WARN:%llu:%s:%s():%d:[%lu];" fmt, get_now_ms(), filename_printf(__FILE__), \ + __FUNCTION__, __LINE__, pthread_self(), ##__VA_ARGS__); \ + }else if (level == LEVEL_ERROR) { \ + printf("ERROR:%llu:%s:%s():%d:[%lu];" fmt, get_now_ms(), filename_printf(__FILE__), \ + __FUNCTION__, __LINE__, pthread_self(), ##__VA_ARGS__); \ + } \ + } \ +} while(0) #endif -#define LOG_BUG_ON(cond, fmt, ...) \ - do { \ - if ((cond)) { \ - LOG_ERROR(fmt, ##__VA_ARGS__); \ - LOG_SYNC(); \ - BUG(); \ - } \ - } while (0) +#define LOG_BUG_ON(cond, fmt, ...) do { \ + if((cond)) { \ + LOG_ERROR(fmt, ##__VA_ARGS__); \ + LOG_SYNC(); \ + BUG(); \ + } \ +}while(0) #define DEBUG_TRACE_MAGIC 0x456789 -#define LOG_BUF_SIZE (1024LL << 11) -#define BIN_BUF_SIZE (1024LL << 10) +#define LOG_BUF_SIZE (1024LL << 11) +#define BIN_BUF_SIZE (1024LL << 10) -#define LOG_FILE_SIZE (200LL << 20) -#define LOG_FILE_PATH "/var/log/ps3sas_drv.log" -#define LOG_FILE_PREFIX "ps3sas_drv.log" +#define LOG_FILE_SIZE (200LL << 20) +#define LOG_FILE_PATH "/var/log/ps3sas_drv.log" +#define LOG_FILE_PREFIX "ps3sas_drv.log" #define BINARY_FILE_PREFIX "ps3sas_drv.bin" #define BINARY_FILE_SIZE (200LL << 20) @@ -196,213 +155,198 @@ enum { DEBUG_TYPE_NR, }; -struct debug_func { +typedef struct { struct list_head list; char name[64]; -}; +} debug_func_t; -struct debug_file { +typedef struct { struct list_head list; char name[64]; -}; +} debug_file_t; -struct ps3_log { +typedef struct { struct { - char *buf; - int buf_size; - long long head; - long long tail; + char *buf; + int buf_size; + long long head; + long long tail; spinlock_t lock; - unsigned char is_drop; + unsigned char is_drop; }; struct { - char *file_path; - struct file *file; - long long file_pos; - long long file_size; - unsigned int file_num; - unsigned int index; + char *file_path; + struct file *file; + long long file_pos; + long long file_size; + U32 file_num; + U32 index; }; -}; +} ps3_log_t; -struct ps3_thread_local { - int magic; +typedef struct { + S32 magic; char data[0]; -}; +} ps3_thread_local_t; -struct ps3_ctxt { +typedef struct { struct page *page; - void *buff; -}; - -struct ps3_thread_key { - int offset; -}; - -struct ps3_debug { - enum debug_level level; - unsigned short key_offset; - struct ps3_ctxt __percpu *ctxt; - struct list_head filter_func; - struct list_head filter_file; - struct task_struct *task; - struct ps3_log log[DEBUG_TYPE_NR]; -}; - -void ps3_thread_key_create(int size, struct ps3_thread_key *key); -void *ps3_thread_get_specific(struct ps3_thread_key *key); -void ps3_thread_clear_specific(struct ps3_thread_key *key); - -int ps3_filter_file_add(char *name); + void *buff; +} ps3_ctxt_t; + +typedef struct { + S32 offset; +} ps3_thread_key_t; + +typedef struct { + debug_level_e level; + U16 key_offset; + ps3_ctxt_t __percpu *ctxt; + struct list_head filter_func; + struct list_head filter_file; + struct task_struct *task; + ps3_log_t log[DEBUG_TYPE_NR]; +} ps3_debug_t; + +void ps3_thread_key_create(int size, ps3_thread_key_t *key); +void *ps3_thread_get_specific(ps3_thread_key_t *key); +void ps3_thread_clear_specific(ps3_thread_key_t *key); + +int ps3_filter_file_add(char *name); void ps3_filter_file_del(char *name); void ps3_filter_file_clear(void); -int ps3_filter_func_add(char *name); +int ps3_filter_func_add(char *name); void ps3_filter_func_del(char *name); void ps3_filter_func_clear(void); void ps3_level_set(int level); -int ps3_level_get(void); +S32 ps3_level_get(void); -int ps3_debug_init(void); +int ps3_debug_init(void); void ps3_debug_exit(void); -void ps3_log_string(enum debug_level level, const char *file, int line, - const char *fmt, ...); +void ps3_log_string(debug_level_e level, const char *file, + int line, const char *fmt, ...); -void ps3_log_binary(const char *file, int line, char *ptr, int size, char *str); +void ps3_log_binary(const char *file, int line, char *ptr, + S32 size, char *str); void ps3_log_sync(void); -int ps3_ramfs_test_query(void); -void ps3_ramfs_test_store(int val); +extern S32 g_ramfs_test_enable; +static inline S32 ps3_ramfs_test_query(void) +{ + return g_ramfs_test_enable; +} + +static inline void ps3_ramfs_test_store(S32 val) +{ + g_ramfs_test_enable = val; +} #if defined DRIVER_DEBUG && defined __KERNEL__ -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -#define WRITE_LOG(level, fmt, ...) \ +#define WRITE_LOG(level, fmt, ...) \ ps3_log_string(level, __FILE__, __LINE__, fmt, ##__VA_ARGS__) #define LOG_DEBUG(fmt, ...) WRITE_LOG(LEVEL_DEBUG, fmt, ##__VA_ARGS__) -#define LOG_INFO(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_INFO(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) #define LOG_ERROR(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) -#define LOG2_DEBUG(fmt, ...) \ - do { \ - WRITE_LOG(LEVEL_DEBUG, fmt, ##__VA_ARGS__); \ - ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__); \ - } while (0) -#define LOG2_INFO(fmt, ...) \ - do { \ - WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__); \ - ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__); \ - } while (0) -#define LOG2_WARN(fmt, ...) \ - do { \ - WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__); \ - ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__); \ - } while (0) -#define LOG2_ERROR(fmt, ...) \ - do { \ - WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ - ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__); \ - } while (0) +#define LOG2_DEBUG(fmt, ...) WRITE_LOG(LEVEL_DEBUG, fmt, ##__VA_ARGS__); \ + ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__) +#define LOG2_INFO(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__); \ + ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__) +#define LOG2_WARN(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__); \ + ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__) +#define LOG2_ERROR(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__) #define LOG_LEVEL(log_lvl, fmt, ...) WRITE_LOG(log_lvl, fmt, ##__VA_ARGS__) -#define LOG_INFO_LIM(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN_LIM(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_INFO_LIM(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN_LIM(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) #define LOG_ERROR_LIM(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) -#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) \ - do { \ - (void)caller_jiffies; \ - (void)time; \ - WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__); \ - } while (0) -#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) \ - do { \ - (void)caller_jiffies; \ - (void)time; \ - WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__); \ - } while (0) -#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) \ - do { \ - (void)caller_jiffies; \ - (void)time; \ - WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG2_INFO_LIM(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG2_WARN_LIM(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ + (void)caller_jiffies; \ + (void)time; \ + WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__); \ +} while (0) +#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ + (void)caller_jiffies; \ + (void)time; \ + WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__); \ +} while (0) +#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ + (void)caller_jiffies; \ + (void)time; \ + WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ +} while (0) + +#define LOG2_INFO_LIM(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG2_WARN_LIM(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) #define LOG2_ERROR_LIM(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) -#define LOG_FILE_INFO(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_FILE_WARN(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) -#define LOG_FILE_ERROR(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) +#define LOG_FILE_INFO(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_FILE_WARN(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_FILE_ERROR(fmt, ...)WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) #define LOG_SPC_ERROR(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) -#define LOG_INFO_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) -#define LOG_ERROR_IN_IRQ(ins, fmt, ...) \ - WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) - -#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ - WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ - WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) -#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ - WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) - -#define LOG_SYNC() ps3_log_sync() -#define DATA_DUMP(ptr, size, str) \ - ps3_log_binary(__FILE__, __LINE__, (char *)ptr, size, str) +#define LOG_INFO_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_ERROR_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) + +#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) + +#define LOG_SYNC() ps3_log_sync() +#define DATA_DUMP(ptr, size, str) \ + ps3_log_binary(__FILE__, __LINE__, (char*)ptr, size, str) #else -#define LOG_DEBUG(fmt, ...) ps3_printk(LEVEL_DEBUG, fmt, ##__VA_ARGS__) -#define LOG_INFO(fmt, ...) ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN(fmt, ...) ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__) -#define LOG_ERROR(fmt, ...) ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__) - -#define LOG2_DEBUG(fmt, ...) ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__) -#define LOG2_INFO(fmt, ...) ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__) -#define LOG2_WARN(fmt, ...) ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__) -#define LOG2_ERROR(fmt, ...) ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__) - -#define LOG_INFO_LIM(fmt, ...) \ - ps3_printk_ratelimited(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN_LIM(fmt, ...) \ - ps3_printk_ratelimited(LEVEL_WARN, fmt, ##__VA_ARGS__) -#define LOG_ERROR_LIM(fmt, ...) \ - ps3_printk_ratelimited(LEVEL_ERROR, fmt, ##__VA_ARGS__) - -#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) \ - do { \ - if (printk_timed_ratelimit(caller_jiffies, time)) { \ - ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); \ - } \ - } while (0) -#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) \ - do { \ - if (printk_timed_ratelimit(caller_jiffies, time)) { \ - ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); \ - } \ - } while (0) -#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) \ - do { \ - if (printk_timed_ratelimit(caller_jiffies, time)) { \ - ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ - } \ - } while (0) - -#define LOG2_INFO_LIM(fmt, ...) LOG_INFO_LIM(fmt, ##__VA_ARGS__) -#define LOG2_WARN_LIM(fmt, ...) LOG_WARN_LIM(fmt, ##__VA_ARGS__) -#define LOG2_ERROR_LIM(fmt, ...) LOG_ERROR_LIM(fmt, ##__VA_ARGS__) -#define LOG_SPC_ERROR(fmt, ...) LOG_INFO(fmt, ##__VA_ARGS__) +#define LOG_DEBUG(fmt, ...) ps3_printk(LEVEL_DEBUG, fmt, ##__VA_ARGS__); +#define LOG_INFO(fmt, ...) ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); +#define LOG_WARN(fmt, ...) ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); +#define LOG_ERROR(fmt, ...) ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); + +#define LOG2_DEBUG(fmt, ...) do { ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__); } while (0) +#define LOG2_INFO(fmt, ...) do { ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__); } while (0) +#define LOG2_WARN(fmt, ...) do { ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__); } while (0) +#define LOG2_ERROR(fmt, ...) do { ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__); } while (0) + +#define LOG_INFO_LIM(fmt, ...) ps3_printk_ratelimited(LEVEL_INFO, fmt, ##__VA_ARGS__); +#define LOG_WARN_LIM(fmt, ...) ps3_printk_ratelimited(LEVEL_WARN, fmt, ##__VA_ARGS__); +#define LOG_ERROR_LIM(fmt, ...) ps3_printk_ratelimited(LEVEL_ERROR, fmt, ##__VA_ARGS__); + +#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ + if (printk_timed_ratelimit(caller_jiffies, time)) { \ + ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); \ + } \ +} while (0) +#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ + if (printk_timed_ratelimit(caller_jiffies, time)) { \ + ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); \ + } \ +} while (0) +#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ + if (printk_timed_ratelimit(caller_jiffies, time)) { \ + ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + } \ +} while (0) + +#define LOG2_INFO_LIM(fmt, ...) LOG_INFO_LIM(fmt, ##__VA_ARGS__) +#define LOG2_WARN_LIM(fmt, ...) LOG_WARN_LIM(fmt, ##__VA_ARGS__) +#define LOG2_ERROR_LIM(fmt, ...) LOG_ERROR_LIM(fmt, ##__VA_ARGS__) + +#define LOG_SPC_ERROR(fmt, ...) LOG_INFO(fmt, ##__VA_ARGS__) #define LOG_FILE_INFO(fmt, ...) #define LOG_FILE_WARN(fmt, ...) @@ -410,153 +354,136 @@ void ps3_ramfs_test_store(int val); #define LOG_LEVEL(log_lvl, fmt, ...) ps3_printk(log_lvl, fmt, ##__VA_ARGS__) -#define LOG_INFO_IN_IRQ(ins, fmt, ...) \ - do { \ - if ((ins)->is_irq_prk_support) { \ - ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); \ - } \ - } while (0) - -#define LOG_WARN_IN_IRQ(ins, fmt, ...) \ - do { \ - if ((ins)->is_irq_prk_support) { \ - ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); \ - } \ - } while (0) - -#define LOG_ERROR_IN_IRQ(ins, fmt, ...) \ - do { \ - if ((ins)->is_irq_prk_support) { \ - ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ - } \ - } while (0) -#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ - do { \ - if (need_prk_err) { \ - LOG_INFO_LIM(fmt, ##__VA_ARGS__); \ - } else { \ - LOG_INFO_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ - } \ - } while (0) - -#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ - do { \ - if (need_prk_err) { \ - LOG_WARN_LIM(fmt, ##__VA_ARGS__); \ - } else { \ - LOG_WARN_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ - } \ - } while (0) - -#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ - do { \ - if (need_prk_err) { \ - LOG_ERROR_LIM(fmt, ##__VA_ARGS__); \ - } else { \ - LOG_ERROR_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ - } \ - } while (0) +#define LOG_INFO_IN_IRQ(ins, fmt, ...) do { \ + if((ins)->is_irq_prk_support) { \ + ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); \ + } \ +}while(0) + +#define LOG_WARN_IN_IRQ(ins, fmt, ...) do { \ + if((ins)->is_irq_prk_support) { \ + ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); \ + } \ +}while(0) + +#define LOG_ERROR_IN_IRQ(ins, fmt, ...) do { \ + if((ins)->is_irq_prk_support) { \ + ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + } \ +}while(0) + +#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ + if (need_prk_err) { \ + LOG_INFO_LIM(fmt, ##__VA_ARGS__); \ + } else { \ + LOG_INFO_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ + } \ +} while (0) + +#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ + if (need_prk_err) { \ + LOG_WARN_LIM(fmt, ##__VA_ARGS__); \ + } else { \ + LOG_WARN_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ + } \ +} while (0) + +#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ + if (need_prk_err) { \ + LOG_ERROR_LIM(fmt, ##__VA_ARGS__); \ + } else { \ + LOG_ERROR_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ + } \ +} while (0) #define LOG_SYNC() #define DATA_DUMP(ptr, size, str) #endif -static inline unsigned char ps3_fs_requires_dev(struct file *fp) +static inline Bool ps3_fs_requires_dev(struct file *fp) { - if (ps3_ramfs_test_query()) + if (ps3_ramfs_test_query()) { return PS3_FALSE; + } return (fp->f_inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV); } #else -#define LOG_DEBUG(fmt, ...) ps3_print(PS3_TRUE, PRINT_DEBUG, fmt, ##__VA_ARGS__) -#define LOG_INFO(fmt, ...) ps3_print(PS3_TRUE, PRINT_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN(fmt, ...) ps3_print(PS3_TRUE, PRINT_WARN, fmt, ##__VA_ARGS__) -#define LOG_ERROR(fmt, ...) ps3_print(PS3_TRUE, PRINT_ERR, fmt, ##__VA_ARGS__) - -#define LOG2_DEBUG(fmt, ...) \ - ps3_print(PS3_TRUE, PRINT_DEBUG, fmt, ##__VA_ARGS__) -#define LOG2_INFO(fmt, ...) ps3_print(PS3_TRUE, PRINT_INFO, fmt, ##__VA_ARGS__) -#define LOG2_WARN(fmt, ...) ps3_print(PS3_TRUE, PRINT_WARN, fmt, ##__VA_ARGS__) -#define LOG2_ERROR(fmt, ...) ps3_print(PS3_TRUE, PRINT_ERR, fmt, ##__VA_ARGS__) - -#define LOG_LEVEL(log_lvl, fmt, ...) \ - ps3_print(PS3_TRUE, log_lvl, fmt, ##__VA_ARGS__) - -#define LOG_INFO_LIM(fmt, ...) \ - ps3_print(PS3_TRUE, LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN_LIM(fmt, ...) \ - ps3_print(PS3_TRUE, LEVEL_WARN, fmt, ##__VA_ARGS__) -#define LOG_ERROR_LIM(fmt, ...) \ - ps3_print(PS3_TRUE, LEVEL_ERROR, fmt, ##__VA_ARGS__) - -#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) \ - do { \ - (void)caller_jiffies; \ - (void)time; \ - ps3_print(PS3_TRUE, LEVEL_INFO, fmt, ##__VA_ARGS__); \ - } while (0) -#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) \ - do { \ - (void)caller_jiffies; \ - (void)time; \ - ps3_print(PS3_TRUE, LEVEL_WARN, fmt, ##__VA_ARGS__); \ - } while (0) -#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) \ - do { \ - (void)caller_jiffies; \ - (void)time; \ - ps3_print(PS3_TRUE, LEVEL_ERROR, fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG2_INFO_LIM(fmt, ...) LOG_INFO_LIM(fmt, ##__VA_ARGS__) -#define LOG2_WARN_LIM(fmt, ...) LOG_WARN_LIM(fmt, ##__VA_ARGS__) -#define LOG2_ERROR_LIM(fmt, ...) LOG_ERROR_LIM(fmt, ##__VA_ARGS__) +#define LOG_DEBUG(fmt, ...) ps3_print(PS3_TRUE, PRINT_DEBUG, fmt, ##__VA_ARGS__) +#define LOG_INFO(fmt, ...) ps3_print(PS3_TRUE, PRINT_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN(fmt, ...) ps3_print(PS3_TRUE, PRINT_WARN, fmt, ##__VA_ARGS__) +#define LOG_ERROR(fmt, ...) ps3_print(PS3_TRUE, PRINT_ERR, fmt, ##__VA_ARGS__) + +#define LOG2_DEBUG(fmt, ...) ps3_print(PS3_TRUE, PRINT_DEBUG, fmt, ##__VA_ARGS__) +#define LOG2_INFO(fmt, ...) ps3_print(PS3_TRUE, PRINT_INFO, fmt, ##__VA_ARGS__) +#define LOG2_WARN(fmt, ...) ps3_print(PS3_TRUE, PRINT_WARN, fmt, ##__VA_ARGS__) +#define LOG2_ERROR(fmt, ...) ps3_print(PS3_TRUE, PRINT_ERR, fmt, ##__VA_ARGS__) + +#define LOG_LEVEL(log_lvl, fmt, ...) ps3_print(PS3_TRUE, log_lvl, fmt, ##__VA_ARGS__) + +#define LOG_INFO_LIM(fmt, ...) ps3_print(PS3_TRUE, LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN_LIM(fmt, ...) ps3_print(PS3_TRUE, LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_ERROR_LIM(fmt, ...) ps3_print(PS3_TRUE, LEVEL_ERROR, fmt, ##__VA_ARGS__) + +#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ + (void)caller_jiffies; \ + (void)time; \ + ps3_print(PS3_TRUE, LEVEL_INFO, fmt, ##__VA_ARGS__); \ +} while (0) +#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ + (void)caller_jiffies; \ + (void)time; \ + ps3_print(PS3_TRUE, LEVEL_WARN, fmt, ##__VA_ARGS__); \ +} while (0) +#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ + (void)caller_jiffies; \ + (void)time; \ + ps3_print(PS3_TRUE, LEVEL_ERROR, fmt, ##__VA_ARGS__); \ +} while (0) + +#define LOG2_INFO_LIM(fmt, ...) LOG_INFO_LIM(fmt, ##__VA_ARGS__) +#define LOG2_WARN_LIM(fmt, ...) LOG_WARN_LIM(fmt, ##__VA_ARGS__) +#define LOG2_ERROR_LIM(fmt, ...) LOG_ERROR_LIM(fmt, ##__VA_ARGS__) #define LOG_FILE_INFO(fmt, ...) #define LOG_FILE_WARN(fmt, ...) #define LOG_FILE_ERROR(fmt, ...) -#define LOG_SPC_ERROR(fmt, ...) LOG_INFO(fmt, ##__VA_ARGS__) - -#define LOG_INFO_IN_IRQ(ins, fmt, ...) \ - do { \ - (void)ins; \ - ps3_print(PS3_FALSE, LEVEL_INFO, fmt, ##__VA_ARGS__); \ - } while (0) -#define LOG_WARN_IN_IRQ(ins, fmt, ...) \ - do { \ - (void)ins; \ - ps3_print(PS3_FALSE, LEVEL_WARN, fmt, ##__VA_ARGS__); \ - } while (0) -#define LOG_ERROR_IN_IRQ(ins, fmt, ...) \ - do { \ - (void)ins; \ - ps3_print(PS3_FALSE, LEVEL_ERROR, fmt, ##__VA_ARGS__); \ - } while (0) -#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ - do { \ - (void)ins; \ - ps3_print((need_prk_err), LEVEL_INFO, fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ - do { \ - (void)ins; \ - ps3_print((need_prk_err), LEVEL_WARN, fmt, ##__VA_ARGS__); \ - } while (0) - -#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ - do { \ - (void)ins; \ - ps3_print((need_prk_err), LEVEL_ERROR, fmt, ##__VA_ARGS__); \ - } while (0) +#define LOG_SPC_ERROR(fmt, ...) LOG_INFO(fmt, ##__VA_ARGS__) + +#define LOG_INFO_IN_IRQ(ins, fmt, ...) do { \ + (void)ins; \ + ps3_print(PS3_FALSE, LEVEL_INFO, fmt, ##__VA_ARGS__); \ +}while(0) +#define LOG_WARN_IN_IRQ(ins, fmt, ...) do { \ + (void)ins; \ + ps3_print(PS3_FALSE, LEVEL_WARN, fmt, ##__VA_ARGS__); \ +}while(0) +#define LOG_ERROR_IN_IRQ(ins, fmt, ...) do { \ + (void)ins; \ + ps3_print(PS3_FALSE, LEVEL_ERROR, fmt, ##__VA_ARGS__); \ +}while(0) + +#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ + (void)ins; \ + ps3_print((need_prk_err), LEVEL_INFO, fmt, ##__VA_ARGS__); \ +} while (0) + +#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ + (void)ins; \ + ps3_print((need_prk_err), LEVEL_WARN, fmt, ##__VA_ARGS__); \ +} while (0) + +#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ + (void)ins; \ + ps3_print((need_prk_err), LEVEL_ERROR, fmt, ##__VA_ARGS__); \ +} while (0) #define LOG_SYNC() #define DATA_DUMP(ptr, size, str) -static inline unsigned char ps3_fs_requires_dev(struct file *fp) +static inline Bool ps3_fs_requires_dev(struct file *fp) { (void)fp; return PS3_TRUE; @@ -570,85 +497,67 @@ static inline unsigned char ps3_fs_requires_dev(struct file *fp) #if defined(PS3_CFG_OCM_DBGBUG) || defined(PS3_CFG_OCM_RELEASE) -#define PS3_BUG_ON(cond) \ - do { \ - if ((cond)) { \ - pr_err("BUG_ON's condition(%s) has been triggered\n", \ - #cond); \ - LOG_ERROR( \ - "BUG_ON's condition(%s) has been triggered\n", \ - #cond); \ - } \ - } while (0) - -#define PS3_BUG_ON_NO_SYNC(cond) \ - do { \ - if ((cond)) { \ - pr_err("BUG_ON's condition(%s) has been triggered\n", \ - #cond); \ - LOG_ERROR( \ - "BUG_ON's condition(%s) has been triggered\n", \ - #cond); \ - } \ - } while (0) +#define PS3_BUG_ON(cond) do { \ + if((cond)) { \ + printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ + LOG_ERROR("BUG_ON's condition(%s) has been triggered\n", #cond); \ + } \ +}while(0) + +#define PS3_BUG_ON_NO_SYNC(cond) do { \ + if((cond)) { \ + printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ + LOG_ERROR("BUG_ON's condition(%s) has been triggered\n", #cond); \ + } \ +}while(0) #else -#define PS3_BUG_ON(cond) \ - do { \ - if ((cond)) { \ - pr_err("BUG_ON's condition(%s) has been triggered\n", \ - #cond); \ - } \ - } while (0) - -#define PS3_BUG_ON_NO_SYNC(cond) \ - do { \ - if ((cond)) { \ - pr_err("BUG_ON's condition(%s) has been triggered\n", \ - #cond); \ - } \ - } while (0) +#define PS3_BUG_ON(cond) do { \ + if((cond)) { \ + printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ + } \ + }while(0) + +#define PS3_BUG_ON_NO_SYNC(cond) do { \ + if((cond)) { \ + printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ + } \ + }while(0) #endif #else -#define PS3_BUG_ON(cond) \ - do { \ - if ((cond)) { \ - pr_err("BUG_ON's condition(%s) has been triggered\n", \ - #cond); \ - LOG_ERROR( \ - "BUG_ON's condition(%s) has been triggered\n", \ - #cond); \ - LOG_SYNC(); \ - } \ - BUG_ON(cond); \ - } while (0) - -#define PS3_BUG(void) \ - do { \ - LOG_SYNC(); \ - BUG(void); \ - } while (0) - -#define PS3_BUG_ON_NO_SYNC(cond) \ - do { \ - if ((cond)) { \ - pr_err( \ - "BUG_ON's condition(%s) has been triggered\n", \ - #cond); \ - LOG_ERROR( \ - "BUG_ON's condition(%s) has been triggered\n", \ - #cond); \ - } \ - BUG_ON(cond); \ - } while (0) - -#define PS3_BUG_NO_SYNC(void) BUG(void) +#define PS3_BUG_ON(cond) do { \ + if((cond)) { \ + printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ + LOG_ERROR("BUG_ON's condition(%s) has been triggered\n", #cond); \ + LOG_SYNC(); \ + } \ + BUG_ON(cond); \ +}while(0) + +#define PS3_BUG(void) do { \ + LOG_SYNC(); \ + BUG(void); \ +}while(0) + +#define PS3_BUG_ON_NO_SYNC(cond) do { \ + if((cond)) { \ + printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ + LOG_ERROR("BUG_ON's condition(%s) has been triggered\n", #cond); \ + } \ + BUG_ON(cond); \ +}while(0) + +#define PS3_BUG_NO_SYNC(void) do { \ + BUG(void); \ +}while(0) #endif -#define PS3_WARN_ON(cond) WARN_ON(cond) +#define PS3_WARN_ON(cond) do { \ + WARN_ON(cond); \ +}while(0) #ifdef __cplusplus } diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_dump.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_dump.c index 0b97206d998e..c2bd62106ab8 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_dump.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_dump.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include #include #include @@ -8,9 +6,7 @@ #include #include #include -#ifdef PS3_UT -#include -#endif +#include #include "ps3_dump.h" #include "ps3_mgr_cmd.h" @@ -21,26 +17,26 @@ #include "ps3_util.h" #include "ps3_cli.h" #include "ps3_module_para.h" -#include "ps3_kernel_version.h" +#include "ps3_err_inject.h" static inline void ps3_dump_status_set(struct ps3_instance *instance, - unsigned long long value); + U64 value); -int ps3_dump_local_time(struct rtc_time *tm) +S32 ps3_dump_local_time(struct rtc_time *tm) { -#if defined(PS3_DUMP_TIME_32) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) struct timeval time; - unsigned long long local_time; + U64 local_time; do_gettimeofday(&time); - local_time = (unsigned long long)(time.tv_sec - (sys_tz.tz_minuteswest * 60)); + local_time = (U64)(time.tv_sec - (sys_tz.tz_minuteswest * 60)); rtc_time_to_tm(local_time, tm); #else struct timespec64 time; - unsigned long long local_time; + U64 local_time; ktime_get_real_ts64(&time); - local_time = (unsigned long long)(time.tv_sec - (sys_tz.tz_minuteswest * 60)); + local_time = (U64)(time.tv_sec - (sys_tz.tz_minuteswest * 60)); rtc_time64_to_tm(local_time, tm); #endif tm->tm_mon += 1; @@ -48,40 +44,36 @@ int ps3_dump_local_time(struct rtc_time *tm) return 0; } -int ps3_dump_filename_build(struct ps3_instance *instance, char *filename, - unsigned int len, unsigned char *prefix) +S32 ps3_dump_filename_build(struct ps3_instance *instance, + char *filename, U32 len, U8 *prefix) { struct ps3_dump_context *ctxt = &instance->dump_context; struct rtc_time tm; char *p_str = filename; - if (filename == NULL || prefix == NULL) + if (filename == NULL || prefix == NULL) { return -1; + } ps3_dump_local_time(&tm); - p_str += - snprintf(p_str, len - (p_str - filename), "%s", ctxt->dump_dir); - p_str += - snprintf(p_str, len - (p_str - filename), (const char *)prefix); - p_str += snprintf(p_str, len - (p_str - filename), "host%d-", - instance->host->host_no); - p_str += snprintf(p_str, len - (p_str - filename), - "%04d%02d%02d-%02d%02d%02d-", tm.tm_year, tm.tm_mon, - tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); - p_str += snprintf(p_str, len - (p_str - filename), "%llu", - instance->ioc_fw_version); + p_str += snprintf(p_str, len - (p_str - filename), "%s", ctxt->dump_dir); + p_str += snprintf(p_str, len - (p_str - filename), (const char*)prefix); + p_str += snprintf(p_str, len - (p_str - filename), "host%d-", instance->host->host_no); + p_str += snprintf(p_str, len - (p_str - filename), "%04d%02d%02d-%02d%02d%02d-", + tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + p_str += snprintf(p_str, len - (p_str - filename), "%llu", instance->ioc_fw_version); return 0; } -int ps3_dump_file_open(struct ps3_dump_context *ctxt, unsigned int dump_type) +S32 ps3_dump_file_open(struct ps3_dump_context *ctxt, U32 dump_type) { struct ps3_dump_file_info *file_info = &ctxt->dump_out_file; - unsigned char filename[PS3_DUMP_FILE_NAME_LEN] = { 0 }; - unsigned char *p_prefix = NULL; - int ret = PS3_SUCCESS; + U8 filename[PS3_DUMP_FILE_NAME_LEN] = {0}; + U8 *p_prefix = NULL; + S32 ret = PS3_SUCCESS; struct file *fp = NULL; -#if defined(PS3_SUPPORT_FS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) mm_segment_t old_fs; #endif @@ -93,15 +85,15 @@ int ps3_dump_file_open(struct ps3_dump_context *ctxt, unsigned int dump_type) memset(file_info, 0, sizeof(struct ps3_dump_file_info)); - switch (dump_type) { + switch (dump_type){ case PS3_DUMP_TYPE_FW_LOG: - p_prefix = (unsigned char *)PS3_DUMP_FILE_FWLOG_PREFIX; + p_prefix = (U8*)PS3_DUMP_FILE_FWLOG_PREFIX; break; case PS3_DUMP_TYPE_BAR_DATA: - p_prefix = (unsigned char *)PS3_DUMP_FILE_BAR_PREFIX; + p_prefix = (U8*)PS3_DUMP_FILE_BAR_PREFIX; break; case PS3_DUMP_TYPE_CRASH: - p_prefix = (unsigned char *)PS3_DUMP_FILE_CORE_PREFIX; + p_prefix = (U8*)PS3_DUMP_FILE_CORE_PREFIX; break; default: LOG_INFO("dump file create: unknown dump type %d\n", dump_type); @@ -109,37 +101,34 @@ int ps3_dump_file_open(struct ps3_dump_context *ctxt, unsigned int dump_type) goto l_out; } - if (ps3_dump_filename_build(ctxt->instance, (char *)filename, - PS3_DUMP_FILE_NAME_LEN, p_prefix) != 0) { + if (ps3_dump_filename_build(ctxt->instance, (char*)filename, + PS3_DUMP_FILE_NAME_LEN, p_prefix) != 0) { LOG_INFO("dump file create: filename build NOK\n"); ret = -PS3_FAILED; goto l_out; } - fp = (struct file *)filp_open( - (char *)filename, O_CREAT | O_RDWR | O_TRUNC | O_LARGEFILE, 0); + fp = (struct file*)filp_open((char*)filename, O_CREAT |O_RDWR | O_TRUNC | O_LARGEFILE, 0); if (IS_ERR(fp)) { - LOG_INFO( - "dump file create: filp_open error filename %s errno %d\n", - filename, (int)PTR_ERR(fp)); + LOG_INFO("dump file create: filp_open error filename %s errno %d\n", filename, (int)PTR_ERR(fp)); ret = -PS3_FAILED; goto l_out; } if (!ps3_fs_requires_dev(fp)) { -#if defined(PS3_KERNEL_WRITE_GET_DS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) old_fs = get_fs(); - set_fs(get_ds()); -#elif defined(PS3_KERNEL_WRITE) + set_fs(get_ds() ); +#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) old_fs = get_fs(); - set_fs(KERNEL_DS); -#elif defined(PS3_VFS_WRITE) + set_fs( KERNEL_DS ); +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) #else old_fs = force_uaccess_begin(); #endif filp_close(fp, NULL); -#if defined(PS3_SET_FS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) set_fs(old_fs); -#elif defined(PS3_FORCE_UACCESS) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) #else force_uaccess_end(old_fs); #endif @@ -157,68 +146,69 @@ int ps3_dump_file_open(struct ps3_dump_context *ctxt, unsigned int dump_type) return ret; } -int ps3_dump_file_write(struct ps3_dump_file_info *file_info, unsigned char *buf, unsigned int len) +S32 ps3_dump_file_write(struct ps3_dump_file_info *file_info, U8 *buf, U32 len) { struct file *fp = NULL; -#if defined(PS3_SUPPORT_FS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) mm_segment_t old_fs; #endif - int ret = 0; + S32 ret = 0; if (file_info && file_info->fp) { fp = file_info->fp; -#if defined(PS3_KERNEL_WRITE_GET_DS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) old_fs = get_fs(); - set_fs(get_ds()); -#elif defined(PS3_KERNEL_WRITE) + set_fs(get_ds() ); +#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) old_fs = get_fs(); - set_fs(KERNEL_DS); -#elif defined(PS3_VFS_WRITE) + set_fs( KERNEL_DS ); +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) #else old_fs = force_uaccess_begin(); #endif -#if defined(PS3_KERNEL_WRITE_FILE) - ret = kernel_write(fp, (char *)buf, len, &fp->f_pos); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) + ret = kernel_write(fp, (char*)buf, len, &fp->f_pos); #else - ret = vfs_write(fp, (char *)buf, len, &fp->f_pos); + ret = vfs_write(fp, (char*)buf, len, &fp->f_pos); #endif -#if defined(PS3_SET_FS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) set_fs(old_fs); -#elif defined(PS3_FORCE_UACCESS) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) #else force_uaccess_end(old_fs); #endif - if (ret > 0) + if (ret > 0) { file_info->file_size += len; + } file_info->file_w_cnt++; } return ret; } -int ps3_dump_file_close(struct ps3_dump_file_info *file_info) +S32 ps3_dump_file_close(struct ps3_dump_file_info *file_info) { -#if defined(PS3_SUPPORT_FS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) mm_segment_t old_fs; #endif if (file_info && file_info->fp) { PS3_BUG_ON(IS_ERR(file_info->fp)); -#if defined(PS3_KERNEL_WRITE_GET_DS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) old_fs = get_fs(); set_fs(get_ds()); -#elif defined(PS3_KERNEL_WRITE) +#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) old_fs = get_fs(); - set_fs(KERNEL_DS); -#elif defined(PS3_VFS_WRITE) + set_fs( KERNEL_DS ); +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) #else old_fs = force_uaccess_begin(); #endif filp_close(file_info->fp, NULL); -#if defined(PS3_SET_FS) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) set_fs(old_fs); -#elif defined(PS3_FORCE_UACCESS) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) #else force_uaccess_end(old_fs); #endif @@ -229,24 +219,23 @@ int ps3_dump_file_close(struct ps3_dump_file_info *file_info) return 0; } -struct ps3_dump_context *dev_to_dump_context(struct device *cdev) +struct ps3_dump_context * dev_to_dump_context(struct device *cdev) { struct Scsi_Host *shost = class_to_shost(cdev); - struct ps3_instance *instance = (struct ps3_instance *)shost->hostdata; - + struct ps3_instance *instance = + (struct ps3_instance *) shost->hostdata; return &instance->dump_context; } -static inline unsigned char ps3_dump_ctrl_get(struct ps3_instance *instance, - unsigned long long *dump_ctrl) +static inline Bool ps3_dump_ctrl_get(struct ps3_instance *instance, U64 *dump_ctrl) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpCtrl, - *dump_ctrl); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpCtrl, *dump_ctrl); + INJECT_START(PS3_ERR_IJ_DUMP_CTRL_ERR, dump_ctrl); if (*dump_ctrl == U64_MAX) { LOG_INFO("hno:%u read reg ps3DumpCtrl NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_FALSE; goto l_out; } @@ -256,31 +245,33 @@ static inline unsigned char ps3_dump_ctrl_get(struct ps3_instance *instance, return ret; } -static inline void ps3_dump_ctrl_set(struct ps3_instance *instance, unsigned long long value) +static inline void ps3_dump_ctrl_set(struct ps3_instance *instance, + U64 value) { PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpCtrl, value); } static inline void ps3_dump_abort(struct ps3_instance *instance) { - struct ps3_dump_context *ctxt = &instance->dump_context; - unsigned long long dump_ctrl; - unsigned char ret = PS3_TRUE; + struct ps3_dump_context * ctxt = &instance->dump_context; + U64 dump_ctrl; + Bool ret = PS3_TRUE; if (ctxt->dump_state == PS3_DUMP_STATE_ABORTED || - ctxt->dump_state == PS3_DUMP_STATE_INVALID) { + ctxt->dump_state == PS3_DUMP_STATE_INVALID ) { goto l_ret; } ret = ps3_dump_ctrl_get(instance, &dump_ctrl); + INJECT_START(PS3_ERR_IJ_DUMP_ABORT_GET_CTRL_FAIL, &ret); if (ret) { - if (dump_ctrl) { - LOG_WARN("dump ctrl is not cleared 0x%llx\n", - dump_ctrl); - } + if (dump_ctrl) + LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); + ps3_dump_ctrl_set(instance, PS3_DUMP_CTRL_DUMP_ABORT); } else { - LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", PS3_HOST(instance)); + LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", + PS3_HOST(instance)); } ctxt->dump_state = PS3_DUMP_STATE_ABORTED; l_ret: @@ -289,27 +280,31 @@ static inline void ps3_dump_abort(struct ps3_instance *instance) static inline void ps3_dump_end(struct ps3_instance *instance) { - unsigned long long dump_ctrl; - unsigned char ret = PS3_TRUE; + U64 dump_ctrl; + Bool ret = PS3_TRUE; ret = ps3_dump_ctrl_get(instance, &dump_ctrl); + INJECT_START(PS3_ERR_IJ_DUMP_END_GET_CTRL_FAIL, &ret); if (ret) { - if (dump_ctrl) { - LOG_WARN("dump ctrl is not cleared 0x%llx\n", - dump_ctrl); - } + if (dump_ctrl) + LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); + ps3_dump_ctrl_set(instance, PS3_DUMP_CTRL_DUMP_END); } else { - LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", PS3_HOST(instance)); + LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", + PS3_HOST(instance)); } + + return; } -static inline int ps3_dump_trigger(struct ps3_instance *instance, int dump_type) +static inline S32 ps3_dump_trigger(struct ps3_instance *instance, + S32 dump_type) { - unsigned long long dump_ctrl; - unsigned long long ctrl_val = 0; - int ret = PS3_SUCCESS; - unsigned char reg_ret = PS3_TRUE; + U64 dump_ctrl; + U64 ctrl_val = 0; + S32 ret = PS3_SUCCESS; + Bool reg_ret = PS3_TRUE; switch (dump_type) { case PS3_DUMP_TYPE_CRASH: @@ -327,32 +322,33 @@ static inline int ps3_dump_trigger(struct ps3_instance *instance, int dump_type) } reg_ret = ps3_dump_ctrl_get(instance, &dump_ctrl); + INJECT_START(PS3_ERR_IJ_DUMP_TRIGGER_GET_CTRL_FAIL, ®_ret); if (reg_ret) { if (dump_ctrl) { - LOG_WARN("dump ctrl is not cleared 0x%llx\n", - dump_ctrl); + LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); ret = -PS3_FAILED; } else { ps3_dump_ctrl_set(instance, ctrl_val); } } else { - LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", PS3_HOST(instance)); + LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", + PS3_HOST(instance)); ret = -PS3_FAILED; } l_ret: return ret; } -static inline unsigned char ps3_dump_status_get(struct ps3_instance *instance, - unsigned long long *dump_status) +static inline Bool ps3_dump_status_get(struct ps3_instance *instance, + U64 *dump_status) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpStatus, - *dump_status); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpStatus, *dump_status); + INJECT_START(PS3_ERR_IJ_DUMP_STATUS_ERR, dump_status); if (*dump_status == U64_MAX) { LOG_INFO("hno:%u read reg ps3DumpStatus NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *dump_status = 0; ret = PS3_FALSE; goto l_out; @@ -364,35 +360,35 @@ static inline unsigned char ps3_dump_status_get(struct ps3_instance *instance, return ret; } -static inline void ps3_dump_status_set(struct ps3_instance *instance, unsigned long long value) +static inline void ps3_dump_status_set(struct ps3_instance *instance, + U64 value) { PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpStatus, value); } -static inline unsigned char ps3_dump_data_size_get_clear(struct ps3_instance *instance, - unsigned long long *data_size) +static inline Bool ps3_dump_data_size_get_clear(struct ps3_instance *instance, + U64 *data_size) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpDataSize, - *data_size); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpDataSize, *data_size); + INJECT_START(PS3_ERR_IJ_DUMP_DATA_SIZE_FAIL, data_size); if (*data_size == U64_MAX) { LOG_INFO("hno:%u read reg ps3DumpDataSize NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *data_size = 0; ret = PS3_FALSE; } - PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpDataSize, - 0); + PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpDataSize, 0); return ret; } -static unsigned char ps3_dump_status_check(unsigned long long status, unsigned char dump_type) +static Bool ps3_dump_status_check(U64 status, U8 dump_type) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; - switch (dump_type) { + switch(dump_type){ case PS3_DUMP_TYPE_FW_LOG: ret = PS3_REG_TEST(status, PS3_DUMP_STATUS_REG_FW_DUMP_MASK); break; @@ -408,19 +404,20 @@ static unsigned char ps3_dump_status_check(unsigned long long status, unsigned c goto l_out; } - if (ret == PS3_TRUE) + if (ret == PS3_TRUE) { ret = PS3_REG_TEST(status, PS3_DUMP_STATUS_REG_DMA_FINISH_MASK); + } l_out: return ret; } -static int ps3_dump_dma_data_copy(struct ps3_dump_context *ctxt, unsigned long long status) +static S32 ps3_dump_dma_data_copy(struct ps3_dump_context * ctxt, U64 status) { - unsigned long long dma_size = 0; - unsigned long long dump_ctrl; - int ret = PS3_SUCCESS; - unsigned char reg_ret = PS3_TRUE; + U64 dma_size = 0; + U64 dump_ctrl; + S32 ret = PS3_SUCCESS; + Bool reg_ret = PS3_TRUE; if (!ps3_dump_data_size_get_clear(ctxt->instance, &dma_size)) { ret = -PS3_FAILED; @@ -434,11 +431,10 @@ static int ps3_dump_dma_data_copy(struct ps3_dump_context *ctxt, unsigned long l } ctxt->dump_data_size += dma_size; - ret = ps3_dump_file_write(&ctxt->dump_out_file, ctxt->dump_dma_buf, - dma_size); - if (ret < 0 || ret != (int)dma_size) { - LOG_WARN("error: write data failure ret %d, dma_size %llu\n", - ret, dma_size); + ret = ps3_dump_file_write(&ctxt->dump_out_file, ctxt->dump_dma_buf, dma_size); + INJECT_START(PS3_ERR_IJ_DUMP_WRITE_FAIL, &ret); + if (ret < 0 || ret != (S32)dma_size) { + LOG_WARN("error: write data failure ret %d, dma_size %llu\n", ret, dma_size); ret = -PS3_FAILED; goto l_out; } @@ -448,16 +444,16 @@ static int ps3_dump_dma_data_copy(struct ps3_dump_context *ctxt, unsigned long l ps3_dump_status_set(ctxt->instance, status); reg_ret = ps3_dump_ctrl_get(ctxt->instance, &dump_ctrl); + INJECT_START(PS3_ERR_IJ_DUMP_DATA_COPY_GET_CTRL_FAIL, ®_ret); if (reg_ret) { - if (dump_ctrl) { - LOG_WARN("dump ctrl is not cleared 0x%llx\n", - dump_ctrl); - } + if (dump_ctrl) + LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); + ps3_dump_ctrl_set(ctxt->instance, PS3_DUMP_CTRL_COPY_FINISH); ret = PS3_SUCCESS; } else { LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", - PS3_HOST(ctxt->instance)); + PS3_HOST(ctxt->instance)); ret = -PS3_FAILED; } @@ -465,8 +461,7 @@ static int ps3_dump_dma_data_copy(struct ps3_dump_context *ctxt, unsigned long l return ret; } -static inline void ps3_dump_work_done(struct ps3_dump_context *ctxt, - int cur_state) +static inline void ps3_dump_work_done(struct ps3_dump_context * ctxt, S32 cur_state) { ctxt->dump_work_status = PS3_DUMP_WORK_STOP; ps3_dump_file_close(&ctxt->dump_out_file); @@ -478,58 +473,54 @@ static inline void ps3_dump_work_done(struct ps3_dump_context *ctxt, } } -static void ps3_dump_work(struct work_struct *work) +static void ps3_dump_work(struct work_struct *work) { - unsigned int work_wait_times = 0; - struct ps3_dump_context *ctxt = + static U32 work_wait_times = 0; + struct ps3_dump_context * ctxt = ps3_container_of(work, struct ps3_dump_context, dump_work.work); - unsigned long long status = 0, delay_ms = 0; - int cur_state = 0; - unsigned char ret = PS3_TRUE; + U64 status = 0, delay_ms = 0; + S32 cur_state = 0; + Bool ret = PS3_TRUE; ctxt->dump_work_status = PS3_DUMP_WORK_RUNNING; ret = ps3_dump_status_get(ctxt->instance, &status); + INJECT_START(PS3_ERR_IJ_DUMP_DUMP_STATE_GET_FAIL, &ret); if (!ret) { delay_ms = PS3_REG_READ_INTERVAL_MS; LOG_INFO("ps3_dump_status_get error, delay %llums try again\n", - delay_ms); + delay_ms); queue_delayed_work(ctxt->dump_work_queue, &ctxt->dump_work, - msecs_to_jiffies(delay_ms)); + msecs_to_jiffies(delay_ms)); goto l_out; } + INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID, ctxt->instance); - while (delay_ms == 0) { + while(delay_ms == 0) { if (ctxt->is_hard_recovered) { LOG_WARN("dump in hard recovery, ready to abort\n"); ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; } - switch (ctxt->dump_state) { + switch(ctxt->dump_state) { case PS3_DUMP_STATE_START: - if ((status & PS3_DUMP_STATUS_REG_INVALID_BITS_MASK) == - 0 || - (status & PS3_DUMP_STATUS_REG_ABORT_MASK) != 0) { - LOG_INFO( - "abort dump in START STATE, status: 0x%llx\n", - status); + INJECT_START(PS3_ERR_IJ_DUMP_DUMP_STATE_INVALID, &status); + if ((status & PS3_DUMP_STATUS_REG_INVALID_BITS_MASK) == 0 || + (status & PS3_DUMP_STATUS_REG_ABORT_MASK) != 0) { + LOG_INFO("abort dump in START STATE, status: 0x%llx\n", status); ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; continue; } if ((status & PS3_DUMP_STATUS_REG_MASK) == 0 || - ps3_dump_status_check(status, ctxt->dump_type) == - PS3_FALSE) { + ps3_dump_status_check(status, ctxt->dump_type) == PS3_FALSE) { delay_ms = WAIT_DUMP_COLLECT; work_wait_times++; break; } - if (ctxt->dump_out_file.file_status != - PS3_DUMP_FILE_OPEN) { - if (ps3_dump_file_open(ctxt, - (unsigned int)ctxt->dump_type) != - PS3_SUCCESS) { + if (ctxt->dump_out_file.file_status != PS3_DUMP_FILE_OPEN) { + if (ps3_dump_file_open(ctxt, (U32)ctxt->dump_type) != PS3_SUCCESS) { delay_ms = WAIT_DUMP_COLLECT; work_wait_times++; break; @@ -537,6 +528,7 @@ static void ps3_dump_work(struct work_struct *work) } work_wait_times = 0; ctxt->dump_state = PS3_DUMP_STATE_COPYING; + INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID_2, ctxt->instance); break; case PS3_DUMP_STATE_COPYING: if (status & PS3_DUMP_STATUS_REG_ABORT_MASK) { @@ -550,14 +542,12 @@ static void ps3_dump_work(struct work_struct *work) ctxt->dump_work_status = PS3_DUMP_WORK_DONE; break; } - if (ps3_dump_status_check(status, ctxt->dump_type) == - PS3_FALSE) { + if (ps3_dump_status_check(status, ctxt->dump_type) == PS3_FALSE) { delay_ms = WAIT_DUMP_COLLECT; work_wait_times++; break; } - if (ps3_dump_dma_data_copy(ctxt, status) != - PS3_SUCCESS) { + if (ps3_dump_dma_data_copy(ctxt, status) != PS3_SUCCESS) { LOG_INFO("abort dump in COPYING STATE\n"); ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; continue; @@ -568,7 +558,7 @@ static void ps3_dump_work(struct work_struct *work) break; case PS3_DUMP_STATE_PRE_ABORT: ps3_dump_abort(ctxt->instance); -#if defined(PS3_FALLTHROUGH) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) ps3_dump_work_done(ctxt, cur_state); work_wait_times = 0; goto l_out; @@ -579,27 +569,23 @@ static void ps3_dump_work(struct work_struct *work) work_wait_times = 0; goto l_out; default: - LOG_INFO("warn: dump work state %d\n", - ctxt->dump_state); + LOG_INFO("warn: dump work state %d\n", ctxt->dump_state); ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; continue; } if (delay_ms) { if (work_wait_times >= - max_t(unsigned int, WAIT_DUMP_TIMES_MIN, ctxt->dump_dma_wait_times)) { - LOG_INFO( - "error: wait too many times %d for dump %s, abort it\n", - work_wait_times, - ps3_dump_type_to_name(ctxt->dump_type)); + max((U32)WAIT_DUMP_TIMES_MIN, (U32)ctxt->dump_dma_wait_times)) { + LOG_INFO("error: wait too many times %d for dump %s, abort it\n", + work_wait_times,ps3_dump_type_to_name(ctxt->dump_type)); ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; work_wait_times = 0; delay_ms = 0; continue; } - queue_delayed_work(ctxt->dump_work_queue, - &ctxt->dump_work, - msecs_to_jiffies(delay_ms)); + queue_delayed_work(ctxt->dump_work_queue, &ctxt->dump_work, + msecs_to_jiffies(delay_ms)); break; } } @@ -608,16 +594,18 @@ static void ps3_dump_work(struct work_struct *work) return; } -int ps3_dump_dma_buf_alloc(struct ps3_instance *instance) +S32 ps3_dump_dma_buf_alloc(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_dump_context *ctxt = &instance->dump_context; - ctxt->dump_dma_buf = (unsigned char *)ps3_dma_alloc_coherent( - instance, PS3_DUMP_DMA_BUF_SIZE, (unsigned long long *)&ctxt->dump_dma_addr); + ctxt->dump_dma_buf = (U8*) ps3_dma_alloc_coherent( + instance, + PS3_DUMP_DMA_BUF_SIZE, + &ctxt->dump_dma_addr); + INJECT_START(PS3_ERR_IJ_FORCE_ALLOC_DMA_BUF_FAILED, &ctxt->dump_dma_buf) if (ctxt->dump_dma_buf == NULL) { - LOG_ERROR("host_no[%d], dump dma alloc NOK!\n", - PS3_HOST(instance)); + LOG_ERROR("host_no[%d], dump dma alloc NOK!\n", PS3_HOST(instance)); ret = -PS3_FAILED; } @@ -629,8 +617,9 @@ void ps3_dump_dma_buf_free(struct ps3_instance *instance) struct ps3_dump_context *ctxt = &instance->dump_context; if (ctxt->dump_dma_buf != NULL) { - ps3_dma_free_coherent(instance, PS3_DUMP_DMA_BUF_SIZE, - ctxt->dump_dma_buf, ctxt->dump_dma_addr); + ps3_dma_free_coherent(instance, + PS3_DUMP_DMA_BUF_SIZE, ctxt->dump_dma_buf, + ctxt->dump_dma_addr); ctxt->dump_dma_buf = NULL; } } @@ -644,18 +633,19 @@ static void ps3_dump_reset(struct ps3_dump_context *ctxt) memset(&ctxt->dump_out_file, 0, sizeof(ctxt->dump_out_file)); } -int ps3_dump_type_set(struct ps3_dump_context *ctxt, int type, unsigned int env) +S32 ps3_dump_type_set(struct ps3_dump_context *ctxt, S32 type, U32 env) { - int ret = PS3_SUCCESS; - int cur_state = PS3_INSTANCE_STATE_INIT; - + S32 ret = PS3_SUCCESS; + S32 cur_state = PS3_INSTANCE_STATE_INIT; LOG_INFO("dump type set: type %d\n", type); - if ((type < PS3_DUMP_TYPE_CRASH) || (type > PS3_DUMP_TYPE_BAR_DATA)) { + INJECT_START(PS3_ERR_IJ_DUMP_TYPE_ILLEGAL, &type); + if ( (type < PS3_DUMP_TYPE_CRASH)|| (type > PS3_DUMP_TYPE_BAR_DATA)) { ret = -PS3_FAILED; goto l_ret; } + INJECT_START(PS3_ERR_IJ_DUMP_WORK_QUEUE_NULL, &ctxt->dump_work_queue); if (ctxt->dump_work_queue == NULL) { LOG_WARN("dump type set: no work to do, type %d\n", type); ret = -PS3_FAILED; @@ -663,36 +653,44 @@ int ps3_dump_type_set(struct ps3_dump_context *ctxt, int type, unsigned int env) } ps3_mutex_lock(&ctxt->dump_lock); + INJECT_START(PS3_ERR_IJ_DUMP_STATE_ILLEGAL, &ctxt->dump_state); if (ctxt->dump_state != PS3_DUMP_STATE_INVALID) { - LOG_FILE_ERROR( - "dump type set: work is busy, current state: %d, type %d\n", - ctxt->dump_state, type); + LOG_FILE_ERROR("dump type set: work is busy, current state: %d, type %d\n", ctxt->dump_state, type); ret = -PS3_FAILED; goto l_unlock; } ps3_dump_reset(ctxt); + INJECT_AT_TIMES(PS3_ERR_IJ_WAIT_UNNORMAL, ctxt->instance); + INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID, ctxt->instance); + INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_NORMAL, ctxt->instance); + INJECT_AT_TIMES(PS3_ERR_IJ_WAIT_OPT, ctxt->instance); ctxt->is_hard_recovered = PS3_FALSE; + INJECT_AT_TIMES(PS3_ERR_IJ_WAIT_UNNORMAL, ctxt->instance); + INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID, ctxt->instance); + INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_NORMAL, ctxt->instance); + INJECT_AT_TIMES(PS3_ERR_IJ_WAIT_OPT, ctxt->instance); cur_state = ps3_atomic_read(&ctxt->instance->state_machine.state); if (!ps3_state_is_normal(cur_state)) { LOG_WARN("h_no[%u], instance state is unnormal[%s]\n", - PS3_HOST(ctxt->instance), - namePS3InstanceState(cur_state)); + PS3_HOST(ctxt->instance), namePS3InstanceState(cur_state)); ret = -PS3_FAILED; goto l_unlock; } ctxt->dump_state = PS3_DUMP_STATE_START; - ctxt->dump_type = type; + ctxt->dump_type = type; ctxt->dump_env = env; ctxt->dump_type_times++; + INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID, ctxt->instance); - ret = ps3_dump_trigger(ctxt->instance, type); + ret = ps3_dump_trigger (ctxt->instance, type); + INJECT_START(PS3_ERR_IJ_DUMP_TRIGGER_FAIL, &ret); if (ret != PS3_SUCCESS) { ps3_dump_reset(ctxt); goto l_unlock; @@ -705,10 +703,10 @@ int ps3_dump_type_set(struct ps3_dump_context *ctxt, int type, unsigned int env) return ret; } -int ps3_dump_state_set(struct ps3_dump_context *ctxt, int state) +S32 ps3_dump_state_set(struct ps3_dump_context *ctxt, S32 state) { - int ret = PS3_SUCCESS; - int cur_state; + S32 ret = PS3_SUCCESS; + S32 cur_state; LOG_INFO("dump state set: state %d\n", state); @@ -719,24 +717,26 @@ int ps3_dump_state_set(struct ps3_dump_context *ctxt, int state) ps3_mutex_lock(&ctxt->dump_lock); cur_state = ctxt->dump_state; - if (cur_state == PS3_DUMP_STATE_INVALID) + if (cur_state == PS3_DUMP_STATE_INVALID) { goto l_unlock; + } cancel_delayed_work_sync(&ctxt->dump_work); ctxt->dump_work_status = PS3_DUMP_WORK_CANCEL; ctxt->dump_state_times++; if (cur_state == PS3_DUMP_STATE_PRE_ABORT || - cur_state == PS3_DUMP_STATE_START || - cur_state == PS3_DUMP_STATE_COPYING) { + cur_state == PS3_DUMP_STATE_START || + cur_state == PS3_DUMP_STATE_COPYING) { ps3_dump_abort(ctxt->instance); } ps3_dump_file_close(&ctxt->dump_out_file); ps3_dump_reset(ctxt); - if (cur_state == PS3_DUMP_STATE_COPY_DONE) + if (cur_state == PS3_DUMP_STATE_COPY_DONE) { ps3_dump_end(ctxt->instance); + } l_unlock: ps3_mutex_unlock(&ctxt->dump_lock); l_ret: @@ -746,39 +746,45 @@ int ps3_dump_state_set(struct ps3_dump_context *ctxt, int state) void ps3_dump_detect(struct ps3_instance *instance) { struct ps3_dump_context *p_dump_ctx = &instance->dump_context; - int ret = PS3_SUCCESS; - int dump_type = 0; - unsigned long long status = 0; - union HilReg0Ps3RegisterFPs3DumpStatus dump_status = { 0 }; - unsigned char is_trigger_log; + S32 ret = PS3_SUCCESS; + S32 dump_type = 0; + U64 status = 0; + union HilReg0Ps3RegisterFPs3DumpStatus dump_status = {0}; + U8 is_trigger_log; - if (!ps3_dump_status_get(instance, &status)) + if (!ps3_dump_status_get(instance, &status)) { goto l_out; + } dump_status.val = status; dump_type = dump_status.reg.hasAutoDump; - if (dump_type == 0) + INJECT_START(PS3_ERR_IJ_DUMP_TYPE_INVALID, &dump_type); + if (dump_type == 0) { goto l_out; + } ps3_ioc_dump_support_get(instance); - if (!PS3_IOC_DUMP_SUPPORT(instance)) + if (!PS3_IOC_DUMP_SUPPORT(instance)) { goto l_out; + } LOG_DEBUG("hno:%u detect dump log file type[%d], status[%llx]\n", - PS3_HOST(instance), dump_type, status); + PS3_HOST(instance), dump_type, status); is_trigger_log = ps3_dump_is_trigger_log(instance); - if (!is_trigger_log) { + INJECT_START(PS3_ERR_IJ_DETECT_NO_TRIGGER_LOG, &is_trigger_log) + if(!is_trigger_log) { LOG_DEBUG("cannot dump type set!\n"); goto l_out; } ret = ps3_dump_type_set(p_dump_ctx, dump_type, PS3_DUMP_ENV_NOTIFY); LOG_DEBUG("hno:%u type[%d] autodump set trigger ret %d\n", - PS3_HOST(instance), dump_type, ret); - if (ret == PS3_SUCCESS) + PS3_HOST(instance), dump_type, ret); + if (ret == PS3_SUCCESS) { goto l_out; + } l_out: return; @@ -786,70 +792,70 @@ void ps3_dump_detect(struct ps3_instance *instance) static void ps3_dump_irq_handler_work(struct work_struct *work) { - struct ps3_dump_context *ctxt = ps3_container_of( - work, struct ps3_dump_context, dump_irq_handler_work); + struct ps3_dump_context * ctxt = + ps3_container_of(work, struct ps3_dump_context, dump_irq_handler_work); + + ctxt->dump_irq_handler_work_status = PS3_DUMP_IRQ_HANDLER_WORK_RUNNING; + ps3_dump_detect(ctxt->instance); + ctxt->dump_irq_handler_work_status = PS3_DUMP_IRQ_HANDLER_WORK_DONE; + + return; - ctxt->dump_irq_handler_work_status = PS3_DUMP_IRQ_HANDLER_WORK_RUNNING; - ps3_dump_detect(ctxt->instance); - ctxt->dump_irq_handler_work_status = PS3_DUMP_IRQ_HANDLER_WORK_DONE; } -irqreturn_t ps3_dump_irq_handler(int virq, void *dev_id) +irqreturn_t ps3_dump_irq_handler(S32 virq, void *dev_id) { - struct ps3_instance *pInstance = (struct ps3_instance *)dev_id; - struct ps3_dump_context *p_dump_ctx = &pInstance->dump_context; - unsigned long flags = 0; + struct ps3_instance *pInstance = (struct ps3_instance *)dev_id; + struct ps3_dump_context *p_dump_ctx = &pInstance->dump_context; + ULong flags = 0; spin_lock_irqsave(&p_dump_ctx->dump_irq_handler_lock, flags); if (p_dump_ctx->dump_enabled) { - LOG_DEBUG( - "hno:%u dump irq received, virq: %d, dev_id: 0x%llx\n", - PS3_HOST(pInstance), virq, (unsigned long long)(uintptr_t)dev_id); + LOG_DEBUG("hno:%u dump irq recieved, virq: %d, dev_id: 0x%llx\n", + PS3_HOST(pInstance), virq, (U64)dev_id); if (!work_busy(&p_dump_ctx->dump_irq_handler_work)) { - queue_work(p_dump_ctx->dump_irq_handler_work_queue, - &p_dump_ctx->dump_irq_handler_work); + queue_work(p_dump_ctx->dump_irq_handler_work_queue, &p_dump_ctx->dump_irq_handler_work); } } spin_unlock_irqrestore(&p_dump_ctx->dump_irq_handler_lock, flags); - return IRQ_HANDLED; + return IRQ_HANDLED; } static void ps3_dump_dir_init(char *dump_dir) { - char *log_path_p; - unsigned int log_path_len = 0; + char *log_path_p; + U32 log_path_len = 0; log_path_p = ps3_log_path_query(); - if (log_path_p != NULL) + if (log_path_p != NULL) { log_path_len = strlen(log_path_p); + } if (log_path_p != NULL && log_path_p[0] == '/') { if (log_path_p[log_path_len - 1] == '/') { - snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s", - log_path_p); + snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s", log_path_p); } else { - snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s/", - log_path_p); + snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s/", log_path_p); } } else { - LOG_INFO("provided log dump dir not valid, using default\n"); - snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s/", - PS3_DUMP_FILE_DIR); + LOG_INFO("provided log dump dir not valid, using default\n"); + snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s/", PS3_DUMP_FILE_DIR); } + + return; } -int ps3_dump_init(struct ps3_instance *instance) +S32 ps3_dump_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_dump_context *ctxt = &instance->dump_context; if (reset_devices) { - LOG_INFO( - "resetting device in progress, Do not initialize dump\n"); + LOG_INFO("resetting device in progress, Do not initialize dump\n"); goto l_ret; } @@ -857,10 +863,11 @@ int ps3_dump_init(struct ps3_instance *instance) LOG_INFO("hno:%u init already\n", PS3_HOST(instance)); goto l_ret; } - memset((void *)ctxt, 0, sizeof(struct ps3_dump_context)); + memset((void*)ctxt, 0, sizeof(struct ps3_dump_context )); - if (!ps3_ioc_dump_support_get(instance)) + if (!ps3_ioc_dump_support_get(instance)) { goto l_ret; + } ps3_dump_dir_init((char *)ctxt->dump_dir); @@ -874,8 +881,8 @@ int ps3_dump_init(struct ps3_instance *instance) } INIT_DELAYED_WORK(&ctxt->dump_work, ps3_dump_work); - ctxt->dump_work_queue = - create_singlethread_workqueue((char *)"ps3_dump_work_queue"); + ctxt->dump_work_queue = create_singlethread_workqueue((char*)"ps3_dump_work_queue"); + INJECT_START(PS3_ERR_IJ_DUMP_WORK_FAILED, &ctxt->dump_work_queue); if (ctxt->dump_work_queue == NULL) { LOG_ERROR("dump work queue create NOK\n"); ret = -PS3_FAILED; @@ -884,7 +891,8 @@ int ps3_dump_init(struct ps3_instance *instance) INIT_WORK(&ctxt->dump_irq_handler_work, ps3_dump_irq_handler_work); ctxt->dump_irq_handler_work_queue = create_singlethread_workqueue( - (char *)"ps3_dump_irq_handler_work_queue"); + (char*)"ps3_dump_irq_handler_work_queue"); + INJECT_START(PS3_ERR_DUMP_ALLOC_FAILED, &ctxt->dump_irq_handler_work_queue); if (ctxt->dump_irq_handler_work_queue == NULL) { LOG_ERROR("dump irq handler work queue create NOK\n"); ret = -PS3_FAILED; @@ -904,10 +912,11 @@ int ps3_dump_init(struct ps3_instance *instance) void ps3_dump_exit(struct ps3_instance *instance) { struct ps3_dump_context *ctxt = &instance->dump_context; - unsigned long flags = 0; + ULong flags = 0; - if (ctxt->dump_dma_buf == NULL) + if (ctxt->dump_dma_buf == NULL) { return; + } spin_lock_irqsave(&ctxt->dump_irq_handler_lock, flags); ctxt->dump_enabled = 0; @@ -925,10 +934,11 @@ void ps3_dump_exit(struct ps3_instance *instance) } if (ctxt->dump_work_queue != NULL) { - if (!cancel_delayed_work_sync(&ctxt->dump_work)) + if (!cancel_delayed_work_sync(&ctxt->dump_work)) { flush_workqueue(ctxt->dump_work_queue); - else + } else { ctxt->dump_work_status = PS3_DUMP_WORK_CANCEL; + } destroy_workqueue(ctxt->dump_work_queue); ctxt->dump_work_queue = NULL; } @@ -938,13 +948,13 @@ void ps3_dump_exit(struct ps3_instance *instance) ps3_mutex_destroy(&ctxt->dump_lock); LOG_INFO("hno:%u dump destroy work and stop service\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } void ps3_dump_work_stop(struct ps3_instance *instance) { struct ps3_dump_context *ctxt = &instance->dump_context; - unsigned long flags = 0; + ULong flags = 0; spin_lock_irqsave(&ctxt->dump_irq_handler_lock, flags); if (ctxt->dump_enabled == 0) { @@ -964,49 +974,52 @@ void ps3_dump_work_stop(struct ps3_instance *instance) if (ctxt->dump_work_queue != NULL) { ps3_dump_state_set(ctxt, PS3_DUMP_STATE_INVALID); - if (!cancel_delayed_work_sync(&ctxt->dump_work)) + if (!cancel_delayed_work_sync(&ctxt->dump_work)) { flush_workqueue(ctxt->dump_work_queue); - else + } else { ctxt->dump_work_status = PS3_DUMP_WORK_CANCEL; + } } } void ps3_dump_ctrl_set_int_ready(struct ps3_instance *instance) { if (reset_devices) { - LOG_INFO( - "resetting device in progress, unable to confiure ps3DumpCtrl\n"); + LOG_INFO("resetting device in progress, unable to confiure ps3DumpCtrl\n"); return; } - PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpCtrl, - PS3_DUMP_CTRL_DUMP_INT_READY); + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpCtrl, PS3_DUMP_CTRL_DUMP_INT_READY); } -unsigned char ps3_dump_is_trigger_log(struct ps3_instance *instance) +Bool ps3_dump_is_trigger_log(struct ps3_instance *instance) { - unsigned char is_support_halt = PS3_IOC_STATE_HALT_SUPPORT(instance); - unsigned long long dump_ctrl; - unsigned char is_trigger_log = PS3_FALSE; - int cur_state = ps3_atomic_read(&instance->state_machine.state); - unsigned char is_halt = - (is_support_halt && (cur_state == PS3_INSTANCE_STATE_DEAD)); - unsigned char ret = PS3_TRUE; - - if (likely(is_halt || (cur_state == PS3_INSTANCE_STATE_OPERATIONAL && - !ps3_pci_err_recovery_get(instance)))) { + Bool is_support_halt = PS3_IOC_STATE_HALT_SUPPORT(instance); + U64 dump_ctrl; + Bool is_trigger_log = PS3_FALSE; + S32 cur_state = ps3_atomic_read(&instance->state_machine.state); + Bool is_halt = (is_support_halt && (cur_state == PS3_INSTANCE_STATE_DEAD)); + Bool ret = PS3_TRUE; + + INJECT_START(PS3_ERR_IJ_DUMP_PCIE_ERR, instance); + INJECT_START(PS3_ERR_IJ_DUMP_RECOVERY_ERR, instance); + if (likely(is_halt || + (cur_state == PS3_INSTANCE_STATE_OPERATIONAL && !ps3_pci_err_recovery_get(instance)))) { is_trigger_log = PS3_TRUE; } if (instance->is_support_dump_ctrl) { ret = ps3_dump_ctrl_get(instance, &dump_ctrl); + INJECT_START(PS3_ERR_IJ_DUMP_IS_TRIGGER_GET_CTRL_FAIL, &ret); if (ret) { if (dump_ctrl != 0) is_trigger_log = PS3_FALSE; + } else { LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); is_trigger_log = PS3_FALSE; } } return is_trigger_log; } + diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.c index ba23fb3d25af..e48a49f781d5 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include @@ -8,28 +6,28 @@ #include "ps3_recovery.h" #include "ps3_ioc_state.h" #include "ps3_module_para.h" -#include "ps3_kernel_version.h" static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, - pci_channel_state_t state); + pci_channel_state_t state); static pci_ers_result_t ps3_pci_mmio_enabled(struct pci_dev *pdev); static pci_ers_result_t ps3_pci_slot_reset(struct pci_dev *pdev); static void ps3_pci_resume(struct pci_dev *pdev); -extern int ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance); -extern int ps3_pci_init_complete(struct ps3_instance *instance); +extern S32 ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance); +extern S32 ps3_pci_init_complete(struct ps3_instance *instance); extern void ps3_pci_init_complete_exit(struct ps3_instance *instance); static struct pci_error_handlers ps3_err_handlers = { - .error_detected = ps3_pci_err_detected, - .mmio_enabled = ps3_pci_mmio_enabled, - .slot_reset = ps3_pci_slot_reset, - .resume = ps3_pci_resume + .error_detected = ps3_pci_err_detected, + .mmio_enabled = ps3_pci_mmio_enabled, + .slot_reset = ps3_pci_slot_reset, + .resume = ps3_pci_resume }; void ps3_pci_err_handler_init(struct pci_driver *drv) { drv->err_handler = &ps3_err_handlers; + return; } int ps3_base_init_resources(struct ps3_instance *instance) @@ -38,18 +36,18 @@ int ps3_base_init_resources(struct ps3_instance *instance) struct pci_dev *pdev = instance->pdev; ret = ps3_pci_init(pdev, instance); + INJECT_START(PS3_ERR_IJ_FORCE_PCIE_ERR_PCI_INIT_FAILED, &ret) if (ret) { - LOG_ERROR("hno:%u pci init failed, ret: %d\n", - PS3_HOST(instance), ret); + LOG_ERROR("hno:%u pci init failed, ret: %d\n", PS3_HOST(instance), ret); goto l_out; } instance->is_pci_reset = PS3_FALSE; ret = ps3_pci_init_complete(instance); + INJECT_START(PS3_ERR_IJ_FORCE_PCIE_ERR_PCI_INIT_COMP_FAILED, &ret) if (ret) { - LOG_ERROR("hno:%u pci init complete failed, ret: %d\n", - PS3_HOST(instance), ret); + LOG_ERROR("hno:%u pci init complete failed, ret: %d\n", PS3_HOST(instance), ret); goto l_out; } @@ -70,25 +68,21 @@ void ps3_base_free_resources(struct ps3_instance *instance) ps3_pci_init_complete_exit(instance); } -static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, - pci_channel_state_t state) +static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, pci_channel_state_t state) { pci_ers_result_t ret = PCI_ERS_RESULT_NEED_RESET; - struct ps3_instance *instance = - (struct ps3_instance *)pci_get_drvdata(pdev); + struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); if (instance == NULL) { LOG_INFO("get instance failed\n"); - dev_info(&pdev->dev, "[PS3]%s():%d; get instance failed\n", - __func__, __LINE__); + dev_info(&pdev->dev, "[PS3]%s():%d; get instance failed\n", __FUNCTION__, __LINE__); ret = PCI_ERS_RESULT_DISCONNECT; goto l_out; } - LOG_INFO("[%04x:%02x:%02x:%x]:PCIe err detected state:%u\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), state); + LOG_INFO("[%04x:%02x:%02x:%x]:PCIe err detected state:%u\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), state); dev_info(&pdev->dev, "[PS3]%s():%d;PCIe err detected state:%u\n", - __func__, __LINE__, state); + __FUNCTION__, __LINE__, state); instance->is_pcie_err_detected = PS3_TRUE; switch (state) { case pci_channel_io_normal: @@ -99,8 +93,7 @@ static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, scsi_block_requests(instance->host); ps3_watchdog_stop(instance); if (ps3_recovery_cancel_work_sync(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u work sync failed, state: %u\n", - PS3_HOST(instance), state); + LOG_ERROR("hno:%u work sync failed, state: %u\n", PS3_HOST(instance), state); } instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_CLEAN; ps3_base_free_resources(instance); @@ -110,8 +103,7 @@ static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, ps3_pci_err_recovery_set(instance, PS3_TRUE); ps3_watchdog_stop(instance); if (ps3_recovery_cancel_work_sync(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u work sync failed, state: %u\n", - PS3_HOST(instance), state); + LOG_ERROR("hno:%u work sync failed, state: %u\n", PS3_HOST(instance), state); } ps3_cmd_force_stop(instance); ps3_pci_err_recovery_set(instance, PS3_FALSE); @@ -125,12 +117,11 @@ static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, instance->is_pcie_err_detected = PS3_FALSE; l_out: - LOG_INFO("[%04x:%02x:%02x:%x]:PCIe err detect state:%u ret:%u\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), state, - ret); + LOG_INFO("[%04x:%02x:%02x:%x]:PCIe err detect state:%u ret:%u\n", ps3_get_pci_domain(pdev), + ps3_get_pci_bus(pdev), ps3_get_pci_slot(pdev), + ps3_get_pci_function(pdev), state, ret); dev_info(&pdev->dev, "[PS3]%s():%d;PCIe err detect state:%u ret:%u\n", - __func__, __LINE__, state, ret); + __FUNCTION__, __LINE__, state, ret); return ret; } @@ -138,11 +129,10 @@ static pci_ers_result_t ps3_pci_mmio_enabled(struct pci_dev *pdev) { pci_ers_result_t ret = PCI_ERS_RESULT_RECOVERED; - LOG_INFO("[%04x:%02x:%02x:%x]: PCIe err mmio enabled\n", - ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG_INFO("[%04x:%02x:%02x:%x]: PCIe err mmio enabled\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); dev_info(&pdev->dev, "[PS3]%s():%d; PCIe err mmio enabled\n", - __func__, __LINE__); + __FUNCTION__, __LINE__); return ret; } @@ -150,12 +140,11 @@ static pci_ers_result_t ps3_pci_mmio_enabled(struct pci_dev *pdev) static pci_ers_result_t ps3_pci_slot_reset(struct pci_dev *pdev) { int ret; - struct ps3_instance *instance = - (struct ps3_instance *)pci_get_drvdata(pdev); + struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); LOG_INFO("hno:%u PCIe err slot reset begin.\n", PS3_HOST(instance)); dev_info(&pdev->dev, "[PS3]%s():%d;hno:%u PCIe err slot reset begin.\n", - __func__, __LINE__, PS3_HOST(instance)); + __FUNCTION__, __LINE__, PS3_HOST(instance)); instance->pdev = pdev; pci_restore_state(pdev); @@ -164,24 +153,21 @@ static pci_ers_result_t ps3_pci_slot_reset(struct pci_dev *pdev) ret = ps3_base_init_resources(instance); if (ret) { - LOG_ERROR("hno:%u base init resources failed, ret: %d\n", - PS3_HOST(instance), ret); - dev_info(&pdev->dev, - "[PS3]hno:%u init resources failed, ret: %d\n", - PS3_HOST(instance), ret); + LOG_ERROR("hno:%u base init resources failed, ret: %d\n", PS3_HOST(instance), ret); + dev_info(&pdev->dev, "[PS3]hno:%u init resources failed, ret: %d\n", PS3_HOST(instance), ret); goto l_out; } LOG_INFO("hno:%u PCIe err slot reset succeed.\n", PS3_HOST(instance)); - dev_info(&pdev->dev, - "[PS3]%s():%d;hno:%u PCIe err slot reset succeed.\n", - __func__, __LINE__, PS3_HOST(instance)); + dev_info(&pdev->dev, "[PS3]%s():%d;hno:%u PCIe err slot reset succeed.\n", + __FUNCTION__, __LINE__, PS3_HOST(instance)); ps3_pci_err_recovery_set(instance, PS3_FALSE); instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_INIT; return PCI_ERS_RESULT_RECOVERED; l_out: - if (instance) + if (instance) { ps3_instance_state_transfer_to_dead(instance); + } ps3_pci_err_recovery_set(instance, PS3_FALSE); instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_INIT; @@ -190,56 +176,62 @@ static pci_ers_result_t ps3_pci_slot_reset(struct pci_dev *pdev) static void ps3_pci_resume(struct pci_dev *pdev) { - int ret = PS3_SUCCESS; - unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; - struct ps3_instance *instance = - (struct ps3_instance *)pci_get_drvdata(pdev); + S32 ret = PS3_SUCCESS; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); LOG_INFO("hno:%u PCIe err resume\n", PS3_HOST(instance)); dev_info(&pdev->dev, "[PS3]%s():%d;hno:%u PCIe err resume\n", - __func__, __LINE__, PS3_HOST(instance)); + __FUNCTION__, __LINE__, PS3_HOST(instance)); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); + INJECT_START(PS3_ERR_IJ_FORCE_PCIE_ERR_IOC_RUNNING_INIT_FAILED, &fw_cur_state) if (fw_cur_state == PS3_FW_STATE_RUNNING) { - LOG_INFO("hno:%u not need repeat recovery\n", - PS3_HOST(instance)); - dev_info(&pdev->dev, "[PS3]hno:%u not need repeat recovery\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u not need repeat recovery\n", PS3_HOST(instance)); + dev_info(&pdev->dev, "[PS3]hno:%u not need repeat recovery\n", PS3_HOST(instance)); goto l_norecovery; } + INJECT_START(PS3_ERR_IJ_PCI_FORCE_HARD_RECOVERY_REQ_FAILED, instance) ret = ps3_hard_recovery_request_with_retry(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u hard reset NOK, ret: %d\n", - PS3_HOST(instance), ret); - dev_info(&pdev->dev, "[PS3]hno:%u hard reset NOK, ret: %d\n", - PS3_HOST(instance), ret); + LOG_ERROR("hno:%u hard reset NOK, ret: %d\n", PS3_HOST(instance), ret); + dev_info(&pdev->dev, "[PS3]hno:%u hard reset NOK, ret: %d\n", PS3_HOST(instance), ret); goto l_failed; } ret = ps3_instance_wait_for_operational(instance, PS3_TRUE); + INJECT_START(PS3_ERR_IJ_PCI_FORCE_WAIT_OPERARIONAL_FAILED, &ret) if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u wait for opt NOK.\n", PS3_HOST(instance)); - dev_info(&pdev->dev, "[PS3]hno:%u wait for opt NOK.\n", - PS3_HOST(instance)); + dev_info(&pdev->dev, "[PS3]hno:%u wait for opt NOK.\n", PS3_HOST(instance)); goto l_failed; } l_norecovery: -#if defined(PS3_AER_CLEAR_STATUS) - pci_aer_clear_nonfatal_status(pdev); -#elif defined(PS3_AER_CLEAR_STATUS_LOW_KERNER) - pci_cleanup_aer_uncorrect_error_status(pdev); +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 3)) \ + || (defined(CONFIG_SUSE_KERNEL) && ((CONFIG_SUSE_VERSION == 15) \ + && (CONFIG_SUSE_PATCHLEVEL >= 2)))) + pci_aer_clear_nonfatal_status(pdev); +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) + pci_cleanup_aer_uncorrect_error_status(pdev); #endif ps3_watchdog_start(instance); scsi_unblock_requests(instance->host); instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; return; l_failed: -#if defined(PS3_AER_CLEAR_STATUS) - pci_aer_clear_nonfatal_status(pdev); -#elif defined(PS3_AER_CLEAR_STATUS_LOW_KERNER) - pci_cleanup_aer_uncorrect_error_status(pdev); +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 3)) \ + || (defined(CONFIG_SUSE_KERNEL) && ((CONFIG_SUSE_VERSION == 15) \ + && (CONFIG_SUSE_PATCHLEVEL >= 2)))) + pci_aer_clear_nonfatal_status(pdev); +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) + pci_cleanup_aer_uncorrect_error_status(pdev); #endif - if (instance) + if (instance) { ps3_instance_state_transfer_to_dead(instance); + } instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; + return; } + diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.h b/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.h index e83ceab5bb83..81f1361789ad 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.h +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_PCIE_ERR_HANDLE_H_ #define _PS3_PCIE_ERR_HANDLE_H_ @@ -8,7 +7,7 @@ #include "ps3_instance_manager.h" #ifdef __cplusplus -extern "C" { +extern "C"{ #endif void ps3_pci_err_handler_init(struct pci_driver *drv); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.c b/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.c index 17972ea3c1a7..00dfd663b0c2 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.c @@ -1,6 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ -#ifndef _WINDOWS + +#ifndef _WINDOWS #include #include #include @@ -28,80 +27,67 @@ #include "ps3_ioc_state.h" #include "ps3_mgr_cmd.h" -static int ps3_req_frame_alloc(struct ps3_instance *instance); +static S32 ps3_req_frame_alloc(struct ps3_instance *instance); static void ps3_req_frame_free(struct ps3_instance *instance); -static int ps3_cmd_resp_frame_alloc(struct ps3_instance *instance); +static S32 ps3_cmd_resp_frame_alloc(struct ps3_instance *instance); static void ps3_cmd_resp_frame_free(struct ps3_instance *instance); -static int ps3_cmd_buf_alloc(struct ps3_instance *instance); +static S32 ps3_cmd_buf_alloc(struct ps3_instance *instance); static void ps3_cmd_buf_free(struct ps3_instance *instance); -static int ps3_cmd_ext_buf_alloc(struct ps3_instance *instance); +static S32 ps3_cmd_ext_buf_alloc(struct ps3_instance *instance); static void ps3_cmd_ext_buf_free(struct ps3_instance *instance); -static int ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance); +static S32 ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance); static void ps3_cmd_r1xlock_buff_free(struct ps3_instance *instance); -static int ps3_cmd_init(struct ps3_instance *instance); +static S32 ps3_cmd_init(struct ps3_instance *instance); static void ps3_cmd_content_init(struct ps3_cmd *cmd); -static inline unsigned char is_mgr_cmd(struct ps3_instance *instance, - unsigned int index); -static inline unsigned char is_task_cmd(struct ps3_instance *instance, - unsigned int index); -static void cmd_pool_free(struct list_head *pool_list, spinlock_t *pool_lock, - struct ps3_cmd *cmd); -static struct ps3_cmd *cmd_pool_alloc(struct list_head *pool_list, - spinlock_t *pool_lock); -#define PS3_RESP_FRAME_LENGTH (PS3_SENSE_BUFFER_SIZE + 32) - -static inline unsigned char is_mgr_cmd(struct ps3_instance *instance, - unsigned int index) +static inline Bool is_mgr_cmd(struct ps3_instance *instance, U32 index); +static inline Bool is_task_cmd(struct ps3_instance *instance, U32 index); +static void cmd_pool_free(ps3_list_head *pool_list, + ps3_spinlock *pool_lock, struct ps3_cmd *cmd); +static struct ps3_cmd *cmd_pool_alloc(ps3_list_head *pool_list, + ps3_spinlock *pool_lock); + +#define PS3_RESP_FRAME_LENGH (PS3_SENSE_BUFFER_SIZE + 32) + +static inline Bool is_mgr_cmd(struct ps3_instance *instance, U32 index) { index -= instance->cmd_context.max_scsi_cmd_count; - return index < instance->max_mgr_cmd_count ? PS3_DRV_TRUE : - PS3_DRV_FALSE; + return index < instance->max_mgr_cmd_count ? PS3_DRV_TRUE : PS3_DRV_FALSE; } -static inline unsigned char is_task_cmd(struct ps3_instance *instance, - unsigned int index) +static inline Bool is_task_cmd(struct ps3_instance *instance, U32 index) { - index -= (instance->cmd_context.max_scsi_cmd_count + - instance->max_mgr_cmd_count); - return index < instance->max_task_cmd_count ? PS3_DRV_TRUE : - PS3_DRV_FALSE; + index -= (instance->cmd_context.max_scsi_cmd_count + instance->max_mgr_cmd_count); + return index < instance->max_task_cmd_count ? PS3_DRV_TRUE : PS3_DRV_FALSE; } -static inline unsigned char is_r1x_peer_cmd(struct ps3_instance *instance, - unsigned int index) +static inline Bool is_r1x_peer_cmd(struct ps3_instance *instance, U32 index) { struct ps3_cmd_context *cmd_ctx = &instance->cmd_context; - - return ((cmd_ctx->max_scsi_cmd_count - cmd_ctx->max_r1x_cmd_count) <= - index && + return ((cmd_ctx->max_scsi_cmd_count - cmd_ctx->max_r1x_cmd_count) <= index && index < cmd_ctx->max_scsi_cmd_count) ? - PS3_DRV_TRUE : - PS3_DRV_FALSE; + PS3_DRV_TRUE : PS3_DRV_FALSE; } -struct ps3_cmd *ps3_r1x_peer_cmd_alloc(struct ps3_instance *instance, - unsigned int index) +struct ps3_cmd *ps3_r1x_peer_cmd_alloc(struct ps3_instance *instance, U32 index) { struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - unsigned int offset = - context->max_scsi_cmd_count - context->max_r1x_cmd_count; - + U32 offset = context->max_scsi_cmd_count - context->max_r1x_cmd_count; if (instance->r1x_mode == PS3_R1X_MODE_PERF) { cmd = context->cmd_buf[index + offset]; cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; ps3_trace_id_alloc(&cmd->trace_id); init_completion(&cmd->sync_done); } else { - cmd = cmd_pool_alloc(&context->r1x_scsi_cmd_pool, - &context->r1x_scsi_pool_lock); + cmd = cmd_pool_alloc(&context->r1x_scsi_cmd_pool, &context->r1x_scsi_pool_lock); if (cmd != NULL && cmd->is_aborting == 1) { cmd->cmd_state.state = PS3_CMD_STATE_INIT; cmd->trace_id = 0; - cmd_pool_free(&context->r1x_scsi_cmd_pool, - &context->r1x_scsi_pool_lock, cmd); + INJECT_START(PS3_ERR_IJ_SET_CMD_TID_FLAG, cmd); + cmd_pool_free(&context->r1x_scsi_cmd_pool, &context->r1x_scsi_pool_lock, cmd); cmd = NULL; } + INJECT_START(PS3_ERR_IJ_SET_CMD_TID_FLAG, cmd); } return cmd; } @@ -109,14 +95,13 @@ struct ps3_cmd *ps3_r1x_peer_cmd_alloc(struct ps3_instance *instance, struct ps3_cmd *ps3_mgr_cmd_alloc(struct ps3_instance *instance) { struct ps3_cmd_context *context = &instance->cmd_context; - return cmd_pool_alloc(&context->mgr_cmd_pool, &context->mgr_pool_lock); } -int ps3_mgr_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd) +S32 ps3_mgr_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - unsigned long flags = 0; + S32 ret = PS3_SUCCESS; + ULong flags = 0; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); ret = ps3_mgr_cmd_free_nolock(instance, cmd); @@ -132,15 +117,16 @@ struct ps3_cmd *ps3_task_cmd_alloc(struct ps3_instance *instance) context = &instance->cmd_context; cmd = cmd_pool_alloc(&context->task_cmd_pool, &context->task_pool_lock); - if (cmd == NULL) + if (cmd == NULL) { cmd = ps3_mgr_cmd_alloc(instance); + } return cmd; } -int ps3_task_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd) +S32 ps3_task_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd) { - unsigned long flags = 0; - int ret = PS3_SUCCESS; + ULong flags = 0; + S32 ret = PS3_SUCCESS; (void)instance; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); @@ -150,24 +136,25 @@ int ps3_task_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd) return ret; } -static int ps3_req_frame_alloc(struct ps3_instance *instance) +static S32 ps3_req_frame_alloc(struct ps3_instance *instance) { - unsigned int size = 0; + U32 size = 0; struct ps3_cmd_context *context = &instance->cmd_context; size = PS3_DEFAULT_REQ_FRAME_SIZE * context->max_cmd_count; - context->req_frame_dma_pool = (struct dma_pool *)ps3_dma_pool_create( - "PS3 req frame pool", &instance->pdev->dev, size, + context->req_frame_dma_pool = (struct dma_pool *) ps3_dma_pool_create( + "PS3 req frame pool",&instance->pdev->dev, size, DMA_ALIGN_BYTES_256, 0); + INJECT_START(PS3_ERR_IJ_PS3_REQ_FRAME_BUF_ALLOC, &context->req_frame_dma_pool); if (!context->req_frame_dma_pool) { LOG_ERROR("Failed to setup frame pool\n"); goto l_create_dma_pool_failed; } - context->req_frame_buf = (unsigned char *)ps3_dma_pool_alloc( - instance, context->req_frame_dma_pool, GFP_KERNEL, - &context->req_frame_buf_phys); + context->req_frame_buf = (U8 *)ps3_dma_pool_alloc(instance, + context->req_frame_dma_pool, + GFP_KERNEL, &context->req_frame_buf_phys); if (!context->req_frame_buf) { LOG_ERROR("Failed to alloc frame dma memory\n"); goto l_free_mem; @@ -190,8 +177,8 @@ static void ps3_req_frame_free(struct ps3_instance *instance) #ifndef _WINDOWS if (context->req_frame_buf) { ps3_dma_pool_free(context->req_frame_dma_pool, - context->req_frame_buf, - context->req_frame_buf_phys); + context->req_frame_buf, + context->req_frame_buf_phys); context->req_frame_buf = NULL; } if (context->req_frame_dma_pool) { @@ -200,41 +187,39 @@ static void ps3_req_frame_free(struct ps3_instance *instance) } #else if (context->req_frame_buf != NULL) { - ps3_dma_free_coherent(instance, context->req_frame_buf_size, - context->req_frame_buf, - context->req_frame_buf_phys); + ps3_dma_free_coherent(instance, + context->req_frame_buf_size, + context->req_frame_buf, + context->req_frame_buf_phys); context->req_frame_buf = NULL; context->req_frame_buf_size = 0; } #endif } -static int ps3_cmd_resp_frame_alloc(struct ps3_instance *instance) +static S32 ps3_cmd_resp_frame_alloc(struct ps3_instance *instance) { - unsigned int sense_size = 0; + U32 sense_size = 0; struct ps3_cmd_context *context = &instance->cmd_context; - sense_size = PS3_RESP_FRAME_LENGTH * context->max_cmd_count; + sense_size = PS3_RESP_FRAME_LENGH * context->max_cmd_count; - context->response_frame_dma_pool = - (struct dma_pool *)ps3_dma_pool_create("PS3 respSense pool", - &instance->pdev->dev, - sense_size, - DMA_ALIGN_BYTES_4K, 0); + context->response_frame_dma_pool = (struct dma_pool *)ps3_dma_pool_create("PS3 respSense pool", + &instance->pdev->dev, sense_size, + DMA_ALIGN_BYTES_4K, 0); if (!context->response_frame_dma_pool) { LOG_ERROR("Failed to setup sense pool\n"); goto l_failed_alloc; } - context->response_frame_buf = (unsigned char *)ps3_dma_pool_alloc( - instance, context->response_frame_dma_pool, GFP_KERNEL, - &context->response_frame_buf_phys); + context->response_frame_buf = (U8 *)ps3_dma_pool_alloc(instance, context->response_frame_dma_pool, + GFP_KERNEL, &context->response_frame_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_RESP_FRAME_BUF_ALLOC, &context->response_frame_buf); if (!context->response_frame_buf) { LOG_ERROR("Failed to alloc sense dma memory\n"); goto l_free_mem; } - ps3_get_so_addr_ranger(instance, context->response_frame_buf_phys, - sense_size); + ps3_get_so_addr_ranger(instance, context->response_frame_buf_phys, sense_size); return PS3_SUCCESS; l_free_mem: @@ -253,8 +238,7 @@ static void ps3_cmd_resp_frame_free(struct ps3_instance *instance) #ifndef _WINDOWS if (context->response_frame_buf) { ps3_dma_pool_free(context->response_frame_dma_pool, - context->response_frame_buf, - context->response_frame_buf_phys); + context->response_frame_buf, context->response_frame_buf_phys); context->response_frame_buf = NULL; } if (context->response_frame_dma_pool) { @@ -264,9 +248,9 @@ static void ps3_cmd_resp_frame_free(struct ps3_instance *instance) #else if (context->response_frame_buf != NULL) { ps3_dma_free_coherent(instance, - context->response_frame_buf_size, - context->response_frame_buf, - context->response_frame_buf_phys); + context->response_frame_buf_size, + context->response_frame_buf, + context->response_frame_buf_phys); context->response_frame_buf = NULL; context->response_frame_buf_size = 0; } @@ -275,18 +259,17 @@ static void ps3_cmd_resp_frame_free(struct ps3_instance *instance) static void ps3_cmd_mgr_trans_free(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - if (context->cmd_buf == NULL) + if (context->cmd_buf == NULL) { return; + } for (i = 0; i < instance->max_mgr_cmd_count; i++) { if (context->cmd_buf) { - cmd = context->cmd_buf[instance->cmd_context - .max_scsi_cmd_count + - i]; + cmd = context->cmd_buf[instance->cmd_context.max_scsi_cmd_count + i]; if (cmd && cmd->transient) { ps3_kfree(instance, cmd->transient); cmd->transient = NULL; @@ -295,18 +278,18 @@ static void ps3_cmd_mgr_trans_free(struct ps3_instance *instance) } } -static int ps3_cmd_mgr_trans_alloc(struct ps3_instance *instance) +static S32 ps3_cmd_mgr_trans_alloc(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd *cmd; struct ps3_cmd_context *context = &instance->cmd_context; for (i = 0; i < instance->max_mgr_cmd_count; i++) { - cmd = context->cmd_buf[instance->cmd_context.max_scsi_cmd_count + - i]; + cmd = context->cmd_buf[instance->cmd_context.max_scsi_cmd_count + i]; - cmd->transient = (struct ps3_ioctl_transient *)ps3_kzalloc( - instance, sizeof(struct ps3_ioctl_transient)); + cmd->transient = (struct ps3_ioctl_transient *) + ps3_kzalloc(instance, sizeof(struct ps3_ioctl_transient)); + INJECT_START(PS3_ERR_IJ_PS3_IOCTL_TRANSIENT_ALLOC, &cmd->transient); if (cmd->transient == NULL) { LOG_ERROR("Failed to alloc sge dma memory\n"); goto l_free; @@ -316,21 +299,21 @@ static int ps3_cmd_mgr_trans_alloc(struct ps3_instance *instance) l_free: ps3_cmd_mgr_trans_free(instance); return -PS3_FAILED; + } -static int ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) +static S32 ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) { - unsigned int i = 0; - unsigned int sge_frame_size = 0; + U32 i = 0; + U32 sge_frame_size = 0; struct ps3_cmd *cmd; struct ps3_cmd_context *context = &instance->cmd_context; sge_frame_size = sizeof(struct PS3Sge) * context->ext_sge_frame_count; - context->ext_buf_size = - PS3_MAX(sge_frame_size, PS3_CMD_EXT_BUF_DEFAULT_SIZE); + context->ext_buf_size = PS3_MAX(sge_frame_size, PS3_CMD_EXT_BUF_DEFAULT_SIZE); #ifndef _WINDOWS - context->ext_buf_dma_pool = (struct dma_pool *)ps3_dma_pool_create( - "PS3 ext buf pool", &instance->pdev->dev, context->ext_buf_size, + context->ext_buf_dma_pool = (struct dma_pool *)ps3_dma_pool_create("PS3 ext buf pool", + &instance->pdev->dev, context->ext_buf_size, PS3_CMD_EXT_BUF_DEFAULT_SIZE, 0); if (!context->ext_buf_dma_pool) { LOG_ERROR("Failed to setup sense pool\n"); @@ -339,10 +322,9 @@ static int ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) for (i = 0; i < context->max_scsi_cmd_count; i++) { cmd = context->cmd_buf[i]; - cmd->ext_buf = - ps3_dma_pool_zalloc(instance, context->ext_buf_dma_pool, - GFP_KERNEL, - (dma_addr_t *)&cmd->ext_buf_phys); + cmd->ext_buf = ps3_dma_pool_zalloc(instance, context->ext_buf_dma_pool, + GFP_KERNEL, &cmd->ext_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_EXT_BUF_ALLOC, &cmd->ext_buf); if (!cmd->ext_buf) { LOG_ERROR("Failed to alloc scsi ext buf memory\n"); goto l_free_sge; @@ -350,9 +332,9 @@ static int ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) } context->mgr_ext_buf_size = PS3_CMD_EXT_BUF_SIZE_MGR; - context->mgr_ext_buf_dma_pool = (struct dma_pool *)ps3_dma_pool_create( - "PS3 mgr ext buf pool", &instance->pdev->dev, - context->ext_buf_size, PS3_CMD_EXT_BUF_SIZE_MGR, 0); + context->mgr_ext_buf_dma_pool = (struct dma_pool *)ps3_dma_pool_create("PS3 mgr ext buf pool", + &instance->pdev->dev, context->ext_buf_size, + PS3_CMD_EXT_BUF_SIZE_MGR, 0); if (!context->mgr_ext_buf_dma_pool) { LOG_ERROR("Failed to setup sense pool\n"); goto l_failed_alloc; @@ -360,9 +342,9 @@ static int ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; - cmd->ext_buf = ps3_dma_pool_zalloc( - instance, context->mgr_ext_buf_dma_pool, GFP_KERNEL, - (dma_addr_t *)&cmd->ext_buf_phys); + cmd->ext_buf = ps3_dma_pool_zalloc(instance, context->mgr_ext_buf_dma_pool, + GFP_KERNEL, &cmd->ext_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_MGR_EXT_BUF_ALLOC, &cmd->ext_buf); if (!cmd->ext_buf) { LOG_ERROR("Failed to alloc mgr ext buf memory\n"); goto l_free_sge; @@ -373,13 +355,12 @@ static int ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) l_free_sge: ps3_cmd_ext_buf_free(instance); l_failed_alloc: - return -PS3_FAILED; + return -PS3_FAILED; #else for (i = 0; i < context->max_scsi_cmd_count; i++) { cmd = context->cmd_buf[i]; - cmd->ext_buf = ps3_dma_alloc_coherent( - instance, context->ext_buf_size, - (unsigned long long *)&cmd->ext_buf_phys); + cmd->ext_buf = ps3_dma_alloc_coherent(instance, context->ext_buf_size, + &cmd->ext_buf_phys); if (cmd->ext_buf == NULL) { LOG_ERROR("Failed to alloc scsi ext buf memory\n"); goto l_failed; @@ -389,9 +370,8 @@ static int ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) context->mgr_ext_buf_size = PS3_CMD_EXT_BUF_SIZE_MGR; for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; - cmd->ext_buf = ps3_dma_alloc_coherent( - instance, context->mgr_ext_buf_size, - (unsigned long long *)&cmd->ext_buf_phys); + cmd->ext_buf = ps3_dma_alloc_coherent(instance, context->mgr_ext_buf_size, + &cmd->ext_buf_phys); if (cmd->ext_buf == NULL) { LOG_ERROR("Failed to alloc mgr ext buf memory\n"); goto l_failed; @@ -409,18 +389,20 @@ static int ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) static void ps3_cmd_ext_buf_free(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - if (context->cmd_buf == NULL) + if (context->cmd_buf == NULL) { return; + } #ifndef _WINDOWS for (i = 0; i < context->max_scsi_cmd_count; i++) { cmd = context->cmd_buf[i]; if ((cmd != NULL) && (cmd->ext_buf != NULL)) { ps3_dma_pool_free(context->ext_buf_dma_pool, - cmd->ext_buf, cmd->ext_buf_phys); + cmd->ext_buf, + cmd->ext_buf_phys); cmd->ext_buf = NULL; } } @@ -434,7 +416,8 @@ static void ps3_cmd_ext_buf_free(struct ps3_instance *instance) cmd = context->cmd_buf[i]; if ((cmd != NULL) && (cmd->ext_buf != NULL)) { ps3_dma_pool_free(context->mgr_ext_buf_dma_pool, - cmd->ext_buf, cmd->ext_buf_phys); + cmd->ext_buf, + cmd->ext_buf_phys); cmd->ext_buf = NULL; } } @@ -448,7 +431,8 @@ static void ps3_cmd_ext_buf_free(struct ps3_instance *instance) cmd = context->cmd_buf[i]; if ((cmd != NULL) && (cmd->ext_buf != NULL)) { ps3_dma_free_coherent(instance, context->ext_buf_size, - cmd->ext_buf, cmd->ext_buf_phys); + cmd->ext_buf, + cmd->ext_buf_phys); cmd->ext_buf = NULL; } } @@ -456,29 +440,29 @@ static void ps3_cmd_ext_buf_free(struct ps3_instance *instance) for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; if ((cmd != NULL) && (cmd->ext_buf != NULL)) { - ps3_dma_free_coherent(instance, - context->mgr_ext_buf_size, - cmd->ext_buf, cmd->ext_buf_phys); + ps3_dma_free_coherent(instance, context->mgr_ext_buf_size, + cmd->ext_buf, + cmd->ext_buf_phys); cmd->ext_buf = NULL; } } #endif } -static int ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance) +static S32 ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_context *context = &instance->cmd_context; struct ps3_cmd *cmd = NULL; - unsigned int node_buff_size = ps3_r1x_get_node_Buff_size(); + U32 node_buff_size = ps3_r1x_get_node_Buff_size(); for (i = 0; i < context->max_scsi_cmd_count; i++) { cmd = context->cmd_buf[i]; cmd->szblock_cnt = 0; cmd->node_buff = ps3_kzalloc(instance, node_buff_size); + INJECT_START(PS3_ERR_IJ_PS3_R1XLOCK_BUF_ALLOC, &cmd->node_buff); if (!cmd->node_buff) { - LOG_ERROR( - "Failed to alloc r1x write lock range node buf memory\n"); + LOG_ERROR("Failed to alloc r1x write lock range node buf memory\n"); goto l_free_node; } } @@ -492,41 +476,46 @@ static int ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance) static void ps3_cmd_r1xlock_buff_free(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_context *context = &instance->cmd_context; - struct ps3_cmd *cmd = NULL; + struct ps3_cmd* cmd = NULL; - if (context->cmd_buf == NULL) + if (context->cmd_buf == NULL) { return; + } for (i = 0; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; - if (cmd != NULL) { + if(cmd != NULL) { cmd->szblock_cnt = 0; - if (cmd->node_buff != NULL) { + if(cmd->node_buff != NULL){ ps3_kfree(instance, cmd->node_buff); cmd->node_buff = NULL; } } } + + return; } -static int ps3_cmd_buf_alloc(struct ps3_instance *instance) +static S32 ps3_cmd_buf_alloc(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_context *context = &instance->cmd_context; - context->cmd_buf = (struct ps3_cmd **)ps3_kcalloc( - instance, context->max_cmd_count, sizeof(struct ps3_cmd *)); + context->cmd_buf = (struct ps3_cmd**)ps3_kcalloc(instance, context->max_cmd_count, + sizeof(struct ps3_cmd*)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_BUF_ALLOC, &context->cmd_buf); if (context->cmd_buf == NULL) { LOG_ERROR("Failed to kcalloc memory for cmd_buf\n"); goto l_failed; } memset(context->cmd_buf, 0, - sizeof(struct ps3_cmd *) * context->max_cmd_count); + sizeof(struct ps3_cmd*) * context->max_cmd_count); for (i = 0; i < context->max_cmd_count; i++) { - context->cmd_buf[i] = (struct ps3_cmd *)ps3_kzalloc( - instance, sizeof(struct ps3_cmd)); + context->cmd_buf[i] = (struct ps3_cmd*)ps3_kzalloc(instance, + sizeof(struct ps3_cmd)); + INJECT_START(PS3_ERR_IJ_PS3_PS3_CMD_ALLOC, &context->cmd_buf[i]); if (context->cmd_buf[i] == NULL) { LOG_ERROR("Failed to malloc memory for ps3_cmd\n"); goto l_failed; @@ -548,13 +537,14 @@ static int ps3_cmd_buf_alloc(struct ps3_instance *instance) static void ps3_cmd_buf_free(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_context *context = &instance->cmd_context; - if (context->cmd_buf == NULL) + if (context->cmd_buf == NULL) { goto l_out; + } - while (i < context->max_cmd_count && context->cmd_buf[i]) { + while(i < context->max_cmd_count && context->cmd_buf[i]) { ps3_kfree(instance, context->cmd_buf[i]); context->cmd_buf[i] = NULL; i++; @@ -572,11 +562,11 @@ static void ps3_cmd_buf_free(struct ps3_instance *instance) return; } -static int ps3_cmd_init(struct ps3_instance *instance) +static S32 ps3_cmd_init(struct ps3_instance *instance) { - unsigned short i = 0; - int ret = PS3_SUCCESS; - unsigned int offset = 0; + U16 i = 0; + S32 ret = PS3_SUCCESS; + U32 offset = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; @@ -584,44 +574,43 @@ static int ps3_cmd_init(struct ps3_instance *instance) for (i = 0; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; if (!cmd) { - LOG_ERROR("Failed %s\n", __func__); + LOG_ERROR("Failed ps3_cmd_init \n"); ret = -PS3_FAILED; goto l_out; } cmd->instance = instance; - offset = i * PS3_RESP_FRAME_LENGTH; - cmd->resp_frame = - (union PS3RespFrame *)(context->response_frame_buf + - offset); - cmd->resp_frame_phys = - context->response_frame_buf_phys + offset; + offset = i * PS3_RESP_FRAME_LENGH; + cmd->resp_frame = (PS3RespFrame_u *) + (context->response_frame_buf + offset); + cmd->resp_frame_phys = context->response_frame_buf_phys + offset; cmd->index = i; cmd->is_aborting = 0; #ifndef _WINDOWS cmd->scmd = NULL; #endif offset = i * PS3_DEFAULT_REQ_FRAME_SIZE; - cmd->req_frame = - (union PS3ReqFrame *)(context->req_frame_buf + offset); + cmd->req_frame = (union PS3ReqFrame *) + (context->req_frame_buf + offset); cmd->req_frame_phys = context->req_frame_buf_phys + offset; ps3_spin_lock_init(&cmd->cmd_state.lock); ps3_cmd_content_init(cmd); if (is_r1x_peer_cmd(instance, i)) { if (instance->r1x_mode == PS3_R1X_MODE_NORMAL) { list_add_tail(&cmd->cmd_list, - &context->r1x_scsi_cmd_pool); + &context->r1x_scsi_cmd_pool); } - } else if (is_task_cmd(instance, i)) { + } else if (is_task_cmd(instance,i)) { list_add_tail(&cmd->cmd_list, &context->task_cmd_pool); init_completion(&cmd->sync_done); - } else if (is_mgr_cmd(instance, i)) { + } else if (is_mgr_cmd(instance,i)) { list_add_tail(&cmd->cmd_list, &context->mgr_cmd_pool); init_completion(&cmd->sync_done); } #ifdef _WINDOWS - else + else { list_add_tail(&cmd->cmd_list, &context->scsi_cmd_pool); + } #endif } @@ -634,13 +623,10 @@ static inline void ps3_host_max_sge_count(struct ps3_cmd_context *context) context->max_host_sge_count = PS3_FRAME_REQ_SGE_NUM_HW; if (context->sgl_mode_support) { if (context->ext_sge_frame_count > PS3_FRAME_REQ_EXT_SGE_MIN) { - context->max_host_sge_count += - (unsigned short)context->ext_sge_frame_count - - PS3_FRAME_REQ_EXT_SGE_MIN; + context->max_host_sge_count += (U16)context->ext_sge_frame_count - PS3_FRAME_REQ_EXT_SGE_MIN; } } else if (context->ext_sge_frame_count > 1) { - context->max_host_sge_count = PS3_MAX( - (unsigned short)(context->ext_sge_frame_count - 1), + context->max_host_sge_count = PS3_MAX((U16)(context->ext_sge_frame_count - 1), context->max_host_sge_count); } } @@ -648,102 +634,110 @@ static inline void ps3_host_max_sge_count(struct ps3_cmd_context *context) static inline void ps3_r1x_mode_set(struct ps3_instance *instance) { struct ps3_cmd_context *context = &instance->cmd_context; - - if (context->max_r1x_cmd_count >= context->max_scsi_cmd_count / 2) + if (context->max_r1x_cmd_count >= context->max_scsi_cmd_count / 2) { instance->r1x_mode = PS3_R1X_MODE_PERF; - LOG_INFO("host_no:%u r1x_mode:%u\n", PS3_HOST(instance), - instance->r1x_mode); + } + LOG_INFO("host_no:%u r1x_mode:%u\n", PS3_HOST(instance), instance->r1x_mode); } -int ps3_cmd_context_init(struct ps3_instance *instance) +S32 ps3_cmd_context_init(struct ps3_instance *instance) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct ps3_cmd_context *context = &instance->cmd_context; int cpu = 0; - long long *scsi_cmd_deliver = NULL; + S64 *scsi_cmd_deliver = NULL; - if (!ps3_ioc_mgr_max_fw_cmd_get(instance, &context->max_cmd_count)) + if (!ps3_ioc_mgr_max_fw_cmd_get(instance, &context->max_cmd_count)) { goto l_failed; + } #ifdef PS3_HARDWARE_SIM context->max_r1x_cmd_count = 16; #else if (!ps3_get_max_r1x_cmds_with_check(instance, - &context->max_r1x_cmd_count)) { + &context->max_r1x_cmd_count)) { goto l_failed; } #endif - LOG_DEBUG("host_no:%u max_r1x_cmd_count:%u\n", PS3_HOST(instance), - context->max_r1x_cmd_count); + LOG_DEBUG("host_no:%u max_r1x_cmd_count:%u\n", + PS3_HOST(instance), context->max_r1x_cmd_count); context->max_mgr_cmd_count = instance->max_mgr_cmd_total_count; - context->max_scsi_cmd_count = - context->max_cmd_count - instance->max_mgr_cmd_total_count; + context->max_scsi_cmd_count = context->max_cmd_count - + instance->max_mgr_cmd_total_count; - if (context->max_r1x_cmd_count > (context->max_scsi_cmd_count / 2)) + if (context->max_r1x_cmd_count > (context->max_scsi_cmd_count / 2 )) { context->max_r1x_cmd_count = (context->max_scsi_cmd_count / 2); + } ps3_r1x_mode_set(instance); - LOG_DEBUG("host_no:%u max_r1x_cmd_final count:%u\n", PS3_HOST(instance), - context->max_r1x_cmd_count); + LOG_DEBUG("host_no:%u max_r1x_cmd_final count:%u\n", + PS3_HOST(instance), context->max_r1x_cmd_count); if (!ps3_ioc_mgr_max_chain_size_get(instance, - &context->ext_sge_frame_count)) { + &context->ext_sge_frame_count)) { goto l_failed; } context->ext_sge_frame_count /= sizeof(struct PS3Sge); - if (!ps3_ioc_mgr_max_nvme_page_size_get( - instance, &instance->cmd_attr.nvme_page_size)) { + if (!ps3_ioc_mgr_max_nvme_page_size_get(instance, + &instance->cmd_attr.nvme_page_size)) { goto l_failed; } - context->max_prp_count = - PS3_FRAME_REQ_PRP_NUM_FE + (instance->cmd_attr.nvme_page_size / - sizeof(unsigned long long)); + context->max_prp_count = PS3_FRAME_REQ_PRP_NUM_FE + + (instance->cmd_attr.nvme_page_size / sizeof(U64)); ps3_host_max_sge_count(context); if (context->max_cmd_count <= instance->max_mgr_cmd_total_count) { - LOG_ERROR("max_cmd_count %d too few\n", context->max_cmd_count); + LOG_ERROR("max_cmd_count %d too few\n", + context->max_cmd_count); goto l_failed; } ret = ps3_cmd_buf_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_failed; + } ret = ps3_req_frame_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_failed; + } ret = ps3_cmd_resp_frame_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_failed; + } ret = ps3_cmd_ext_buf_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_failed; + } ret = ps3_cmd_r1xlock_buff_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_failed; + } ret = ps3_cmd_mgr_trans_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_failed; + } ret = ps3_cmd_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_failed; + } - instance->scsi_cmd_deliver = alloc_percpu(long long); + instance->scsi_cmd_deliver = alloc_percpu(S64); + INJECT_START(PS3_ERR_IJ_PS3_PERCPU_ALLOC, &instance->scsi_cmd_deliver); if (!instance->scsi_cmd_deliver) { LOG_ERROR("alloc per_cpu scsi_cmd_deliver failed. hno:%u\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_failed; } else { for_each_possible_cpu(cpu) { - scsi_cmd_deliver = - per_cpu_ptr(instance->scsi_cmd_deliver, cpu); + scsi_cmd_deliver = per_cpu_ptr(instance->scsi_cmd_deliver, cpu); *scsi_cmd_deliver = 0; } } @@ -804,22 +798,21 @@ static void ps3_cmd_content_init(struct ps3_cmd *cmd) cmd->r1x_read_pd = 0; memset(&cmd->io_attr, 0, sizeof(struct ps3_scsi_io_attr)); - memset((void *)&cmd->sync_done, 0, sizeof(cmd->sync_done)); - if (cmd->transient == NULL || cmd->transient->sge_num == 0) - memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); + memset((void*)&cmd->sync_done, 0, sizeof(cmd->sync_done)); + if (cmd->transient == NULL || cmd->transient->sge_num == 0) { + memset((void*)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); + } - memset((void *)cmd->resp_frame, 0xff, sizeof(union PS3RespFrame)); + memset((void*)cmd->resp_frame, 0xff, sizeof(PS3RespFrame_u)); memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); INIT_LIST_HEAD(&cmd->qos_list); - memset(&cmd->target_pd, 0, - sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); + memset(&cmd->target_pd, 0, sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); cmd->target_pd_count = 0; cmd->first_over_quota_pd_idx = 0; cmd->qos_waitq_flag = 0; - memset(&cmd->cmdq_info, 0, - sizeof(struct ps3_qos_cmdq_info) * PS3_QOS_MAX_CMDQ_ONE_CMD); + memset(&cmd->cmdq_info, 0, sizeof(struct ps3_qos_cmdq_info) * PS3_QOS_MAX_CMDQ_ONE_CMD); cmd->cmdq_count = 0; } @@ -856,14 +849,11 @@ static void ps3_scsi_cmd_content_init(struct ps3_cmd *cmd) cmd->flighting = PS3_FALSE; cmd->r1x_read_pd = 0; - if (cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].length != - 0) { - memset(cmd->ext_buf, 0, - cmd->instance->cmd_context.ext_buf_size); - } + if (cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].length != 0) + memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); if (!ps3_scsih_is_rw_type(cmd->io_attr.rw_flag) && - (cmd->transient == NULL || cmd->transient->sge_num == 0)) { + (cmd->transient == NULL || cmd->transient->sge_num == 0)) { memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); } @@ -876,24 +866,21 @@ static void ps3_scsi_cmd_content_init(struct ps3_cmd *cmd) memset((void *)&cmd->sync_done, 0, sizeof(cmd->sync_done)); memset(&cmd->io_attr, 0, sizeof(struct ps3_scsi_io_attr)); INIT_LIST_HEAD(&cmd->qos_list); - memset(&cmd->target_pd, 0, - sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); + memset(&cmd->target_pd, 0, sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); cmd->target_pd_count = 0; cmd->first_over_quota_pd_idx = 0; cmd->qos_waitq_flag = 0; - memset(&cmd->cmdq_info, 0, - sizeof(struct ps3_qos_cmdq_info) * PS3_QOS_MAX_CMDQ_ONE_CMD); + memset(&cmd->cmdq_info, 0, sizeof(struct ps3_qos_cmdq_info) * PS3_QOS_MAX_CMDQ_ONE_CMD); cmd->cmdq_count = 0; } #ifndef _WINDOWS -struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, - unsigned int tag) +struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, U32 tag) { struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - if (tag < (unsigned int)instance->cmd_attr.cur_can_que) { + if (tag < (U32)instance->cmd_attr.cur_can_que) { cmd = context->cmd_buf[tag]; cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; ps3_trace_id_alloc(&cmd->trace_id); @@ -902,11 +889,11 @@ struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, return cmd; } -int ps3_scsi_cmd_free(struct ps3_cmd *cmd) +S32 ps3_scsi_cmd_free(struct ps3_cmd *cmd) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; - if (cmd->index < (unsigned int)cmd->instance->cmd_attr.cur_can_que) { + if (cmd->index < (U32)cmd->instance->cmd_attr.cur_can_que) { ps3_scsi_cmd_content_init(cmd); ret = PS3_SUCCESS; } @@ -917,12 +904,11 @@ struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance) { struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - unsigned long flags = 0; + ULong flags = 0; ps3_spin_lock_irqsave(&context->scsi_pool_lock, &flags); if (!list_empty(&context->scsi_cmd_pool)) { - cmd = list_entry(list_remove_head(&context->scsi_cmd_pool), - struct ps3_cmd, cmd_list); + cmd = list_entry(list_remove_head(&context->scsi_cmd_pool), struct ps3_cmd, cmd_list); } ps3_spin_unlock_irqrestore(&context->scsi_pool_lock, flags); @@ -933,15 +919,16 @@ struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance) return cmd; } -int ps3_scsi_cmd_free(struct ps3_cmd *cmd) +S32 ps3_scsi_cmd_free(struct ps3_cmd *cmd) { - int ret = -PS3_FAILED; - unsigned int max_count = 0; - unsigned long flags = 0; + S32 ret = -PS3_FAILED; + U32 max_count = 0; + ULong flags = 0; struct ps3_cmd_context *context = &cmd->instance->cmd_context; - if (unlikely(cmd == NULL)) + if (unlikely(cmd == NULL)) { goto l_out; + } max_count = context->max_scsi_cmd_count; if (cmd->index < max_count) { @@ -957,21 +944,20 @@ int ps3_scsi_cmd_free(struct ps3_cmd *cmd) } #endif -static void cmd_pool_free(struct list_head *pool_list, spinlock_t *pool_lock, - struct ps3_cmd *cmd) +static void cmd_pool_free(ps3_list_head *pool_list, + ps3_spinlock *pool_lock, struct ps3_cmd *cmd) { - unsigned long flags = 0; - + ULong flags = 0; ps3_spin_lock_irqsave(pool_lock, &flags); list_add_tail(&cmd->cmd_list, pool_list); ps3_spin_unlock_irqrestore(pool_lock, flags); } -static struct ps3_cmd *cmd_pool_alloc(struct list_head *pool_list, - spinlock_t *pool_lock) +static struct ps3_cmd *cmd_pool_alloc(ps3_list_head *pool_list, + ps3_spinlock *pool_lock) { struct ps3_cmd *cmd = NULL; - unsigned long flags = 0; + ULong flags = 0; #ifdef _WINDOWS struct ps3_cmd_context *context = NULL; #endif @@ -986,7 +972,7 @@ static struct ps3_cmd *cmd_pool_alloc(struct list_head *pool_list, } ps3_spin_unlock_irqrestore(pool_lock, flags); - if (cmd != NULL) { + if(cmd != NULL) { #ifndef _WINDOWS ps3_trace_id_alloc(&cmd->trace_id); #else @@ -1000,9 +986,9 @@ static struct ps3_cmd *cmd_pool_alloc(struct list_head *pool_list, return cmd; } -unsigned char ps3_r1x_peer_cmd_free_nolock(struct ps3_cmd *cmd) +Bool ps3_r1x_peer_cmd_free_nolock(struct ps3_cmd *cmd) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; struct ps3_cmd_context *context = NULL; struct ps3_instance *instance = cmd->instance; @@ -1012,21 +998,22 @@ unsigned char ps3_r1x_peer_cmd_free_nolock(struct ps3_cmd *cmd) goto l_out; } - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) + if(cmd->cmd_state.state == PS3_CMD_STATE_INIT) { goto l_out; + } ps3_scsi_cmd_content_init(cmd); if (instance->r1x_mode == PS3_R1X_MODE_NORMAL) { cmd_pool_free(&context->r1x_scsi_cmd_pool, - &context->r1x_scsi_pool_lock, cmd); + &context->r1x_scsi_pool_lock, cmd); } l_out: return ret; } -int ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd) +S32 ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd_context *context = NULL; context = &instance->cmd_context; @@ -1035,19 +1022,21 @@ int ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd) goto l_out; } - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) + if(cmd->cmd_state.state == PS3_CMD_STATE_INIT) { goto l_out; + } ps3_cmd_content_init(cmd); + INJECT_START(PS3_ERR_FORCE_SET_CMD_INDEX_NOT_MGR, &cmd->index); if (is_task_cmd(instance, cmd->index)) { - cmd_pool_free(&context->task_cmd_pool, &context->task_pool_lock, - cmd); + cmd_pool_free(&context->task_cmd_pool, + &context->task_pool_lock, cmd); } else if (is_mgr_cmd(instance, cmd->index)) { - cmd_pool_free(&context->mgr_cmd_pool, &context->mgr_pool_lock, - cmd); + cmd_pool_free(&context->mgr_cmd_pool, + &context->mgr_pool_lock, cmd); } else { LOG_INFO_IN_IRQ(instance, "host_no:%u CFID:%u not mgr cmd!\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); PS3_BUG(); ret = -PS3_FAILED; } @@ -1055,30 +1044,30 @@ int ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd) return ret; } -int ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd) +S32 ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - int cur_state = PS3_INSTANCE_STATE_INIT; + S32 ret = PS3_SUCCESS; + S32 cur_state = PS3_INSTANCE_STATE_INIT; ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); - mb(); /* in order to force CPU ordering */ + mb(); ret = ps3_cmd_send_pre_check(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } cur_state = ps3_atomic_read(&instance->state_machine.state); + if (cmd == instance->event_context.event_cmd) { + INJECT_START(PS3_ERR_IJ_FORCE_EVENT_CMD_FAIL_DEAD, &cur_state) + } if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { if (instance->is_probe_finish && !instance->is_resume) { - LOG_FILE_ERROR( - "host_no:%u cannot send async cmd due to %s, return fail\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state)); + LOG_FILE_ERROR("host_no:%u cannot send async cmd due to %s, return fail\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = -PS3_FAILED; } else { - LOG_FILE_WARN( - "host_no:%u cannot send async cmd due to %s, return recovered\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state)); + LOG_FILE_WARN("host_no:%u cannot send async cmd due to %s, return recovered\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = -PS3_RECOVERED; } goto l_out; @@ -1092,13 +1081,13 @@ int ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd) #ifndef _WINDOWS static void ps3_r1x_peer_cmd_build(struct ps3_cmd *cmd, - struct ps3_cmd *peer_cmd) + struct ps3_cmd *peer_cmd) { - memcpy(peer_cmd->req_frame, cmd->req_frame, sizeof(union PS3ReqFrame)); - memcpy((void *)&peer_cmd->io_attr, (void *)&cmd->io_attr, - sizeof(struct ps3_scsi_io_attr)); - memcpy(peer_cmd->ext_buf, cmd->ext_buf, - cmd->instance->cmd_context.ext_buf_size); + memcpy(peer_cmd->req_frame, cmd->req_frame, + sizeof(union PS3ReqFrame)); + memcpy((void*)&peer_cmd->io_attr, (void*)&cmd->io_attr, + sizeof(struct ps3_scsi_io_attr)); + memcpy(peer_cmd->ext_buf, cmd->ext_buf, cmd->instance->cmd_context.ext_buf_size); peer_cmd->scmd = cmd->scmd; peer_cmd->is_got_r1x = cmd->is_got_r1x; @@ -1106,13 +1095,11 @@ static void ps3_r1x_peer_cmd_build(struct ps3_cmd *cmd, peer_cmd->os_sge_map_count = cmd->os_sge_map_count; peer_cmd->cmd_receive_cb = cmd->cmd_receive_cb; peer_cmd->io_attr.pd_entry = cmd->io_attr.peer_pd_entry; - peer_cmd->io_attr.disk_id = - PS3_PDID(&peer_cmd->io_attr.pd_entry->disk_pos); + peer_cmd->io_attr.disk_id = PS3_PDID(&peer_cmd->io_attr.pd_entry->disk_pos); peer_cmd->io_attr.plba = cmd->io_attr.plba_back; peer_cmd->cmd_word_value = cmd->cmd_word_value; - peer_cmd->cmd_word.phyDiskID = - PS3_PDID(&peer_cmd->io_attr.pd_entry->disk_pos); + peer_cmd->cmd_word.phyDiskID = PS3_PDID(&peer_cmd->io_attr.pd_entry->disk_pos); peer_cmd->cmd_word.cmdFrameID = peer_cmd->index; peer_cmd->req_frame->hwReq.reqHead.cmdFrameID = peer_cmd->index; @@ -1127,20 +1114,19 @@ static void ps3_r1x_peer_cmd_build(struct ps3_cmd *cmd, cmd->is_r1x_scsi_complete = PS3_FALSE; peer_cmd->is_r1x_scsi_complete = PS3_FALSE; - LOG_DEBUG( - "hno:%u r1x direct write cmd:%d, peer cmd:%d build: tid:0x%llx pid:%u plba:0x%llx\n", - PS3_HOST(cmd->instance), cmd->index, peer_cmd->index, - peer_cmd->trace_id, peer_cmd->cmd_word.phyDiskID, - peer_cmd->io_attr.plba); + LOG_DEBUG("host_no:%u r1x direct write cmd:%d, peer cmd:%d build:" + " tid:0x%llx pid:%u plba:0x%llx\n", + PS3_HOST(cmd->instance), cmd->index, peer_cmd->index, + peer_cmd->trace_id, peer_cmd->cmd_word.phyDiskID, + peer_cmd->io_attr.plba); } -static struct ps3_cmd *ps3_r1x_scsi_peer_prepare(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static struct ps3_cmd* ps3_r1x_scsi_peer_prepare(struct ps3_instance *instance, + struct ps3_cmd *cmd) { struct ps3_cmd *peer_cmd = NULL; - if (cmd->io_attr.direct_flag != PS3_CMDWORD_DIRECT_ADVICE || - cmd->io_attr.peer_pd_entry == NULL) { + cmd->io_attr.peer_pd_entry == NULL) { goto _lout; } @@ -1148,8 +1134,7 @@ static struct ps3_cmd *ps3_r1x_scsi_peer_prepare(struct ps3_instance *instance, if (peer_cmd != NULL) { ps3_r1x_peer_cmd_build(cmd, peer_cmd); } else { - LOG_DEBUG( - "host_no:%u cmd:%d can not alloc r1x peer cmd any more\n", + LOG_DEBUG("host_no:%u cmd:%d can not alloc r1x peer cmd any more\n", PS3_HOST(instance), cmd->index); instance->ioc_adpter->io_cmd_rebuild(cmd); } @@ -1157,30 +1142,27 @@ static struct ps3_cmd *ps3_r1x_scsi_peer_prepare(struct ps3_instance *instance, return peer_cmd; } -void ps3_wait_scsi_cmd_done(struct ps3_instance *instance, - unsigned char time_out) +void ps3_wait_scsi_cmd_done(struct ps3_instance *instance, Bool time_out) { int cpu = 0; - long long result = 0; - unsigned short try_cnt = 0; + S64 result = 0; + U16 try_cnt = 0; if (instance->scsi_cmd_deliver) { do { result = 0; for_each_possible_cpu(cpu) { - result += *per_cpu_ptr( - instance->scsi_cmd_deliver, cpu); + result += *per_cpu_ptr(instance->scsi_cmd_deliver, cpu); } if (result > 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); if (time_out) { try_cnt++; - if (try_cnt > - PS3_WAIT_SCSI_CMD_DONE_COUNT) { - LOG_WARN( - "hno:%u wait scsi cmd done NOK\n", + if (try_cnt > PS3_WAIT_SCSI_CMD_DONE_COUNT) { + LOG_WARN("hno:%u wait scsi cmd done NOK\n", PS3_HOST(instance)); + INJECT_START(PS3_ERR_IJ_WAIT_SCSI_CMD_DONE_FAIL, instance); break; } } @@ -1189,13 +1171,12 @@ void ps3_wait_scsi_cmd_done(struct ps3_instance *instance, } LOG_INFO("wait scsi cmd done end. hno:%u try_cnt[%u]\n", - PS3_HOST(instance), try_cnt); + PS3_HOST(instance), try_cnt); } void ps3_scsi_cmd_deliver_get(struct ps3_instance *instance) { - long long *cmd_deliver = NULL; - + S64 *cmd_deliver = NULL; cmd_deliver = get_cpu_ptr(instance->scsi_cmd_deliver); (*cmd_deliver)++; put_cpu_ptr(cmd_deliver); @@ -1203,47 +1184,49 @@ void ps3_scsi_cmd_deliver_get(struct ps3_instance *instance) void ps3_scsi_cmd_deliver_put(struct ps3_instance *instance) { - long long *cmd_deliver = NULL; - + S64 *cmd_deliver = NULL; cmd_deliver = get_cpu_ptr(instance->scsi_cmd_deliver); (*cmd_deliver)--; put_cpu_ptr(cmd_deliver); } -void ps3_wait_mgr_cmd_done(struct ps3_instance *instance, - unsigned char time_out) +void ps3_wait_mgr_cmd_done(struct ps3_instance *instance, Bool time_out) { - unsigned short try_cnt = 0; + U16 try_cnt = 0; while (ps3_atomic_read(&instance->cmd_statistics.cmd_delivering) != 0) { + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_2, instance); ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); if (time_out) { try_cnt++; if (try_cnt > PS3_WAIT_SCSI_CMD_DONE_COUNT) { LOG_WARN("hno:%u wait mgr cmd done NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); break; } } } LOG_INFO("wait mgr cmd done end. hno:%u try_cnt[%u]\n", - PS3_HOST(instance), try_cnt); + PS3_HOST(instance), try_cnt); } -int ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, - unsigned char need_prk_err) +S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, Bool need_prk_err) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *peer_cmd = NULL; ret = ps3_cmd_send_pre_check(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } + PS3_IJ_SLEEP(10000, PS3_ERR_IJ_SCSI_DELIVER_DELAY); + INJECT_START(PS3_ERR_IJ_WAIT_TASK_MGR_BUSY, instance); + INJECT_START(PS3_ERR_IJ_FORCE_TASK_MGR_BUSY, instance); if (unlikely(instance->task_manager_host_busy)) { - LOG_INFO_LIM_WITH_CHECK( - instance, need_prk_err, + INJECT_START(PS3_ERR_IJ_SEND_CMD_TASK_MGR_BUSY, instance); + LOG_INFO_LIM_WITH_CHECK(instance, need_prk_err, "host_no:%u cannot send block cmd due to task_manager_host_busy\n", PS3_HOST(instance)); @@ -1251,15 +1234,17 @@ int ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, goto l_out; } + INJECT_START(PS3_ERR_IJ_CMD_SEND_FORCE_INS_UNLOAD, instance) if (!instance->state_machine.is_load) { - LOG_WARN_LIM_WITH_CHECK( - instance, need_prk_err, - "host_no:%u instance state not is_load\n", - PS3_HOST(instance)); + LOG_WARN_LIM_WITH_CHECK(instance, need_prk_err, + "host_no:%u instance state not is_load\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } + INJECT_START(PS3_ERR_IJ_CMD_SEND_BLOCK, instance); + INJECT_START(PS3_ERR_IJ_CMD_SEND_FORCE_UNORMAL, instance); + PS3_IJ_SLEEP(10000, PS3_ERR_IJ_SCSI_DELIVER_DELAY_2); if (!ps3_is_instance_state_normal(instance, need_prk_err)) { ret = -PS3_RECOVERED; @@ -1273,9 +1258,11 @@ int ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, PS3_DEV_IO_OUTSTAND_INC(instance, cmd); PS3_IO_DRV2IOC_START_INC(instance, cmd); cmd->flighting = PS3_FALSE; - wmb(); /* in order to force CPU ordering */ + wmb(); + INJECT_START(PS3_ERR_IJ_CMD_BLOCK_BEFORE_SEND_TO_IOC, instance); ps3_ioc_scsi_cmd_send(instance, &cmd->cmd_word); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_DONE, instance); if (peer_cmd != NULL) { PS3_IO_DRV2IOC_START_INC(instance, peer_cmd); ps3_ioc_scsi_cmd_send(instance, &peer_cmd->cmd_word); @@ -1286,23 +1273,19 @@ int ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, } #endif -struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, - unsigned short cmd_frame_id) +struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, U16 cmd_frame_id) { struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - if (cmd_frame_id >= context->max_cmd_count) { LOG_ERROR_IN_IRQ(instance, "host_no:%u CFID:%d invalid\n", - PS3_HOST(instance), cmd_frame_id); + PS3_HOST(instance), cmd_frame_id); goto l_failed; } cmd = context->cmd_buf[cmd_frame_id]; if (cmd->index != cmd_frame_id) { - LOG_ERROR_IN_IRQ( - instance, - "host_no:%u CFID:%d incorrect, expect CFID:%d\n", + LOG_ERROR_IN_IRQ(instance, "host_no:%u CFID:%d incorrect, expect CFID:%d\n", PS3_HOST(instance), cmd_frame_id, cmd->index); cmd = NULL; goto l_failed; @@ -1312,57 +1295,54 @@ struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, return cmd; } -int ps3_cmd_dispatch(struct ps3_instance *instance, unsigned short cmd_frame_id, - struct PS3ReplyWord *reply_word) +S32 ps3_cmd_dispatch(struct ps3_instance *instance, U16 cmd_frame_id, struct PS3ReplyWord *reply_word) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct ps3_cmd *cmd = NULL; - unsigned short reply_flags = 0xff; + U16 reply_flags = 0xff; if (reply_word->retType == PS3_HARD_RET && - reply_word->retStatus == PS3_REPLY_WORD_FLAG_REPEAT_REPLY) { - LOG_ERROR_IN_IRQ( - instance, - "hno:%u repeated response CFID:%u reply_word:0x%llx\n", - PS3_HOST(instance), cmd_frame_id, - *(unsigned long long *)reply_word); + reply_word->retStatus == PS3_REPLY_WORD_FLAG_REPEAT_REPLY) { + LOG_ERROR_IN_IRQ(instance, "hno:%u repeated response CFID:%u reply_word:0x%llx\n", + PS3_HOST(instance), cmd_frame_id, *(U64 *)reply_word); goto l_out; } cmd = ps3_cmd_find(instance, cmd_frame_id); - if (cmd == NULL) + if (cmd == NULL) { goto l_out; + } memcpy(&(cmd->reply_word), reply_word, sizeof(struct PS3ReplyWord)); reply_flags = reply_word->retStatus; if (cmd->cmd_receive_cb) { ret = cmd->cmd_receive_cb(cmd, reply_flags); } else { - LOG_ERROR_IN_IRQ( - instance, - "warn ps3 cmd index %d has no cmd_receive_cb\n", + LOG_ERROR_IN_IRQ(instance, "warn ps3 cmd index %d has no cmd_receive_cb\n", cmd->index); } l_out: return ret; } -unsigned char -ps3_is_instance_state_allow_cmd_execute(struct ps3_instance *instance) +Bool ps3_is_instance_state_allow_cmd_execute(struct ps3_instance *instance) { - unsigned char ret = PS3_TRUE; - int cur_state = PS3_INSTANCE_STATE_INIT; + Bool ret = PS3_TRUE; + S32 cur_state = PS3_INSTANCE_STATE_INIT; cur_state = ps3_atomic_read(&instance->state_machine.state); + INJECT_START(PS3_ERR_IJ_INS_STATE_UNNORMAL, &cur_state) + INJECT_START(PS3_ERR_IJ_INS_STATE_DEAD, &cur_state) + INJECT_START(PS3_ERR_IJ_V2_FORCE_INS_STATE_UNNORMAL, instance); + INJECT_START(PS3_ERR_IJ_V2_FORCE_INS_DEAD, instance); if (cur_state == PS3_INSTANCE_STATE_DEAD && - (PS3_IOC_STATE_HALT_SUPPORT(instance) == PS3_TRUE) && - PS3_HALT_CLI_SUPPORT(instance)) { + (PS3_IOC_STATE_HALT_SUPPORT(instance) == PS3_TRUE) && + PS3_HALT_CLI_SUPPORT(instance)){ goto l_out; } if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { - LOG_FILE_INFO( - "host_no:%u cannot handle cmd, driver state: %s\n", + cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && + cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { + LOG_FILE_INFO("host_no:%u cannot handle cmd, driver state: %s\n", PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = PS3_FALSE; } @@ -1371,19 +1351,18 @@ ps3_is_instance_state_allow_cmd_execute(struct ps3_instance *instance) return ret; } -int ps3_cmd_send_pre_check(struct ps3_instance *instance) +S32 ps3_cmd_send_pre_check(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - + S32 ret = PS3_SUCCESS; if (instance->is_probe_finish && !instance->state_machine.is_load) { LOG_FILE_INFO("host_no:%u instance state state is unloading\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } + INJECT_START(PS3_ERR_IJ_CMD_SEND_FORCE_PCI_ERR, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_FILE_WARN( - "host_no:%u cannot send block cmd due to pci err recovery\n", + LOG_FILE_WARN("host_no:%u cannot send block cmd due to pci err recovery\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; @@ -1392,24 +1371,26 @@ int ps3_cmd_send_pre_check(struct ps3_instance *instance) return ret; } -int ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, - unsigned char no_check) +S32 ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, Bool no_check) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE, instance); if (!no_check && !instance->state_machine.is_load) { LOG_WARN_LIM("hno[%u] instance state not is_load\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_IN_UNLOAD; goto l_out; } + INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_UNORMAL, instance); if (!ps3_is_instance_state_allow_cmd_execute(instance)) { ret = -PS3_RECOVERED; goto l_out; } + INJECT_START(PS3_ERR_IJ_V2_PCIE_ERR, instance); if (ps3_pci_err_recovery_get(instance)) { LOG_WARN_LIM("hno[%u] host in pci err recovery\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } @@ -1417,32 +1398,34 @@ int ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, return ret; } -int ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd) +S32 ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - int cur_state = ps3_atomic_read(&instance->state_machine.state); + S32 ret = PS3_SUCCESS; + S32 cur_state = ps3_atomic_read(&instance->state_machine.state); + INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE, instance); if (!instance->state_machine.is_load) { if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT) { ret = -PS3_IN_UNLOAD; goto l_failed; } } + INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_UNORMAL, instance); + INJECT_START(PS3_ERR_IJ_V2_FORCE_INS_DEAD1, instance); if (!ps3_is_instance_state_allow_cmd_execute(instance)) { ret = -PS3_RECOVERED; if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) { - cur_state = - ps3_atomic_read(&instance->state_machine.state); + cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_DEAD) { + cur_state == PS3_INSTANCE_STATE_DEAD) { goto l_failed; } - cmd->resp_frame->normalRespFrame.respStatus = - PS3_DRV_MGR_BUSY; + cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; ret = -PS3_RESP_ERR; } goto l_failed; } + INJECT_START(PS3_ERR_IJ_V2_PCIE_ERR, instance); if (ps3_pci_err_recovery_get(instance)) { ret = -PS3_IN_PCIE_ERR; goto l_failed; @@ -1450,18 +1433,15 @@ int ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd) goto l_out; l_failed: - LOG_WARN_LIM( - "hno:%u, tid:0x%llx CFID:%u type:%d state:%d send check ret:%d\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - PS3_MGR_CMD_TYPE(cmd), cur_state, ret); + LOG_WARN_LIM("hno:%u, tid:0x%llx CFID:%u type:%d state:%d send check ret:%d\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, PS3_MGR_CMD_TYPE(cmd), cur_state, ret); l_out: return ret; } -void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, - unsigned char bit_pos) +void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, U8 bit_pos) { - unsigned int i = 0; + U32 i = 0; struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_cmd_context *cmd_context = &instance->cmd_context; struct ps3_debug_context *debug_context = &instance->debug_context; @@ -1470,192 +1450,150 @@ void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, struct ps3_sas_dev_context *ps3_sas_ctx = &instance->sas_dev_context; struct ps3_cmd *cmd = NULL; - irq_context->reply_fifo_desc_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, irq_context->reply_fifo_desc_buf_phys); - irq_context->reply_fifo_desc_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + irq_context->reply_fifo_desc_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, + irq_context->reply_fifo_desc_buf_phys); + irq_context->reply_fifo_desc_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, irq_context->reply_fifo_desc_buf_phys); for (; i < irq_context->valid_msix_vector_count; i++) { irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, irq_context->reply_fifo_desc_buf[i] - .ReplyFifoBaseAddr); - irq_context->reply_fifo_desc_buf[i] - .ReplyFifoBaseAddr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr); + irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr = + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr); + irq_context->reply_fifo_phys_base_addr_buf[i] = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, + irq_context->reply_fifo_phys_base_addr_buf[i]); irq_context->reply_fifo_phys_base_addr_buf[i] = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, - irq_context->reply_fifo_phys_base_addr_buf[i]); - irq_context->reply_fifo_phys_base_addr_buf[i] = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, - irq_context->reply_fifo_phys_base_addr_buf[i]); - } - cmd_context->init_frame_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, cmd_context->init_frame_buf_phys); - cmd_context->init_frame_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, cmd_context->init_frame_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + irq_context->reply_fifo_phys_base_addr_buf[i]); + } + cmd_context->init_frame_buf_phys = + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->init_frame_buf_phys); + cmd_context->init_frame_buf_phys = + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + cmd_context->init_frame_buf_phys); cmd_context->init_filter_table_phy_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, cmd_context->init_filter_table_phy_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->init_filter_table_phy_addr); cmd_context->init_filter_table_phy_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, cmd_context->init_filter_table_phy_addr); if (cmd_context->init_frame_sys_info_buf != NULL) { cmd_context->init_frame_sys_info_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, cmd_context->init_frame_sys_info_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->init_frame_sys_info_phys); cmd_context->init_frame_sys_info_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, - cmd_context->init_frame_sys_info_phys); - } - instance->ctrl_info_buf_h = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, instance->ctrl_info_buf_h); - instance->ctrl_info_buf_h = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, instance->ctrl_info_buf_h); - cmd_context->req_frame_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, cmd_context->req_frame_buf_phys); - cmd_context->req_frame_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, cmd_context->req_frame_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + cmd_context->init_frame_sys_info_phys); + } + instance->ctrl_info_buf_h = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->ctrl_info_buf_h); + instance->ctrl_info_buf_h = + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->ctrl_info_buf_h); + cmd_context->req_frame_buf_phys = + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->req_frame_buf_phys); + cmd_context->req_frame_buf_phys = + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, cmd_context->req_frame_buf_phys); cmd_context->response_frame_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, cmd_context->response_frame_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->response_frame_buf_phys); cmd_context->response_frame_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, cmd_context->response_frame_buf_phys); for (i = 0; i < cmd_context->max_cmd_count; i++) { cmd = cmd_context->cmd_buf[i]; if (cmd->ext_buf != NULL) { - cmd->ext_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, cmd->ext_buf_phys); - cmd->ext_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, cmd->ext_buf_phys); + cmd->ext_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd->ext_buf_phys); + cmd->ext_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + cmd->ext_buf_phys); } } if (debug_context->debug_mem_buf != NULL) { debug_context->debug_mem_buf_phy = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, debug_context->debug_mem_buf_phy); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, debug_context->debug_mem_buf_phy); debug_context->debug_mem_buf_phy = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, debug_context->debug_mem_buf_phy); for (i = 0; i < debug_context->debug_mem_array_num; i++) { + debug_context->debug_mem_buf[i].debugMemAddr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, + debug_context->debug_mem_buf[i].debugMemAddr); debug_context->debug_mem_buf[i].debugMemAddr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, debug_context->debug_mem_buf[i] - .debugMemAddr); - debug_context->debug_mem_buf[i].debugMemAddr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, - debug_context->debug_mem_buf[i] - .debugMemAddr); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + debug_context->debug_mem_buf[i].debugMemAddr); } } if (dump_context->dump_dma_buf != NULL) { dump_context->dump_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, dump_context->dump_dma_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dump_context->dump_dma_addr); dump_context->dump_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dump_context->dump_dma_addr); } - instance->drv_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, instance->drv_info_buf_phys); - instance->drv_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, instance->drv_info_buf_phys); - instance->host_mem_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, instance->host_mem_info_buf_phys); - instance->host_mem_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, instance->host_mem_info_buf_phys); + instance->drv_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->drv_info_buf_phys); + instance->drv_info_buf_phys = + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->drv_info_buf_phys); + instance->host_mem_info_buf_phys = + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->host_mem_info_buf_phys); + instance->host_mem_info_buf_phys = + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + instance->host_mem_info_buf_phys); if (dev_context->pd_list_buf != NULL) { dev_context->pd_list_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, dev_context->pd_list_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->pd_list_buf_phys); dev_context->pd_list_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dev_context->pd_list_buf_phys); } if (dev_context->pd_info_buf != NULL) { dev_context->pd_info_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, dev_context->pd_info_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->pd_info_buf_phys); dev_context->pd_info_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dev_context->pd_info_buf_phys); } if (dev_context->vd_list_buf != NULL) { dev_context->vd_list_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, dev_context->vd_list_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->vd_list_buf_phys); dev_context->vd_list_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dev_context->vd_list_buf_phys); } if (dev_context->vd_info_buf_sync != NULL) { dev_context->vd_info_buf_phys_sync = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, dev_context->vd_info_buf_phys_sync); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->vd_info_buf_phys_sync); dev_context->vd_info_buf_phys_sync = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dev_context->vd_info_buf_phys_sync); } if (dev_context->vd_info_buf_async != NULL) { dev_context->vd_info_buf_phys_async = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, dev_context->vd_info_buf_phys_async); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->vd_info_buf_phys_async); dev_context->vd_info_buf_phys_async = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dev_context->vd_info_buf_phys_async); } if (ps3_sas_ctx->ps3_sas_buff != NULL) { ps3_sas_ctx->ps3_sas_buff_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, ps3_sas_ctx->ps3_sas_buff_dma_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ps3_sas_ctx->ps3_sas_buff_dma_addr); ps3_sas_ctx->ps3_sas_buff_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ps3_sas_ctx->ps3_sas_buff_dma_addr); } if (ps3_sas_ctx->ps3_sas_phy_buff != NULL) { ps3_sas_ctx->ps3_sas_phy_buff_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, - ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); ps3_sas_ctx->ps3_sas_phy_buff_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); } - instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, instance->so_start_addr); - instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, instance->so_start_addr); - instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, instance->so_end_addr); - instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, instance->so_end_addr); + instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->so_start_addr); + instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + instance->so_start_addr); + instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->so_end_addr); + instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->so_end_addr); } -unsigned char ps3_bit_pos_update(struct ps3_instance *instance) +Bool ps3_bit_pos_update(struct ps3_instance *instance) { - unsigned char old_bit_pos = instance->dma_addr_bit_pos; - unsigned char bit_pos = 0; - unsigned char ret = PS3_FALSE; + U8 old_bit_pos = instance->dma_addr_bit_pos; + U8 bit_pos = 0; + Bool ret = PS3_FALSE; if (!ps3_ioc_atu_support_retry_read(instance, &bit_pos)) goto l_out; @@ -1672,7 +1610,7 @@ unsigned char ps3_bit_pos_update(struct ps3_instance *instance) break; default: LOG_WARN("hno:%u bit pos value is unexpect %u\n", - PS3_HOST(instance), bit_pos); + PS3_HOST(instance), bit_pos); goto l_out; } mb(); /* in order to force CPU ordering */ @@ -1681,9 +1619,10 @@ unsigned char ps3_bit_pos_update(struct ps3_instance *instance) goto l_out; } ps3_dma_addr_bit_pos_update(instance, old_bit_pos); - LOG_WARN("hno:%u bit pos %u change to %u\n", PS3_HOST(instance), - old_bit_pos, instance->dma_addr_bit_pos); + LOG_WARN("hno:%u bit pos %u change to %u\n", + PS3_HOST(instance), old_bit_pos, instance->dma_addr_bit_pos); ret = PS3_TRUE; l_out: return ret; } + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.h b/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.h index 1a55bc0c8284..932ed3cd43cf 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_CMD_CHANNEL_H_ #define _PS3_CMD_CHANNEL_H_ @@ -21,31 +20,31 @@ #define PS3_WAIT_SCSI_CMD_DONE_COUNT (1200) enum { - DMA_ALIGN_BYTES_4K = 4096, - DMA_ALIGN_BYTES_2K = 2048, - DMA_ALIGN_BYTES_1K = 1024, - DMA_ALIGN_BYTES_512 = 512, - DMA_ALIGN_BYTES_256 = 256, - DMA_ALIGN_BYTES_128 = 128, - DMA_ALIGN_BYTES_64 = 64, - DMA_ALIGN_BYTES_16 = 16, - DMA_ALIGN_BYTES_4 = 4, + DMA_ALIGN_BYTES_4K = 4096, + DMA_ALIGN_BYTES_2K = 2048, + DMA_ALIGN_BYTES_1K = 1024, + DMA_ALIGN_BYTES_512 = 512, + DMA_ALIGN_BYTES_256 = 256, + DMA_ALIGN_BYTES_128 = 128, + DMA_ALIGN_BYTES_64 = 64, + DMA_ALIGN_BYTES_16 = 16, + DMA_ALIGN_BYTES_4 = 4, }; enum { - PS3_CMD_STATE_INIT = 0, - PS3_CMD_STATE_PROCESS = 1, - PS3_CMD_STATE_COMPLETE = 2, - PS3_CMD_STATE_DEAD = 3, + PS3_CMD_STATE_INIT = 0, + PS3_CMD_STATE_PROCESS = 1, + PS3_CMD_STATE_COMPLETE = 2, + PS3_CMD_STATE_DEAD = 3, }; enum { - PS3_CMD_FLAG_SOFTRESET = 1, - PS3_CMD_FLAG_HARDRESET = 2, + PS3_CMD_FLAG_SOFTRESET = 1, + PS3_CMD_FLAG_HARDRESET = 2, }; enum { - PS3_R1X_MODE_NORMAL = 0, - PS3_R1X_MODE_PERF = 1, + PS3_R1X_MODE_NORMAL = 0, + PS3_R1X_MODE_PERF = 1, }; #define PS3_CMD_EXT_BUF_DEFAULT_SIZE (4096) @@ -53,105 +52,108 @@ enum { #define PS3_MIN_SCSI_CMD_COUNT (4096) -static inline const char *namePS3CmdState(unsigned int s) +static inline const S8 *namePS3CmdState(U32 s) { - static const char * const myNames[] = { - [PS3_CMD_STATE_INIT] = "PS3_CMD_STATE_INIT", - [PS3_CMD_STATE_PROCESS] = "PS3_CMD_STATE_PROCESS", - [PS3_CMD_STATE_COMPLETE] = "PS3_CMD_STATE_COMPLETE", - [PS3_CMD_STATE_DEAD] = "PS3_CMD_STATE_DEAD" + static const S8 *myNames[] = { + [PS3_CMD_STATE_INIT] = "PS3_CMD_STATE_INIT", + [PS3_CMD_STATE_PROCESS] = "PS3_CMD_STATE_PROCESS", + [PS3_CMD_STATE_COMPLETE] = "PS3_CMD_STATE_COMPLETE", + [PS3_CMD_STATE_DEAD] = "PS3_CMD_STATE_DEAD" }; - if (s > PS3_CMD_STATE_DEAD) + if (s > PS3_CMD_STATE_DEAD) { return "PS3_CMD_STATE_INVALID"; + } return myNames[s]; } struct ps3_cmd_state_t { - unsigned char state; - unsigned char reset_flag; - unsigned char reserived[6]; - spinlock_t lock; -}; -union ps3_scsi_cdb_option { - struct { - unsigned char non_ncq : 1; - unsigned char reserved0 : 1; - unsigned char reserved1 : 1; - unsigned char fua : 1; - unsigned char dpo : 1; - unsigned char protect : 3; - }; - unsigned char option; + U8 state; + U8 reset_flag; + U8 reserived[6]; + ps3_spinlock lock; }; - -struct ps3_scsi_io_attr { - unsigned char is_retry_cmd; - unsigned char direct_flag; - unsigned char seq_flag; - unsigned char dev_type; - union { - struct { - unsigned char rw_flag : 7; - unsigned char is_confilct_check : 1; +typedef union ps3_scsi_cdb_option { + struct { + U8 non_ncq : 1; + U8 reserved0 : 1; + U8 reserved1 : 1; + U8 fua : 1; + U8 dpo : 1; + U8 protect : 3; + }; + U8 option; +} ps3_scsi_cdb_opts_u; + +struct ps3_scsi_io_attr +{ + Bool is_retry_cmd; + U8 direct_flag; + U8 seq_flag; + U8 dev_type; + union + { + struct{ + U8 rw_flag : 7; + U8 is_confilct_check : 1; }; - unsigned char rw_type; + U8 rw_type; }; - unsigned int num_blocks; - unsigned int lba_lo; - unsigned int lba_hi; + U32 num_blocks; + U32 lba_lo; + U32 lba_hi; const struct ps3_pd_entry *pd_entry; const struct ps3_pd_entry *peer_pd_entry; const struct PS3VDEntry *vd_entry; - unsigned long long plba; - unsigned long long plba_back; - unsigned char span_idx; - unsigned char span_pd_idx; - unsigned short disk_id; - unsigned char is_use_frontend_prp; - unsigned char span_pd_idx_p; - unsigned char span_pd_idx_q; - unsigned char is_force_normal : 1; - unsigned char reserved : 7; - union ps3_scsi_cdb_option cdb_opts; - unsigned char cdb[PS3_FRAME_CDB_BUFLEN]; - unsigned int sgl_buf_len; - unsigned int reserved1; + U64 plba; + U64 plba_back; + U8 span_idx; + U8 span_pd_idx; + U16 disk_id; + Bool is_use_frontend_prp; + U8 span_pd_idx_p; + U8 span_pd_idx_q; + U8 is_force_normal:1; + U8 reserved:7; + ps3_scsi_cdb_opts_u cdb_opts; + U8 cdb[PS3_FRAME_CDB_BUFLEN]; + U32 sgl_buf_len; + U32 reserved1; }; struct ps3_ioctl_transient { - unsigned short sge_num; - unsigned char reserved[6]; + U16 sge_num; + U8 reserved[6]; void *transient_buff[PS3_MAX_IOCTL_SGE_NUM]; }; #define PS3_QOS_MAX_PD_IN_VD (17) struct ps3_qos_member_pd_info { - unsigned short flat_disk_id; - unsigned short strip_count; - unsigned char get_quota; + U16 flat_disk_id; + U16 strip_count; + Bool get_quota; }; #define PS3_QOS_MAX_CMDQ_ONE_CMD 2 struct ps3_qos_cmdq_info { - unsigned char que_id; - unsigned char get_rc; + U8 que_id; + Bool get_rc; }; struct ps3_cmd { union PS3ReqFrame *req_frame; - unsigned long long req_frame_phys; + U64 req_frame_phys; void *ext_buf; - unsigned long long ext_buf_phys; - union PS3RespFrame *resp_frame; - unsigned long long resp_frame_phys; + U64 ext_buf_phys; + PS3RespFrame_u *resp_frame; + U64 resp_frame_phys; struct ps3_instance *instance; union { struct PS3CmdWord cmd_word; struct PS3InitCmdWord init_cmd_word; - unsigned long long cmd_word_value; + U64 cmd_word_value; }; struct scsi_cmnd *scmd; @@ -159,38 +161,37 @@ struct ps3_cmd { #ifndef _WINDOWS struct list_head cmd_list; #else - SCSI_REQUEST_BLOCK * srb; - struct list_head cmd_list; + SCSI_REQUEST_BLOCK *srb; + ps3_list_head cmd_list; #endif - unsigned long long trace_id; - unsigned short index; - unsigned char no_reply_word; - unsigned char is_force_polling; - unsigned char is_got_r1x; - unsigned char is_inserted_c_q; - unsigned char is_r1x_aborting; - unsigned char is_r1x_scsi_complete; - unsigned short r1x_read_pd; + U64 trace_id; + U16 index; + U8 no_reply_word; + U8 is_force_polling; + U8 is_got_r1x; + U8 is_inserted_c_q; + U8 is_r1x_aborting; + Bool is_r1x_scsi_complete; + U16 r1x_read_pd; struct ps3_cmd *r1x_peer_cmd; - unsigned char is_aborting; - unsigned char r1x_reply_flag; - unsigned char qos_processing; - unsigned int os_sge_map_count; + U8 is_aborting; + U8 r1x_reply_flag; + U8 qos_processing; + U32 os_sge_map_count; struct ps3_cmd_state_t cmd_state; - unsigned short time_out; - unsigned char is_interrupt; - unsigned char szblock_cnt; - unsigned int retry_cnt; - void *node_buff; + U16 time_out; + Bool is_interrupt; + U8 szblock_cnt; + U32 retry_cnt; + void* node_buff; #ifdef _WINDOWS KEVENT sync_done; #else struct completion sync_done; #endif - int (*cmd_send_cb)(struct ps3_instance *, struct ps3_cmd *, - unsigned short); - int (*cmd_receive_cb)(struct ps3_cmd *cmd, unsigned short reply_flags); + S32 (*cmd_send_cb)(struct ps3_instance *, struct ps3_cmd *, U16 ); + S32 (*cmd_receive_cb)(struct ps3_cmd *, U16); struct ps3_ioctl_transient *transient; struct ps3_scsi_io_attr io_attr; #ifdef _WINDOWS @@ -201,51 +202,51 @@ struct ps3_cmd { struct list_head qos_list; struct ps3_qos_member_pd_info target_pd[PS3_QOS_MAX_PD_IN_VD]; struct ps3_qos_cmdq_info cmdq_info[PS3_QOS_MAX_CMDQ_ONE_CMD]; - unsigned short target_pd_count; - unsigned short first_over_quota_pd_idx; - unsigned char qos_waitq_flag; - unsigned char cmdq_count; - unsigned char flighting; + U16 target_pd_count; + U16 first_over_quota_pd_idx; + U8 qos_waitq_flag; + U8 cmdq_count; + Bool flighting; }; -struct ps3_cmd_context { - unsigned int max_cmd_count; - unsigned int max_scsi_cmd_count; - unsigned int max_mgr_cmd_count; - unsigned int max_prp_count; +struct ps3_cmd_context { + U32 max_cmd_count; + U32 max_scsi_cmd_count; + U32 max_mgr_cmd_count; + U32 max_prp_count; struct ps3_cmd **cmd_buf; - dma_addr_t init_frame_buf_phys; - unsigned char *init_frame_buf; - dma_addr_t init_filter_table_phy_addr; - unsigned char *init_filter_table_buff; + dma_addr_t init_frame_buf_phys; + U8 *init_frame_buf; + dma_addr_t init_filter_table_phy_addr; + U8 *init_filter_table_buff; #ifndef _WINDOWS - struct dma_pool *req_frame_dma_pool; + struct dma_pool* req_frame_dma_pool; #endif - unsigned int req_frame_buf_size; - dma_addr_t req_frame_buf_phys; - unsigned char *req_frame_buf; + U32 req_frame_buf_size; + dma_addr_t req_frame_buf_phys; + U8 *req_frame_buf; #ifndef _WINDOWS - struct dma_pool *response_frame_dma_pool; + struct dma_pool* response_frame_dma_pool; #endif - unsigned int response_frame_buf_size; - dma_addr_t response_frame_buf_phys; - unsigned char *response_frame_buf; + U32 response_frame_buf_size; + dma_addr_t response_frame_buf_phys; + U8 *response_frame_buf; #ifndef _WINDOWS - struct dma_pool *ext_buf_dma_pool; + struct dma_pool* ext_buf_dma_pool; #endif - unsigned int ext_buf_size; - unsigned int ext_sge_frame_count; + U32 ext_buf_size; + U32 ext_sge_frame_count; #ifndef _WINDOWS - struct dma_pool *mgr_ext_buf_dma_pool; + struct dma_pool* mgr_ext_buf_dma_pool; #endif - unsigned int mgr_ext_buf_size; + U32 mgr_ext_buf_size; - dma_addr_t init_frame_sys_info_phys; - unsigned char *init_frame_sys_info_buf; - unsigned char sgl_mode_support; - unsigned char reserved0[1]; - unsigned short max_host_sge_count; + dma_addr_t init_frame_sys_info_phys; + U8 *init_frame_sys_info_buf; + U8 sgl_mode_support; + U8 reserved0[1]; + U16 max_host_sge_count; #ifndef _WINDOWS struct list_head mgr_cmd_pool; @@ -255,100 +256,89 @@ struct ps3_cmd_context { spinlock_t task_pool_lock; spinlock_t r1x_scsi_pool_lock; #else - struct list_head mgr_cmd_pool; - struct list_head task_cmd_pool; - struct list_head scsi_cmd_pool; - spinlock_t mgr_pool_lock; - spinlock_t task_pool_lock; - spinlock_t scsi_pool_lock; - - atomic64_t trace_id; + ps3_list_head mgr_cmd_pool; + ps3_list_head task_cmd_pool; + ps3_list_head scsi_cmd_pool; + ps3_spinlock mgr_pool_lock; + ps3_spinlock task_pool_lock; + ps3_spinlock scsi_pool_lock; + + ps3_atomic64 trace_id; #endif - unsigned short max_r1x_cmd_count; - unsigned char reserved1[6]; + U16 max_r1x_cmd_count; + U8 reserved1[6]; }; -int ps3_cmd_context_init(struct ps3_instance *instance); +S32 ps3_cmd_context_init(struct ps3_instance *instance); void ps3_cmd_context_exit(struct ps3_instance *instance); #ifndef _WINDOWS -struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, - unsigned int tag); +struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, U32 tag); #else struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance); #endif -int ps3_scsi_cmd_free(struct ps3_cmd *cmd); +S32 ps3_scsi_cmd_free(struct ps3_cmd *cmd); struct ps3_cmd *ps3_mgr_cmd_alloc(struct ps3_instance *instance); -int ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd); -int ps3_mgr_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd); +S32 ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd); +S32 ps3_mgr_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd); struct ps3_cmd *ps3_task_cmd_alloc(struct ps3_instance *instance); -int ps3_task_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd); +S32 ps3_task_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd); -int ps3_reply_cmd_dispatcher(struct ps3_instance *instance, - unsigned short cmd_frame_id); +S32 ps3_reply_cmd_dispatcher(struct ps3_instance *instance, U16 cmd_frame_id); -int ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd); +S32 ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd); #ifndef _WINDOWS -int ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, - unsigned char need_prk_err); +S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, Bool need_prk_err); #endif -struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, - unsigned short cmd_frame_id); +struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, U16 cmd_frame_id); -int ps3_cmd_dispatch(struct ps3_instance *instance, unsigned short cmd_frame_id, - struct PS3ReplyWord *reply_word); +S32 ps3_cmd_dispatch(struct ps3_instance *instance, U16 cmd_frame_id, + struct PS3ReplyWord *reply_word); -struct ps3_cmd *ps3_r1x_peer_cmd_alloc(struct ps3_instance *instance, - unsigned int index); +struct ps3_cmd *ps3_r1x_peer_cmd_alloc(struct ps3_instance *instance, U32 index); -unsigned char ps3_r1x_peer_cmd_free_nolock(struct ps3_cmd *cmd); +Bool ps3_r1x_peer_cmd_free_nolock(struct ps3_cmd *cmd); -static inline unsigned short ps3_cmd_frame_id(struct ps3_cmd *cmd) +static inline U16 ps3_cmd_frame_id(struct ps3_cmd *cmd) { return cmd->index; } -static inline unsigned long long ps3_cmd_trace_id(struct ps3_cmd *cmd) +static inline U64 ps3_cmd_trace_id(struct ps3_cmd *cmd) { return cmd->trace_id; } -static inline void ps3_cmd_trace_id_replace(struct ps3_cmd *cmd, - unsigned long long trace_id) +static inline void ps3_cmd_trace_id_replace(struct ps3_cmd *cmd, U64 trace_id) { cmd->trace_id = trace_id; } -unsigned char -ps3_is_instance_state_allow_cmd_execute(struct ps3_instance *instance); +Bool ps3_is_instance_state_allow_cmd_execute(struct ps3_instance *instance); -int ps3_cmd_send_pre_check(struct ps3_instance *instance); +S32 ps3_cmd_send_pre_check(struct ps3_instance *instance); -void ps3_wait_scsi_cmd_done(struct ps3_instance *instance, - unsigned char time_out); +void ps3_wait_scsi_cmd_done(struct ps3_instance *instance, Bool time_out); void ps3_scsi_cmd_deliver_get(struct ps3_instance *instance); void ps3_scsi_cmd_deliver_put(struct ps3_instance *instance); -void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, - unsigned char bit_pos); +void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, U8 bit_pos); -unsigned char ps3_bit_pos_update(struct ps3_instance *instance); +Bool ps3_bit_pos_update(struct ps3_instance *instance); -void ps3_wait_mgr_cmd_done(struct ps3_instance *instance, - unsigned char time_out); +void ps3_wait_mgr_cmd_done(struct ps3_instance *instance, Bool time_out); -int ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, - unsigned char no_check); +S32 ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, Bool no_check); -int ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd); +S32 ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.c b/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.c index 22270357cb9c..a14e2606ae07 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #ifdef _WINDOWS #else @@ -20,69 +19,68 @@ #include "ps3_ioc_manager.h" #include "ps3_scsi_cmd_err.h" -static inline unsigned char ps3_reply_word_is_valid(unsigned long long val); +static inline Bool ps3_reply_word_is_valid(U64 val); static inline void ps3_reply_word_next(struct ps3_irq *irq, - struct PS3ReplyWord **reply_word); -static int ps3_reply_fifo_traverse(struct ps3_irq *irq, - struct ps3_instance *instance, - struct PS3ReplyWord *reply_word, - int *completed_count); -static inline struct PS3ReplyWord *ps3_reply_word_query(struct ps3_irq *irq, - unsigned short idx); - -int ps3_cmd_complete(struct ps3_irq *irq) + struct PS3ReplyWord **reply_word); +static S32 ps3_reply_fifo_traverse(struct ps3_irq *irq, + struct ps3_instance *instance, struct PS3ReplyWord* reply_word, + S32 *completed_count); +static inline struct PS3ReplyWord* ps3_reply_word_query( + struct ps3_irq *irq, U16 idx); + +S32 ps3_cmd_complete(struct ps3_irq *irq) { - int ret = PS3_SUCCESS; - int completed_count = 0; + S32 ret = PS3_SUCCESS; + S32 completed_count = 0; struct PS3ReplyWord *reply_word = NULL; struct ps3_instance *instance = irq->instance; - int cur_state = PS3_INSTANCE_STATE_INIT; + S32 cur_state = PS3_INSTANCE_STATE_INIT; #ifndef _WINDOWS - LOG_DEBUG( - "hno:%u start isr_os:%d, name:%s sn:%d, en:%d, poll:%d, last_reply_idx:%d, is_busy:%d\n", - PS3_HOST(irq->instance), irq->irqNo, irq->name, irq->isrSN, - irq->is_enable_irq, irq->is_sched_irq_poll, - irq->last_reply_idx, atomic_read(&irq->is_busy)); + LOG_DEBUG("hno:%u start isr_os:%d, name:%s isr_sn:%d, " + "irq_enable:%d, irq_poll:%d, last_reply_idx:%d, is_busy:%d\n", + PS3_HOST(irq->instance), irq->irqNo, irq->name, + irq->isrSN, irq->is_enable_irq, irq->is_sched_irq_poll, + irq->last_reply_idx, atomic_read(&irq->is_busy)); #else - LOG_DEBUG("hno:%u start isr_os:%d, name:%s isr_sn:%d, last_reply_idx:%d, is_busy:%d\n", - PS3_HOST(irq->instance), irq->irqNo, irq->name, irq->isrSN, - irq->last_reply_idx, ps3_atomic_read(&irq->is_busy)); + LOG_DEBUG("hno:%u start isr_os:%d, name:%s isr_sn:%d, " + "last_reply_idx:%d, is_busy:%d\n", + PS3_HOST(irq->instance), irq->irqNo, irq->name, + irq->isrSN, irq->last_reply_idx, ps3_atomic_read(&irq->is_busy)); #endif cur_state = ps3_atomic_read(&instance->state_machine.state); - if (unlikely(cur_state == PS3_INSTANCE_STATE_QUIT)) { + if (unlikely (cur_state == PS3_INSTANCE_STATE_QUIT) ) { LOG_WARN_IN_IRQ(instance, "hno:%u instance state is quit\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } if (!ps3_irq_busy_add(irq)) { - LOG_INFO_IN_IRQ(instance, "hno:%u irq is_busy:%d\n", - PS3_HOST(instance), - ps3_atomic_read(&irq->is_busy)); + LOG_INFO_IN_IRQ(instance, "hno:%u irq is_busy:%d\n", PS3_HOST(instance), + ps3_atomic_read(&irq->is_busy)); goto l_out; } reply_word = ps3_reply_word_query(irq, irq->last_reply_idx); - if (!ps3_reply_word_is_valid(*(unsigned long long *)reply_word)) { + if (!ps3_reply_word_is_valid(*(U64*)reply_word)) { ps3_irq_busy_dec(irq); LOG_DEBUG("hno:%u reply_w:0x%llx last_reply_idx:%d\n", - PS3_HOST(instance), *(unsigned long long *)reply_word, - irq->last_reply_idx); + PS3_HOST(instance), *(U64*)reply_word, + irq->last_reply_idx); goto l_out; } - ret = ps3_reply_fifo_traverse(irq, instance, reply_word, - &completed_count); + ret = ps3_reply_fifo_traverse(irq, instance, + reply_word, &completed_count); if (ret == -PS3_IN_IRQ_POLLING) { ps3_irq_busy_dec(irq); LOG_DEBUG("hno:%u reply in irq polling:%d\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } if (completed_count != 0) { - wmb(); /* in order to force CPU ordering */ + wmb(); #ifndef _WINDOWS ps3_can_queue_depth_update(instance); #endif @@ -90,53 +88,53 @@ int ps3_cmd_complete(struct ps3_irq *irq) ps3_irq_busy_dec(irq); #ifndef _WINDOWS - LOG_DEBUG( - "hno:%u end isr_os:%d, name:%s sn:%d, en:%d, poll:%d, lastidx:%d, count:%d, is_busy:%d\n", - PS3_HOST(instance), irq->irqNo, irq->name, irq->isrSN, - irq->is_enable_irq, irq->is_sched_irq_poll, irq->last_reply_idx, - completed_count, atomic_read(&irq->is_busy)); + LOG_DEBUG("hno:%u end isr_os:%d, name:%s isr_sn:%d, " + "irq_enable:%d, irq_poll:%d, last_reply_idx:%d, complete_count:%d, is_busy:%d\n", + PS3_HOST(instance), irq->irqNo, irq->name, irq->isrSN, + irq->is_enable_irq, irq->is_sched_irq_poll, irq->last_reply_idx, + completed_count, atomic_read(&irq->is_busy)); #else - LOG_DEBUG( - "hno:%u end isr_os:%d, name:%s sn:%d, irq_enable:%d, complete_count:%d, is_busy:%d\n", - PS3_HOST(instance), irq->irqNo, irq->name, irq->isrSN, - irq->last_reply_idx, completed_count, - ps3_atomic_read(&irq->is_busy)); + LOG_DEBUG("hno:%u end isr_os:%d, name:%s isr_sn:%d, " + "irq_enable:%d, complete_count:%d, is_busy:%d\n", + PS3_HOST(instance), irq->irqNo, irq->name, irq->isrSN, + irq->last_reply_idx, completed_count, ps3_atomic_read(&irq->is_busy)); #endif l_out: return completed_count; } -static inline struct PS3ReplyWord *ps3_reply_word_query(struct ps3_irq *irq, - unsigned short idx) +static inline struct PS3ReplyWord *ps3_reply_word_query( + struct ps3_irq *irq, U16 idx) { return irq->reply_fifo_virt_base_addr + idx; } -static inline unsigned char ps3_reply_word_is_valid(unsigned long long val) +static inline Bool ps3_reply_word_is_valid(U64 val) { - unsigned long long type = val & U64_MAX; - + U64 type = val & U64_MAX; return (type != U64_MAX); } static inline void ps3_reply_word_next(struct ps3_irq *irq, - struct PS3ReplyWord **reply_word) + struct PS3ReplyWord **reply_word) { - if (!irq->last_reply_idx) + if (!irq->last_reply_idx) { *reply_word = ps3_reply_word_query(irq, irq->last_reply_idx); - else + } else { ++(*reply_word); + } + return; } #ifndef _WINDOWS void ps3_trigger_irq_poll(struct ps3_irq *irq) { LOG_DEBUG("host_no:%u trigger irq_poll isrSN:%d\n", - PS3_HOST(irq->instance), irq->isrSN); + PS3_HOST(irq->instance), irq->isrSN); if (irq->is_sched_irq_poll) { LOG_DEBUG("host_no:%u irq_poll_is_processing is PS3_TRUE\n", - PS3_HOST(irq->instance)); + PS3_HOST(irq->instance)); goto l_out; } @@ -150,53 +148,48 @@ void ps3_trigger_irq_poll(struct ps3_irq *irq) void ps3_can_queue_depth_update(struct ps3_instance *instance) { - unsigned long flag = 0; - unsigned long time_threahold = 5; - int old_host_can_que = 0; + ULong flag = 0; + ULong time_threahold = 5; + S32 old_host_can_que = 0; if (instance->fault_context.ioc_busy && - time_after(jiffies, instance->fault_context.last_time + - time_threahold * HZ) && - (atomic_read(&instance->cmd_statistics.io_outstanding) < - (instance->cmd_attr.throttle_que_depth + 1))) { + time_after(jiffies, instance->fault_context.last_time + + time_threahold * HZ) && + (atomic_read(&instance->cmd_statistics.io_outstanding) < + (instance->cmd_attr.throttle_que_depth + 1))) { instance->fault_context.ioc_busy = PS3_FALSE; spin_lock_irqsave(instance->host->host_lock, flag); old_host_can_que = instance->host->can_queue; instance->host->can_queue = instance->cmd_attr.cur_can_que; spin_unlock_irqrestore(instance->host->host_lock, flag); - LOG_INFO( - "hno:%u old_can_queue:%d, cur_can_que:%d, ioc_busy:%d.\n", + LOG_INFO("hno:%u old_can_queue:%d, cur_can_que:%d, ioc_busy:%d.\n", PS3_HOST(instance), old_host_can_que, instance->cmd_attr.cur_can_que, instance->fault_context.ioc_busy); } + return ; } #endif -static int ps3_reply_fifo_traverse(struct ps3_irq *irq, - struct ps3_instance *instance, - struct PS3ReplyWord *reply_word, - int *completed_count) +static S32 ps3_reply_fifo_traverse(struct ps3_irq *irq, + struct ps3_instance *instance, struct PS3ReplyWord *reply_word, + S32 *completed_count) { - int ret = PS3_SUCCESS; - unsigned int reply_threshold_count = 0; - unsigned long long *r_word = NULL; - static unsigned short reply_word_size = sizeof(struct PS3ReplyWord); - - while (ps3_reply_word_is_valid(*(unsigned long long *)reply_word)) { - r_word = (unsigned long long *)reply_word; - LOG_DEBUG( - "hno:%u CFID:%d reply_word:0x%llx reply_f:%d reply_mode:%d rettype:%d\n", - PS3_HOST(instance), le16_to_cpu(reply_word->cmdFrameID), - *r_word, reply_word->retStatus, reply_word->mode, - reply_word->retType); + S32 ret = PS3_SUCCESS; + U32 reply_threshold_count = 0; + U64 *r_word = NULL; + static U16 reply_word_size = sizeof(struct PS3ReplyWord); + + while (ps3_reply_word_is_valid(*(U64*)reply_word)) { + r_word = (U64 *)reply_word; + LOG_DEBUG("hno:%u CFID:%d reply_word:0x%llx reply_f:%d reply_mode:%d rettype:%d\n", + PS3_HOST(instance), le16_to_cpu(reply_word->cmdFrameID), *r_word, + reply_word->retStatus, reply_word->mode, reply_word->retType); ret = ps3_cmd_dispatch(instance, - le16_to_cpu(reply_word->cmdFrameID), - reply_word); + le16_to_cpu(reply_word->cmdFrameID), + reply_word); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_IN_IRQ( - instance, - "host_no:%u CFID:%d dispatch cmd fail\n", + LOG_ERROR_IN_IRQ(instance, "host_no:%u CFID:%d dispatch cmd fail\n", PS3_HOST(instance), le16_to_cpu(reply_word->cmdFrameID)); } @@ -205,28 +198,27 @@ static int ps3_reply_fifo_traverse(struct ps3_irq *irq, ++(irq->last_reply_idx); if (irq->last_reply_idx >= - instance->irq_context.reply_fifo_depth) { - LOG_DEBUG("last_reply_idx = %d, depth=%d\n", - irq->last_reply_idx, - instance->irq_context.reply_fifo_depth); + instance->irq_context.reply_fifo_depth) { + LOG_DEBUG("last_reply_idx = %d, depth=%d\n", irq->last_reply_idx, + instance->irq_context.reply_fifo_depth); irq->last_reply_idx = 0; } - if (((++(*completed_count)) & (PS3_QOS_NOTIFY_CMD_COUNT - 1)) == - 0) { - ps3_qos_waitq_notify(instance); - } + if (((++(*completed_count)) & (PS3_QOS_NOTIFY_CMD_COUNT - 1)) == 0) { + ps3_qos_waitq_notify(instance); + } ++reply_threshold_count; ps3_reply_word_next(irq, &reply_word); - if (!ps3_reply_word_is_valid(*(unsigned long long *)reply_word)) + if (!ps3_reply_word_is_valid(*(U64*)reply_word)) { break; + } #ifndef _WINDOWS #ifdef CONFIG_IRQ_POLL if (reply_threshold_count >= irq->irq_poll_sched_threshold) { reply_threshold_count = 0; - wmb(); /* in order to force CPU ordering */ + wmb(); ps3_trigger_irq_poll(irq); ret = -PS3_IN_IRQ_POLLING; break; @@ -235,15 +227,16 @@ static int ps3_reply_fifo_traverse(struct ps3_irq *irq, #endif } - if (((*completed_count) & (PS3_QOS_NOTIFY_CMD_COUNT - 1)) > 0) + if (((*completed_count) & (PS3_QOS_NOTIFY_CMD_COUNT - 1)) > 0) { ps3_qos_waitq_notify(instance); + } return ret; } -int ps3_resp_status_convert(unsigned int resp_status) +S32 ps3_resp_status_convert(U32 resp_status) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; switch (resp_status) { case U8_MAX: @@ -260,49 +253,48 @@ int ps3_resp_status_convert(unsigned int resp_status) return ret; } -int ps3_cmd_reply_polling(struct ps3_instance *instance, struct ps3_cmd *cmd, - unsigned long timeout, unsigned char ignore) +S32 ps3_cmd_reply_polling(struct ps3_instance *instance, + struct ps3_cmd *cmd, ULong timeout, Bool ignore) { - const unsigned int seconds_to_msecs_unit = 1000; - const unsigned int step_size = 20; - const unsigned int read_fw_satus_period = 5000; - unsigned int local_resp_status = U8_MAX; - unsigned int msecs = U32_MAX; - unsigned int i = 0; - unsigned long flags = 0; - unsigned int time_out; - int cur_state = PS3_INSTANCE_STATE_INIT; - - time_out = max_t(unsigned long, cmd->time_out, timeout); - if (time_out != 0) + const U32 seconds_to_msecs_unit = 1000; + const U32 step_size = 20; + const U32 read_fw_satus_period = 5000; + U32 local_resp_status = U8_MAX; + U32 msecs = U32_MAX; + U32 i = 0; + ULong flags = 0; + U32 time_out; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + + time_out = max((ULong)cmd->time_out, timeout); + if (time_out != 0) { msecs = time_out * seconds_to_msecs_unit; + } - for (i = 0; - (i < msecs) && (cmd->resp_frame->normalRespFrame.respStatus == - PS3_SCSI_STATUS_MASK); - i += step_size) { - rmb(); /* in order to force CPU ordering */ + for (i = 0; (i < msecs) && + (cmd->resp_frame->normalRespFrame.respStatus == PS3_SCSI_STATUS_MASK); + i += step_size) { + rmb(); ps3_msleep(step_size); - if (i % read_fw_satus_period) + if (i % read_fw_satus_period) { continue; + } if (ignore) { - cur_state = - ps3_atomic_read(&instance->state_machine.state); - if (cur_state == PS3_INSTANCE_STATE_DEAD) + cur_state = ps3_atomic_read(&instance->state_machine.state); + if (cur_state == PS3_INSTANCE_STATE_DEAD) { break; + } } else { - if (!ps3_is_instance_state_allow_cmd_execute( - instance)) { + if (!ps3_is_instance_state_allow_cmd_execute(instance)) { break; } } } - local_resp_status = - le32_to_cpu(cmd->resp_frame->normalRespFrame.respStatus); - LOG_DEBUG("host_no:%u CFID:%d, respStatus:0x%x\n", PS3_HOST(instance), - cmd->index, local_resp_status); + local_resp_status = le32_to_cpu(cmd->resp_frame->normalRespFrame.respStatus); + LOG_DEBUG("host_no:%u CFID:%d, respStatus:0x%x\n", + PS3_HOST(instance), cmd->index, local_resp_status); if (local_resp_status != U8_MAX) { ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); @@ -312,37 +304,36 @@ int ps3_cmd_reply_polling(struct ps3_instance *instance, struct ps3_cmd *cmd, return ps3_resp_status_convert(local_resp_status); } -int ps3_cmd_reply_polling_when_recovery(struct ps3_instance *instance, - struct ps3_cmd *cmd, - unsigned long timeout) +S32 ps3_cmd_reply_polling_when_recovery(struct ps3_instance *instance, + struct ps3_cmd *cmd, ULong timeout) { - const unsigned int seconds_to_msecs_unit = 1000; - const unsigned int step_size = 20; - const unsigned int read_fw_satus_period = 5000; - unsigned int local_resp_status = U8_MAX; - unsigned int msecs = U32_MAX; - unsigned int i = 0; - unsigned long flags = 0; - unsigned int time_out; - - time_out = max_t(unsigned long, cmd->time_out, timeout); - if (time_out != 0) + const U32 seconds_to_msecs_unit = 1000; + const U32 step_size = 20; + const U32 read_fw_satus_period = 5000; + U32 local_resp_status = U8_MAX; + U32 msecs = U32_MAX; + U32 i = 0; + ULong flags = 0; + U32 time_out; + + time_out = max((ULong)cmd->time_out, timeout); + if (time_out != 0) { msecs = time_out * seconds_to_msecs_unit; + } - for (i = 0; - (i < msecs) && (cmd->resp_frame->normalRespFrame.respStatus == - PS3_SCSI_STATUS_MASK); - i += step_size) { - rmb(); /* in order to force CPU ordering */ + for (i = 0; (i < msecs) && + (cmd->resp_frame->normalRespFrame.respStatus == PS3_SCSI_STATUS_MASK); + i += step_size) { + rmb(); ps3_msleep(step_size); - if (i % read_fw_satus_period) + if (i % read_fw_satus_period) { continue; + } } - local_resp_status = - le32_to_cpu(cmd->resp_frame->normalRespFrame.respStatus); - LOG_DEBUG("host_no:%u CFID:%d, respStatus:0x%x\n", PS3_HOST(instance), - cmd->index, local_resp_status); + local_resp_status = le32_to_cpu(cmd->resp_frame->normalRespFrame.respStatus); + LOG_DEBUG("host_no:%u CFID:%d, respStatus:0x%x\n", + PS3_HOST(instance), cmd->index, local_resp_status); if (local_resp_status != U8_MAX) { ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); @@ -355,10 +346,12 @@ int ps3_cmd_reply_polling_when_recovery(struct ps3_instance *instance, void ps3_all_reply_fifo_complete(struct ps3_instance *instance) { - unsigned int i = 0; - + U32 i = 0; if (instance->irq_context.irqs == NULL) return; - for (; i < instance->irq_context.valid_msix_vector_count; ++i) + for (; i < instance->irq_context.valid_msix_vector_count; ++i) { (void)ps3_cmd_complete(instance->irq_context.irqs + i); + } + + return; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.h b/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.h index 13a024332cd1..b4fe4e1ebdca 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_CMD_COMPLETE_H_ #define _PS3_CMD_COMPLETE_H_ @@ -8,14 +7,13 @@ #include "ps3_instance_manager.h" #include "ps3_inner_data.h" -int ps3_cmd_complete(struct ps3_irq *irq); +S32 ps3_cmd_complete(struct ps3_irq *irq); -int ps3_cmd_reply_polling(struct ps3_instance *instance, struct ps3_cmd *cmd, - unsigned long timeout, unsigned char ignore); +S32 ps3_cmd_reply_polling(struct ps3_instance *instance, + struct ps3_cmd *cmd, ULong timeout, Bool ignore); -int ps3_cmd_reply_polling_when_recovery(struct ps3_instance *instance, - struct ps3_cmd *cmd, - unsigned long timeout); +S32 ps3_cmd_reply_polling_when_recovery(struct ps3_instance *instance, + struct ps3_cmd *cmd, ULong timeout); void ps3_all_reply_fifo_complete(struct ps3_instance *instance); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_stat_def.h b/drivers/scsi/linkdata/ps3stor/ps3_cmd_stat_def.h index aed423989c97..3db2a3767609 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_stat_def.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_stat_def.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_CMD_STAT_DEF_H_ #define _PS3_CMD_STAT_DEF_H_ @@ -12,7 +11,7 @@ #include "ps3_htp_def.h" #ifdef __cplusplus -extern "C" { +extern "C"{ #endif struct ps3_instance; @@ -49,76 +48,74 @@ enum ps3_cmd_stat_item { PS3_SCSI_ABORT, PS3_SCSI_DEVICE_RESET, PS3_SCSI_RETRY_CMD, - PS3_QOS_PD_PRO, - PS3_QOS_VD_PRO, - PS3_QOS_TAG_PRO, + PS3_QOS_PD_PRO, + PS3_QOS_VD_PRO, + PS3_QOS_TAG_PRO, PS3_QOS_MGR_PRO, PS3_QOS_CMD_PRO, PS3_QOS_PD_QUEUE, - PS3_QOS_VD_QUEUE, - PS3_QOS_TAG_QUEUE, + PS3_QOS_VD_QUEUE, + PS3_QOS_TAG_QUEUE, PS3_QOS_MGR_QUEUE, PS3_QOS_CMD_QUEUE, PS3_CMD_STAT_COUNT, }; -static inline const char * -ps3_cmd_stat_item_tostring(enum ps3_cmd_stat_item type) +static inline const S8 *ps3_cmd_stat_item_tostring(enum ps3_cmd_stat_item type) { - static const char * const itme_string[] = { - [PS3_SCSI_DRV_READ] = "scsi_drv_read", - [PS3_SCSI_DRV_WRITE] = "scsi_drv_write", - [PS3_SCSI_DRV_NORW] = "scsi_drv_norw", - [PS3_SCSI_DRV_ALL] = "scsi_drv_all", - [PS3_DRV_IOC_READ] = "scsi_drv_ioc_read", - [PS3_DRV_IOC_WRITE] = "scsi_drv_ioc_write", - [PS3_DRV_IOC_NORW] = "scsi_drv_ioc_norw", - [PS3_DRV_IOC_ALL] = "scsi_drv_ioc_all", - [PS3_DRV_IOC_VD_READ] = "scsi_drv_ioc_vd_read", - [PS3_DRV_IOC_VD_WRITE] = "scsi_drv_ioc_vd_write", - [PS3_DRV_IOC_VD_NORW] = "scsi_drv_ioc_vd_norw", - [PS3_DRV_IOC_PD_READ] = "scsi_drv_ioc_pd_read", - [PS3_DRV_IOC_PD_WRITE] = "scsi_drv_ioc_pd_write", - [PS3_DRV_IOC_PD_NORW] = "scsi_drv_ioc_pd_norw", - [PS3_DRV_IOC_VD_D_READ] = "scsi_drv_ioc_vd_d_read", - [PS3_DRV_IOC_VD_D_WRITE] = "scsi_drv_ioc_vd_d_write", - [PS3_DRV_IOC_PD_D_READ] = "scsi_drv_ioc_pd_d_read", - [PS3_DRV_IOC_PD_D_WRITE] = "scsi_drv_ioc_pd_d_write", - [PS3_DRV_IOC_MGR] = "mgr_drv_ioc_cmd", - [PS3_SCSI_ABORT] = "task_abort", - [PS3_SCSI_DEVICE_RESET] = "task_reset", - [PS3_SCSI_RETRY_CMD] = "scsi_retry_cmd", - [PS3_QOS_PD_PRO] = "qos_pd_pro", - [PS3_QOS_VD_PRO] = "qos_vd_pro", - [PS3_QOS_TAG_PRO] = "qos_tag_pro", - [PS3_QOS_MGR_PRO] = "qos_mgr_pro", - [PS3_QOS_CMD_PRO] = "qos_cmd_pro", - [PS3_QOS_PD_QUEUE] = "qos_pd_queue", - [PS3_QOS_VD_QUEUE] = "qos_vd_queue", - [PS3_QOS_TAG_QUEUE] = "qos_tag_queue", - [PS3_QOS_MGR_QUEUE] = "qos_mgr_queue", - [PS3_QOS_CMD_QUEUE] = "qos_cmd_queue", - [PS3_CMD_STAT_COUNT] = "type_unknown", + static const S8 *itme_string[] = { + [PS3_SCSI_DRV_READ] = "scsi_drv_read", + [PS3_SCSI_DRV_WRITE] = "scsi_drv_write", + [PS3_SCSI_DRV_NORW] = "scsi_drv_norw", + [PS3_SCSI_DRV_ALL] = "scsi_drv_all", + [PS3_DRV_IOC_READ] = "scsi_drv_ioc_read", + [PS3_DRV_IOC_WRITE] = "scsi_drv_ioc_write", + [PS3_DRV_IOC_NORW] = "scsi_drv_ioc_norw", + [PS3_DRV_IOC_ALL] = "scsi_drv_ioc_all", + [PS3_DRV_IOC_VD_READ] = "scsi_drv_ioc_vd_read", + [PS3_DRV_IOC_VD_WRITE] = "scsi_drv_ioc_vd_write", + [PS3_DRV_IOC_VD_NORW] = "scsi_drv_ioc_vd_norw", + [PS3_DRV_IOC_PD_READ] = "scsi_drv_ioc_pd_read", + [PS3_DRV_IOC_PD_WRITE] = "scsi_drv_ioc_pd_write", + [PS3_DRV_IOC_PD_NORW] = "scsi_drv_ioc_pd_norw", + [PS3_DRV_IOC_VD_D_READ] = "scsi_drv_ioc_vd_d_read", + [PS3_DRV_IOC_VD_D_WRITE] = "scsi_drv_ioc_vd_d_write", + [PS3_DRV_IOC_PD_D_READ] = "scsi_drv_ioc_pd_d_read", + [PS3_DRV_IOC_PD_D_WRITE] = "scsi_drv_ioc_pd_d_write", + [PS3_DRV_IOC_MGR] = "mgr_drv_ioc_cmd", + [PS3_SCSI_ABORT] = "task_abort", + [PS3_SCSI_DEVICE_RESET] = "task_reset", + [PS3_SCSI_RETRY_CMD] = "scsi_retry_cmd", + [PS3_QOS_PD_PRO] = "qos_pd_pro", + [PS3_QOS_VD_PRO] = "qos_vd_pro", + [PS3_QOS_TAG_PRO] = "qos_tag_pro", + [PS3_QOS_MGR_PRO] = "qos_mgr_pro", + [PS3_QOS_CMD_PRO] = "qos_cmd_pro", + [PS3_QOS_PD_QUEUE] = "qos_pd_queue", + [PS3_QOS_VD_QUEUE] = "qos_vd_queue", + [PS3_QOS_TAG_QUEUE] = "qos_tag_queue", + [PS3_QOS_MGR_QUEUE] = "qos_mgr_queue", + [PS3_QOS_CMD_QUEUE] = "qos_cmd_queue", + [PS3_CMD_STAT_COUNT] = "type_unknown", }; - return (type >= PS3_CMD_STAT_COUNT) ? "type_unknown" : - itme_string[type]; + return (type >= PS3_CMD_STAT_COUNT) ? "type_unknown" : itme_string[type]; } struct ps3_lagency_info { - unsigned long long start_time; - unsigned long long back_time; - unsigned long long avg; - unsigned long long max_lagency; - unsigned long long min_lagency; - unsigned long long all; + U64 start_time; + U64 back_time; + U64 avg; + U64 max_lagency; + U64 min_lagency; + U64 all; }; struct ps3_cmd_stat_entry { - unsigned long long start; - unsigned long long back_good; - unsigned long long back_err; - unsigned long long not_back; + U64 start; + U64 back_good; + U64 back_err; + U64 not_back; struct ps3_lagency_info lagency; }; @@ -137,16 +134,17 @@ struct ps3_single_cmd_stat { }; enum ps3_cmd_stat_switch_flag { - PS3_STAT_ALL_SWITCH_CLOSE = 0x00, + PS3_STAT_ALL_SWITCH_CLOSE = 0x00, PS3_STAT_OUTSTAND_SWITCH_OPEN = 0x01, - PS3_STAT_INC_SWITCH_OPEN = 0x02, - PS3_STAT_LOG_SWITCH_OPEN = 0x04, - PS3_STAT_DEV_SWITCH_OPEN = 0x08, - PS3_STAT_QOS_SWITCH_OPEN = 0x10, - PS3_STAT_ALL_SWITCH_OPEN = - (PS3_STAT_OUTSTAND_SWITCH_OPEN | PS3_STAT_INC_SWITCH_OPEN | - PS3_STAT_LOG_SWITCH_OPEN | PS3_STAT_DEV_SWITCH_OPEN | - PS3_STAT_QOS_SWITCH_OPEN), + PS3_STAT_INC_SWITCH_OPEN = 0x02, + PS3_STAT_LOG_SWITCH_OPEN = 0x04, + PS3_STAT_DEV_SWITCH_OPEN = 0x08, + PS3_STAT_QOS_SWITCH_OPEN = 0x10, + PS3_STAT_ALL_SWITCH_OPEN = (PS3_STAT_OUTSTAND_SWITCH_OPEN | + PS3_STAT_INC_SWITCH_OPEN | + PS3_STAT_LOG_SWITCH_OPEN | + PS3_STAT_DEV_SWITCH_OPEN | + PS3_STAT_QOS_SWITCH_OPEN), }; struct ps3_cmd_stat_wrokq_context { @@ -157,34 +155,34 @@ struct ps3_cmd_stat_wrokq_context { #else struct ps3_delay_worker statis_work; #endif - unsigned char is_stop; + Bool is_stop; }; struct ps3_cmd_statistics_context { - atomic_t cmd_outstanding; - atomic_t io_outstanding; - atomic_t vd_io_outstanding; - atomic_t cmd_delivering; - atomic_t scsi_cmd_delivering; - atomic64_t cmd_word_send_count; + ps3_atomic32 cmd_outstanding; + ps3_atomic32 io_outstanding; + ps3_atomic32 vd_io_outstanding; + ps3_atomic32 cmd_delivering; + ps3_atomic32 scsi_cmd_delivering; + ps3_atomic64 cmd_word_send_count; struct ps3_total_cmd_stat total_stat; struct ps3_total_cmd_stat inc_stat; struct ps3_single_cmd_stat **cmd_stat_backup_buf; struct ps3_single_cmd_stat **last_stat_buf; struct ps3_single_cmd_stat **cmd_stat_buf; - unsigned int stat_entry_max_count; - unsigned int stat_interval; + U32 stat_entry_max_count; + U32 stat_interval; struct ps3_cmd_stat_wrokq_context stat_workq; - unsigned char cmd_stat_switch; - unsigned char log_record_count; - atomic_t cli_cnt; - atomic_t cmd_qos_processing; - atomic64_t cmd_qos_total; - unsigned char reserved2[2]; + U8 cmd_stat_switch; + U8 log_record_count; + ps3_atomic32 cli_cnt; + ps3_atomic32 cmd_qos_processing; + ps3_atomic64 cmd_qos_total; + U8 reserved2[2]; }; #ifdef __cplusplus } #endif -#endif +#endif \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.c b/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.c index ac907e0ae370..227d6b72678b 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #ifndef _WINDOWS #include #endif @@ -7,60 +6,63 @@ #include "ps3_cmd_statistics.h" #include "ps3_cmd_channel.h" #include "ps3_driver_log.h" -#include "ps3_util.h" -static int ps3_cmd_stat_buf_alloc(struct ps3_instance *instance); +static S32 ps3_cmd_stat_buf_alloc(struct ps3_instance *instance); static void ps3_cmd_stat_buf_free(struct ps3_instance *instance); static inline void ps3_stat_data_collect(struct ps3_instance *instance); static void ps3_cmd_stat_content_init(struct ps3_instance *instance); static inline void ps3_stat_buf_init(struct ps3_instance *instance); static void ps3_dev_io_recv_bytes_stat_inc(struct ps3_instance *ins, - const struct ps3_cmd *cmd); -static int ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance); -static int ps3_last_stat_buf_alloc(struct ps3_instance *instance); + const struct ps3_cmd *cmd); +static S32 ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance); +static S32 ps3_last_stat_buf_alloc(struct ps3_instance *instance); static void ps3_cmd_stat_backup_buf_free(struct ps3_instance *instance); static void ps3_last_stat_buf_free(struct ps3_instance *instance); static inline void ps3_cmd_stat_backup_buf_init(struct ps3_instance *instance); static inline void ps3_last_stat_init(struct ps3_instance *instance); -int ps3_cmd_statistics_init(struct ps3_instance *instance) +S32 ps3_cmd_statistics_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; ps3_atomic_set(&instance->cmd_statistics.cmd_outstanding, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&instance->cmd_statistics.io_outstanding, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&instance->cmd_statistics.vd_io_outstanding, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&instance->cmd_statistics.cmd_delivering, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&instance->cmd_statistics.scsi_cmd_delivering, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); ps3_atomic64_set(&instance->cmd_statistics.cmd_word_send_count, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&instance->cmd_statistics.cmd_qos_total, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic_set(&instance->cmd_statistics.cmd_qos_processing, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&instance->cmd_statistics.cmd_qos_total, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&instance->cmd_statistics.cmd_qos_processing, + PS3_CMD_STAT_INIT_VALUE); ret = ps3_cmd_stat_buf_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_free_stat_buf; + } ret = ps3_cmd_stat_backup_buf_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_free_stat_buf; + } ret = ps3_last_stat_buf_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_free_stat_buf; + } ps3_cmd_stat_content_init(instance); ret = ps3_stat_workq_start(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_stop_workq; + } goto l_out; @@ -86,7 +88,6 @@ void ps3_cmd_statistics_exit(struct ps3_instance *instance) void ps3_cmd_stat_content_clear(struct ps3_instance *instance) { struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - memset(&ctx->total_stat, 0, sizeof(struct ps3_total_cmd_stat)); memset(&ctx->inc_stat, 0, sizeof(struct ps3_total_cmd_stat)); ps3_stat_buf_init(instance); @@ -104,45 +105,60 @@ static void ps3_cmd_stat_content_init(struct ps3_instance *instance) #ifdef PS3_CFG_RELEASE ctx->cmd_stat_switch = PS3_STAT_OUTSTAND_SWITCH_OPEN; #else - ctx->cmd_stat_switch = PS3_STAT_OUTSTAND_SWITCH_OPEN | - PS3_STAT_INC_SWITCH_OPEN | - PS3_STAT_QOS_SWITCH_OPEN; + ctx->cmd_stat_switch = PS3_STAT_OUTSTAND_SWITCH_OPEN | PS3_STAT_INC_SWITCH_OPEN + | PS3_STAT_QOS_SWITCH_OPEN; #endif } -static inline unsigned char ps3_cmd_is_vd(const struct ps3_cmd *cmd) +static inline Bool ps3_cmd_is_vd(const struct ps3_cmd *cmd) { return cmd->io_attr.dev_type == PS3_DEV_TYPE_VD; } void ps3_dev_io_statis_init(struct ps3_dev_io_statis *statis) { - ps3_atomic64_set(&statis->read_send_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_send_ok_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_send_wait_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_send_err_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_recv_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_recv_ok_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_recv_err_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_ok_bytes, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_send_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_send_ok_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_send_wait_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_send_err_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_recv_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_recv_ok_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_recv_err_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_ok_bytes, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->qos_processing_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_send_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_send_ok_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_send_wait_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_send_err_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_recv_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_recv_ok_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_recv_err_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_ok_bytes, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_send_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_send_ok_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_send_wait_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_send_err_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_recv_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_recv_ok_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_recv_err_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_ok_bytes, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->qos_processing_cnt, + PS3_CMD_STAT_INIT_VALUE); } void ps3_io_statis_inc(struct scsi_device *sdev, enum ps3_dev_io_stat_type type) { struct ps3_scsi_priv_data *data = NULL; - data = PS3_SDEV_PRI_DATA(sdev); - switch (type) { + switch(type) { case PS3_DEV_IO_STAT_TYPE_R_SEND: ps3_atomic64_inc(&data->statis.read_send_cnt); break; @@ -192,14 +208,12 @@ void ps3_io_statis_inc(struct scsi_device *sdev, enum ps3_dev_io_stat_type type) } static inline void ps3_io_statis_add(struct scsi_device *sdev, - enum ps3_dev_io_stat_type type, - unsigned long long offset) + enum ps3_dev_io_stat_type type, U64 offset) { struct ps3_scsi_priv_data *data = NULL; - data = PS3_SDEV_PRI_DATA(sdev); - switch (type) { + switch(type) { case PS3_DEV_IO_STAT_TYPE_R_OK_BYTES: ps3_atomic64_add(offset, &data->statis.read_ok_bytes); break; @@ -212,13 +226,13 @@ static inline void ps3_io_statis_add(struct scsi_device *sdev, } } -void ps3_io_statis_dec(struct scsi_device *sdev, enum ps3_dev_io_stat_type type) +void ps3_io_statis_dec(struct scsi_device *sdev, + enum ps3_dev_io_stat_type type) { struct ps3_scsi_priv_data *data = NULL; - data = PS3_SDEV_PRI_DATA(sdev); - switch (type) { + switch(type) { case PS3_DEV_IO_STAT_TYPE_R_SEND_WAIT: ps3_atomic64_dec(&data->statis.read_send_wait_cnt); break; @@ -245,17 +259,16 @@ void ps3_io_statis_clear(struct scsi_device *sdev) } void ps3_dev_io_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { - if (instance == NULL || cmd == NULL) + if (instance == NULL || cmd == NULL) { goto l_out; + } if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_R_SEND); + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_SEND); } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_W_SEND); + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_SEND); } l_out: @@ -263,17 +276,16 @@ void ps3_dev_io_start_inc(struct ps3_instance *instance, } void ps3_dev_io_start_err_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { - if (instance == NULL || cmd == NULL) + if (instance == NULL || cmd == NULL) { goto l_out; + } if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_R_SEND_ERR); + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_SEND_ERR); } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_W_SEND_ERR); + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_SEND_ERR); } l_out: @@ -281,17 +293,16 @@ void ps3_dev_io_start_err_inc(struct ps3_instance *instance, } void ps3_dev_io_start_ok_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { - if (instance == NULL || cmd == NULL) + if (instance == NULL || cmd == NULL) { goto l_out; + } if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_R_SEND_OK); + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_SEND_OK); } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_W_SEND_OK); + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_SEND_OK); } l_out: @@ -301,34 +312,32 @@ void ps3_dev_io_start_ok_inc(struct ps3_instance *instance, void ps3_dev_io_outstand_dec(const struct ps3_cmd *cmd) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_dec(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_R_SEND_WAIT); + ps3_io_statis_dec(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_SEND_WAIT); } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_dec(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_W_SEND_WAIT); + ps3_io_statis_dec(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_SEND_WAIT); } } -void ps3_dev_io_qos_inc(struct ps3_scsi_priv_data *priv_data) +void ps3_dev_io_qos_inc(struct ps3_scsi_priv_data* priv_data) { - ps3_atomic64_inc(&priv_data->statis.qos_processing_cnt); + ps3_atomic64_inc(&priv_data->statis.qos_processing_cnt); } -void ps3_dev_io_qos_dec(struct ps3_scsi_priv_data *priv_data) +void ps3_dev_io_qos_dec(struct ps3_scsi_priv_data* priv_data) { - ps3_atomic64_dec(&priv_data->statis.qos_processing_cnt); + ps3_atomic64_dec(&priv_data->statis.qos_processing_cnt); } void ps3_io_outstand_dec(struct ps3_instance *instance, - const struct scsi_cmnd *s_cmd) + const struct scsi_cmnd *s_cmd) { - if (instance == NULL || s_cmd == NULL) + if (instance == NULL || s_cmd == NULL) { goto l_out; + } ps3_atomic_dec(&instance->cmd_statistics.io_outstanding); - if ((instance->cmd_attr.vd_io_threshold != 0) && - ps3_is_vd_rw_cmd(s_cmd)) { + if((instance->cmd_attr.vd_io_threshold != 0) && ps3_is_vd_rw_cmd(s_cmd)) { ps3_atomic_dec(&instance->cmd_statistics.vd_io_outstanding); } @@ -336,21 +345,21 @@ void ps3_io_outstand_dec(struct ps3_instance *instance, return; } -void ps3_vd_outstand_dec(struct ps3_instance *instance, - const struct scsi_cmnd *s_cmd) +void ps3_vd_outstand_dec(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd) { struct ps3_scsi_priv_data *data = PS3_SDEV_PRI_DATA(s_cmd->device); struct PS3VDEntry *vd_entry = NULL; if (data->dev_type == PS3_DEV_TYPE_VD) { - vd_entry = ps3_dev_mgr_lookup_vd_info( - instance, s_cmd->device->channel, s_cmd->device->id); + vd_entry = ps3_dev_mgr_lookup_vd_info(instance, s_cmd->device->channel,\ + s_cmd->device->id); if (unlikely(vd_entry != NULL)) { if (ps3_is_read_cmd(s_cmd)) { atomic_dec(&data->rd_io_outstand); } else if (ps3_is_write_cmd(s_cmd)) { - if (!vd_entry->isNvme && !vd_entry->isSsd) + if (!vd_entry->isNvme && !vd_entry->isSsd) { atomic_dec(&data->wr_io_outstand); + } } } } @@ -359,78 +368,75 @@ void ps3_vd_outstand_dec(struct ps3_instance *instance, void ps3_dev_io_outstand_inc(const struct ps3_cmd *cmd) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_R_SEND_WAIT); + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_SEND_WAIT); } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_W_SEND_WAIT); + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_SEND_WAIT); } } -void ps3_vd_outstand_inc(struct ps3_instance *instance, - const struct scsi_cmnd *s_cmd) +void ps3_vd_outstand_inc(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd) { struct ps3_scsi_priv_data *data = PS3_SDEV_PRI_DATA(s_cmd->device); struct PS3VDEntry *vd_entry = NULL; if (data->dev_type == PS3_DEV_TYPE_VD) { - vd_entry = ps3_dev_mgr_lookup_vd_info( - instance, s_cmd->device->channel, s_cmd->device->id); + vd_entry = ps3_dev_mgr_lookup_vd_info(instance, s_cmd->device->channel,\ + s_cmd->device->id); if (unlikely(vd_entry != NULL)) { if (ps3_is_read_cmd(s_cmd)) { atomic_inc(&data->rd_io_outstand); } else if (ps3_is_write_cmd(s_cmd)) { - if (!vd_entry->isNvme && !vd_entry->isSsd) + if (!vd_entry->isNvme && !vd_entry->isSsd) { atomic_inc(&data->wr_io_outstand); + } } } } } void ps3_io_outstand_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { if (ps3_stat_outstand_switch_is_open(instance)) { ps3_atomic_inc(&instance->cmd_statistics.io_outstanding); if (ps3_is_vd_rw_cmd(cmd->scmd) && - (instance->cmd_attr.vd_io_threshold != 0)) { - ps3_atomic_inc( - &instance->cmd_statistics.vd_io_outstanding); + (instance->cmd_attr.vd_io_threshold != 0)) { + ps3_atomic_inc(&instance->cmd_statistics.vd_io_outstanding); } } + + return; } void ps3_io_recv_ok_stat_inc(struct ps3_instance *ins, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { - if (ins == NULL || cmd == NULL) + if (ins == NULL || cmd == NULL) { goto l_out; + } - if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_R_RECV_OK); - } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_W_RECV_OK); + if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)){ + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_RECV_OK); + } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)){ + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_RECV_OK); } l_out: return; } -void ps3_dev_io_back_inc(struct ps3_instance *ins, const struct ps3_cmd *cmd, - unsigned char status) +void ps3_dev_io_back_inc(struct ps3_instance *ins, + const struct ps3_cmd *cmd, U8 status) { - if (ins == NULL || cmd == NULL) + if (ins == NULL || cmd == NULL) { goto l_out; + } - if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_R_RECV); - } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_W_RECV); + if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)){ + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_RECV); + } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)){ + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_RECV); } if (status == PS3_REPLY_WORD_FLAG_SUCCESS) { @@ -443,19 +449,20 @@ void ps3_dev_io_back_inc(struct ps3_instance *ins, const struct ps3_cmd *cmd, } static void ps3_dev_io_recv_bytes_stat_inc(struct ps3_instance *ins, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { - if (ins == NULL || cmd == NULL || cmd->scmd == NULL) + if (ins == NULL || cmd == NULL || cmd->scmd == NULL) { goto l_out; + } - if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { + if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)){ ps3_io_statis_add(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_R_OK_BYTES, - scsi_bufflen(cmd->scmd)); - } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { + PS3_DEV_IO_STAT_TYPE_R_OK_BYTES, + scsi_bufflen(cmd->scmd)); + } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)){ ps3_io_statis_add(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_W_OK_BYTES, - scsi_bufflen(cmd->scmd)); + PS3_DEV_IO_STAT_TYPE_W_OK_BYTES, + scsi_bufflen(cmd->scmd)); } l_out: @@ -464,21 +471,24 @@ static void ps3_dev_io_recv_bytes_stat_inc(struct ps3_instance *ins, void ps3_qos_cmd_inc(struct ps3_instance *instance) { - ps3_atomic64_inc(&instance->cmd_statistics.cmd_qos_total); + ps3_atomic64_inc(&instance->cmd_statistics.cmd_qos_total); } static void ps3_cmd_stat_buf_free(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - if (ctx->cmd_stat_buf == NULL) + if (ctx->cmd_stat_buf == NULL) { goto l_out; + } for (; i < ctx->stat_entry_max_count; ++i) { - if (ctx->cmd_stat_buf[i] == NULL) + if (ctx->cmd_stat_buf[i] == NULL) { continue; + } ps3_kfree(instance, ctx->cmd_stat_buf[i]); ctx->cmd_stat_buf[i] = NULL; + } ps3_kfree(instance, ctx->cmd_stat_buf); @@ -487,16 +497,16 @@ static void ps3_cmd_stat_buf_free(struct ps3_instance *instance) return; } -static int ps3_cmd_stat_buf_alloc(struct ps3_instance *instance) +static S32 ps3_cmd_stat_buf_alloc(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int i = 0; + S32 ret = PS3_SUCCESS; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; ctx->stat_entry_max_count = instance->cmd_context.max_cmd_count; - ctx->cmd_stat_buf = (struct ps3_single_cmd_stat **)ps3_kzalloc( - instance, ctx->stat_entry_max_count * - sizeof(struct ps3_single_cmd_stat *)); + ctx->cmd_stat_buf = (struct ps3_single_cmd_stat**)ps3_kzalloc(instance, + ctx->stat_entry_max_count * sizeof(struct ps3_single_cmd_stat*)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC1, &ctx->cmd_stat_buf); if (ctx->cmd_stat_buf == NULL) { LOG_ERROR("failed to kcalloc for cmd_stat_buf\n"); ret = -PS3_FAILED; @@ -504,12 +514,11 @@ static int ps3_cmd_stat_buf_alloc(struct ps3_instance *instance) } for (; i < ctx->stat_entry_max_count; ++i) { - ctx->cmd_stat_buf[i] = - (struct ps3_single_cmd_stat *)ps3_kzalloc( - instance, sizeof(struct ps3_single_cmd_stat)); + ctx->cmd_stat_buf[i] = (struct ps3_single_cmd_stat*)ps3_kzalloc(instance, + sizeof(struct ps3_single_cmd_stat)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC2, &ctx->cmd_stat_buf[i]); if (ctx->cmd_stat_buf[i] == NULL) { - LOG_ERROR( - "Failed to alloc mem for ps3_single_cmd_stat\n"); + LOG_ERROR("Failed to alloc mem for ps3_single_cmd_stat\n"); ret = -PS3_FAILED; goto l_free_mem; } @@ -525,17 +534,20 @@ static int ps3_cmd_stat_buf_alloc(struct ps3_instance *instance) static void ps3_last_stat_buf_free(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - if (ctx->last_stat_buf == NULL) + if (ctx->last_stat_buf == NULL) { goto l_out; + } for (; i < ctx->stat_entry_max_count; ++i) { - if (ctx->last_stat_buf[i] == NULL) + if (ctx->last_stat_buf[i] == NULL) { continue; + } ps3_kfree(instance, ctx->last_stat_buf[i]); ctx->last_stat_buf[i] = NULL; + } ps3_kfree(instance, ctx->last_stat_buf); @@ -544,16 +556,16 @@ static void ps3_last_stat_buf_free(struct ps3_instance *instance) return; } -static int ps3_last_stat_buf_alloc(struct ps3_instance *instance) +static S32 ps3_last_stat_buf_alloc(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int i = 0; + S32 ret = PS3_SUCCESS; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; ctx->stat_entry_max_count = instance->cmd_context.max_cmd_count; - ctx->last_stat_buf = (struct ps3_single_cmd_stat **)ps3_kzalloc( - instance, ctx->stat_entry_max_count * - sizeof(struct ps3_single_cmd_stat *)); + ctx->last_stat_buf = (struct ps3_single_cmd_stat**)ps3_kzalloc(instance, + ctx->stat_entry_max_count * sizeof(struct ps3_single_cmd_stat*)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC1, &ctx->last_stat_buf); if (ctx->last_stat_buf == NULL) { LOG_ERROR("failed to kzalloc for last_stat_buf\n"); ret = -PS3_FAILED; @@ -561,12 +573,11 @@ static int ps3_last_stat_buf_alloc(struct ps3_instance *instance) } for (; i < ctx->stat_entry_max_count; ++i) { - ctx->last_stat_buf[i] = - (struct ps3_single_cmd_stat *)ps3_kzalloc( - instance, sizeof(struct ps3_single_cmd_stat)); + ctx->last_stat_buf[i] = (struct ps3_single_cmd_stat*)ps3_kzalloc(instance, + sizeof(struct ps3_single_cmd_stat)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC2, &ctx->last_stat_buf[i]); if (ctx->last_stat_buf[i] == NULL) { - LOG_ERROR( - "Failed to alloc mem for ps3_single_cmd_stat\n"); + LOG_ERROR("Failed to alloc mem for ps3_single_cmd_stat\n"); ret = -PS3_FAILED; goto l_free_mem; } @@ -580,38 +591,41 @@ static int ps3_last_stat_buf_alloc(struct ps3_instance *instance) return ret; } -static inline struct ps3_single_cmd_stat * -ps3_last_stat_entry_find(unsigned int index, struct ps3_instance *instance) +static inline struct ps3_single_cmd_stat* ps3_last_stat_entry_find(U32 index, + struct ps3_instance *instance) { return (index < instance->cmd_statistics.stat_entry_max_count) ? - instance->cmd_statistics.last_stat_buf[index] : - NULL; + instance->cmd_statistics.last_stat_buf[index] : NULL; } static inline void ps3_last_stat_init(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; for (; i < ctx->stat_entry_max_count; ++i) { - memset(ctx->last_stat_buf[i], 0, - sizeof(struct ps3_single_cmd_stat)); - mb(); /* in order to force CPU ordering */ + memset(ctx->last_stat_buf[i], 0, sizeof(struct ps3_single_cmd_stat)); + mb(); } + + return; } static void ps3_cmd_stat_backup_buf_free(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - if (ctx->cmd_stat_backup_buf == NULL) + if (ctx->cmd_stat_backup_buf == NULL) { goto l_out; + } for (; i < ctx->stat_entry_max_count; ++i) { - if (ctx->cmd_stat_backup_buf[i] == NULL) + if (ctx->cmd_stat_backup_buf[i] == NULL) { continue; + } ps3_kfree(instance, ctx->cmd_stat_backup_buf[i]); ctx->cmd_stat_backup_buf[i] = NULL; + } ps3_kfree(instance, ctx->cmd_stat_backup_buf); @@ -620,16 +634,16 @@ static void ps3_cmd_stat_backup_buf_free(struct ps3_instance *instance) return; } -static int ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance) +static S32 ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int i = 0; + S32 ret = PS3_SUCCESS; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; ctx->stat_entry_max_count = instance->cmd_context.max_cmd_count; - ctx->cmd_stat_backup_buf = (struct ps3_single_cmd_stat **)ps3_kzalloc( - instance, ctx->stat_entry_max_count * - sizeof(struct ps3_single_cmd_stat *)); + ctx->cmd_stat_backup_buf = (struct ps3_single_cmd_stat**)ps3_kzalloc(instance, + ctx->stat_entry_max_count * sizeof(struct ps3_single_cmd_stat*)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC1, &ctx->cmd_stat_backup_buf); if (ctx->cmd_stat_backup_buf == NULL) { LOG_ERROR("failed to kzalloc for cmd_stat_backup_buf\n"); ret = -PS3_FAILED; @@ -637,12 +651,11 @@ static int ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance) } for (; i < ctx->stat_entry_max_count; ++i) { - ctx->cmd_stat_backup_buf[i] = - (struct ps3_single_cmd_stat *)ps3_kzalloc( - instance, sizeof(struct ps3_single_cmd_stat)); + ctx->cmd_stat_backup_buf[i] = (struct ps3_single_cmd_stat*)ps3_kzalloc(instance, + sizeof(struct ps3_single_cmd_stat)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC2, &ctx->cmd_stat_backup_buf[i]); if (ctx->cmd_stat_backup_buf[i] == NULL) { - LOG_ERROR( - "Failed to alloc mem for ps3_single_cmd_stat\n"); + LOG_ERROR("Failed to alloc mem for ps3_single_cmd_stat\n"); ret = -PS3_FAILED; goto l_free_mem; } @@ -656,43 +669,44 @@ static int ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance) return ret; } -static inline struct ps3_single_cmd_stat * -ps3_backup_stat_entry_find(unsigned int index, struct ps3_instance *instance) +static inline struct ps3_single_cmd_stat* ps3_backup_stat_entry_find(U32 index, + struct ps3_instance *instance) { return (index < instance->cmd_statistics.stat_entry_max_count) ? - instance->cmd_statistics.cmd_stat_backup_buf[index] : - NULL; + instance->cmd_statistics.cmd_stat_backup_buf[index] : NULL; } static inline void ps3_cmd_stat_backup_buf_init(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; for (; i < ctx->stat_entry_max_count; ++i) { memset(ctx->cmd_stat_backup_buf[i], 0, - sizeof(struct ps3_single_cmd_stat)); - mb(); /* in order to force CPU ordering */ + sizeof(struct ps3_single_cmd_stat)); + mb(); } + + return; } -static inline struct ps3_single_cmd_stat * -ps3_stat_entry_find(unsigned int index, struct ps3_instance *instance) +static inline struct ps3_single_cmd_stat* ps3_stat_entry_find(U32 index, + struct ps3_instance *instance) { return (index < instance->cmd_statistics.stat_entry_max_count) ? - instance->cmd_statistics.cmd_stat_buf[index] : - NULL; + instance->cmd_statistics.cmd_stat_buf[index] : NULL; } static inline void ps3_stat_buf_init(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; for (; i < ctx->stat_entry_max_count; ++i) { - memset(ctx->cmd_stat_buf[i], 0, - sizeof(struct ps3_single_cmd_stat)); - mb(); /* in order to force CPU ordering */ + memset(ctx->cmd_stat_buf[i], 0, sizeof(struct ps3_single_cmd_stat)); + mb(); } + + return; } void ps3_stat_all_clear(struct ps3_instance *instance) @@ -700,14 +714,12 @@ void ps3_stat_all_clear(struct ps3_instance *instance) ps3_stat_buf_init(instance); ps3_cmd_stat_backup_buf_init(instance); ps3_last_stat_init(instance); - memset(&instance->cmd_statistics.total_stat, 0, - sizeof(struct ps3_total_cmd_stat)); - memset(&instance->cmd_statistics.inc_stat, 0, - sizeof(struct ps3_total_cmd_stat)); + memset(&instance->cmd_statistics.total_stat, 0, sizeof(struct ps3_total_cmd_stat)); + memset(&instance->cmd_statistics.inc_stat, 0, sizeof(struct ps3_total_cmd_stat)); } -static inline void ps3_stat_start_inc(unsigned short type, - struct ps3_single_cmd_stat *cmd_stat) +static inline void ps3_stat_start_inc(U16 type, + struct ps3_single_cmd_stat *cmd_stat) { if (type >= PS3_CMD_STAT_COUNT) { LOG_ERROR("type:%u overflow\n", type); @@ -723,68 +735,69 @@ static inline void ps3_stat_start_inc(unsigned short type, } static inline void ps3_stat_lagency_update(struct ps3_lagency_info *lagency, - unsigned long long start_time, - unsigned long long back_time) + U64 start_time, U64 back_time) { - unsigned long long intervals = back_time - start_time; + U64 intervals = back_time - start_time; lagency->all += intervals; - if (intervals > lagency->max_lagency) + if (intervals > lagency->max_lagency) { lagency->max_lagency = intervals; + } - if (intervals < lagency->min_lagency || lagency->min_lagency == 0) + if (intervals < lagency->min_lagency || lagency->min_lagency == 0) { lagency->min_lagency = intervals; + } + + return; } static inline void ps3_stat_lagency_merge(struct ps3_lagency_info *target, - const struct ps3_lagency_info *source) + const struct ps3_lagency_info *source) { target->all += source->all; - if (source->max_lagency > target->max_lagency) + if (source->max_lagency > target->max_lagency) { target->max_lagency = source->max_lagency; + } if ((source->min_lagency < target->min_lagency && - source->min_lagency != 0) || - target->min_lagency == 0) { + source->min_lagency != 0) || target->min_lagency == 0) { target->min_lagency = source->min_lagency; } + + return; } -static inline void -ps3_stat_lagency_avg_calc(struct ps3_total_cmd_stat *total_stat) +static inline void ps3_stat_lagency_avg_calc(struct ps3_total_cmd_stat *total_stat) { - unsigned long long back_count = 0; - unsigned short i = 0; + U64 back_count = 0; + U16 i = 0; - for (; i < PS3_CMD_STAT_COUNT; ++i) { + for(; i < PS3_CMD_STAT_COUNT; ++i) { back_count = total_stat->stat[i].back_good + - total_stat->stat[i].back_err; + total_stat->stat[i].back_err; if (back_count != 0) { - total_stat->stat[i].lagency.avg = PS3_DIV64_32( - total_stat->stat[i].lagency.all, back_count); + total_stat->stat[i].lagency.avg = + (total_stat->stat[i].lagency.all / back_count); } - mb(); /* in order to force CPU ordering */ + mb(); } } static inline void ps3_stat_lagency_inc_cal(struct ps3_lagency_info *inc, - const struct ps3_lagency_info *cur, - const struct ps3_lagency_info *last) + const struct ps3_lagency_info *cur, + const struct ps3_lagency_info *last) { inc->all += cur->all - last->all; inc->max_lagency = (cur->max_lagency > inc->max_lagency) ? - cur->max_lagency : - inc->max_lagency; - inc->min_lagency = ((cur->min_lagency < inc->min_lagency && - cur->min_lagency != 0) || - inc->min_lagency == 0) ? - cur->min_lagency : - inc->min_lagency; + cur->max_lagency : inc->max_lagency; + inc->min_lagency = ((cur->min_lagency < inc->min_lagency && cur->min_lagency != 0) + || inc->min_lagency == 0) ? cur->min_lagency : inc->min_lagency; + + return; } -static inline void ps3_stat_back_inc(unsigned short type, - struct ps3_single_cmd_stat *single_stat, - unsigned char status) +static inline void ps3_stat_back_inc(U16 type, + struct ps3_single_cmd_stat *single_stat, U8 status) { if (type >= PS3_CMD_STAT_COUNT) { LOG_ERROR("type:%u err\n", type); @@ -809,13 +822,13 @@ static inline void ps3_stat_back_inc(unsigned short type, } ps3_stat_lagency_update(&single_stat->stat[type].lagency, - single_stat->stat[type].lagency.start_time, - single_stat->stat[type].lagency.back_time); + single_stat->stat[type].lagency.start_time, + single_stat->stat[type].lagency.back_time); if (type == PS3_SCSI_ABORT) { LOG_WARN("start:%llu back:%llu all:%llu\n", - single_stat->stat[type].lagency.start_time, - single_stat->stat[type].lagency.back_time, - single_stat->stat[type].lagency.all); + single_stat->stat[type].lagency.start_time, + single_stat->stat[type].lagency.back_time, + single_stat->stat[type].lagency.all); } l_out: @@ -823,41 +836,39 @@ static inline void ps3_stat_back_inc(unsigned short type, } #ifndef _WINDOWS -static inline void ps3_scmd_start_inc(struct ps3_single_cmd_stat *stat_entry, - const struct scsi_cmnd *s_cmd) +static inline void ps3_scmd_start_inc(struct ps3_single_cmd_stat* stat_entry, + const struct scsi_cmnd *s_cmd) { - unsigned char type = - PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); - + U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); if (ps3_scsih_is_rw_type(type)) { - if (ps3_scsih_is_read_cmd(type)) + if (ps3_scsih_is_read_cmd(type)) { ps3_stat_start_inc(PS3_SCSI_DRV_READ, stat_entry); - else + } else { ps3_stat_start_inc(PS3_SCSI_DRV_WRITE, stat_entry); + } } else { ps3_stat_start_inc(PS3_SCSI_DRV_NORW, stat_entry); } ps3_stat_start_inc(PS3_SCSI_DRV_ALL, stat_entry); - if (s_cmd->retries != 0) + if (s_cmd->retries != 0) { ps3_stat_start_inc(PS3_SCSI_RETRY_CMD, stat_entry); + } + + return; } -static inline void ps3_scmd_back_inc(struct ps3_single_cmd_stat *stat_entry, - const struct scsi_cmnd *s_cmd, - unsigned char status) +static inline void ps3_scmd_back_inc(struct ps3_single_cmd_stat* stat_entry, + const struct scsi_cmnd *s_cmd, U8 status) { - unsigned char type = - PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); + U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); if (ps3_scsih_is_rw_type(type)) { if (ps3_scsih_is_read_cmd(type)) { - ps3_stat_back_inc(PS3_SCSI_DRV_READ, stat_entry, - status); + ps3_stat_back_inc(PS3_SCSI_DRV_READ, stat_entry, status); } else { - ps3_stat_back_inc(PS3_SCSI_DRV_WRITE, stat_entry, - status); + ps3_stat_back_inc(PS3_SCSI_DRV_WRITE, stat_entry, status); } } else { ps3_stat_back_inc(PS3_SCSI_DRV_NORW, stat_entry, status); @@ -865,14 +876,17 @@ static inline void ps3_scmd_back_inc(struct ps3_single_cmd_stat *stat_entry, ps3_stat_back_inc(PS3_SCSI_DRV_ALL, stat_entry, status); - if (s_cmd->retries != 0) + if (s_cmd->retries != 0) { ps3_stat_back_inc(PS3_SCSI_RETRY_CMD, stat_entry, status); + } + + return; } -void ps3_scmd_inc(struct ps3_instance *instance, struct scsi_cmnd *s_cmd, - unsigned char type, unsigned char status) +void ps3_scmd_inc(struct ps3_instance *instance, + struct scsi_cmnd *s_cmd, U8 type, U8 status) { - struct ps3_single_cmd_stat *stat_entry = NULL; + struct ps3_single_cmd_stat* stat_entry = NULL; if (s_cmd == NULL) { LOG_ERROR("scsi cmd is null\n"); @@ -884,68 +898,68 @@ void ps3_scmd_inc(struct ps3_instance *instance, struct scsi_cmnd *s_cmd, goto l_out; } - stat_entry = - ps3_stat_entry_find(SCMD_GET_REQUEST(s_cmd)->tag, instance); + stat_entry = ps3_stat_entry_find(SCMD_GET_REQUEST(s_cmd)->tag, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u CFID:%u stat entry find fail\n", - PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag); + PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag); goto l_out; } - if (type == PS3_STAT_START) + if (type == PS3_STAT_START) { ps3_scmd_start_inc(stat_entry, s_cmd); - else if (type == PS3_STAT_BACK) + } else if (type == PS3_STAT_BACK) { ps3_scmd_back_inc(stat_entry, s_cmd, status); - else + } else { LOG_ERROR("type:%u is err\n", type); + } l_out: return; } #else -static inline void ps3_scmd_start_inc(struct ps3_single_cmd_stat *stat_entry, - const struct scsi_cmnd *s_cmd) +static inline void ps3_scmd_start_inc(struct ps3_single_cmd_stat* stat_entry, + const struct scsi_cmnd *s_cmd) { - unsigned char type = - PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); - + U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); if (ps3_scsih_is_rw_type(type)) { - if (ps3_scsih_is_read_cmd(type)) + if (ps3_scsih_is_read_cmd(type)) { ps3_stat_start_inc(PS3_SCSI_DRV_READ, stat_entry); - else + } else { ps3_stat_start_inc(PS3_SCSI_DRV_WRITE, stat_entry); - } else + } + } else { ps3_stat_start_inc(PS3_SCSI_DRV_NORW, stat_entry); + } ps3_stat_start_inc(PS3_SCSI_DRV_ALL, stat_entry); + + return; } -static inline void ps3_scmd_back_inc(struct ps3_single_cmd_stat *stat_entry, - const struct scsi_cmnd *s_cmd, - unsigned char status) +static inline void ps3_scmd_back_inc(struct ps3_single_cmd_stat* stat_entry, + const struct scsi_cmnd *s_cmd, U8 status) { - unsigned char type = PS3_SCSI_CMD_TYPE( - ps3_scsih_cdb_rw_type_get(scsi_cmnd_cdb(s_cmd))); + U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(scsi_cmnd_cdb(s_cmd))); if (ps3_scsih_is_rw_type(type)) { if (ps3_scsih_is_read_cmd(type)) { - ps3_stat_back_inc(PS3_SCSI_DRV_READ, stat_entry, - status); + ps3_stat_back_inc(PS3_SCSI_DRV_READ, stat_entry, status); } else { - ps3_stat_back_inc(PS3_SCSI_DRV_WRITE, stat_entry, - status); + ps3_stat_back_inc(PS3_SCSI_DRV_WRITE, stat_entry, status); } } else { ps3_stat_back_inc(PS3_SCSI_DRV_NORW, stat_entry, status); } ps3_stat_back_inc(PS3_SCSI_DRV_ALL, stat_entry, status); + + return; } -void ps3_scmd_inc(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd, - unsigned int tag, unsigned char type, unsigned char status) +void ps3_scmd_inc(struct ps3_instance *instance, + const struct scsi_cmnd *s_cmd, U32 tag, U8 type, U8 status) { - struct ps3_single_cmd_stat *stat_entry = NULL; + struct ps3_single_cmd_stat* stat_entry = NULL; if (s_cmd == NULL) { LOG_ERROR("scsi cmd is null\n"); @@ -955,49 +969,50 @@ void ps3_scmd_inc(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd, stat_entry = ps3_stat_entry_find(tag, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u CFID:%u stat entry find fail\n", - PS3_HOST(instance), tag); + PS3_HOST(instance), tag); goto l_out; } - if (type == PS3_STAT_START) + if (type == PS3_STAT_START) { ps3_scmd_start_inc(stat_entry, s_cmd); - else if (type == PS3_STAT_BACK) + } + else if (type == PS3_STAT_BACK) { ps3_scmd_back_inc(stat_entry, s_cmd, status); - else + } else { LOG_ERROR("type:%u is err\n", type); + } l_out: return; } #endif -static inline unsigned char ps3_is_direct_cmd(unsigned char type) +static inline Bool ps3_is_direct_cmd(U8 type) { return (type == PS3_CMDWORD_DIRECT_OK || type == PS3_CMDWORD_DIRECT_ADVICE); } -static inline void -ps3_direct_cmd_start_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry, - unsigned char vd_flag) +static inline void ps3_direct_cmd_start_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry, Bool vd_flag) { - unsigned short type = PS3_DRV_IOC_READ; + U16 type = PS3_DRV_IOC_READ; if (ps3_is_direct_cmd(cmd->io_attr.direct_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { type = vd_flag ? PS3_DRV_IOC_VD_D_READ : - PS3_DRV_IOC_PD_D_READ; + PS3_DRV_IOC_PD_D_READ; } else { type = vd_flag ? PS3_DRV_IOC_VD_D_WRITE : - PS3_DRV_IOC_PD_D_WRITE; + PS3_DRV_IOC_PD_D_WRITE; } ps3_stat_start_inc(type, stat_entry); } + + return; } -static inline void -ps3_scmd_drv2ioc_start_vd_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry) +static inline void ps3_scmd_drv2ioc_start_vd_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry) { if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { @@ -1015,9 +1030,8 @@ ps3_scmd_drv2ioc_start_vd_inc(const struct ps3_cmd *cmd, ps3_direct_cmd_start_inc(cmd, stat_entry, PS3_TRUE); } -static inline void -ps3_scmd_drv2ioc_start_pd_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry) +static inline void ps3_scmd_drv2ioc_start_pd_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry) { if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { @@ -1036,24 +1050,26 @@ ps3_scmd_drv2ioc_start_pd_inc(const struct ps3_cmd *cmd, } void ps3_scmd_drv2ioc_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { struct ps3_single_cmd_stat *stat_entry = NULL; - if (cmd == NULL) + if (cmd == NULL) { goto l_out; + } stat_entry = ps3_stat_entry_find(cmd->index, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u index:%u stat entry find fail\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); goto l_out; } - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { ps3_scmd_drv2ioc_start_vd_inc(cmd, stat_entry); - else + } else { ps3_scmd_drv2ioc_start_pd_inc(cmd, stat_entry); + } ps3_stat_start_inc(PS3_DRV_IOC_ALL, stat_entry); ps3_atomic_inc(&instance->cmd_statistics.cmd_outstanding); @@ -1062,40 +1078,34 @@ void ps3_scmd_drv2ioc_start_inc(struct ps3_instance *instance, return; } -static inline void -ps3_direct_cmd_back_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry, - unsigned char vd_flag, unsigned char status) +static inline void ps3_direct_cmd_back_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry, Bool vd_flag, U8 status) { - unsigned short type = PS3_DRV_IOC_READ; - + U16 type = PS3_DRV_IOC_READ; if (ps3_is_direct_cmd(cmd->io_attr.direct_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { type = vd_flag ? PS3_DRV_IOC_VD_D_READ : - PS3_DRV_IOC_PD_D_READ; + PS3_DRV_IOC_PD_D_READ; } else { type = vd_flag ? PS3_DRV_IOC_VD_D_WRITE : - PS3_DRV_IOC_PD_D_WRITE; + PS3_DRV_IOC_PD_D_WRITE; } ps3_stat_back_inc(type, stat_entry, status); } + + return; } -static inline void -ps3_scmd_drv2ioc_back_vd_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry, - unsigned char status) +static inline void ps3_scmd_drv2ioc_back_vd_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry, U8 status) { if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_stat_back_inc(PS3_DRV_IOC_VD_READ, stat_entry, - status); + ps3_stat_back_inc(PS3_DRV_IOC_VD_READ, stat_entry, status); ps3_stat_back_inc(PS3_DRV_IOC_READ, stat_entry, status); } else { - ps3_stat_back_inc(PS3_DRV_IOC_VD_WRITE, stat_entry, - status); - ps3_stat_back_inc(PS3_DRV_IOC_WRITE, stat_entry, - status); + ps3_stat_back_inc(PS3_DRV_IOC_VD_WRITE, stat_entry, status); + ps3_stat_back_inc(PS3_DRV_IOC_WRITE, stat_entry, status); } } else { ps3_stat_back_inc(PS3_DRV_IOC_NORW, stat_entry, status); @@ -1103,23 +1113,20 @@ ps3_scmd_drv2ioc_back_vd_inc(const struct ps3_cmd *cmd, } ps3_direct_cmd_back_inc(cmd, stat_entry, PS3_TRUE, status); + + return; } -static inline void -ps3_scmd_drv2ioc_back_pd_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry, - unsigned char status) +static inline void ps3_scmd_drv2ioc_back_pd_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry, U8 status) { if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_stat_back_inc(PS3_DRV_IOC_PD_READ, stat_entry, - status); + ps3_stat_back_inc(PS3_DRV_IOC_PD_READ, stat_entry, status); ps3_stat_back_inc(PS3_DRV_IOC_READ, stat_entry, status); } else { - ps3_stat_back_inc(PS3_DRV_IOC_PD_WRITE, stat_entry, - status); - ps3_stat_back_inc(PS3_DRV_IOC_WRITE, stat_entry, - status); + ps3_stat_back_inc(PS3_DRV_IOC_PD_WRITE, stat_entry, status); + ps3_stat_back_inc(PS3_DRV_IOC_WRITE, stat_entry, status); } } else { ps3_stat_back_inc(PS3_DRV_IOC_PD_NORW, stat_entry, status); @@ -1130,7 +1137,7 @@ ps3_scmd_drv2ioc_back_pd_inc(const struct ps3_cmd *cmd, } void ps3_scmd_drv2ioc_back_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd, unsigned char status) + const struct ps3_cmd *cmd, U8 status) { struct ps3_single_cmd_stat *stat_entry = NULL; @@ -1142,14 +1149,15 @@ void ps3_scmd_drv2ioc_back_inc(struct ps3_instance *instance, stat_entry = ps3_stat_entry_find(cmd->index, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u index:%u stat entry find fail\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); goto l_out; } - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { ps3_scmd_drv2ioc_back_vd_inc(cmd, stat_entry, status); - else + } else { ps3_scmd_drv2ioc_back_pd_inc(cmd, stat_entry, status); + } ps3_stat_back_inc(PS3_DRV_IOC_ALL, stat_entry, status); ps3_atomic_dec(&instance->cmd_statistics.cmd_outstanding); @@ -1158,9 +1166,8 @@ void ps3_scmd_drv2ioc_back_inc(struct ps3_instance *instance, return; } -static inline void -ps3_task_cmd_start_inc(struct ps3_single_cmd_stat *stat_entry, - const struct ps3_cmd *cmd) +static inline void ps3_task_cmd_start_inc(struct ps3_single_cmd_stat *stat_entry, + const struct ps3_cmd *cmd) { switch (cmd->req_frame->mgrReq.reqHead.cmdSubType) { case PS3_TASK_CMD_SCSI_TASK_ABORT: @@ -1174,15 +1181,18 @@ ps3_task_cmd_start_inc(struct ps3_single_cmd_stat *stat_entry, default: break; } + + return; } -void ps3_mgr_start_inc(struct ps3_instance *instance, const struct ps3_cmd *cmd) +void ps3_mgr_start_inc(struct ps3_instance *instance, + const struct ps3_cmd *cmd) { struct ps3_single_cmd_stat *stat_entry = ps3_stat_entry_find(cmd->index, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u CFID:%u stat entry find fail\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); goto l_out; } @@ -1205,8 +1215,7 @@ void ps3_mgr_start_inc(struct ps3_instance *instance, const struct ps3_cmd *cmd) } static inline void ps3_task_cmd_back_inc(struct ps3_single_cmd_stat *stat_entry, - const struct ps3_cmd *cmd, - unsigned char status) + const struct ps3_cmd *cmd, U8 status) { switch (cmd->req_frame->mgrReq.reqHead.cmdSubType) { case PS3_TASK_CMD_SCSI_TASK_ABORT: @@ -1220,16 +1229,18 @@ static inline void ps3_task_cmd_back_inc(struct ps3_single_cmd_stat *stat_entry, default: break; } + + return; } -void ps3_mgr_back_inc(struct ps3_instance *instance, const struct ps3_cmd *cmd, - unsigned char status) +void ps3_mgr_back_inc(struct ps3_instance *instance, + const struct ps3_cmd *cmd, U8 status) { struct ps3_single_cmd_stat *stat_entry = ps3_stat_entry_find(cmd->index, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u index:%u stat entry find fail\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); goto l_out; } @@ -1257,8 +1268,8 @@ void ps3_mgr_back_inc(struct ps3_instance *instance, const struct ps3_cmd *cmd, static inline void ps3_stat_workq_service(struct work_struct *work) { - struct ps3_cmd_stat_wrokq_context *ctx = ps3_container_of( - work, struct ps3_cmd_stat_wrokq_context, stat_work.work); + struct ps3_cmd_stat_wrokq_context *ctx = ps3_container_of(work, + struct ps3_cmd_stat_wrokq_context, stat_work.work); struct ps3_instance *instance = NULL; if (ctx == NULL) { @@ -1280,27 +1291,24 @@ static inline void ps3_stat_workq_service(struct work_struct *work) ps3_stat_data_collect(instance); if (ctx->stat_queue != NULL) { - queue_delayed_work( - ctx->stat_queue, &ctx->stat_work, - msecs_to_jiffies( - instance->cmd_statistics.stat_interval)); + queue_delayed_work(ctx->stat_queue, &ctx->stat_work, + msecs_to_jiffies(instance->cmd_statistics.stat_interval)); } l_out: return; } -int ps3_stat_workq_start(struct ps3_instance *instance) +S32 ps3_stat_workq_start(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - struct ps3_cmd_stat_wrokq_context *ctx = - &instance->cmd_statistics.stat_workq; + S32 ret = PS3_SUCCESS; + struct ps3_cmd_stat_wrokq_context *ctx = &instance->cmd_statistics.stat_workq; char qname[PS3_STAT_WROKQ_NAME_MAX_LEN] = { 0 }; struct delayed_work *work = &ctx->stat_work; if (ctx->stat_queue != NULL) { LOG_INFO("host_no:%u stat work for is already started!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -1312,7 +1320,7 @@ int ps3_stat_workq_start(struct ps3_instance *instance) ctx->stat_queue = create_singlethread_workqueue(qname); if (ctx->stat_queue == NULL) { LOG_ERROR("host_no:%u cmd stat work queue create failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -1325,8 +1333,7 @@ int ps3_stat_workq_start(struct ps3_instance *instance) } ctx->is_stop = PS3_FALSE; - queue_delayed_work( - ctx->stat_queue, work, + queue_delayed_work(ctx->stat_queue, work, msecs_to_jiffies(instance->cmd_statistics.stat_interval)); l_out: @@ -1343,26 +1350,28 @@ void ps3_stat_workq_stop(struct ps3_instance *instance) ctx->is_stop = PS3_TRUE; - if (ctx->stat_queue == NULL) + if (ctx->stat_queue == NULL) { goto l_out; + } workq = ctx->stat_queue; - if (!cancel_delayed_work_sync(&ctx->stat_work)) + if (!cancel_delayed_work_sync(&ctx->stat_work)) { flush_workqueue(workq); + } ctx->stat_queue = NULL; destroy_workqueue(workq); l_out: memset(ctx, 0, sizeof(struct ps3_cmd_stat_wrokq_context)); + return; } #else static inline void ps3_stat_workq_service(void *ins) { - struct ps3_instance *instance = (struct ps3_instance *)ins; - struct ps3_cmd_stat_wrokq_context *ctx = - &instance->cmd_statistics.stat_workq; + struct ps3_instance *instance = (struct ps3_instance*)ins; + struct ps3_cmd_stat_wrokq_context* ctx = &instance->cmd_statistics.stat_workq; if (ctx == NULL) { LOG_ERROR("ps3_cmd_stat_wrokq_context is null\n"); @@ -1381,25 +1390,23 @@ static inline void ps3_stat_workq_service(void *ins) ps3_stat_data_collect(instance); - ps3_delay_worker_start(&ctx->statis_work, - instance->cmd_statistics.stat_interval); + ps3_delay_worker_start(&ctx->statis_work, instance->cmd_statistics.stat_interval); l_out: return; } -int ps3_stat_workq_start(struct ps3_instance *instance) +S32 ps3_stat_workq_start(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - struct ps3_cmd_stat_wrokq_context *ctx = - &instance->cmd_statistics.stat_workq; - struct ps3_delay_worker *statis_work = &ctx->statis_work; + S32 ret = PS3_SUCCESS; + struct ps3_cmd_stat_wrokq_context* ctx = &instance->cmd_statistics.stat_workq; + struct ps3_delay_worker* statis_work = &ctx->statis_work; memset(ctx, 0, sizeof(struct ps3_cmd_stat_wrokq_context)); - if (ps3_delay_worker_init(instance, statis_work, "ps3_statis", - ps3_stat_workq_service) != PS3_SUCCESS) { - LOG_ERROR("host_no:%u timer init failed\n", PS3_HOST(instance)); + if (ps3_delay_worker_init(instance, statis_work, "ps3_statis", ps3_stat_workq_service) != PS3_SUCCESS) { + LOG_ERROR("host_no:%u timer init failed\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -1410,11 +1417,9 @@ int ps3_stat_workq_start(struct ps3_instance *instance) } ctx->is_stop = PS3_FALSE; - if (ps3_delay_worker_start(statis_work, - instance->cmd_statistics.stat_interval) != - PS3_SUCCESS) { + if (ps3_delay_worker_start(statis_work, instance->cmd_statistics.stat_interval) != PS3_SUCCESS) { LOG_ERROR("host_no:%u timer request failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; ctx->is_stop = PS3_TRUE; goto l_out; @@ -1425,155 +1430,161 @@ int ps3_stat_workq_start(struct ps3_instance *instance) void ps3_stat_workq_stop(struct ps3_instance *instance) { - struct ps3_cmd_stat_wrokq_context *ctx = NULL; - + struct ps3_cmd_stat_wrokq_context* ctx = NULL; ctx = &instance->cmd_statistics.stat_workq; ctx->is_stop = PS3_TRUE; ps3_delay_worker_exit(&ctx->statis_work); memset(ctx, 0, sizeof(struct ps3_cmd_stat_wrokq_context)); + return; } #endif static void ps3_backup_stat_entry_build(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; for (; i < ctx->stat_entry_max_count; ++i) { memcpy(ctx->cmd_stat_backup_buf[i], ctx->cmd_stat_buf[i], - sizeof(struct ps3_single_cmd_stat)); - mb(); /* in order to force CPU ordering */ + sizeof(struct ps3_single_cmd_stat)); + mb(); } + + return; } static inline void ps3_last_stat_entry_build(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; for (; i < ctx->stat_entry_max_count; ++i) { memcpy(ctx->last_stat_buf[i], ctx->cmd_stat_backup_buf[i], - sizeof(struct ps3_single_cmd_stat)); - mb(); /* in order to force CPU ordering */ + sizeof(struct ps3_single_cmd_stat)); + mb(); } + + return; } static void ps3_stat_inc_data_collect(struct ps3_instance *instance) { - unsigned int i = 0; - unsigned short j = 0; + U32 i = 0; + U16 j = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; struct ps3_single_cmd_stat *backup_stat = NULL; struct ps3_single_cmd_stat *last_stat = NULL; - unsigned long long inc_back_good = 0; - unsigned long long inc_back_err = 0; + U64 inc_back_good = 0; + U64 inc_back_err = 0; memset(&ctx->inc_stat, 0, sizeof(ctx->inc_stat)); for (; i < ctx->stat_entry_max_count; ++i) { backup_stat = ps3_backup_stat_entry_find(i, instance); if (backup_stat == NULL) { LOG_WARN("host_no:%u index:%u get backup_stat err\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); continue; } last_stat = ps3_last_stat_entry_find(i, instance); if (last_stat == NULL) { LOG_WARN("host_no:%u index:%u get last_stat err\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); continue; } - mb(); /* in order to force CPU ordering */ + mb(); for (j = 0; j < PS3_CMD_STAT_COUNT; ++j) { ctx->inc_stat.stat[j].start += - backup_stat->stat[j].start - - last_stat->stat[j].start; + backup_stat->stat[j].start - last_stat->stat[j].start; inc_back_good = backup_stat->stat[j].back_good - - last_stat->stat[j].back_good; + last_stat->stat[j].back_good; inc_back_err = backup_stat->stat[j].back_err - - last_stat->stat[j].back_err; - if ((inc_back_good + inc_back_err) == 0) + last_stat->stat[j].back_err; + if ((inc_back_good + inc_back_err) == 0) { continue; - mb(); /* in order to force CPU ordering */ + } + mb(); ctx->inc_stat.stat[j].back_good += inc_back_good; ctx->inc_stat.stat[j].back_err += inc_back_err; ctx->inc_stat.stat[j].not_back += backup_stat->stat[j].not_back - last_stat->stat[j].not_back; ps3_stat_lagency_inc_cal(&ctx->inc_stat.stat[j].lagency, - &backup_stat->stat[j].lagency, - &last_stat->stat[j].lagency); + &backup_stat->stat[j].lagency, + &last_stat->stat[j].lagency); } } ps3_stat_lagency_avg_calc(&ctx->inc_stat); + + return; } static inline void ps3_stat_total_data_collect(struct ps3_instance *instance) { struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - unsigned long long back_count = 0; - unsigned short i = 0; + U64 back_count = 0; + U16 i = 0; for (; i < PS3_CMD_STAT_COUNT; ++i) { ctx->total_stat.stat[i].start += ctx->inc_stat.stat[i].start; - ctx->total_stat.stat[i].back_good += - ctx->inc_stat.stat[i].back_good; - ctx->total_stat.stat[i].back_err += - ctx->inc_stat.stat[i].back_err; - back_count = ctx->total_stat.stat[i].back_good + - ctx->total_stat.stat[i].back_err; - ctx->total_stat.stat[i].not_back = - ctx->total_stat.stat[i].start - back_count; + ctx->total_stat.stat[i].back_good += ctx->inc_stat.stat[i].back_good; + ctx->total_stat.stat[i].back_err += ctx->inc_stat.stat[i].back_err; + back_count = ctx->total_stat.stat[i].back_good + ctx->total_stat.stat[i].back_err; + ctx->total_stat.stat[i].not_back = ctx->total_stat.stat[i].start - back_count; ps3_stat_lagency_merge(&ctx->total_stat.stat[i].lagency, - &ctx->inc_stat.stat[i].lagency); - mb(); /* in order to force CPU ordering */ + &ctx->inc_stat.stat[i].lagency); + mb(); if (back_count != 0) { - ctx->total_stat.stat[i].lagency.avg = PS3_DIV64_32( - ctx->total_stat.stat[i].lagency.all, - back_count); + ctx->total_stat.stat[i].lagency.avg = + (ctx->total_stat.stat[i].lagency.all / back_count); } } + + return; } static inline void ps3_stat_data_log(const struct ps3_cmd_stat_entry *stat, - const struct ps3_cmd_stat_entry *inc_stat, - unsigned short stat_num) + const struct ps3_cmd_stat_entry *inc_stat, U16 stat_num) { - unsigned short i = 0; + U16 i = 0; for (; i < stat_num; ++i) { - if (inc_stat[i].start == 0) + if (inc_stat[i].start == 0) { continue; - LOG_INFO( - "[%s:] st:%llu bg:%llu ber:%llu nb:%llu avg[%lluus] max[%lluus] min[%lluus]\n", - ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), - stat[i].start, stat[i].back_good, stat[i].back_err, - stat[i].not_back, stat[i].lagency.avg, - stat[i].lagency.max_lagency, - stat[i].lagency.min_lagency); + } + LOG_INFO("[%s:] start:%llu back_good:%llu back_err:%llu " + "not_back:%llu avg[%lluus] max[%lluus] min[%lluus]\n", + ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), + stat[i].start, stat[i].back_good, stat[i].back_err, + stat[i].not_back, stat[i].lagency.avg, + stat[i].lagency.max_lagency, stat[i].lagency.min_lagency); } + + return; } static inline void ps3_stat_total_data_log(struct ps3_instance *instance) { LOG_INFO("host_no:%u total cmd stat show begin\n", PS3_HOST(instance)); ps3_stat_data_log(instance->cmd_statistics.total_stat.stat, - instance->cmd_statistics.inc_stat.stat, - PS3_CMD_STAT_COUNT); + instance->cmd_statistics.inc_stat.stat, PS3_CMD_STAT_COUNT); LOG_INFO("host_no:%u total cmd stat show end\n", PS3_HOST(instance)); + + return; } static inline void ps3_stat_inc_data_log(struct ps3_instance *instance) { - LOG_INFO("host_no:%u inc cmd stat show begin\n", PS3_HOST(instance)); + LOG_INFO("host_no:%u inc cmd stat show begin \n", PS3_HOST(instance)); ps3_stat_data_log(instance->cmd_statistics.inc_stat.stat, - instance->cmd_statistics.inc_stat.stat, - PS3_CMD_STAT_COUNT); - LOG_INFO("host_no:%u inc cmd stat show end\n", PS3_HOST(instance)); + instance->cmd_statistics.inc_stat.stat, PS3_CMD_STAT_COUNT); + LOG_INFO("host_no:%u inc cmd stat show end \n", PS3_HOST(instance)); + + return; } -static inline unsigned char ps3_stat_is_write_log(struct ps3_instance *instance) +static inline Bool ps3_stat_is_write_log(struct ps3_instance *instance) { return instance->cmd_statistics.log_record_count == PS3_STAT_LOG_COUNT; } @@ -1581,8 +1592,7 @@ static inline unsigned char ps3_stat_is_write_log(struct ps3_instance *instance) static inline void ps3_stat_log_count_inc(struct ps3_instance *instance) { instance->cmd_statistics.log_record_count++; - if (instance->cmd_statistics.log_record_count == - PS3_STAT_LOG_MAX_COUNT) { + if (instance->cmd_statistics.log_record_count == PS3_STAT_LOG_MAX_COUNT) { instance->cmd_statistics.log_record_count = 0; } } @@ -1590,7 +1600,7 @@ static inline void ps3_stat_log_count_inc(struct ps3_instance *instance) static inline void ps3_stat_write_log(struct ps3_instance *instance) { if (ps3_stat_log_switch_is_open(instance) && - ps3_stat_inc_switch_is_open(instance)) { + ps3_stat_inc_switch_is_open(instance)) { if (ps3_stat_is_write_log(instance)) { ps3_stat_inc_data_log(instance); @@ -1598,6 +1608,8 @@ static inline void ps3_stat_write_log(struct ps3_instance *instance) } ps3_stat_log_count_inc(instance); } + + return; } static inline void ps3_stat_data_collect(struct ps3_instance *instance) @@ -1611,21 +1623,23 @@ static inline void ps3_stat_data_collect(struct ps3_instance *instance) ps3_last_stat_entry_build(instance); ps3_stat_write_log(instance); + + return; } -void ps3_qos_stat_inc(struct ps3_instance *instance, struct ps3_cmd *cmd, - unsigned short stat, unsigned short type) +void ps3_qos_stat_inc(struct ps3_instance *instance, + struct ps3_cmd *cmd, U16 stat, U16 type) { - struct ps3_single_cmd_stat *stat_entry = - ps3_stat_entry_find(cmd->index, instance); + struct ps3_single_cmd_stat *stat_entry = ps3_stat_entry_find(cmd->index, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u index:%u stat entry find fail\n", - PS3_HOST(instance), cmd->index); - return; + PS3_HOST(instance), cmd->index); + return; } - if (type == PS3_STAT_START) + if (type == PS3_STAT_START) { ps3_stat_start_inc(stat, stat_entry); - else if (type == PS3_STAT_BACK) + } else if (type == PS3_STAT_BACK) { ps3_stat_back_inc(stat, stat_entry, PS3_STAT_BACK_OK); + } } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.h b/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.h index 63c72d8d950f..d11d5cdbe39b 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_CMD_STATICTIS_H_ #define _PS3_CMD_STATICTIS_H_ #ifndef _WINDOWS @@ -16,7 +15,7 @@ #include "ps3_scsih.h" #ifdef __cplusplus -extern "C" { +extern "C"{ #endif #define PS3_CMD_STAT_INIT_VALUE (0) @@ -25,384 +24,346 @@ extern "C" { void ps3_dev_io_statis_init(struct ps3_dev_io_statis *statis); -void ps3_io_statis_inc(struct scsi_device *sdev, - enum ps3_dev_io_stat_type type); +void ps3_io_statis_inc(struct scsi_device *sdev, enum ps3_dev_io_stat_type type); void ps3_io_statis_dec(struct scsi_device *sdev, - enum ps3_dev_io_stat_type type); + enum ps3_dev_io_stat_type type); void ps3_io_statis_clear(struct scsi_device *sdev); -int ps3_cmd_statistics_init(struct ps3_instance *instance); +S32 ps3_cmd_statistics_init(struct ps3_instance *instance); void ps3_cmd_statistics_exit(struct ps3_instance *instance); void ps3_dev_io_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); void ps3_dev_io_start_err_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); void ps3_dev_io_start_ok_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); void ps3_dev_io_back_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd, unsigned char status); + const struct ps3_cmd *cmd, U8 status); static inline void ps3_dev_scsi_err_stat_inc(struct ps3_cmd *cmd) { - if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_R_RECV_ERR); - } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_W_RECV_ERR); + if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)){ + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_RECV_ERR); + } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)){ + ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_RECV_ERR); } } -static inline unsigned char ps3_is_vd_rw_cmd(const struct scsi_cmnd *s_cmd) +static inline Bool ps3_is_vd_rw_cmd(const struct scsi_cmnd *s_cmd) { - return (PS3_SDEV_PRI_DATA(s_cmd->device)->dev_type == - PS3_DEV_TYPE_VD) && - ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd); + return (PS3_SDEV_PRI_DATA(s_cmd->device)->dev_type == PS3_DEV_TYPE_VD) && + ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd); + } -static inline unsigned char ps3_is_read_cmd(const struct scsi_cmnd *s_cmd) +static inline Bool ps3_is_read_cmd(const struct scsi_cmnd *s_cmd) { return ps3_scsih_cdb_is_read_cmd(s_cmd->cmnd); } -static inline unsigned char ps3_is_write_cmd(const struct scsi_cmnd *s_cmd) +static inline Bool ps3_is_write_cmd(const struct scsi_cmnd *s_cmd) { return ps3_scsih_cdb_is_write_cmd(s_cmd->cmnd); } void ps3_io_outstand_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); void ps3_io_outstand_dec(struct ps3_instance *instance, - const struct scsi_cmnd *s_cmd); + const struct scsi_cmnd *s_cmd); -void ps3_vd_outstand_dec(struct ps3_instance *instance, - const struct scsi_cmnd *s_cmd); +void ps3_vd_outstand_dec(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd); -void ps3_vd_outstand_inc(struct ps3_instance *instance, - const struct scsi_cmnd *s_cmd); +void ps3_vd_outstand_inc(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd); void ps3_dev_io_outstand_dec(const struct ps3_cmd *cmd); -void ps3_dev_io_qos_inc(struct ps3_scsi_priv_data *priv_data); +void ps3_dev_io_qos_inc(struct ps3_scsi_priv_data* priv_data); -void ps3_dev_io_qos_dec(struct ps3_scsi_priv_data *priv_data); +void ps3_dev_io_qos_dec(struct ps3_scsi_priv_data* priv_data); void ps3_dev_io_outstand_inc(const struct ps3_cmd *cmd); void ps3_qos_cmd_inc(struct ps3_instance *instance); -void ps3_qos_stat_inc(struct ps3_instance *instance, struct ps3_cmd *cmd, - unsigned short stat, unsigned short type); +void ps3_qos_stat_inc(struct ps3_instance *instance, + struct ps3_cmd *cmd, U16 stat, U16 type); -static inline unsigned char -ps3_cmd_word_index_get(struct ps3_instance *instance) +static inline U8 ps3_cmd_word_index_get(struct ps3_instance *instance) { - unsigned long long cmd_count = - (unsigned long long)ps3_atomic64_inc_return( - &instance->cmd_statistics.cmd_word_send_count); - return (unsigned char)(cmd_count & PS3_CMD_WORD_INDEX_SHIFT); + U64 cmd_count = (U64)ps3_atomic64_inc_return(&instance->cmd_statistics.cmd_word_send_count); + return (U8)(cmd_count & PS3_CMD_WORD_INDEX_SHIFT); } static inline void ps3_cmd_word_stat_inc(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word) + struct PS3CmdWord *cmd_word) { (void)cmd_word; (void)ps3_cmd_word_index_get(instance); + return; } #ifndef _WINDOWS -void ps3_scmd_inc(struct ps3_instance *instance, struct scsi_cmnd *s_cmd, - unsigned char type, unsigned char status); +void ps3_scmd_inc(struct ps3_instance *instance, + struct scsi_cmnd *s_cmd, U8 type, U8 status); #else -void ps3_scmd_inc(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd, - unsigned int tag, unsigned char type, unsigned char status); +void ps3_scmd_inc(struct ps3_instance *instance, + const struct scsi_cmnd *s_cmd, U32 tag, U8 type, U8 status); #endif void ps3_scmd_drv2ioc_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); void ps3_scmd_drv2ioc_back_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd, unsigned char status); + const struct ps3_cmd *cmd, U8 status); + -static inline unsigned char -ps3_resp_stauts_to_stat_status(unsigned char reply_flags) +static inline U8 ps3_resp_stauts_to_stat_status(U8 reply_flags) { return (reply_flags == PS3_REPLY_WORD_FLAG_SUCCESS) ? - (unsigned char)PS3_STAT_BACK_OK : - (unsigned char)PS3_STAT_BACK_FAIL; + (U8)PS3_STAT_BACK_OK : (U8)PS3_STAT_BACK_FAIL; } void ps3_mgr_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); -void ps3_mgr_back_inc(struct ps3_instance *instance, const struct ps3_cmd *cmd, - unsigned char status); +void ps3_mgr_back_inc(struct ps3_instance *instance, + const struct ps3_cmd *cmd, U8 status); void ps3_stat_all_clear(struct ps3_instance *instance); -static inline unsigned char -ps3_stat_inc_switch_is_open(const struct ps3_instance *instance) +static inline Bool ps3_stat_inc_switch_is_open(const struct ps3_instance *instance) { - return (instance->cmd_statistics.cmd_stat_switch & - PS3_STAT_INC_SWITCH_OPEN); + return (instance->cmd_statistics.cmd_stat_switch & PS3_STAT_INC_SWITCH_OPEN); } -static inline unsigned char -ps3_stat_log_switch_is_open(const struct ps3_instance *instance) +static inline Bool ps3_stat_log_switch_is_open(const struct ps3_instance *instance) { - return (instance->cmd_statistics.cmd_stat_switch & - PS3_STAT_LOG_SWITCH_OPEN); + return (instance->cmd_statistics.cmd_stat_switch & PS3_STAT_LOG_SWITCH_OPEN); } -static inline unsigned char -ps3_stat_outstand_switch_is_open(const struct ps3_instance *instance) +static inline Bool ps3_stat_outstand_switch_is_open(const struct ps3_instance *instance) { - return (instance->cmd_statistics.cmd_stat_switch & - PS3_STAT_OUTSTAND_SWITCH_OPEN); + return (instance->cmd_statistics.cmd_stat_switch & PS3_STAT_OUTSTAND_SWITCH_OPEN); } -static inline unsigned char -ps3_stat_dev_switch_is_open(const struct ps3_instance *instance) +static inline Bool ps3_stat_dev_switch_is_open(const struct ps3_instance *instance) { - return (instance->cmd_statistics.cmd_stat_switch & - PS3_STAT_DEV_SWITCH_OPEN); + return (instance->cmd_statistics.cmd_stat_switch & PS3_STAT_DEV_SWITCH_OPEN); } #ifndef _WINDOWS static inline void ps3_sdev_busy_inc(struct scsi_cmnd *scmd) { #if defined DRIVER_SUPPORT_PRIV_BUSY - struct ps3_scsi_priv_data *device_priv_data = - (struct ps3_scsi_priv_data *)scmd->device->hostdata; - if (device_priv_data == NULL) + struct ps3_scsi_priv_data *device_priv_data = (struct ps3_scsi_priv_data*)scmd->device->hostdata; + if (device_priv_data == NULL) { return; + } atomic_inc(&device_priv_data->sdev_priv_busy); #else #ifdef PS3_UT atomic_inc(&scmd->device->device_busy); #else - (void)scmd; + (void) scmd; #endif #endif + + return; } static inline void ps3_sdev_busy_dec(struct scsi_cmnd *scmd) { #if defined DRIVER_SUPPORT_PRIV_BUSY - struct ps3_scsi_priv_data *device_priv_data = - (struct ps3_scsi_priv_data *)scmd->device->hostdata; - if (device_priv_data == NULL) + struct ps3_scsi_priv_data *device_priv_data = (struct ps3_scsi_priv_data*)scmd->device->hostdata; + if (device_priv_data == NULL) { return; + } atomic_dec(&device_priv_data->sdev_priv_busy); #else #ifdef PS3_UT atomic_dec(&scmd->device->device_busy); #else - (void)scmd; + (void) scmd; #endif #endif + return; } -#define PS3_DEV_BUSY_DEC(cmd) ps3_sdev_busy_dec((cmd)) +#define PS3_DEV_BUSY_DEC(cmd) do { \ + ps3_sdev_busy_dec((cmd)); \ +} while (0) -#define PS3_DEV_BUSY_INC(cmd) ps3_sdev_busy_inc((cmd)) +#define PS3_DEV_BUSY_INC(cmd) do { \ + ps3_sdev_busy_inc((cmd)); \ +} while (0) #else #define PS3_DEV_BUSY_DEC(cmd) #define PS3_DEV_BUSY_INC(cmd) #endif -static inline unsigned char -ps3_stat_qos_switch_is_open(const struct ps3_instance *instance) +static inline Bool ps3_stat_qos_switch_is_open(const struct ps3_instance *instance) { - return (instance->cmd_statistics.cmd_stat_switch & - PS3_STAT_QOS_SWITCH_OPEN); + return (instance->cmd_statistics.cmd_stat_switch & PS3_STAT_QOS_SWITCH_OPEN); } -#define PS3_CMD_WORD_STAT_INC(instance, cmd_word) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_cmd_word_stat_inc((instance), (cmd_word)); \ - } \ - } while (0) - -#define PS3_DEV_IO_START_OK_INC(instance, cmd) \ - do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_start_ok_inc((instance), (cmd)); \ - } \ - } while (0) - -#define PS3_DEV_IO_BACK_INC(instance, cmd, status) \ - do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_back_inc((instance), (cmd), (status)); \ - } \ - } while (0) - -#define PS3_DEV_IO_START_ERR_INC(instance, cmd) \ - do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_start_err_inc((instance), (cmd)); \ - } \ - } while (0) - -#define PS3_DEV_IO_START_INC(instance, cmd) \ - do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_start_inc((instance), (cmd)); \ - } \ - } while (0) +#define PS3_CMD_WORD_STAT_INC(instance, cmd_word) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_cmd_word_stat_inc((instance), (cmd_word)); \ + } \ +} while (0) + +#define PS3_DEV_IO_START_OK_INC(instance, cmd) do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_start_ok_inc((instance), (cmd)); \ + } \ +} while (0); + +#define PS3_DEV_IO_BACK_INC(instance, cmd, status) do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_back_inc((instance), (cmd), (status)); \ + } \ +} while (0); + +#define PS3_DEV_IO_START_ERR_INC(instance, cmd) do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_start_err_inc((instance), (cmd)); \ + } \ +} while (0); + +#define PS3_DEV_IO_START_INC(instance, cmd) do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_start_inc((instance), (cmd)); \ + } \ +} while (0) #ifndef _WINDOWS -#define PS3_IO_BACK_INC(instance, s_cmd, status) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc( \ - (instance), (s_cmd), PS3_STAT_BACK, \ - ps3_resp_stauts_to_stat_status((status))); \ - } \ - } while (0) +#define PS3_IO_BACK_INC(instance, s_cmd, status) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc((instance), (s_cmd), PS3_STAT_BACK, \ + ps3_resp_stauts_to_stat_status((status))); \ + } \ +} while (0) #else -#define PS3_IO_BACK_INC(instance, s_cmd, tag, status) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc( \ - (instance), (s_cmd), (tag), PS3_STAT_BACK, \ - ps3_resp_stauts_to_stat_status((status))); \ - } \ - } while (0) +#define PS3_IO_BACK_INC(instance, s_cmd, tag, status) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc((instance), (s_cmd), (tag), PS3_STAT_BACK, \ + ps3_resp_stauts_to_stat_status((status))); \ + } \ +} while (0) #endif -#define PS3_IO_OUTSTANDING_INC(instance, cmd) ps3_io_outstand_inc(instance, cmd) - -#define PS3_DEV_IO_ERR_STAT_INC(instance, cmd) \ - do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_scsi_err_stat_inc((cmd)); \ - } \ - } while (0) +#define PS3_IO_OUTSTANDING_INC(instance, cmd) do { \ + ps3_io_outstand_inc(instance, cmd); \ +} while (0) + +#define PS3_DEV_IO_ERR_STAT_INC(instance, cmd) do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_scsi_err_stat_inc((cmd)); \ + } \ +} while (0) #ifndef _WINDOWS -#define PS3_IO_START_INC(instance, s_cmd) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc((instance), (s_cmd), PS3_STAT_START, \ - PS3_STAT_BACK_OK); \ - } \ - } while (0) - -#define PS3_IO_BACK_ERR_INC(instance, s_cmd) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc((instance), (s_cmd), PS3_STAT_BACK, \ - PS3_STAT_BACK_FAIL); \ - } \ - } while (0) +#define PS3_IO_START_INC(instance, s_cmd) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc((instance), (s_cmd), PS3_STAT_START, PS3_STAT_BACK_OK); \ + } \ +} while (0) + +#define PS3_IO_BACK_ERR_INC(instance, s_cmd) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc((instance), (s_cmd), PS3_STAT_BACK, PS3_STAT_BACK_FAIL); \ + } \ +} while (0) #else -#define PS3_IO_START_INC(instance, s_cmd, tag) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc((instance), (s_cmd), (tag), \ - PS3_STAT_START, PS3_STAT_BACK_OK); \ - } \ - } while (0) - -#define PS3_IO_BACK_ERR_INC(instance, s_cmd, tag) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc((instance), (s_cmd), (tag), \ - PS3_STAT_BACK, PS3_STAT_BACK_FAIL); \ - } \ - } while (0) +#define PS3_IO_START_INC(instance, s_cmd, tag) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc((instance), (s_cmd), (tag), PS3_STAT_START, PS3_STAT_BACK_OK); \ + } \ +} while (0) + +#define PS3_IO_BACK_ERR_INC(instance, s_cmd, tag) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc((instance), (s_cmd), (tag), PS3_STAT_BACK, PS3_STAT_BACK_FAIL); \ + } \ +} while (0) #endif -#define PS3_IO_DRV2IOC_START_INC(instance, cmd) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_drv2ioc_start_inc((instance), (cmd)); \ - } \ - } while (0) - -#define PS3_IOC_DRV2IOC_BACK_INC(instance, cmd, status) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_drv2ioc_back_inc( \ - (instance), (cmd), \ - ps3_resp_stauts_to_stat_status((status))); \ - } \ - } while (0) - -#define PS3_MGR_CMD_STAT_INC(instance, cmd) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_mgr_start_inc((instance), (cmd)); \ - } \ - } while (0) - -#define PS3_MGR_CMD_BACK_INC(instance, cmd, status) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_mgr_back_inc( \ - (instance), (cmd), \ - ps3_resp_stauts_to_stat_status((status))); \ - } \ - } while (0) - -#define PS3_IO_OUTSTAND_DEC(instance, s_cmd) \ - do { \ - if (ps3_stat_outstand_switch_is_open((instance))) { \ - ps3_io_outstand_dec((instance), (s_cmd)); \ - } \ - } while (0) - -#define PS3_VD_OUTSTAND_DEC(instance, s_cmd) \ - ps3_vd_outstand_dec(instance, s_cmd) \ - -#define PS3_VD_OUTSTAND_INC(instance, s_cmd) ps3_vd_outstand_inc(instance, s_cmd) - -#define PS3_DEV_IO_OUTSTAND_DEC(instance, cmd) \ - do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_outstand_dec((cmd)); \ - } \ - } while (0) - -#define PS3_DEV_IO_OUTSTAND_INC(instance, cmd) \ - do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_outstand_inc((cmd)); \ - } \ - } while (0) - -#define PS3_QOS_CMD_INC(instance) \ - do { \ - if (ps3_stat_qos_switch_is_open((instance))) { \ - ps3_qos_cmd_inc((instance)); \ - } \ - } while (0) - -#define PS3_QOS_STAT_START(instance, cmd, type) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_qos_stat_inc((instance), (cmd), (type), \ - PS3_STAT_START); \ - } \ +#define PS3_IO_DRV2IOC_START_INC(instance, cmd) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_drv2ioc_start_inc((instance), (cmd)); \ + } \ +} while (0) + +#define PS3_IOC_DRV2IOC_BACK_INC(instance, cmd, status) { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_drv2ioc_back_inc((instance), (cmd), \ + ps3_resp_stauts_to_stat_status((status))); \ + } \ +} while (0) + +#define PS3_MGR_CMD_STAT_INC(instance, cmd) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_mgr_start_inc((instance), (cmd)); \ + } \ +} while (0) + +#define PS3_MGR_CMD_BACK_INC(instance, cmd, status) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_mgr_back_inc((instance), (cmd), \ + ps3_resp_stauts_to_stat_status((status))); \ + } \ +} while (0) + +#define PS3_IO_OUTSTAND_DEC(instance, s_cmd) do { \ + if (ps3_stat_outstand_switch_is_open((instance))) { \ + ps3_io_outstand_dec((instance), (s_cmd)); \ + } \ +} while (0) + +#define PS3_VD_OUTSTAND_DEC(instance, s_cmd) do { \ + ps3_vd_outstand_dec(instance, s_cmd); \ +} while (0) + +#define PS3_VD_OUTSTAND_INC(instance, s_cmd) do { \ + ps3_vd_outstand_inc(instance, s_cmd); \ +} while (0) + +#define PS3_DEV_IO_OUTSTAND_DEC(instance, cmd) do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_outstand_dec((cmd)); \ + } \ +} while (0) + +#define PS3_DEV_IO_OUTSTAND_INC(instance, cmd) do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_outstand_inc((cmd)); \ + } \ +} while (0) + +#define PS3_QOS_CMD_INC(instance) do { \ + if (ps3_stat_qos_switch_is_open((instance))) { \ + ps3_qos_cmd_inc((instance)); \ + } \ +} while (0) + +#define PS3_QOS_STAT_START(instance, cmd, type) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_qos_stat_inc((instance), (cmd), (type), PS3_STAT_START); \ + } \ } while (0) -#define PS3_QOS_STAT_END(instance, cmd, type) \ - do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_qos_stat_inc((instance), (cmd), (type), \ - PS3_STAT_BACK); \ - } \ +#define PS3_QOS_STAT_END(instance, cmd, type) do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_qos_stat_inc((instance), (cmd), (type), PS3_STAT_BACK); \ + } \ } while (0) -int ps3_stat_workq_start(struct ps3_instance *instance); +S32 ps3_stat_workq_start(struct ps3_instance *instance); void ps3_stat_workq_stop(struct ps3_instance *instance); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_debug.c b/drivers/scsi/linkdata/ps3stor/ps3_debug.c index 1fa2edcee5aa..15dd4b5a4730 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_debug.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_debug.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #ifndef _WINDOWS #include @@ -29,150 +27,151 @@ #include "ps3_instance_manager.h" #include "ps3_event.h" #include "ps3_dump.h" -#include "ps3_kernel_version.h" +#define REG_OFFSET_BY_ADDR(instance, reg) ((U8*)(reg) - ((U8*)(instance)->reg_set)) -#define REG_OFFSET_BY_ADDR(instance, reg) \ - ((unsigned char *)(reg) - ((unsigned char *)(instance)->reg_set)) +#ifndef _WINDOWS +typedef void (*dma_dump_mappings_cb)(struct device *dev); +#endif struct ps3_reg_name { - unsigned long long read_dump_interval_ms; - unsigned long long write_dump_interval_ms; - unsigned int reg_cnt; - char name[32]; + U64 read_dump_interval_ms; + U64 write_dump_interval_ms; + U32 reg_cnt; + S8 name[32]; }; static struct ps3_reg_name g_ps3_reg_name_table[] = { - { 0, 0, 8, "reserved0" }, - { 0, 0, 1, "ps3Doorbell" }, - { 0, 0, 1, "ps3DoorbellIrqClear" }, - { 0, 0, 1, "ps3DoorbellIrqMask" }, - { 0, 0, 1, "ps3IrqControl" }, - { 0, 0, 20, "reserved1" }, - - { 0, 0, 1, "ps3SoftresetKey" }, - { 1000, 0, 1, "ps3SoftresetState" }, - { 0, 0, 1, "ps3Softreset" }, - { 0, 0, 1, "ps3SoftresetIrqClear" }, - { 0, 0, 1, "ps3SoftresetIrqMask" }, - { 0, 0, 1, "ps3SoftresetKeyShiftRegLow" }, - { 0, 0, 1, "ps3SoftresetKeyShiftRegHigh" }, - { 0, 0, 1, "ps3SoftresetTimeCnt" }, - { 0, 0, 1, "ps3SoftresetTimeOutEn" }, - { 0, 0, 23, "reserved2" }, - - { 0, 0, 1, "ps3HardresetKey" }, - { 1000, 0, 1, "ps3HardresetState" }, - { 0, 0, 1, "ps3Hardreset" }, - { 0, 0, 1, "ps3HardresetKeyShiftRegLow" }, - { 0, 0, 1, "ps3HardresetKeyShiftRegHigh" }, - { 0, 0, 1, "ps3HardresetTimeCnt" }, - { 0, 0, 1, "ps3HardresetTimeOutEn" }, - { 0, 0, 1, "ps3KeyGapCfg" }, - { 0, 0, 1, "ps3HardresetIrqClear" }, - { 0, 0, 1, "ps3HardresetIrqMask" }, - { 0, 0, 22, "reserved3" }, - - { 10000, 0, 1, "ps3SocFwState" }, - { 0, 0, 1, "ps3MaxFwCmd" }, - { 0, 0, 1, "ps3MaxChainSize" }, - { 0, 0, 1, "ps3MaxVdInfoSize" }, - { 0, 0, 1, "ps3MaxNvmePageSize" }, - { 0, 0, 1, "ps3FeatureSupport" }, - { 0, 0, 1, "ps3FirmwareVersion" }, - { 0, 0, 1, "ps3MaxReplyque" }, - { 0, 0, 1, "ps3HardwareVersion" }, - { 0, 0, 1, "ps3MgrQueueDepth" }, - { 0, 0, 1, "ps3CmdQueueDepth" }, - { 0, 0, 1, "ps3TfifoDepth" }, - { 0, 0, 1, "ps3MaxSecR1xCmds" }, - { 0, 0, 19, "reserved4" }, - - { 0, 0, 1, "ps3HilAdvice2directCnt0" }, - { 0, 0, 1, "ps3HilAdvice2directCnt1" }, - { 0, 0, 1, "ps3HilAdvice2directCnt2" }, - { 0, 0, 1, "ps3HilAdvice2directCnt3" }, - { 0, 0, 1, "ps3HilAdvice2directCntAll" }, - { 0, 0, 3, "reserved5" }, - { 0, 0, 1, "ps3IrqStatusRpt" }, - { 0, 0, 23, "reserved6" }, - - { 0, 0, 1, "ps3DumpCtrl" }, - { 0, 0, 1, "ps3DumpCtrlIrqClear" }, - { 0, 0, 1, "ps3DumpCtrlIrqMask" }, - { 0, 0, 1, "ps3DumpStatus" }, - { 0, 0, 1, "ps3DumpDataSize" }, - { 0, 0, 27, "reserved7" }, - - { 0, 0, 1, "ps3CmdTrigger" }, - { 0, 0, 1, "ps3CmdTriggerIrqClear" }, - { 0, 0, 1, "ps3CmdTriggerIrqMask" }, - { 0, 0, 1, "ps3SoftresetCounter" }, - { 0, 0, 1, "ps3RegCmdState" }, - { 0, 0, 1, "ps3Debug0" }, - { 0, 0, 1, "ps3Debug0IrqClear" }, - { 0, 0, 1, "ps3Debug0IrqMask" }, - { 0, 0, 1, "ps3Debug1" }, - { 0, 0, 1, "ps3Debug1IrqClear" }, - { 0, 0, 1, "ps3Debug1IrqMask" }, - { 0, 0, 1, "ps3Debug2" }, - { 0, 0, 1, "ps3Debug2IrqClear" }, - { 0, 0, 1, "ps3Debug2IrqMask" }, - { 0, 0, 1, "ps3Debug3" }, - { 0, 0, 1, "ps3Debug3IrqClear" }, - { 0, 0, 1, "ps3Debug3IrqMask" }, - { 0, 0, 1, "ps3Debug4" }, - { 0, 0, 1, "ps3Debug4IrqClear" }, - { 0, 0, 1, "ps3Debug4IrqMask" }, - { 0, 0, 1, "ps3Debug5" }, - { 0, 0, 1, "ps3Debug6" }, - { 0, 0, 1, "ps3Debug7" }, - { 0, 0, 1, "ps3Debug8" }, - { 0, 0, 1, "ps3Debug9" }, - { 0, 0, 1, "ps3Debug10" }, - { 0, 0, 1, "ps3Debug11" }, - { 0, 0, 1, "ps3Debug12" }, - { 0, 0, 4, "reserved8" }, - - { 0, 0, 1, "ps3SessioncmdAddr" }, - { 0, 0, 1, "ps3SessioncmdAddrIrqClear" }, - { 0, 0, 1, "ps3SessioncmdAddrIrqMask" }, - { 0, 0, 7965, "reserved9" }, - { 0, 0, 1, "ps3RequestQueue" }, - { 0, 0, 1, "fifoErrCnt" }, - { 0, 0, 1, "fifoStatus" }, - { 0, 0, 1, "fifoLevelConfig" }, - { 0, 0, 1, "fifoRst" }, - { 0, 0, 1, "fifoIOCnt" }, - { 0, 0, 1, "fifoFlowCnt" }, - { 0, 0, 1, "fifoIntStatus" }, - { 0, 0, 1, "fifoIntSet" }, - { 0, 0, 1, "fifoIntClr" }, - { 0, 0, 1, "fifoIntMask" }, - { 0, 0, 1, "fifoCntClr" }, - { 0, 0, 1, "fifoOrderError" }, - { 0, 0, 4, "fifoDinShift" }, - { 0, 0, 4, "fifoDoutShift" }, - { 0, 0, 1, "fifoStatusMaxLevel" }, - { 0, 0, 1, "fifoInit" }, - { 0, 0, 1, "fifoinitEn" }, - { 0, 0, 1, "fifoinitMax" }, - { 0, 0, 1, "fifoStatusEccCnt" }, - { 0, 0, 1, "fifoStatusEccAddr" }, - { 0, 0, 1, "fifoDecoderOverflow" }, - { 0, 0, 1, "fifoEccBadProject" }, - { 0, 0, 1, "fifoOverFlowWord" }, - { 0, 0, 34, "reserved10" }, - - { 0, 0, 1, "ps3FucntionLock" }, - { 0, 0, 1, "ps3FunctionLockOwner" }, - { 0, 0, 30, "reserved11" }, + {0, 0, 8, "reserved0"}, + {0, 0, 1, "ps3Doorbell"}, + {0, 0, 1, "ps3DoorbellIrqClear"}, + {0, 0, 1, "ps3DoorbellIrqMask"}, + {0, 0, 1, "ps3IrqControl"}, + {0, 0, 20, "reserved1"}, + + {0, 0, 1, "ps3SoftresetKey"}, + {1000, 0, 1, "ps3SoftresetState"}, + {0, 0, 1, "ps3Softreset"}, + {0, 0, 1, "ps3SoftresetIrqClear"}, + {0, 0, 1, "ps3SoftresetIrqMask"}, + {0, 0, 1, "ps3SoftresetKeyShiftRegLow"}, + {0, 0, 1, "ps3SoftresetKeyShiftRegHigh"}, + {0, 0, 1, "ps3SoftresetTimeCnt"}, + {0, 0, 1, "ps3SoftresetTimeOutEn"}, + {0, 0, 23, "reserved2"}, + + {0, 0, 1, "ps3HardresetKey"}, + {1000, 0, 1, "ps3HardresetState"}, + {0, 0, 1, "ps3Hardreset"}, + {0, 0, 1, "ps3HardresetKeyShiftRegLow"}, + {0, 0, 1, "ps3HardresetKeyShiftRegHigh"}, + {0, 0, 1, "ps3HardresetTimeCnt"}, + {0, 0, 1, "ps3HardresetTimeOutEn"}, + {0, 0, 1, "ps3KeyGapCfg"}, + {0, 0, 1, "ps3HardresetIrqClear"}, + {0, 0, 1, "ps3HardresetIrqMask"}, + {0, 0, 22, "reserved3"}, + + {10000, 0, 1, "ps3SocFwState"}, + {0, 0, 1, "ps3MaxFwCmd"}, + {0, 0, 1, "ps3MaxChainSize"}, + {0, 0, 1, "ps3MaxVdInfoSize"}, + {0, 0, 1, "ps3MaxNvmePageSize"}, + {0, 0, 1, "ps3FeatureSupport"}, + {0, 0, 1, "ps3FirmwareVersion"}, + {0, 0, 1, "ps3MaxReplyque"}, + {0, 0, 1, "ps3HardwareVersion"}, + {0, 0, 1, "ps3MgrQueueDepth"}, + {0, 0, 1, "ps3CmdQueueDepth"}, + {0, 0, 1, "ps3TfifoDepth"}, + {0, 0, 1, "ps3MaxSecR1xCmds"}, + {0, 0, 19, "reserved4"}, + + {0, 0, 1, "ps3HilAdvice2directCnt0"}, + {0, 0, 1, "ps3HilAdvice2directCnt1"}, + {0, 0, 1, "ps3HilAdvice2directCnt2"}, + {0, 0, 1, "ps3HilAdvice2directCnt3"}, + {0, 0, 1, "ps3HilAdvice2directCntAll"}, + {0, 0, 3, "reserved5"}, + {0, 0, 1, "ps3IrqStatusRpt"}, + {0, 0, 23, "reserved6"}, + + {0, 0, 1, "ps3DumpCtrl"}, + {0, 0, 1, "ps3DumpCtrlIrqClear"}, + {0, 0, 1, "ps3DumpCtrlIrqMask"}, + {0, 0, 1, "ps3DumpStatus"}, + {0, 0, 1, "ps3DumpDataSize"}, + {0, 0, 27, "reserved7"}, + + {0, 0, 1, "ps3CmdTrigger"}, + {0, 0, 1, "ps3CmdTriggerIrqClear"}, + {0, 0, 1, "ps3CmdTriggerIrqMask"}, + {0, 0, 1, "ps3SoftresetCounter"}, + {0, 0, 1, "ps3RegCmdState"}, + {0, 0, 1, "ps3Debug0"}, + {0, 0, 1, "ps3Debug0IrqClear"}, + {0, 0, 1, "ps3Debug0IrqMask"}, + {0, 0, 1, "ps3Debug1"}, + {0, 0, 1, "ps3Debug1IrqClear"}, + {0, 0, 1, "ps3Debug1IrqMask"}, + {0, 0, 1, "ps3Debug2"}, + {0, 0, 1, "ps3Debug2IrqClear"}, + {0, 0, 1, "ps3Debug2IrqMask"}, + {0, 0, 1, "ps3Debug3"}, + {0, 0, 1, "ps3Debug3IrqClear"}, + {0, 0, 1, "ps3Debug3IrqMask"}, + {0, 0, 1, "ps3Debug4"}, + {0, 0, 1, "ps3Debug4IrqClear"}, + {0, 0, 1, "ps3Debug4IrqMask"}, + {0, 0, 1, "ps3Debug5"}, + {0, 0, 1, "ps3Debug6"}, + {0, 0, 1, "ps3Debug7"}, + {0, 0, 1, "ps3Debug8"}, + {0, 0, 1, "ps3Debug9"}, + {0, 0, 1, "ps3Debug10"}, + {0, 0, 1, "ps3Debug11"}, + {0, 0, 1, "ps3Debug12"}, + {0, 0, 4, "reserved8"}, + + {0, 0, 1, "ps3SessioncmdAddr"}, + {0, 0, 1, "ps3SessioncmdAddrIrqClear"}, + {0, 0, 1, "ps3SessioncmdAddrIrqMask"}, + {0, 0, 7965, "reserved9"}, + {0, 0, 1, "ps3RequestQueue"}, + {0, 0, 1, "fifoErrCnt"}, + {0, 0, 1, "fifoStatus"}, + {0, 0, 1, "fifoLevelConfig"}, + {0, 0, 1, "fifoRst"}, + {0, 0, 1, "fifoIOCnt"}, + {0, 0, 1, "fifoFlowCnt"}, + {0, 0, 1, "fifoIntStatus"}, + {0, 0, 1, "fifoIntSet"}, + {0, 0, 1, "fifoIntClr"}, + {0, 0, 1, "fifoIntMask"}, + {0, 0, 1, "fifoCntClr"}, + {0, 0, 1, "fifoOrderError"}, + {0, 0, 4, "fifoDinShift"}, + {0, 0, 4, "fifoDoutShift"}, + {0, 0, 1, "fifoStatusMaxLevel"}, + {0, 0, 1, "fifoInit"}, + {0, 0, 1, "fifoinitEn"}, + {0, 0, 1, "fifoinitMax"}, + {0, 0, 1, "fifoStatusEccCnt"}, + {0, 0, 1, "fifoStatusEccAddr"}, + {0, 0, 1, "fifoDecoderOverflow"}, + {0, 0, 1, "fifoEccBadProject"}, + {0, 0, 1, "fifoOverFlowWord"}, + {0, 0, 34, "reserved10"}, + + {0, 0, 1, "ps3FucntionLock"}, + {0, 0, 1, "ps3FunctionLockOwner"}, + {0, 0, 30, "reserved11"}, }; -static inline unsigned long long ps3_util_now_timestamp_ms_get(void) +static inline U64 ps3_util_now_timestamp_ms_get(void) { - unsigned long long timenow = 0; + U64 timenow = 0; #ifndef _WINDOWS -#if defined(PS3_DUMP_TIME_32) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) struct timespec now; now = current_kernel_time(); @@ -187,39 +186,37 @@ static inline unsigned long long ps3_util_now_timestamp_ms_get(void) StorPortQuerySystemTime(&now); - timenow = (unsigned long long)(now.QuadPart / 10000); + timenow = (U64)(now.QuadPart / 10000); #endif return timenow; + } static void ps3_reg_dump_attr_init(struct ps3_instance *instance) { - unsigned int local_index = 0; - unsigned int count = 0; - unsigned int table_index = 0; - unsigned int table_cnt = 0; - unsigned int table_size = (sizeof(g_ps3_reg_name_table) / - sizeof(g_ps3_reg_name_table[0])); + U32 local_index = 0; + U32 count = 0; + U32 table_index = 0; + U32 table_cnt = 0; + U32 table_size = (sizeof(g_ps3_reg_name_table)/sizeof(g_ps3_reg_name_table[0])); struct ps3_reg_dump_attr *reg_dump = instance->debug_context.reg_dump; for (table_index = 0; table_index < table_size; table_index++) { table_cnt = g_ps3_reg_name_table[table_index].reg_cnt; for (local_index = 0; local_index < table_cnt; local_index++) { - if (count >= (PS3_REGISTER_SET_SIZE / - sizeof(unsigned long long))) + if (count >= (PS3_REGISTER_SET_SIZE/sizeof(U64))) { goto l_out; + } reg_dump[count].read_dump_timestamp = 0; reg_dump[count].write_dump_timestamp = 0; reg_dump[count].read_dump_interval_ms = - g_ps3_reg_name_table[table_index] - .read_dump_interval_ms; + g_ps3_reg_name_table[table_index].read_dump_interval_ms; reg_dump[count].write_dump_interval_ms = - g_ps3_reg_name_table[table_index] - .write_dump_interval_ms; + g_ps3_reg_name_table[table_index].write_dump_interval_ms; memcpy(reg_dump[count].name, - g_ps3_reg_name_table[table_index].name, 32); + g_ps3_reg_name_table[table_index].name, 32); reg_dump[count].lastest_value = 0; count++; @@ -229,23 +226,20 @@ static void ps3_reg_dump_attr_init(struct ps3_instance *instance) return; } -void ps3_reg_dump(struct ps3_instance *instance, void __iomem *reg, - unsigned long long value, unsigned char is_read) +void ps3_reg_dump(struct ps3_instance *instance, + void __iomem *reg, U64 value, Bool is_read) { - unsigned char is_dump = PS3_FALSE; - const char *dump_type = NULL; - unsigned long long timestamp_ms = ps3_util_now_timestamp_ms_get(); - unsigned long long last_dump_timestamp = 0; - unsigned long long dump_interval = 0; - unsigned int reg_index = - (unsigned int)REG_OFFSET_BY_ADDR(instance, reg) / - sizeof(unsigned long long); + Bool is_dump = PS3_FALSE; + const S8 *dump_type = NULL; + U64 timestamp_ms = ps3_util_now_timestamp_ms_get(); + U64 last_dump_timestamp = 0; + U64 dump_interval = 0; + U32 reg_index = (U32)REG_OFFSET_BY_ADDR(instance, reg)/sizeof(U64); struct ps3_reg_dump_attr *reg_dump = instance->debug_context.reg_dump; - if ((reg == NULL) || - ((unsigned char *)reg < (unsigned char *)instance->reg_set) || - (((unsigned char *)reg - (unsigned char *)instance->reg_set) > - PS3_REGISTER_SET_SIZE)) { + if( (reg == NULL) || + ((U8*)reg < (U8*)instance->reg_set) || + (((U8*)reg - (U8*)instance->reg_set) > PS3_REGISTER_SET_SIZE)) { return; } @@ -259,61 +253,61 @@ void ps3_reg_dump(struct ps3_instance *instance, void __iomem *reg, dump_interval = reg_dump[reg_index].write_dump_interval_ms; } - if (timestamp_ms - last_dump_timestamp >= dump_interval) + if (timestamp_ms - last_dump_timestamp >= dump_interval) { is_dump = PS3_TRUE; + } if (reg_dump[reg_index].lastest_value != value) { is_dump = PS3_TRUE; reg_dump[reg_index].lastest_value = value; } - if (!is_dump) + if (!is_dump) { return; + } - LOG_DEBUG("hno:%u %s:0x%04x:%s:0x%08llx\n", PS3_HOST(instance), - dump_type, - (unsigned int)(reg_index * sizeof(unsigned long long)), - reg_dump[reg_index].name, value); - if (is_read) + LOG_DEBUG("hno:%u %s:0x%04x:%s:0x%08llx \n", + PS3_HOST(instance), dump_type, + (U32)(reg_index * sizeof(U64)), + reg_dump[reg_index].name, value); + if (is_read) { reg_dump[reg_index].read_dump_timestamp = timestamp_ms; - else + } else { reg_dump[reg_index].write_dump_timestamp = timestamp_ms; + } } #ifndef _WINDOWS -static inline unsigned char ps3_is_alloc_debug_mem(unsigned int debug_mem_size) +static inline Bool ps3_is_alloc_debug_mem(U32 debug_mem_size) { return (debug_mem_size != 0); } -static int ps3_debug_mem_array_alloc(struct ps3_instance *instance, - unsigned int debug_mem_size) +static S32 ps3_debug_mem_array_alloc(struct ps3_instance *instance, + U32 debug_mem_size) { - int ret = PS3_SUCCESS; - unsigned int array_num = 0; - unsigned int alloc_size = 0; + S32 ret = PS3_SUCCESS; + U32 array_num = 0; + U32 alloc_size = 0; struct ps3_debug_context *ctx = &instance->debug_context; - struct Ps3DebugMemEntry *entry = - (struct Ps3DebugMemEntry *)ctx->debug_mem_buf; - unsigned char i = 0; + Ps3DebugMemEntry_s *entry = (Ps3DebugMemEntry_s*)ctx->debug_mem_buf; + U8 i = 0; for (; i < PS3_DEBUG_MEM_ARRAY_MAX_NUM; ++i) { - if (debug_mem_size == 0) + if (debug_mem_size == 0) { break; + } array_num++; if (debug_mem_size <= PS3_MAX_DMA_MEM_SIZE) { alloc_size = debug_mem_size * 1024; ctx->debug_mem_vaddr[i].debugMemAddr = - (unsigned long long)(uintptr_t) - ps3_dma_alloc_coherent( - instance, alloc_size, - (unsigned long long *)&entry[i] - .debugMemAddr); + (U64)ps3_dma_alloc_coherent(instance, alloc_size, + &entry[i].debugMemAddr); + INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_ADDR_ALLOC, &ctx->debug_mem_vaddr[i].debugMemAddr); if (ctx->debug_mem_vaddr[i].debugMemAddr == 0) { - LOG_ERROR( - "hno:%u alloc debug_mem[%u] end failed\n", + LOG_ERROR("hno:%u alloc debug_mem[%u] end failed\n", PS3_HOST(instance), i); ret = -PS3_ENOMEM; goto l_out; @@ -321,72 +315,59 @@ static int ps3_debug_mem_array_alloc(struct ps3_instance *instance, ctx->debug_mem_vaddr[i].debugMemSize = debug_mem_size; entry[i].debugMemSize = debug_mem_size; debug_mem_size = 0; - LOG_INFO( - "hno:%u index[%u] vaddr[0x%llx], dma[0x%llx], size[%u]KB\n", - PS3_HOST(instance), i, - ctx->debug_mem_vaddr[i].debugMemAddr, + LOG_INFO("hno:%u index[%u] vaddr[0x%llx], dma[0x%llx], size[%u]KB\n", + PS3_HOST(instance), i, ctx->debug_mem_vaddr[i].debugMemAddr, entry[i].debugMemAddr, entry[i].debugMemSize); + break; } else { debug_mem_size -= PS3_MAX_DMA_MEM_SIZE; alloc_size = PS3_MAX_DMA_MEM_SIZE * 1024; ctx->debug_mem_vaddr[i].debugMemAddr = - (unsigned long long)(uintptr_t) - ps3_dma_alloc_coherent( - instance, alloc_size, - (unsigned long long *)&entry[i] - .debugMemAddr); + (U64)ps3_dma_alloc_coherent(instance, alloc_size, + &entry[i].debugMemAddr); + INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_ADDR_ALLOC, &ctx->debug_mem_vaddr[i].debugMemAddr); if (ctx->debug_mem_vaddr[i].debugMemAddr == 0) { - LOG_ERROR( - "hno:%u alloc debug_mem index[%u] failed\n", + LOG_ERROR("hno:%u alloc debug_mem index[%u] failed\n", PS3_HOST(instance), i); ret = -PS3_ENOMEM; goto l_out; } - ctx->debug_mem_vaddr[i].debugMemSize = - PS3_MAX_DMA_MEM_SIZE; + ctx->debug_mem_vaddr[i].debugMemSize = PS3_MAX_DMA_MEM_SIZE; entry[i].debugMemSize = PS3_MAX_DMA_MEM_SIZE; - LOG_INFO( - "hno:%u index[%u] m vaddr[0x%llx], dma[0x%llx], size[%u]KB\n", - PS3_HOST(instance), i, - ctx->debug_mem_vaddr[i].debugMemAddr, - entry[i].debugMemAddr, entry[i].debugMemSize); } + LOG_INFO("hno:%u index[%u] m vaddr[0x%llx], dma[0x%llx], size[%u]KB\n", + PS3_HOST(instance), i, ctx->debug_mem_vaddr[i].debugMemAddr, + entry[i].debugMemAddr, entry[i].debugMemSize); } ctx->debug_mem_array_num = array_num; - LOG_INFO("hno:%u debug mem array num [%u]\n", PS3_HOST(instance), - array_num); + LOG_INFO("hno:%u debug mem array num [%u]\n", PS3_HOST(instance), array_num); l_out: return ret; } -int ps3_debug_mem_alloc(struct ps3_instance *instance) +S32 ps3_debug_mem_alloc(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int debug_mem_size = ps3_debug_mem_size_query(); - unsigned int buf_size = - PS3_DEBUG_MEM_ARRAY_MAX_NUM * sizeof(struct Ps3DebugMemEntry); + S32 ret = PS3_SUCCESS; + U32 debug_mem_size = ps3_debug_mem_size_query(); + U32 buf_size = PS3_DEBUG_MEM_ARRAY_MAX_NUM * sizeof(Ps3DebugMemEntry_s); - if (!ps3_is_alloc_debug_mem(debug_mem_size)) + if (!ps3_is_alloc_debug_mem(debug_mem_size)) { goto l_out; + } if (debug_mem_size > PS3_MAX_DEBUG_MEM_SIZE_PARA) { - LOG_WARN( - "hno:%u debug mem size is greater than the maximum value\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u debug mem size is greater than the maximum value\n", PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_out; } - instance->debug_context.debug_mem_buf = - (struct Ps3DebugMemEntry *)ps3_dma_alloc_coherent( - instance, buf_size, - (unsigned long long *)&instance->debug_context - .debug_mem_buf_phy); + instance->debug_context.debug_mem_buf = (Ps3DebugMemEntry_s*)ps3_dma_alloc_coherent(instance, + buf_size, &instance->debug_context.debug_mem_buf_phy); + INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_BUF_ALLOC, &instance->debug_context.debug_mem_buf); if (instance->debug_context.debug_mem_buf == NULL) { - LOG_ERROR("hno:%u alloc debug_mem_buf failed\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u alloc debug_mem_buf failed\n", PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_out; } @@ -394,17 +375,14 @@ int ps3_debug_mem_alloc(struct ps3_instance *instance) ret = ps3_debug_mem_array_alloc(instance, debug_mem_size); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u alloc debug_mem_array failed\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u alloc debug_mem_array failed\n", PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_free; } - LOG_INFO( - "hno:%u alloc debug_mem buf vaddr[0x%p], dma[0x%llx], size[%u]KB\n", + LOG_INFO("hno:%u alloc debug_mem buf vaddr[0x%p], dma[0x%llx], size[%u]KB\n", PS3_HOST(instance), instance->debug_context.debug_mem_buf, - (unsigned long long)instance->debug_context.debug_mem_buf_phy, - buf_size); + instance->debug_context.debug_mem_buf_phy, buf_size); goto l_out; @@ -414,13 +392,13 @@ int ps3_debug_mem_alloc(struct ps3_instance *instance) return ret; } -int ps3_debug_mem_free(struct ps3_instance *instance) +S32 ps3_debug_mem_free(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_debug_context *ctx = &instance->debug_context; - struct Ps3DebugMemEntry *entry = ctx->debug_mem_buf; - unsigned int size = 0; - unsigned char i = 0; + Ps3DebugMemEntry_s *entry = ctx->debug_mem_buf; + U32 size = 0; + U8 i = 0; if (entry == NULL) { ret = PS3_SUCCESS; @@ -428,21 +406,21 @@ int ps3_debug_mem_free(struct ps3_instance *instance) } for (i = 0; i < PS3_DEBUG_MEM_ARRAY_MAX_NUM; ++i) { - if (ctx->debug_mem_vaddr[i].debugMemAddr == 0) + if (ctx->debug_mem_vaddr[i].debugMemAddr == 0) { continue; + } size = ctx->debug_mem_vaddr[i].debugMemSize * 1024; - LOG_INFO("dma free size[%u] addr[0x%llx]\n", size, - ctx->debug_mem_vaddr[i].debugMemAddr); - (void)ps3_dma_free_coherent( - instance, size, - (void *)(uintptr_t)ctx->debug_mem_vaddr[i].debugMemAddr, + LOG_INFO("dma free size[%u] addr[0x%llx]\n", + size, ctx->debug_mem_vaddr[i].debugMemAddr); + (void)ps3_dma_free_coherent(instance, size, + (void*)ctx->debug_mem_vaddr[i].debugMemAddr, entry[i].debugMemAddr); } memset(ctx->debug_mem_vaddr, 0, sizeof(ctx->debug_mem_vaddr)); - size = PS3_DEBUG_MEM_ARRAY_MAX_NUM * sizeof(struct Ps3DebugMemEntry); - (void)ps3_dma_free_coherent(instance, size, ctx->debug_mem_buf, - ctx->debug_mem_buf_phy); + size = PS3_DEBUG_MEM_ARRAY_MAX_NUM * sizeof(Ps3DebugMemEntry_s); + (void)ps3_dma_free_coherent(instance, size, + ctx->debug_mem_buf, ctx->debug_mem_buf_phy); ctx->debug_mem_buf = NULL; ctx->debug_mem_buf_phy = 0; LOG_INFO("free debug mem end\n"); @@ -459,9 +437,8 @@ void ps3_debug_context_init(struct ps3_instance *instance) ps3_reg_dump_attr_init(instance); } -static inline struct ps3_instance * -ps3_debug_instance_query(struct device *cdev, struct device_attribute *attr, - const char *buf) +static inline struct ps3_instance *ps3_debug_instance_query(struct device *cdev, + struct device_attribute *attr, const char *buf) { struct Scsi_Host *shost = NULL; struct ps3_instance *instance = NULL; @@ -478,6 +455,12 @@ ps3_debug_instance_query(struct device *cdev, struct device_attribute *attr, goto l_out; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,19,0) + if (shost->hostdata == NULL) { + instance = NULL; + goto l_out; + } +#endif instance = (struct ps3_instance *)shost->hostdata; l_out: @@ -485,19 +468,18 @@ ps3_debug_instance_query(struct device *cdev, struct device_attribute *attr, } ssize_t ps3_vd_io_outstanding_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; goto l_out; } - ret = snprintf( - buf, PAGE_SIZE, "%d\n", + ret = snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->cmd_statistics.vd_io_outstanding)); l_out: @@ -505,11 +487,11 @@ ssize_t ps3_vd_io_outstanding_show(struct device *cdev, } ssize_t ps3_io_outstanding_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; @@ -517,18 +499,18 @@ ssize_t ps3_io_outstanding_show(struct device *cdev, } ret = snprintf(buf, PAGE_SIZE, "%d\n", - atomic_read(&instance->cmd_statistics.io_outstanding)); + atomic_read(&instance->cmd_statistics.io_outstanding)); l_out: return ret; } -ssize_t ps3_is_load_show(struct device *cdev, struct device_attribute *attr, - char *buf) +ssize_t ps3_is_load_show(struct device *cdev, + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; @@ -541,11 +523,11 @@ ssize_t ps3_is_load_show(struct device *cdev, struct device_attribute *attr, return ret; } ssize_t ps3_dump_ioc_regs_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; @@ -559,11 +541,11 @@ ssize_t ps3_dump_ioc_regs_show(struct device *cdev, } ssize_t ps3_max_scsi_cmds_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; @@ -571,31 +553,30 @@ ssize_t ps3_max_scsi_cmds_show(struct device *cdev, } ret = snprintf(buf, PAGE_SIZE, "%d\n", - instance->cmd_context.max_scsi_cmd_count); + instance->cmd_context.max_scsi_cmd_count); l_out: return ret; } #endif -static ssize_t ps3_event_map_get(unsigned int event_type_map, char *buf, - ssize_t left_len) +static ssize_t ps3_event_map_get(U32 event_type_map, char *buf, + ssize_t left_len) { ssize_t len = 0; - unsigned int mask_bit = 0X00000001; - unsigned int idx = 0; - unsigned int event_type = event_type_map & mask_bit; - unsigned int line_cnt = 2; + U32 mask_bit = 0X00000001; + U32 idx = 0; + U32 event_type = event_type_map & mask_bit; + U32 line_cnt = 2; while (mask_bit != 0) { if (event_type != 0) { if (idx && (!(idx % line_cnt))) { - len += snprintf(buf + len, left_len - len, - "\n"); + len += snprintf(buf + len, + left_len - len, "\n"); } - len += snprintf( - buf + len, left_len - len, "\t%s", - ps3_event_print((enum MgrEvtType)event_type)); + len += snprintf(buf + len, left_len - len, "\t%s", + ps3_event_print((MgrEvtType_e)event_type)); } mask_bit = mask_bit << 1; @@ -607,53 +588,51 @@ static ssize_t ps3_event_map_get(unsigned int event_type_map, char *buf, return len; } -ssize_t ps3_event_subscribe_info_get(struct ps3_instance *instance, char *buf, - ssize_t total_len) +ssize_t ps3_event_subscribe_info_get(struct ps3_instance *instance, + char *buf, ssize_t total_len) { ssize_t len = 0; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; struct PS3MgrEvent *event_req_info = NULL; - unsigned long flags = 0; - - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags); + ULong flags = 0; + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); cmd = instance->event_context.event_cmd; if (cmd != NULL) { - mgr_req_frame = (struct PS3MgrReqFrame *)cmd->req_frame; + mgr_req_frame = (PS3MgrReqFrame_s *)cmd->req_frame; event_req_info = (struct PS3MgrEvent *)&mgr_req_frame->value.event; len += snprintf(buf + len, total_len - len, - "Event subscribe cmd index:\t%d\n", cmd->index); + "Event subscribe cmd index:\t%d\n", + cmd->index); len += snprintf(buf + len, total_len - len, - "Event subscribe level:\t%d\n", - event_req_info->eventLevel); + "Event subscribe level:\t%d\n", + event_req_info->eventLevel); len += snprintf(buf + len, total_len - len, - "Event subscribe type:\n"); + "Event subscribe type:\n"); len += ps3_event_map_get(event_req_info->eventTypeMap, - buf + len, total_len - len); + buf + len, total_len - len); len += snprintf(buf + len, total_len - len, - "Event proc failed type:\n"); + "Event proc failed type:\n"); len += ps3_event_map_get(event_req_info->eventTypeMapProcResult, - buf + len, total_len - len); + buf + len, total_len - len); goto l_out; } l_out: - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); return len; } #ifndef _WINDOWS ssize_t ps3_event_subscribe_info_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; @@ -671,18 +650,17 @@ static ssize_t ps3_ioc_state_dump(struct ps3_instance *instance, char *buf) ssize_t total_len = PAGE_SIZE; len += snprintf(buf + len, total_len - len, "%s\n", - ps3_ioc_state_print( - instance->ioc_adpter->ioc_state_get(instance))); + ps3_ioc_state_print(instance->ioc_adpter->ioc_state_get(instance))); return len; } ssize_t ps3_ioc_state_show(struct device *cdev, struct device_attribute *attr, - char *buf) + char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; @@ -694,15 +672,16 @@ ssize_t ps3_ioc_state_show(struct device *cdev, struct device_attribute *attr, return ret; } -ssize_t ps3_log_level_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count) +ssize_t ps3_log_level_store(struct device *cdev, + struct device_attribute *attr, const char *buf, size_t count) { int level = 0; ssize_t ret = count; (void)attr; - if (cdev == NULL || buf == NULL) + if (cdev == NULL || buf == NULL) { goto l_out; + } if (kstrtoint(buf, 10, &level)) { LOG_ERROR("invalid log level, could not set log level\n"); @@ -710,8 +689,8 @@ ssize_t ps3_log_level_store(struct device *cdev, struct device_attribute *attr, goto l_out; } -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else if (level > LEVEL_INFO) { @@ -727,15 +706,16 @@ ssize_t ps3_log_level_store(struct device *cdev, struct device_attribute *attr, return ret; } -ssize_t ps3_log_level_show(struct device *cdev, struct device_attribute *attr, - char *buf) +ssize_t ps3_log_level_show(struct device *cdev, + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - int level = ps3_level_get(); + S32 level = ps3_level_get(); (void)attr; - if (cdev == NULL || buf == NULL) + if (cdev == NULL || buf == NULL) { goto l_out; + } ret = snprintf(buf, PAGE_SIZE, "%d\n", level); LOG_DEBUG("get log level to %d\n", level); @@ -744,13 +724,12 @@ ssize_t ps3_log_level_show(struct device *cdev, struct device_attribute *attr, } ssize_t ps3_io_trace_switch_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, const char *buf, size_t count) { - unsigned char trace_switch = 0; + U8 trace_switch = 0; ssize_t ret = count; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = count; @@ -766,18 +745,18 @@ ssize_t ps3_io_trace_switch_store(struct device *cdev, instance->debug_context.io_trace_switch = trace_switch; LOG_WARN("set io trace switch is %d\n", - instance->debug_context.io_trace_switch); + instance->debug_context.io_trace_switch); l_out: return ret; } ssize_t ps3_io_trace_switch_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; @@ -785,21 +764,20 @@ ssize_t ps3_io_trace_switch_show(struct device *cdev, } ret = snprintf(buf, PAGE_SIZE, "%d\n", - instance->debug_context.io_trace_switch); + instance->debug_context.io_trace_switch); LOG_DEBUG("get io trace switch is %d\n", - instance->debug_context.io_trace_switch); + instance->debug_context.io_trace_switch); l_out: return ret; } -ssize_t ps3_dump_state_show(struct device *cdev, struct device_attribute *attr, - char *buf) +ssize_t ps3_dump_state_show(struct device *cdev,struct device_attribute *attr, char *buf) { ssize_t ret = 0; struct ps3_dump_context *ctxt = NULL; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; @@ -807,31 +785,30 @@ ssize_t ps3_dump_state_show(struct device *cdev, struct device_attribute *attr, } ctxt = &instance->dump_context; - ret = snprintf(buf, PAGE_SIZE, "%d\n", ctxt->dump_state); + ret = snprintf(buf, PAGE_SIZE,"%d \n",ctxt->dump_state); l_out: return ret; } -ssize_t ps3_dump_state_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count) +ssize_t ps3_dump_state_store(struct device *cdev,struct device_attribute *attr, + const char *buf, size_t count) { - int val = 0; - int ret = 0; + S32 val = 0; + S32 ret = 0; struct ps3_dump_context *ctxt = NULL; (void)attr; - ctxt = dev_to_dump_context(cdev); + ctxt = dev_to_dump_context (cdev); if (kstrtoint(buf, 0, &val) != 0) { ret = -EINVAL; goto l_ret; } - if ((val != PS3_DUMP_STATE_INVALID) && - (val != PS3_DUMP_STATE_ABORTED)) { - LOG_ERROR("hno:%u dump state should be %d or %d, %d is an invalid value\n", - PS3_HOST(ctxt->instance), PS3_DUMP_STATE_INVALID, - PS3_DUMP_STATE_ABORTED, val); + if ((val != PS3_DUMP_STATE_INVALID) && (val != PS3_DUMP_STATE_ABORTED)) { + LOG_ERROR("hno:%u dump state should be %d or %d," + "%d is an invalid value\n",PS3_HOST(ctxt->instance), + PS3_DUMP_STATE_INVALID,PS3_DUMP_STATE_ABORTED,val); ret = -EINVAL; goto l_ret; } @@ -846,44 +823,43 @@ ssize_t ps3_dump_state_store(struct device *cdev, struct device_attribute *attr, return ret; } -ssize_t ps3_product_model_show(struct device *cdev, - struct device_attribute *attr, char *buf) +ssize_t ps3_product_model_show(struct device *cdev,struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, attr, buf); (void)attr; - if (instance == NULL) + if (instance == NULL) { goto l_out; + } ret = snprintf(buf, PAGE_SIZE, "%s\n", instance->product_model); l_out: return ret; } -ssize_t ps3_dump_dir_show(struct device *cdev, struct device_attribute *attr, - char *buf) +ssize_t ps3_dump_dir_show(struct device *cdev,struct device_attribute *attr, char *buf) { struct ps3_dump_context *ctxt; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); ssize_t ret = 0; - if (instance == NULL) + if (instance == NULL) { goto l_out; + } ctxt = &instance->dump_context; - ret = snprintf(buf, PAGE_SIZE, "%s\n", ctxt->dump_dir); + ret = snprintf(buf,PAGE_SIZE,"%s\n",ctxt->dump_dir); l_out: return ret; } -int ps3_dump_dir_length(const char *buf, size_t count) +S32 ps3_dump_dir_length( const char *buf, size_t count) { - int i = 0; + S32 i = 0; char c; while ((size_t)i++ < count) { @@ -895,7 +871,7 @@ int ps3_dump_dir_length(const char *buf, size_t count) if (isalpha(c)) continue; - switch (c) { + switch(c) { case '-': case '_': case '/': @@ -911,35 +887,74 @@ int ps3_dump_dir_length(const char *buf, size_t count) return i; } -ssize_t ps3_dump_type_show(struct device *cdev, struct device_attribute *attr, - char *buf) +#if 0 +ssize_t ps3_dump_dir_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count) +{ +#if 1 + LOG_INFO("set dump log dir is not supported\n"); + return 0; +#else + S32 ret = 0, length = 0; + struct ps3_dump_context *ctxt = NULL; + (void)attr; + + LOG_INFO("dir param %s\n", buf); + + ctxt = dev_to_dump_context (cdev); + + length = ps3_dump_dir_length(buf, count); + length = min(length, (S32)PS3_DUMP_FILE_DIR_LEN); + if (length <= 0 || count > PS3_DUMP_FILE_DIR_LEN) { + ret = -EINVAL; + LOG_ERROR("Invalid param %s\n", buf); + goto l_ret; + } + + ps3_mutex_lock(&ctxt->dump_lock); + memset(ctxt->dump_dir, 0, sizeof(ctxt->dump_dir)); + (void)strncpy((char*)ctxt->dump_dir, buf, length); + ps3_mutex_unlock(&ctxt->dump_lock); + + LOG_INFO("dump dir change to %s\n", ctxt->dump_dir); + + ret = count; + +l_ret: + return ret; +#endif +} +#endif + +ssize_t ps3_dump_type_show(struct device *cdev,struct device_attribute *attr, char *buf) { struct ps3_dump_context *ctxt; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); ssize_t ret = 0; - if (instance == NULL) + if (instance == NULL) { goto l_out; + } ctxt = &instance->dump_context; - ret = snprintf(buf, PAGE_SIZE, "%d\n", ctxt->dump_type); + ret = snprintf(buf,PAGE_SIZE,"%d \n",ctxt->dump_type); l_out: return ret; } ssize_t ps3_dump_type_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { - int val = 0; - int ret = 0; + S32 val = 0; + S32 ret = 0; struct ps3_dump_context *ctxt = NULL; - unsigned char is_trigger_log = PS3_FALSE; + Bool is_trigger_log = PS3_FALSE; (void)attr; - ctxt = dev_to_dump_context(cdev); + ctxt = dev_to_dump_context (cdev); if (kstrtoint(buf, 0, &val) != 0) { ret = -EINVAL; @@ -947,16 +962,17 @@ ssize_t ps3_dump_type_store(struct device *cdev, struct device_attribute *attr, } if ((val < PS3_DUMP_TYPE_CRASH) || (val > PS3_DUMP_TYPE_BAR_DATA)) { - LOG_ERROR("host_no[%d],dump state should be %d - %d, %d is an invalid value\n", - PS3_HOST(ctxt->instance), PS3_DUMP_TYPE_CRASH, - PS3_DUMP_TYPE_BAR_DATA, val); + LOG_ERROR("host_no[%d],dump state should be %d - %d," + "%d is an invalid value\n", PS3_HOST(ctxt->instance), + PS3_DUMP_TYPE_CRASH, PS3_DUMP_TYPE_BAR_DATA, val); ret = -EINVAL; goto l_ret; } ps3_ioc_dump_support_get(ctxt->instance); is_trigger_log = ps3_dump_is_trigger_log(ctxt->instance); - if (!is_trigger_log) { + INJECT_START(PS3_ERR_IJ_STORE_NO_TRIGGER_LOG, &is_trigger_log) + if(!is_trigger_log) { LOG_INFO("cannot dump type set!\n"); ret = -EBUSY; goto l_ret; @@ -973,32 +989,28 @@ ssize_t ps3_dump_type_store(struct device *cdev, struct device_attribute *attr, void ps3_dma_dump_mapping(struct pci_dev *pdev) { -#if defined(PS3_DMA_MAPPING) -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) - void (*dma_dump_mappings)(struct device *dev) = NULL; - - dma_dump_mappings = (void (*)(struct device *)) - kallsyms_lookup_name("debug_dma_dump_mappings"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) + dma_dump_mappings_cb dma_dump_mappings = NULL; + dma_dump_mappings = (dma_dump_mappings_cb) kallsyms_lookup_name("debug_dma_dump_mappings"); if (dma_dump_mappings && pdev) { - pr_info("ps3 dma dump mapping begin\n"); + printk(KERN_INFO "ps3 dma dump mapping begin\n"); dma_dump_mappings(&pdev->dev); - pr_info("ps3 dma dump mapping end\n"); + printk(KERN_INFO "ps3 dma dump mapping end\n"); } #endif #endif (void)pdev; } -ssize_t ps3_soc_dead_reset_store(struct device *cdev, - struct device_attribute *attr, const char *buf, - size_t count) +ssize_t ps3_soc_dead_reset_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count) { - int val = 0; - int ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + S32 val = 0; + S32 ret = 0; + struct ps3_instance *instance = ps3_debug_instance_query(cdev, attr, buf); (void)attr; (void)count; @@ -1006,14 +1018,14 @@ ssize_t ps3_soc_dead_reset_store(struct device *cdev, ret = -EINVAL; goto l_ret; } - if (ps3_atomic_read(&instance->state_machine.state) != - PS3_INSTANCE_STATE_DEAD) { + if (ps3_atomic_read(&instance->state_machine.state) + != PS3_INSTANCE_STATE_DEAD) { ret = -EPERM; goto l_ret; } if (ps3_need_block_hard_reset_request(instance)) { LOG_WARN("hno:%u can not start hard reset\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } else { ps3_hard_recovery_request_with_retry(instance); } @@ -1022,38 +1034,39 @@ ssize_t ps3_soc_dead_reset_store(struct device *cdev, l_ret: return ret; } -ssize_t ps3_halt_support_cli_show(struct device *cdev, - struct device_attribute *attr, char *buf) +ssize_t ps3_halt_support_cli_show(struct device *cdev,struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; goto l_out; } - ret = snprintf(buf, PAGE_SIZE, "%d\n", instance->is_halt_support_cli); + ret = snprintf(buf, PAGE_SIZE, "%d\n", + instance->is_halt_support_cli); LOG_DEBUG("get halt_support_cli is %d\n", - instance->is_halt_support_cli); + instance->is_halt_support_cli); l_out: return ret; } -ssize_t ps3_halt_support_cli_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) +ssize_t ps3_halt_support_cli_store(struct device *cdev,struct device_attribute *attr, + const char *buf, size_t count) { - unsigned char halt_support_cli = 0; - unsigned char is_halt_support_cli; + U8 halt_support_cli = 0; + Bool is_halt_support_cli; ssize_t ret = count; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); + + if (instance == NULL) { - if (instance == NULL) goto l_out; + } if (kstrtou8(buf, 10, &halt_support_cli)) { ret = -EINVAL; @@ -1061,34 +1074,34 @@ ssize_t ps3_halt_support_cli_store(struct device *cdev, goto l_out; } - is_halt_support_cli = (halt_support_cli == 0) ? (0) : (1); + is_halt_support_cli = (halt_support_cli == 0)?(0):(1); instance->is_halt_support_cli = is_halt_support_cli; - LOG_WARN("set halt_support_cli is %d\n", instance->is_halt_support_cli); + LOG_WARN("set halt_support_cli is %d\n", + instance->is_halt_support_cli); l_out: return ret; } -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else ssize_t ps3_irq_prk_support_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, const char *buf, size_t count) { - int is_prk_in_irq = 0; + int is_prk_in_irq= 0; ssize_t ret = count; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); - if (cdev == NULL || buf == NULL) + if (cdev == NULL || buf == NULL) { goto l_out; + } if (kstrtoint(buf, 10, &is_prk_in_irq)) { - LOG_ERROR( - "invalid is_prk_in_irq, could not set is_prk_in_irq\n"); + LOG_ERROR("invalid is_prk_in_irq, could not set is_prk_in_irq\n"); ret = -EINVAL; goto l_out; } @@ -1101,14 +1114,15 @@ ssize_t ps3_irq_prk_support_store(struct device *cdev, } ssize_t ps3_irq_prk_support_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); - if (cdev == NULL || buf == NULL) + if (cdev == NULL || buf == NULL) { goto l_out; + } ret = snprintf(buf, PAGE_SIZE, "%d\n", instance->is_irq_prk_support); LOG_DEBUG("get log level to %d\n", instance->is_irq_prk_support); @@ -1117,12 +1131,12 @@ ssize_t ps3_irq_prk_support_show(struct device *cdev, } #endif -ssize_t ps3_qos_switch_show(struct device *cdev, struct device_attribute *attr, - char *buf) +ssize_t ps3_qos_switch_show(struct device *cdev, + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = 0; @@ -1130,19 +1144,19 @@ ssize_t ps3_qos_switch_show(struct device *cdev, struct device_attribute *attr, } ret = snprintf(buf, PAGE_SIZE, "%d\n", - instance->qos_context.qos_switch); + instance->qos_context.qos_switch); l_out: return ret; } -ssize_t ps3_qos_switch_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count) +ssize_t ps3_qos_switch_store(struct device *cdev, + struct device_attribute *attr, const char *buf, size_t count) { - unsigned char qos_switch = 0; + U8 qos_switch = 0; ssize_t ret = count; - struct ps3_instance *instance = - ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = ps3_debug_instance_query(cdev, + attr, buf); if (instance == NULL) { ret = count; @@ -1155,16 +1169,18 @@ ssize_t ps3_qos_switch_store(struct device *cdev, struct device_attribute *attr, goto l_out; } - if (instance->qos_context.qos_switch > 0 && qos_switch == 0) { - instance->qos_context.qos_switch = 0; - ps3_qos_close(instance); - } - if (instance->qos_context.qos_switch == 0 && qos_switch > 0) { - ps3_qos_open(instance); - instance->qos_context.qos_switch = qos_switch; - } + if (instance->qos_context.qos_switch > 0 && qos_switch == 0) { + instance->qos_context.qos_switch = 0; + ps3_qos_close(instance); + } + + if (instance->qos_context.qos_switch == 0 && qos_switch > 0) { + ps3_qos_open(instance); + instance->qos_context.qos_switch = qos_switch; + } - LOG_WARN("set qos switch is %d\n", instance->qos_context.qos_switch); + LOG_WARN("set qos switch is %d\n", + instance->qos_context.qos_switch); l_out: return ret; diff --git a/drivers/scsi/linkdata/ps3stor/ps3_debug.h b/drivers/scsi/linkdata/ps3stor/ps3_debug.h index 0b0f8a726aa8..715221e29f3c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_debug.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_debug.h @@ -1,152 +1,150 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_DEBUG_H_ #define _PS3_DEBUG_H_ -#ifndef _WINDOWS +#ifndef _WINDOWS #include #include #include struct ps3_reg_dump_attr { - unsigned long long read_dump_timestamp; - unsigned long long write_dump_timestamp; - unsigned long long read_dump_interval_ms; - unsigned long long write_dump_interval_ms; - unsigned long long lastest_value; - char name[32]; + U64 read_dump_timestamp; + U64 write_dump_timestamp; + U64 read_dump_interval_ms; + U64 write_dump_interval_ms; + U64 lastest_value; + S8 name[32]; }; struct ps3_debug_context { - unsigned char io_trace_switch; - unsigned char reserved[7]; - struct ps3_reg_dump_attr - reg_dump[PS3_REGISTER_SET_SIZE / sizeof(unsigned long long)]; - struct Ps3DebugMemEntry debug_mem_vaddr[PS3_DEBUG_MEM_ARRAY_MAX_NUM]; - struct Ps3DebugMemEntry *debug_mem_buf; + U8 io_trace_switch; + U8 reserved[7]; + struct ps3_reg_dump_attr reg_dump[PS3_REGISTER_SET_SIZE/sizeof(U64)]; + Ps3DebugMemEntry_s debug_mem_vaddr[PS3_DEBUG_MEM_ARRAY_MAX_NUM]; + Ps3DebugMemEntry_s *debug_mem_buf; dma_addr_t debug_mem_buf_phy; - unsigned int debug_mem_array_num; - unsigned char reserved1[4]; + U32 debug_mem_array_num; + U8 reserved1[4]; }; void ps3_debug_context_init(struct ps3_instance *instance); -void ps3_reg_dump(struct ps3_instance *instance, void __iomem *reg, - unsigned long long value, unsigned char is_read); +void ps3_reg_dump(struct ps3_instance *instance, + void __iomem *reg, U64 value, Bool is_read); ssize_t ps3_vd_io_outstanding_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); ssize_t ps3_io_outstanding_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); -ssize_t ps3_is_load_show(struct device *cdev, struct device_attribute *attr, - char *buf); +ssize_t ps3_is_load_show(struct device *cdev, + struct device_attribute *attr, char *buf); ssize_t ps3_dump_ioc_regs_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); ssize_t ps3_max_scsi_cmds_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); ssize_t ps3_event_subscribe_info_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); ssize_t ps3_ioc_state_show(struct device *cdev, struct device_attribute *attr, - char *buf); + char *buf); + +ssize_t ps3_log_level_store(struct device *cdev, + struct device_attribute *attr, const char *buf, size_t count); -ssize_t ps3_log_level_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count); -ssize_t ps3_log_level_show(struct device *cdev, struct device_attribute *attr, - char *buf); +ssize_t ps3_log_level_show(struct device *cdev, + struct device_attribute *attr, char *buf); ssize_t ps3_io_trace_switch_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count); + struct device_attribute *attr, const char *buf, size_t count); ssize_t ps3_io_trace_switch_show(struct device *cdev, - struct device_attribute *attr, char *buf); -ssize_t ps3_halt_support_cli_show(struct device *cdev, - struct device_attribute *attr, char *buf); -ssize_t ps3_halt_support_cli_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count); - -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + struct device_attribute *attr, char *buf); +ssize_t ps3_halt_support_cli_show(struct device *cdev,struct device_attribute *attr, char *buf); + +ssize_t ps3_halt_support_cli_store(struct device *cdev,struct device_attribute *attr, + const char *buf, size_t count); + +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else ssize_t ps3_irq_prk_support_store(struct device *cdev, - struct device_attribute *attr, - const char *buf, size_t count); + struct device_attribute *attr, const char *buf, size_t count); ssize_t ps3_irq_prk_support_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); #endif -ssize_t ps3_product_model_show(struct device *cdev, - struct device_attribute *attr, char *buf); +ssize_t ps3_product_model_show(struct device *cdev,struct device_attribute *attr, char *buf); -ssize_t ps3_qos_switch_show(struct device *cdev, struct device_attribute *attr, - char *buf); +ssize_t ps3_qos_switch_show(struct device *cdev, + struct device_attribute *attr, char *buf); -ssize_t ps3_qos_switch_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count); +ssize_t ps3_qos_switch_store(struct device *cdev, + struct device_attribute *attr, const char *buf, size_t count); #endif ssize_t ps3_event_subscribe_info_get(struct ps3_instance *instance, char *buf, - ssize_t total_len); + ssize_t total_len); #ifndef _WINDOWS -int ps3_debug_mem_alloc(struct ps3_instance *ins); -int ps3_debug_mem_free(struct ps3_instance *ins); -ssize_t ps3_dump_state_show(struct device *cdev, struct device_attribute *attr, - char *buf); -ssize_t ps3_dump_state_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count); -ssize_t ps3_dump_type_show(struct device *cdev, struct device_attribute *attr, - char *buf); +S32 ps3_debug_mem_alloc(struct ps3_instance *ins); + +S32 ps3_debug_mem_free(struct ps3_instance *ins); + +ssize_t ps3_dump_state_show(struct device *cdev,struct device_attribute *attr, char *buf); + +ssize_t ps3_dump_state_store(struct device *cdev,struct device_attribute *attr, + const char *buf, size_t count); + +ssize_t ps3_dump_type_show(struct device *cdev,struct device_attribute *attr, char *buf); ssize_t ps3_dump_type_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count); + const char *buf, size_t count); -ssize_t ps3_dump_dir_show(struct device *cdev, struct device_attribute *attr, - char *buf); +#if 0 +ssize_t ps3_dump_dir_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count); +#endif +ssize_t ps3_dump_dir_show(struct device *cdev,struct device_attribute *attr, char *buf); void ps3_dma_dump_mapping(struct pci_dev *pdev); -ssize_t ps3_soc_dead_reset_store(struct device *cdev, - struct device_attribute *attr, const char *buf, - size_t count); +ssize_t ps3_soc_dead_reset_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count); #else struct ps3_reg_dump_attr { - unsigned long long read_dump_timestamp; - unsigned long long write_dump_timestamp; - unsigned long long read_dump_interval_ms; - unsigned long long write_dump_interval_ms; - unsigned long long lastest_value; - char name[32]; + U64 read_dump_timestamp; + U64 write_dump_timestamp; + U64 read_dump_interval_ms; + U64 write_dump_interval_ms; + U64 lastest_value; + S8 name[32]; }; struct ps3_debug_context { - unsigned char io_trace_switch; - unsigned char reserved[7]; - struct ps3_reg_dump_attr - reg_dump[PS3_REGISTER_SET_SIZE / sizeof(unsigned long long)]; - struct Ps3DebugMemEntry debug_mem_vaddr[PS3_DEBUG_MEM_ARRAY_MAX_NUM]; - struct Ps3DebugMemEntry *debug_mem_buf; + U8 io_trace_switch; + U8 reserved[7]; + struct ps3_reg_dump_attr reg_dump[PS3_REGISTER_SET_SIZE / sizeof(U64)]; + Ps3DebugMemEntry_s debug_mem_vaddr[PS3_DEBUG_MEM_ARRAY_MAX_NUM]; + Ps3DebugMemEntry_s* debug_mem_buf; dma_addr_t debug_mem_buf_phy; - unsigned int debug_mem_array_num; - unsigned char reserved1[4]; + U32 debug_mem_array_num; + U8 reserved1[4]; }; void ps3_debug_context_init(struct ps3_instance *instance); -void ps3_reg_dump(struct ps3_instance *instance, void __iomem *reg, - unsigned long long value, unsigned char is_read); +void ps3_reg_dump(struct ps3_instance *instance, + void __iomem* reg, U64 value, Bool is_read); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_manager.c b/drivers/scsi/linkdata/ps3stor/ps3_device_manager.c index 0b8ef1361c6d..4eaa27243f23 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_manager.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_manager.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #ifndef _WINDOWS #include #include @@ -18,6 +17,8 @@ #include #endif +#include "ps3_meta.h" +#include "ps3_dev_type.h" #include "ps3_device_manager.h" #include "ps3_cmd_statistics.h" #include "ps3_mgr_cmd.h" @@ -29,41 +30,43 @@ #include "ps3_qos.h" static void ps3_nvme_attr_set(const struct ps3_instance *instance, - struct scsi_device *sdev); + struct scsi_device *sdev); -static int ps3_dev_channel_init(struct ps3_instance *instance) +static S32 ps3_dev_channel_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned char i = 0; - unsigned short vd_start = 0; - unsigned short pd_start = 0; + S32 ret = PS3_SUCCESS; + U8 i = 0; + U16 vd_start = 0; + U16 pd_start = 0; struct PS3ChannelInfo *channel_info = &instance->ctrl_info.channelInfo; struct ps3_channel *pd_chan = instance->dev_context.channel_pd; struct ps3_channel *vd_chan = instance->dev_context.channel_vd; - memset(pd_chan, 0, sizeof(struct ps3_channel) * PS3_MAX_CHANNEL_NUM); - memset(vd_chan, 0, sizeof(struct ps3_channel) * PS3_MAX_CHANNEL_NUM); + memset(pd_chan, 0, + sizeof(struct ps3_channel) * PS3_MAX_CHANNEL_NUM); + memset(vd_chan, 0, + sizeof(struct ps3_channel) * PS3_MAX_CHANNEL_NUM); instance->dev_context.pd_channel_count = 0; instance->dev_context.vd_channel_count = 0; instance->dev_context.max_dev_per_channel = 0; - ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); + instance->dev_context.abort_vdpending_cmd = 0; for (i = 0; i < channel_info->channelNum; i++) { LOG_INFO("hno:%u channel[%u] is type %s,max dev num is:%u\n", - PS3_HOST(instance), i, - namePS3ChannelType( - (enum PS3ChannelType)channel_info->channels[i] - .channelType), - channel_info->channels[i].maxDevNum); + PS3_HOST(instance), i, + namePS3ChannelType((enum PS3ChannelType) + channel_info->channels[i].channelType), + channel_info->channels[i].maxDevNum); if (channel_info->channels[i].maxDevNum > - instance->dev_context.max_dev_per_channel) { + instance->dev_context.max_dev_per_channel) { instance->dev_context.max_dev_per_channel = channel_info->channels[i].maxDevNum; } - if (channel_info->channels[i].channelType == PS3_CHAN_TYPE_VD) { + if (channel_info->channels[i].channelType == + PS3_CHAN_TYPE_VD) { vd_chan->channel = i; vd_chan->max_dev_num = channel_info->channels[i].maxDevNum; @@ -75,7 +78,7 @@ static int ps3_dev_channel_init(struct ps3_instance *instance) vd_chan++; instance->dev_context.vd_channel_count++; } else if (channel_info->channels[i].channelType == - PS3_CHAN_TYPE_PD) { + PS3_CHAN_TYPE_PD) { pd_chan->channel = i; pd_chan->max_dev_num = channel_info->channels[i].maxDevNum; @@ -90,7 +93,7 @@ static int ps3_dev_channel_init(struct ps3_instance *instance) if (instance->dev_context.max_dev_per_channel == 0) { LOG_WARN("hno:%u total dev in channel == 0\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } @@ -100,9 +103,10 @@ static int ps3_dev_channel_init(struct ps3_instance *instance) static void ps3_dev_buff_release(struct ps3_instance *instance) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - unsigned char i = 0; + U8 i = 0; - LOG_INFO("hno:%u release all device mgr buffer\n", PS3_HOST(instance)); + LOG_INFO("hno:%u release all device mgr buffer\n", + PS3_HOST(instance)); if (p_dev_ctx->pd_pool.devs_buffer != NULL) { ps3_kfree(instance, p_dev_ctx->pd_pool.devs_buffer); @@ -110,8 +114,7 @@ static void ps3_dev_buff_release(struct ps3_instance *instance) } if (p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array != NULL) { - ps3_vfree(instance, - p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array); + ps3_vfree(instance, p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array); p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array = NULL; } @@ -132,8 +135,7 @@ static void ps3_dev_buff_release(struct ps3_instance *instance) for (i = 0; i < PS3_VD_TABLE_NUM; i++) { if (p_dev_ctx->vd_table[i].vd_idxs_array != NULL) { - ps3_kfree(instance, - p_dev_ctx->vd_table[i].vd_idxs_array); + ps3_kfree(instance, p_dev_ctx->vd_table[i].vd_idxs_array); p_dev_ctx->vd_table[i].vd_idxs_array = NULL; } @@ -144,73 +146,68 @@ static void ps3_dev_buff_release(struct ps3_instance *instance) } } -static int ps3_vd_buff_alloc(struct ps3_instance *instance) +static S32 ps3_vd_buff_alloc(struct ps3_instance *instance) { - unsigned char i = 0; - unsigned char j = 0; + U8 i = 0; + U8 j = 0; struct ps3_channel *p_chan = NULL; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_dev_pool *vd_pool = &p_dev_ctx->vd_pool; struct ps3_vd_table *p_vd_table = p_dev_ctx->vd_table; - struct ps3_pri_data_table *p_vd_pri_data_table = - &p_dev_ctx->vd_pri_data_table; + struct ps3_pri_data_table *p_vd_pri_data_table = &p_dev_ctx->vd_pri_data_table; - ps3_atomic_set(&p_dev_ctx->subwork, 0); + p_dev_ctx->subwork = 0; p_dev_ctx->total_vd_count = 0; if (p_dev_ctx->vd_channel_count > 0) { - p_chan = - &p_dev_ctx->channel_vd[p_dev_ctx->vd_channel_count - 1]; - p_dev_ctx->total_vd_count = - p_chan->channel_start_num + p_chan->max_dev_num; + p_chan = &p_dev_ctx->channel_vd[p_dev_ctx->vd_channel_count-1]; + p_dev_ctx->total_vd_count = p_chan->channel_start_num + + p_chan->max_dev_num; } for (i = 0; i < PS3_VD_TABLE_NUM; i++) { - p_vd_table[i].vd_idxs_array = (unsigned short *)ps3_kzalloc( - instance, - sizeof(unsigned short) * p_dev_ctx->total_vd_count); + p_vd_table[i].vd_idxs_array = (U16*)ps3_kzalloc(instance, sizeof(U16) * + p_dev_ctx->total_vd_count); + INJECT_START(PS3_ERR_IJ_PS3_VD_IDX_ARRAY_ALLOC, &p_vd_table[i].vd_idxs_array); if (p_vd_table[i].vd_idxs_array == NULL) { - LOG_ERROR( - "hno:%u, Failed to allocate VD table %d buffer\n", + LOG_ERROR("hno:%u, Failed to allocate VD table %d buffer\n", PS3_HOST(instance), i); goto free_dev_buff; } - p_dev_ctx->vd_entries_array[i] = - (struct PS3VDEntry *)ps3_kzalloc( - instance, - sizeof(struct PS3VDEntry) * - (PS3_MAX_VD_COUNT(instance) + 1)); + p_dev_ctx->vd_entries_array[i] = (struct PS3VDEntry*) + ps3_kzalloc(instance, sizeof(struct PS3VDEntry) * + (PS3_MAX_VD_COUNT(instance) + 1)); + INJECT_START(PS3_ERR_IJ_PS3_VD_ENTRIES_ARRAY_ALLOC, &p_dev_ctx->vd_entries_array[i]); if (p_dev_ctx->vd_entries_array[i] == NULL) { - LOG_ERROR( - "hno:%u, Failed to allocate VD entry buffer\n", + LOG_ERROR("hno:%u, Failed to allocate VD entry buffer\n", PS3_HOST(instance)); goto free_dev_buff; } } - vd_pool->devs_buffer = (union PS3Device *)ps3_kzalloc( - instance, sizeof(union PS3Device) * p_dev_ctx->total_vd_count); + vd_pool->devs_buffer = (union PS3Device*)ps3_kzalloc(instance, + sizeof(union PS3Device) * p_dev_ctx->total_vd_count); + INJECT_START(PS3_ERR_IJ_PS3_VD_DEVS_BUF_ALLOC, &vd_pool->devs_buffer); if (vd_pool->devs_buffer == NULL) { LOG_ERROR("hno:%u Failed to allocate VD pool buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto free_dev_buff; } - memset(vd_pool->devs_buffer, 0, - sizeof(union PS3Device) * p_dev_ctx->total_vd_count); + memset(vd_pool->devs_buffer, 0, sizeof(union PS3Device) * p_dev_ctx->total_vd_count); p_vd_pri_data_table->vd_pri_data_idxs_array = - (struct ps3_scsi_priv_data **)ps3_vzalloc( - instance, sizeof(struct ps3_scsi_priv_data *) * - p_dev_ctx->total_vd_count); + (struct ps3_scsi_priv_data**)ps3_vzalloc(instance, + sizeof(struct ps3_scsi_priv_data*) * p_dev_ctx->total_vd_count); + INJECT_START(PS3_ERR_IJ_PS3_VD_PRI_DATA_IDXS_ARRAY_ALLOC, &p_vd_pri_data_table->vd_pri_data_idxs_array); if (p_vd_pri_data_table->vd_pri_data_idxs_array == NULL) { LOG_ERROR("hno:%u, Failed to allocate VD R1X table %d buffer\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); goto free_dev_buff; } memset(p_vd_pri_data_table->vd_pri_data_idxs_array, 0, - sizeof(struct ps3_scsi_priv_data *) * p_dev_ctx->total_vd_count); + sizeof(struct ps3_scsi_priv_data*) * p_dev_ctx->total_vd_count); p_chan = p_dev_ctx->channel_vd; for (i = 0; i < p_dev_ctx->vd_channel_count; i++) { @@ -218,13 +215,11 @@ static int ps3_vd_buff_alloc(struct ps3_instance *instance) &vd_pool->devs_buffer[p_chan->channel_start_num]; p_vd_pri_data_table->vd_pri_data_idxs[p_chan->channel] = - &p_vd_pri_data_table->vd_pri_data_idxs_array - [p_chan->channel_start_num]; + &p_vd_pri_data_table->vd_pri_data_idxs_array[p_chan->channel_start_num]; for (j = 0; j < PS3_VD_TABLE_NUM; j++) { p_vd_table[j].vd_idxs[p_chan->channel] = - &p_vd_table[j].vd_idxs_array - [p_chan->channel_start_num]; + &p_vd_table[j].vd_idxs_array[p_chan->channel_start_num]; } p_chan++; @@ -237,9 +232,9 @@ static int ps3_vd_buff_alloc(struct ps3_instance *instance) return -PS3_ENOMEM; } -static int ps3_pd_buff_alloc(struct ps3_instance *instance) +static S32 ps3_pd_buff_alloc(struct ps3_instance *instance) { - unsigned char i = 0; + U8 i = 0; struct ps3_channel *p_chan = NULL; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_dev_pool *pd_pool = &p_dev_ctx->pd_pool; @@ -247,34 +242,36 @@ static int ps3_pd_buff_alloc(struct ps3_instance *instance) p_dev_ctx->total_pd_count = 0; if (p_dev_ctx->pd_channel_count > 0) { - p_chan = - &p_dev_ctx->channel_pd[p_dev_ctx->pd_channel_count - 1]; - p_dev_ctx->total_pd_count = - p_chan->channel_start_num + p_chan->max_dev_num; + p_chan = &p_dev_ctx->channel_pd[p_dev_ctx->pd_channel_count - 1]; + p_dev_ctx->total_pd_count = p_chan->channel_start_num + + p_chan->max_dev_num; } - p_dev_ctx->pd_entries_array = (struct ps3_pd_entry *)ps3_kzalloc( - instance, - sizeof(struct ps3_pd_entry) * (PS3_MAX_PD_COUNT(instance) + 1)); + p_dev_ctx->pd_entries_array = (struct ps3_pd_entry*) + ps3_kzalloc(instance, sizeof(struct ps3_pd_entry) * + (PS3_MAX_PD_COUNT(instance) + 1)); + INJECT_START(PS3_ERR_IJ_PS3_PD_ENTRIES_ARRAY_ALLOC, &p_dev_ctx->pd_entries_array); if (p_dev_ctx->pd_entries_array == NULL) { LOG_ERROR("hno:%u, Failed to allocate PD entry buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto free_dev_pool; } - pd_table->pd_idxs_array = (unsigned short *)ps3_kzalloc( - instance, sizeof(unsigned short) * p_dev_ctx->total_pd_count); + pd_table->pd_idxs_array = (U16*)ps3_kzalloc(instance, sizeof(U16) * + p_dev_ctx->total_pd_count); + INJECT_START(PS3_ERR_IJ_PS3_PD_IDX_ARRAY_ALLOC, &pd_table->pd_idxs_array); if (pd_table->pd_idxs_array == NULL) { LOG_ERROR("hno:%u, Failed to allocate PD table buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto free_dev_pool; } - pd_pool->devs_buffer = (union PS3Device *)ps3_kzalloc( - instance, sizeof(union PS3Device) * p_dev_ctx->total_pd_count); + pd_pool->devs_buffer = (union PS3Device*)ps3_kzalloc(instance, + sizeof(union PS3Device) * p_dev_ctx->total_pd_count); + INJECT_START(PS3_ERR_IJ_PS3_PD_DEVS_BUF_ALLOC, &pd_pool->devs_buffer); if (pd_pool->devs_buffer == NULL) { LOG_ERROR("hno:%u, Failed to allocate PD pool buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto free_dev_pool; } @@ -294,100 +291,91 @@ static int ps3_pd_buff_alloc(struct ps3_instance *instance) return -PS3_ENOMEM; } -static int ps3_dev_buff_alloc(struct ps3_instance *instance) +static S32 ps3_dev_buff_alloc(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; LOG_INFO("hno:%u buff alloc pd count %d, vd count %d\n", - PS3_HOST(instance), PS3_MAX_PD_COUNT(instance), - PS3_MAX_VD_COUNT(instance)); + PS3_HOST(instance), PS3_MAX_PD_COUNT(instance), PS3_MAX_VD_COUNT(instance)); if (PS3_MAX_VD_COUNT(instance) > 0) { ret = ps3_vd_buff_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } } if (PS3_MAX_PD_COUNT(instance) > 0) { ret = ps3_pd_buff_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } } l_out: return ret; } -static inline unsigned short -ps3_pd_dma_alignment_calc(unsigned char align_shift) +static inline U16 ps3_pd_dma_alignment_calc(U8 align_shift) { return align_shift ? 1 << align_shift : 0; } -static inline unsigned char ps3_pd_type_localed(const struct PS3PDInfo *pd_info) +static inline U8 ps3_pd_type_localed(const struct PS3PDInfo *pd_info) { - unsigned char dev_type = PS3_DEV_TYPE_UNKNOWN; + U8 dev_type = PS3_DEV_TYPE_UNKNOWN; - dev_type = ps3_get_converted_dev_type(pd_info->driverType, - pd_info->mediumType); + dev_type = ps3_get_converted_dev_type(pd_info->driverType, pd_info->mediumType); if (unlikely(dev_type == PS3_DEV_TYPE_UNKNOWN)) { - LOG_ERROR( - "pd[%u:%u:%u], magic_num[%#x], driver_type[%s], medium_type[%s], dev_type is unknown\n", - PS3_CHANNEL(&pd_info->diskPos), - PS3_TARGET(&pd_info->diskPos), - PS3_PDID(&pd_info->diskPos), - pd_info->diskPos.diskMagicNum, - getDriverTypeName((enum DriverType)pd_info->driverType), - getMediumTypeName( - (enum MediumType)pd_info->mediumType)); + LOG_ERROR("pd[%u:%u:%u], magic_num[%#x], driver_type[%s], medium_type[%s], dev_type is unknown\n", + PS3_CHANNEL(&pd_info->diskPos), PS3_TARGET(&pd_info->diskPos), + PS3_PDID(&pd_info->diskPos), pd_info->diskPos.diskMagicNum, + getDriverTypeName((DriverType_e)pd_info->driverType), + getMediumTypeName((MediumType_e)pd_info->mediumType)); PS3_BUG(); } else { - LOG_INFO( - "pd[%u:%u:%u], magic_num[%#x], driver_type[%s], medium_type[%s], dev_type[%s]\n", - PS3_CHANNEL(&pd_info->diskPos), - PS3_TARGET(&pd_info->diskPos), - PS3_PDID(&pd_info->diskPos), - pd_info->diskPos.diskMagicNum, - getDriverTypeName((enum DriverType)pd_info->driverType), - getMediumTypeName((enum MediumType)pd_info->mediumType), + LOG_INFO("pd[%u:%u:%u], magic_num[%#x], driver_type[%s], medium_type[%s], dev_type[%s]\n", + PS3_CHANNEL(&pd_info->diskPos), PS3_TARGET(&pd_info->diskPos), + PS3_PDID(&pd_info->diskPos), pd_info->diskPos.diskMagicNum, + getDriverTypeName((DriverType_e)pd_info->driverType), + getMediumTypeName((MediumType_e)pd_info->mediumType), namePS3DevType((enum PS3DevType)dev_type)); } return dev_type; } void ps3_vd_info_show(const struct ps3_instance *instance, - const struct PS3VDEntry *vd_entry) + const struct PS3VDEntry *vd_entry) { - unsigned char i = 0; - unsigned char j = 0; - unsigned char channel = (unsigned char)PS3_CHANNEL(&vd_entry->diskPos); - unsigned short target_id = PS3_TARGET(&vd_entry->diskPos); - unsigned short vd_id = PS3_VDID(&vd_entry->diskPos); - - LOG_INFO_IN_IRQ( - instance, - "hno:%u disk detail info - vd[%u:%u:%u], magicNum[%#x]\n" - "\tdev_type: PS3_DEV_TYPE_VD, isHidden[%s]\n" - "\taccessPolicy[%s], diskGrpId[%u], sectorSize[%u]\n" - "\tstripeDataSize[%u], physDrvCnt[%u], stripSize[%u]\n" - "\tisDirectEnable[%s], raidLevel[%u], spanCount[%u]\n" - "\tdiskState[%u], startLBA[%llu], extentSize[%llu]\n" - "\tisTaskMgmtEnable[%u], taskAbortTimeout[%u]\n" - "\ttaskResetTimeout[%u], mapBlock[%llu], mapBlockVer[%u]\n" - "\tmaxIOSize[%u], devQueDepth[%u], capacity[%llu], isNvme[%u], isSsd[%u]\n" - "\tvirtDiskSeq[%d] bdev_bdi_cap[%d], umapBlkDescCnt[%d], umapNumblk[%d]\n" - "\tnormalQuota[%u], directQuota[%u] dev_busy_scale[%u]\n", - PS3_HOST(instance), channel, target_id, vd_id, + U8 i = 0; + U8 j = 0; + U8 channel = (U8)PS3_CHANNEL(&vd_entry->diskPos); + U16 target_id = PS3_TARGET(&vd_entry->diskPos); + U16 vd_id = PS3_VDID(&vd_entry->diskPos); + + LOG_INFO_IN_IRQ(instance, + "hno:%u disk detail info - vd[%u:%u:%u], magicNum[%#x], " + "dev_type: PS3_DEV_TYPE_VD, isHidden[%s], " + "accessPolicy[%s], diskGrpId[%u], sectorSize[%u], " + "stripeDataSize[%u], physDrvCnt[%u], stripSize[%u], " + "isDirectEnable[%s], raidLevel[%u], spanCount[%u], " + "diskState[%u], startLBA[%llu], extentSize[%llu], " + "isTaskMgmtEnable[%u], taskAbortTimeout[%u], " + "taskResetTimeout[%u], mapBlock[%llu], mapBlockVer[%u], " + "maxIOSize[%u], devQueDepth[%u], capacity[%llu], isNvme[%u], isSsd[%u], virtDiskSeq[%d], " + "bdev_bdi_cap[%d], umapBlkDescCnt[%d], umapNumblk[%d], normalQuota[%u], directQuota[%u], " + "dev_busy_scale[%u]\n" + , PS3_HOST(instance), channel, target_id, vd_id, vd_entry->diskPos.diskMagicNum, (vd_entry->isHidden) ? "true" : "false", - ps3_get_vd_access_plolicy_str( - (enum VDAccessPolicy)vd_entry->accessPolicy), - vd_entry->diskGrpId, vd_entry->sectorSize, - vd_entry->stripeDataSize, vd_entry->physDrvCnt, - vd_entry->stripSize, + ps3_get_vd_access_plolicy_str((VDAccessPolicy_e)vd_entry->accessPolicy), + vd_entry->diskGrpId, + vd_entry->sectorSize, vd_entry->stripeDataSize, + vd_entry->physDrvCnt, vd_entry->stripSize, (vd_entry->isDirectEnable) ? "true" : "false", - vd_entry->raidLevel, vd_entry->spanCount, vd_entry->diskState, + vd_entry->raidLevel, + vd_entry->spanCount, vd_entry->diskState, vd_entry->startLBA, vd_entry->extentSize, vd_entry->isTaskMgmtEnable, vd_entry->taskAbortTimeout, vd_entry->taskResetTimeout, vd_entry->mapBlock, @@ -399,65 +387,58 @@ void ps3_vd_info_show(const struct ps3_instance *instance, vd_entry->dev_busy_scale); for (i = 0; i < vd_entry->spanCount; i++) { - LOG_INFO_IN_IRQ( - instance, - "hno:%u vd[%u:%u:%u] span[%u] stripeDataSize[%u], state[%u], pdNum[%u]\n", - PS3_HOST(instance), channel, target_id, vd_id, i, + LOG_INFO_IN_IRQ(instance, + "hno:%u vd[%u:%u:%u]----span[%u]----" + "spanStripeDataSize[%u], spanState[%u], spanPdNum[%u]\n" + , PS3_HOST(instance), channel, target_id, vd_id, i, vd_entry->span[i].spanStripeDataSize, vd_entry->span[i].spanState, vd_entry->span[i].spanPdNum); for (j = 0; j < vd_entry->span[i].spanPdNum; j++) { - LOG_INFO_IN_IRQ( - instance, - "hno:%u vd[%u:%u:%u] span[%u] ext[%u] pd:[%u:%u:%u], state[%u]\n", - PS3_HOST(instance), channel, target_id, vd_id, - i, j, - vd_entry->span[i] - .extent[j] - .phyDiskID.ps3Dev.softChan, - vd_entry->span[i] - .extent[j] - .phyDiskID.ps3Dev.devID, - vd_entry->span[i] - .extent[j] - .phyDiskID.ps3Dev.phyDiskID, + LOG_INFO_IN_IRQ(instance, + "hno:%u vd[%u:%u:%u]----span[%u]." + "extent[%u]----pd:[%u:%u:%u], state[%u]\n" + , PS3_HOST(instance), channel, target_id, vd_id, i, j, + vd_entry->span[i].extent[j].phyDiskID.ps3Dev.softChan, + vd_entry->span[i].extent[j].phyDiskID.ps3Dev.devID, + vd_entry->span[i].extent[j].phyDiskID.ps3Dev.phyDiskID, vd_entry->span[i].extent[j].state); } } } static void ps3_pd_info_show(const struct ps3_instance *instance, - const struct ps3_pd_entry *pd_entry) + const struct ps3_pd_entry *pd_entry) { - LOG_INFO("hno:%u disk detail info - pd[%u:%u:%u], magicNum[%#x]\n" - "\tstate[%s], dev_type[%s], config_flag[%s], pd_flags[0x%02x]\n" - "\tRWCT[%u], scsi_interface_type[%u]\n" - "\ttask_abort_timeout[%u], task_reset_timeout[%u]\n" - "\tmax_io_size[%u], dev_queue_depth[%u]\n" - "\tsector_size[%u], encl_id[%u], pd phy_id[%u]\n" - "\tdma_addr_alignment[%u], dma_len_alignment[%u]\n" - "\tnormal_quota[%u] direct_quota[%u] is_direct_disable[%u]\n", - PS3_HOST(instance), PS3_CHANNEL(&pd_entry->disk_pos), - PS3_TARGET(&pd_entry->disk_pos), PS3_PDID(&pd_entry->disk_pos), - pd_entry->disk_pos.diskMagicNum, - getDeviceStateName((enum DeviceState)pd_entry->state), - namePS3DevType((enum PS3DevType)pd_entry->dev_type), - getPdStateName((enum MicPdState)pd_entry->config_flag, - instance->is_raid), - pd_entry->pd_flags, pd_entry->RWCT, - pd_entry->scsi_interface_type, pd_entry->task_abort_timeout, - pd_entry->task_reset_timeout, pd_entry->max_io_size, - pd_entry->dev_queue_depth, pd_entry->sector_size, - pd_entry->encl_id, pd_entry->phy_id, - pd_entry->dma_addr_alignment, pd_entry->dma_len_alignment, - pd_entry->normal_quota, pd_entry->direct_quota, - pd_entry->is_direct_disable); + LOG_INFO("hno:%u disk detail info - pd[%u:%u:%u], magicNum[%#x], " + "state[%s], dev_type[%s], config_flag[%s], pd_flags[0x%02x]" + "RWCT[%u], scsi_interface_type[%u], " + "task_abort_timeout[%u], task_reset_timeout[%u], " + "max_io_size[%u], dev_queue_depth[%u], " + "sector_size[%u], encl_id[%u], pd phy_id[%u], " + "dma_addr_alignment[%u], dma_len_alignment[%u], " + "normal_quota[%u] direct_quota[%u] is_direct_disable[%u]\n" + , PS3_HOST(instance), + PS3_CHANNEL(&pd_entry->disk_pos), + PS3_TARGET(&pd_entry->disk_pos), + PS3_PDID(&pd_entry->disk_pos), + pd_entry->disk_pos.diskMagicNum, + getDeviceStateName((DeviceState_e)pd_entry->state), + namePS3DevType((enum PS3DevType)pd_entry->dev_type), + getPdStateName((MicPdState_e)pd_entry->config_flag, instance->is_raid), pd_entry->pd_flags, + pd_entry->RWCT, pd_entry->scsi_interface_type, + pd_entry->task_abort_timeout, pd_entry->task_reset_timeout, + pd_entry->max_io_size, pd_entry->dev_queue_depth, + pd_entry->sector_size, pd_entry->encl_id, + pd_entry->phy_id, pd_entry->dma_addr_alignment, + pd_entry->dma_len_alignment, + pd_entry->normal_quota, pd_entry->direct_quota, pd_entry->is_direct_disable + ); } static inline void ps3_pd_info_localed(const struct ps3_instance *instance, - struct ps3_pd_entry *local_entry, - const struct PS3PDInfo *pd_info) + struct ps3_pd_entry *local_entry, const struct PS3PDInfo *pd_info) { local_entry->disk_pos = pd_info->diskPos; local_entry->dev_type = ps3_pd_type_localed(pd_info); @@ -473,67 +454,67 @@ static inline void ps3_pd_info_localed(const struct ps3_instance *instance, local_entry->is_direct_disable = pd_info->isDirectDisable; local_entry->encl_id = pd_info->enclId; local_entry->phy_id = pd_info->phyId; - local_entry->dma_addr_alignment = - ps3_pd_dma_alignment_calc(pd_info->dmaAddrAlignShift); - local_entry->dma_len_alignment = - ps3_pd_dma_alignment_calc(pd_info->dmaLenAlignShift); + local_entry->dma_addr_alignment = ps3_pd_dma_alignment_calc(pd_info->dmaAddrAlignShift); + local_entry->dma_len_alignment = ps3_pd_dma_alignment_calc(pd_info->dmaLenAlignShift); local_entry->normal_quota = pd_info->normalQuota; local_entry->direct_quota = pd_info->directQuota; if (unlikely(local_entry->sector_size == 0)) { LOG_WARN("pd[%u:%u] sector_size is 0\n", - PS3_CHANNEL(&local_entry->disk_pos), - PS3_TARGET(&local_entry->disk_pos)); + PS3_CHANNEL(&local_entry->disk_pos), + PS3_TARGET(&local_entry->disk_pos)); } ps3_pd_info_show(instance, local_entry); } -int ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, - unsigned short channel, unsigned short target_id, - unsigned short pd_id) +S32 ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, U16 channel, + U16 target_id, U16 pd_id) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct PS3PDInfo *pd_info = NULL; struct ps3_dev_context *dev_ctx = &instance->dev_context; - LOG_DEBUG("hno:%u, get PD info [%u:%u:%u] start\n", PS3_HOST(instance), - channel, target_id, pd_id); + LOG_DEBUG("hno:%u, get PD info [%u:%u:%u] start\n", + PS3_HOST(instance), channel, target_id, pd_id); ret = ps3_pd_info_get(instance, channel, target_id, pd_id); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL6, &ret); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, get single PD info [%u:%u:%u] NOK\n", - PS3_HOST(instance), channel, target_id, pd_id); + PS3_HOST(instance), channel, target_id, pd_id); goto l_out; } pd_info = dev_ctx->pd_info_buf; + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS1, &pd_info->diskPos.diskDev.diskID); if (PS3_PDID_INVALID(&pd_info->diskPos)) { LOG_WARN("hno:%u, cannot found PD info [%u:%u:%u]\n", - PS3_HOST(instance), channel, target_id, pd_id); + PS3_HOST(instance), channel, target_id, pd_id); ret = -PS3_FAILED; goto l_out; } - if (pd_info->dmaAddrAlignShift > PS3_DMA_ALIGN_SHIFT_MAX) { - LOG_WARN( - "hno:%u PD info [%u:%u:%u] invalid dmaAddrAlignShift\n", - PS3_HOST(instance), channel, target_id, - PS3_PDID(&pd_info->diskPos)); + INJECT_START(PS3_ERR_IJ_FORCE_MOD_ALIGN, &pd_info->dmaAddrAlignShift); + if (pd_info->dmaAddrAlignShift > + PS3_DMA_ALIGN_SHIFT_MAX) { + LOG_WARN("hno:%u PD info [%u:%u:%u] invalid dmaAddrAlignShift\n", + PS3_HOST(instance), channel, target_id, PS3_PDID(&pd_info->diskPos)); ret = -PS3_FAILED; goto l_out; } - if (pd_info->dmaLenAlignShift > PS3_DMA_ALIGN_SHIFT_MAX) { + INJECT_START(PS3_ERR_IJ_FORCE_MOD_ALIGN1, &pd_info->dmaLenAlignShift); + if (pd_info->dmaLenAlignShift > + PS3_DMA_ALIGN_SHIFT_MAX) { LOG_WARN("hno:%u PD info [%u:%u:%u] invalid dmalenAlignShift\n", - PS3_HOST(instance), channel, target_id, - PS3_PDID(&pd_info->diskPos)); + PS3_HOST(instance), channel, target_id, PS3_PDID(&pd_info->diskPos)); ret = -PS3_FAILED; goto l_out; } + INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN2, &channel); if (unlikely(PS3_CHANNEL(&pd_info->diskPos) != channel || - PS3_TARGET(&pd_info->diskPos) != target_id)) { - LOG_ERROR( - "hno:%u PD info get [%u:%u:%u]!=[%u:%u:%u] magic[%#x] unmatched\n", + PS3_TARGET(&pd_info->diskPos) != target_id)) { + LOG_ERROR("hno:%u PD info get [%u:%u:%u]!=[%u:%u:%u] magic[%#x] unmatched\n", PS3_HOST(instance), channel, target_id, pd_id, PS3_CHANNEL(&pd_info->diskPos), PS3_TARGET(&pd_info->diskPos), @@ -544,21 +525,19 @@ int ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, goto l_out; } - if (unlikely(PS3_PDID(&pd_info->diskPos) > - PS3_MAX_PD_COUNT(instance))) { + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKID, &PS3_PDID(&pd_info->diskPos)); + if (unlikely(PS3_PDID(&pd_info->diskPos) > PS3_MAX_PD_COUNT(instance))) { LOG_ERROR("hno:%u init pd info NOK, pd_id[%d] > max[%d]\n", - PS3_HOST(instance), PS3_PDID(&pd_info->diskPos), - PS3_MAX_PD_COUNT(instance)); + PS3_HOST(instance), + PS3_PDID(&pd_info->diskPos), PS3_MAX_PD_COUNT(instance)); PS3_BUG(); ret = -PS3_FAILED; goto l_out; } - ps3_pd_info_localed( - instance, - &dev_ctx->pd_entries_array[PS3_PDID(&pd_info->diskPos)], - pd_info); + ps3_pd_info_localed(instance, &dev_ctx->pd_entries_array[ + PS3_PDID(&pd_info->diskPos)], pd_info); dev_ctx->pd_table.pd_idxs[channel][target_id] = PS3_PDID(&pd_info->diskPos); l_out: @@ -567,10 +546,10 @@ int ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, static void ps3_pd_info_get_all(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned short i = 0; - unsigned short j = 0; - unsigned char chan_id = 0; + S32 ret = PS3_SUCCESS; + U16 i = 0; + U16 j = 0; + U8 chan_id = 0; struct ps3_channel *pd_chan = instance->dev_context.channel_pd; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; @@ -578,54 +557,48 @@ static void ps3_pd_info_get_all(struct ps3_instance *instance) struct ps3_dev_pool *p_pd_pool = &p_dev_ctx->pd_pool; memset(p_table->pd_idxs_array, PS3_INVALID_VALUE, - p_dev_ctx->total_pd_count * sizeof(unsigned short)); + p_dev_ctx->total_pd_count * sizeof(U16)); for (i = 0; i < p_dev_ctx->pd_channel_count; i++) { chan_id = pd_chan[i].channel; for (j = 0; j < pd_chan[i].max_dev_num; j++) { - if (PS3_PDID_INVALID( - &p_pd_pool->devs[chan_id][j].pd.diskPos)) { + if (PS3_PDID_INVALID(&p_pd_pool->devs[chan_id][j].pd.diskPos)) continue; - } - ret = ps3_dev_mgr_pd_info_get( - instance, chan_id, j, - PS3_PDID(&p_pd_pool->devs[chan_id][j] - .pd.diskPos)); + ret = ps3_dev_mgr_pd_info_get(instance, chan_id, j, + PS3_PDID(&p_pd_pool->devs[chan_id][j].pd.diskPos)); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, get PD[%u:%u] info NOK\n", - PS3_HOST(instance), chan_id, j); + PS3_HOST(instance), chan_id, j); } } } } -int ps3_dev_mgr_vd_info_subscribe(struct ps3_instance *instance) +S32 ps3_dev_mgr_vd_info_subscribe(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - - LOG_FILE_INFO("hno:%u %s\n", - PS3_HOST(instance), __func__); + S32 ret = PS3_SUCCESS; + LOG_FILE_INFO("hno:%u ps3_dev_mgr_vd_info_subscribe\n", PS3_HOST(instance)); - if (PS3_MAX_VD_COUNT(instance) <= 0) + if (PS3_MAX_VD_COUNT(instance) <= 0) { goto l_out; + } ret = ps3_vd_info_async_get(instance); if (ret != PS3_SUCCESS) { LOG_FILE_ERROR("hno:%u async get VD info failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } l_out: return ret; } -int ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance) +S32 ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance) { - unsigned long flags = 0; - int ret = PS3_SUCCESS; + ULong flags = 0; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; - if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { ret = -PS3_FAILED; goto l_out; @@ -634,7 +607,7 @@ int ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance) cmd = instance->dev_context.vd_pending_cmd; if (cmd == NULL) { LOG_WARN("hno:%u vd pending cmd has been cancel\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } @@ -643,66 +616,64 @@ int ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance) if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); LOG_WARN("hno:%u who steal free this cmd,CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); instance->dev_context.vd_pending_cmd = NULL; goto l_out; } else { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - if (ps3_atomic_add_unless(&instance->dev_context.is_vdpending_abort, 1, - 1) == 0) { - ret = PS3_SUCCESS; - goto l_out; - } - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, - PS3_CANCEL_VDPENDING_CMD); - if (ret == -PS3_ENOMEM) { - LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); + if (ps3_atomic_add_unless(&instance->dev_context.is_vdpending_abort, 1, 1) == 0) { + ret = PS3_SUCCESS; + goto l_out; + } + + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_VDPENDING_CMD); + INJECT_START(PS3_ERR_IJ_CANCEL_VDPENDING_CMD_FAIL, &ret) + if(ret == -PS3_ENOMEM){ + LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); ret = PS3_FAILED; - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; - } else if (ret != PS3_SUCCESS) { + }else if(ret != PS3_SUCCESS){ LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), - ps3_cmd_frame_id( - instance->dev_context.vdpending_abort_cmd), - cmd->index); + PS3_HOST(instance), ps3_cmd_frame_id(instance->dev_context.vdpending_abort_cmd), cmd->index); abort_cmd = instance->dev_context.vdpending_abort_cmd; instance->dev_context.vdpending_abort_cmd = NULL; - if (abort_cmd != NULL) + if (abort_cmd != NULL) { ps3_task_cmd_free(instance, abort_cmd); + } ret = PS3_FAILED; - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; } ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_VDPENDING_CMD); + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_VD_PENDING_FAILED, &ret) if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u unsubscribe vd pending, cancel cmd NOK\n", - PS3_HOST(instance)); - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + PS3_HOST(instance)); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; } - LOG_INFO("hno:%u vd pending cmd free, CFID:%d\n", PS3_HOST(instance), - cmd->index); + LOG_INFO("hno:%u vd pending cmd free, CFID:%d\n", + PS3_HOST(instance), cmd->index); instance->dev_context.vd_pending_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); l_out: return ret; } -int ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance) +S32 ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance) { - unsigned long flags = 0; - int ret = PS3_SUCCESS; + ULong flags = 0; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; - unsigned long flags1 = 0; - unsigned char is_need_resend = PS3_FALSE; - + ULong flags1 = 0; + Bool is_need_resend = PS3_FALSE; if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { ret = -PS3_FAILED; goto l_out; @@ -711,10 +682,9 @@ int ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance) cmd = instance->dev_context.vd_pending_cmd; if (cmd == NULL) { LOG_WARN("hno:%u vd pending cmd has been cancel\n", - PS3_HOST(instance)); + PS3_HOST(instance)); is_need_resend = PS3_TRUE; - ps3_spin_lock_irqsave( - &instance->recovery_context->recovery_lock, &flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); goto l_resend; } @@ -722,84 +692,71 @@ int ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance) if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); LOG_WARN("hno:%u free vdpending cmd,CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); instance->dev_context.vd_pending_cmd = NULL; goto l_out; } else { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - if (ps3_atomic_add_unless(&instance->dev_context.is_vdpending_abort, 1, - 1) == 0) { - ret = PS3_SUCCESS; - goto l_out; - } + if (ps3_atomic_add_unless(&instance->dev_context.is_vdpending_abort, 1, 1) == 0) { + ret = PS3_SUCCESS; + goto l_out; + } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, - PS3_CANCEL_VDPENDING_CMD); - if (ret == -PS3_ENOMEM) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); - LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_VDPENDING_CMD); + if(ret == -PS3_ENOMEM){ + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); ret = -PS3_FAILED; - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; - } else if (ret != PS3_SUCCESS) { - LOG_FILE_INFO( - "hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), - ps3_cmd_frame_id( - instance->dev_context.vdpending_abort_cmd), - cmd->index); + }else if(ret != PS3_SUCCESS){ + LOG_FILE_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", + PS3_HOST(instance), ps3_cmd_frame_id(instance->dev_context.vdpending_abort_cmd), cmd->index); abort_cmd = instance->dev_context.vdpending_abort_cmd; instance->dev_context.vdpending_abort_cmd = NULL; - if (abort_cmd != NULL) + if (abort_cmd != NULL) { ps3_task_cmd_free(instance, abort_cmd); + } ret = -PS3_FAILED; - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; } - ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 1); - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + instance->dev_context.abort_vdpending_cmd = 1; + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_VDPENDING_CMD); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u unsubscribe vd pending, cancel cmd NOK\n", - PS3_HOST(instance)); - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + PS3_HOST(instance)); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - if (ps3_atomic_read(&instance->dev_context.subwork) == 0) { - if (ps3_atomic_read(&instance->dev_context.abort_vdpending_cmd) != 0) { - ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + if(instance->dev_context.subwork == 0){ + if(instance->dev_context.abort_vdpending_cmd != 0){ + instance->dev_context.abort_vdpending_cmd = 0; LOG_FILE_INFO("hno:%u vd pending cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); instance->dev_context.vd_pending_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); is_need_resend = PS3_TRUE; } } - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); l_resend: if (is_need_resend) { ret = ps3_dev_mgr_vd_info_subscribe(instance); if (ret != PS3_SUCCESS) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, - flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); goto l_out; } } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); l_out: return ret; @@ -807,39 +764,37 @@ int ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance) void ps3_dev_mgr_vd_info_clear(struct ps3_instance *instance) { - unsigned long flags = 0; - unsigned long flags1 = 0; + ULong flags = 0; + ULong flags1 = 0; struct ps3_cmd *cmd = NULL; - - ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); + instance->dev_context.abort_vdpending_cmd = 0; cmd = instance->dev_context.vd_pending_cmd; if (cmd == NULL) { LOG_WARN("hno:%u vd pending cmd has been cancel\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_INFO("hno:%u free this cmd,CFID:%d\n", PS3_HOST(instance), - cmd->index); - ps3_spin_lock_irqsave( - &instance->recovery_context->recovery_lock, &flags1); + LOG_INFO("hno:%u free this cmd,CFID:%d\n", + PS3_HOST(instance), cmd->index); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); instance->dev_context.vd_pending_cmd = NULL; - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); goto l_out; } else { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - LOG_INFO("hno:%u vd pending cmd free, CFID:%d\n", PS3_HOST(instance), - cmd->index); + LOG_INFO("hno:%u vd pending cmd free, CFID:%d\n", + PS3_HOST(instance), cmd->index); instance->dev_context.vd_pending_cmd = NULL; - ps3_atomic_set(&instance->dev_context.subwork, 0); + instance->dev_context.subwork = 0; + ps3_mgr_cmd_free(instance, cmd); l_out: @@ -848,26 +803,22 @@ void ps3_dev_mgr_vd_info_clear(struct ps3_instance *instance) #ifndef _WINDOWS void ps3_change_sdev_max_sector(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry) + struct PS3VDEntry *vd_entry) { struct scsi_device *sdev = NULL; struct PS3Dev *p_vd = &vd_entry->diskPos.diskDev.ps3Dev; - sdev = ps3_scsi_device_lookup(instance, p_vd->softChan, p_vd->devID, 0); + sdev = ps3_scsi_device_lookup(instance, p_vd->softChan, + p_vd->devID, 0); if (sdev != NULL) { if (vd_entry->sectorSize == PS3_SECTORSIZE_512B) { - blk_queue_max_hw_sectors(sdev->request_queue, - vd_entry->maxIOSize); + blk_queue_max_hw_sectors(sdev->request_queue, vd_entry->maxIOSize); } else { - blk_queue_max_hw_sectors( - sdev->request_queue, - vd_entry->maxIOSize - << (ilog2(vd_entry->sectorSize) - - PS3_512B_SHIFT)); + blk_queue_max_hw_sectors(sdev->request_queue, + vd_entry->maxIOSize << (ilog2(vd_entry->sectorSize) - PS3_512B_SHIFT)); } - LOG_INFO_IN_IRQ( - instance, + LOG_INFO_IN_IRQ(instance, "hno:%u vd[%u:%u] max sector num change to:%d\n", PS3_HOST(instance), p_vd->softChan, p_vd->devID, vd_entry->maxIOSize); @@ -876,48 +827,51 @@ void ps3_change_sdev_max_sector(struct ps3_instance *instance, } } #endif -int ps3_vd_info_get_all(struct ps3_instance *instance) +S32 ps3_vd_info_get_all(struct ps3_instance *instance) { - int ret = -PS3_FAILED; - unsigned short i = 0; + S32 ret = -PS3_FAILED; + U16 i = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - unsigned char vd_table_idx = (p_dev_ctx->vd_table_idx + 1) & 1; - struct ps3_vd_table *p_vd_table = &p_dev_ctx->vd_table[vd_table_idx]; + U8 vd_table_idx = (p_dev_ctx->vd_table_idx + 1) & 1; + struct ps3_vd_table *p_vd_table = + &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; - struct PS3VDEntry *p_vd_entry = p_dev_ctx->vd_info_buf_sync->vds; + struct PS3VDEntry *p_vd_entry = + p_dev_ctx->vd_info_buf_sync->vds; struct PS3Dev *p_dev = NULL; - unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; + U16 virtDiskIdx = PS3_INVALID_DEV_ID; if (PS3_MAX_VD_COUNT(instance) == 0) { - LOG_INFO("hno:%u vd max count is %d\n", PS3_HOST(instance), - PS3_MAX_VD_COUNT(instance)); + LOG_INFO("hno:%u vd max count is %d\n", + PS3_HOST(instance), PS3_MAX_VD_COUNT(instance)); ret = PS3_SUCCESS; goto l_out; } if (p_dev_ctx->vd_list_buf->count == 0) { - LOG_INFO("hno:%u vd list count is 0\n", PS3_HOST(instance)); + LOG_INFO("hno:%u vd list count is 0\n", + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } ret = ps3_vd_info_sync_get(instance, 0, PS3_MAX_VD_COUNT(instance)); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u, sync get VD info NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u, sync get VD info NOK\n", + PS3_HOST(instance)); goto l_out; } memset(p_vd_table->vd_idxs_array, 0, - p_dev_ctx->total_vd_count * sizeof(unsigned short)); + p_dev_ctx->total_vd_count * sizeof(U16)); - LOG_INFO("hno:%u get vd info count is %d\n", PS3_HOST(instance), - p_dev_ctx->vd_info_buf_sync->count); + LOG_INFO("hno:%u get vd info count is %d\n", + PS3_HOST(instance),p_dev_ctx->vd_info_buf_sync->count); for (i = 0; i < p_dev_ctx->vd_info_buf_sync->count; i++) { if (PS3_VDID_INVALID(&p_vd_entry[i].diskPos)) { - LOG_WARN( - "hno:%u, init %d of %d vd info NOK, vdid is 0\n", + LOG_WARN("hno:%u, init %d of %d vd info NOK, vdid is 0\n", PS3_HOST(instance), i, p_dev_ctx->vd_info_buf_sync->count); continue; @@ -925,20 +879,17 @@ int ps3_vd_info_get_all(struct ps3_instance *instance) p_dev = PS3_DEV(&p_vd_entry[i].diskPos); - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), - p_dev->virtDiskID); - if (!ps3_dev_id_valid_check(instance, - (unsigned char)p_dev->softChan, - p_dev->devID, PS3_DISK_TYPE_VD)) { + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), p_dev->virtDiskID); + if (!ps3_dev_id_valid_check(instance, (U8)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_VD)) { PS3_BUG(); continue; } if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(instance))) { - LOG_ERROR( - "hno:%u init %d of %d vd info NOK, vir_id[%d] > max[%d]\n", - PS3_HOST(instance), i, - p_dev_ctx->vd_info_buf_sync->count - 1, + LOG_ERROR("hno:%u init %d of %d vd info NOK, vir_id[%d] > max[%d]\n", + PS3_HOST(instance),i, + p_dev_ctx->vd_info_buf_sync->count-1, virtDiskIdx, PS3_MAX_VD_COUNT(instance)); PS3_BUG(); @@ -946,89 +897,96 @@ int ps3_vd_info_get_all(struct ps3_instance *instance) } ps3_vd_busy_scale_get(&p_vd_entry[i]); memcpy(&p_vd_array[virtDiskIdx], &p_vd_entry[i], - sizeof(struct PS3VDEntry)); - p_vd_table->vd_idxs[p_dev->softChan][p_dev->devID] = - p_dev->virtDiskID; + sizeof(struct PS3VDEntry)); + p_vd_table->vd_idxs[p_dev->softChan][p_dev->devID] = p_dev->virtDiskID; ps3_vd_info_show(instance, &p_vd_array[virtDiskIdx]); #ifndef _WINDOWS - if (p_vd_entry[i].maxIOSize != 0) + if (p_vd_entry[i].maxIOSize != 0) { ps3_change_sdev_max_sector(instance, &p_vd_entry[i]); + } #endif } - mb(); /* in order to force CPU ordering */ + mb(); p_dev_ctx->vd_table_idx = vd_table_idx; - mb(); /* in order to force CPU ordering */ + mb(); l_out: return ret; } -int ps3_device_mgr_data_init(struct ps3_instance *instance) +S32 ps3_device_mgr_data_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - LOG_DEBUG("hno:%u enter\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u enter\n", + PS3_HOST(instance)); if (PS3_MAX_PD_COUNT(instance) != 0) { ret = ps3_dev_mgr_pd_list_get(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } ps3_pd_info_get_all(instance); } if (PS3_MAX_VD_COUNT(instance) != 0) { ret = ps3_dev_mgr_vd_list_get(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } instance->dev_context.vd_table_idx = 0; ps3_vd_info_get_all(instance); } l_out: - LOG_DEBUG("hno:%u out\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u out\n", + PS3_HOST(instance)); - return ret; + return ret ; } -int ps3_device_mgr_data_exit(struct ps3_instance *instance) +S32 ps3_device_mgr_data_exit(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - LOG_DEBUG("hno:%u\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u \n", PS3_HOST(instance)); return ret; } -int ps3_device_mgr_init(struct ps3_instance *instance) +S32 ps3_device_mgr_init(struct ps3_instance *instance) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; if (PS3_MAX_VD_COUNT(instance) == 0 && - PS3_MAX_PD_COUNT(instance) == 0) { + PS3_MAX_PD_COUNT(instance) == 0) { LOG_ERROR("hno:%u max VD and PD count == 0\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } ret = ps3_dev_channel_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } ret = ps3_dev_buff_alloc(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } ps3_mutex_init(&instance->dev_context.dev_priv_lock); ps3_mutex_init(&instance->dev_context.dev_scan_lock); #ifdef _WINDOWS ps3_windows_channel_map_init(instance); ret = ps3_windows_private_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } #endif l_out: - return ret; + return ret ; } void ps3_device_mgr_exit(struct ps3_instance *instance) @@ -1041,10 +999,10 @@ void ps3_device_mgr_exit(struct ps3_instance *instance) ps3_mutex_destroy(&instance->dev_context.dev_scan_lock); } -int ps3_dev_mgr_pd_list_get(struct ps3_instance *instance) +S32 ps3_dev_mgr_pd_list_get(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int i = 0; + S32 ret = PS3_SUCCESS; + U32 i = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct PS3DevList *p_pd_list = p_dev_ctx->pd_list_buf; struct PS3Dev *p_dev = NULL; @@ -1052,52 +1010,49 @@ int ps3_dev_mgr_pd_list_get(struct ps3_instance *instance) ret = ps3_pd_list_get(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, dev mgr get pd list NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - memset((unsigned char *)p_dev_ctx->pd_pool.devs_buffer, - PS3_INVALID_VALUE, - p_dev_ctx->total_pd_count * sizeof(union PS3Device)); + memset((U8*)p_dev_ctx->pd_pool.devs_buffer, PS3_INVALID_VALUE, + p_dev_ctx->total_pd_count * sizeof(union PS3Device)); - LOG_INFO("hno:%u get pd list count is %d\n", PS3_HOST(instance), - p_pd_list->count); + LOG_INFO("hno:%u get pd list count is %d\n", + PS3_HOST(instance), p_pd_list->count); for (i = 0; i < p_pd_list->count; i++) { p_dev = PS3_DEV(&p_pd_list->devs[i].pd.diskPos); if (PS3_PDID_INVALID(&p_pd_list->devs[i].pd.diskPos)) { LOG_WARN("hno:%u, get pd list %d dev pdid is 0\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); continue; } - if (!ps3_dev_id_valid_check(instance, - (unsigned char)p_dev->softChan, - p_dev->devID, PS3_DISK_TYPE_PD)) { + if (!ps3_dev_id_valid_check(instance, (U8)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_PD)) { PS3_BUG(); continue; } - LOG_INFO( - "hno:%u, pd list %d dev[%u:%u:%u], magic[%#x], state[%s]\n", + LOG_INFO("hno:%u, pd list %d dev[%u:%u:%u], magic[%#x], state[%s]\n", PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, p_dev->phyDiskID, p_pd_list->devs[i].pd.diskPos.diskMagicNum, - getDeviceStateName((enum DeviceState)p_pd_list->devs[i] - .pd.diskState)); + getDeviceStateName((DeviceState_e)p_pd_list->devs[i].pd.diskState)); p_dev_ctx->pd_pool.devs[p_dev->softChan][p_dev->devID].pd = p_pd_list->devs[i].pd; + } l_out: return ret; } -int ps3_dev_mgr_vd_list_get(struct ps3_instance *instance) +S32 ps3_dev_mgr_vd_list_get(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int i = 0; + S32 ret = PS3_SUCCESS; + U32 i = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct PS3DevList *p_vd_list = p_dev_ctx->vd_list_buf; struct PS3Dev *p_dev = NULL; @@ -1105,37 +1060,35 @@ int ps3_dev_mgr_vd_list_get(struct ps3_instance *instance) ret = ps3_vd_list_get(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, dev mgr get vd list NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - memset((unsigned char *)p_dev_ctx->vd_pool.devs_buffer, - PS3_INVALID_VALUE, - p_dev_ctx->total_vd_count * sizeof(union PS3Device)); + memset((U8*)p_dev_ctx->vd_pool.devs_buffer, PS3_INVALID_VALUE, + p_dev_ctx->total_vd_count * sizeof(union PS3Device)); - LOG_INFO("hno:%u get vd list count is %d\n", PS3_HOST(instance), - p_vd_list->count); + LOG_INFO("hno:%u get vd list count is %d\n", + PS3_HOST(instance), p_vd_list->count); for (i = 0; i < p_vd_list->count; i++) { p_dev = PS3_DEV(&p_vd_list->devs[i].vd.diskPos); if (PS3_VDID_INVALID(&p_vd_list->devs[i].vd.diskPos)) { LOG_WARN("hno:%u, get vd list %d vdid is 0\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); continue; } - if (!ps3_dev_id_valid_check(instance, - (unsigned char)p_dev->softChan, - p_dev->devID, PS3_DISK_TYPE_VD)) { + if (!ps3_dev_id_valid_check(instance, (U8)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_VD)) { PS3_BUG(); continue; } LOG_INFO("hno:%u, vd list %d dev[%u:%u:%u], magic[%#x]\n", - PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, - p_dev->virtDiskID, - p_vd_list->devs[i].vd.diskPos.diskMagicNum); + PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, + p_dev->virtDiskID, + p_vd_list->devs[i].vd.diskPos.diskMagicNum); p_dev_ctx->vd_pool.devs[p_dev->softChan][p_dev->devID].vd = p_vd_list->devs[i].vd; @@ -1144,39 +1097,38 @@ int ps3_dev_mgr_vd_list_get(struct ps3_instance *instance) return ret; } -unsigned char ps3_dev_id_valid_check(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id, - unsigned char dev_type) +Bool ps3_dev_id_valid_check(struct ps3_instance *instance, U8 channel, + U16 target_id, U8 dev_type) { - unsigned char ret = PS3_DRV_FALSE; + U8 ret = PS3_DRV_FALSE; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; if (dev_type == PS3_DISK_TYPE_VD) { + INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN1, &channel); if (!PS3_IS_VD_CHANNEL(instance, channel)) { - LOG_ERROR_IN_IRQ( - instance, + LOG_ERROR_IN_IRQ(instance, "hno:%u check channel[%u] is not vd channel\n", PS3_HOST(instance), channel); goto l_out; } } else if (dev_type == PS3_DISK_TYPE_PD) { + INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN3, &channel); if (!PS3_IS_PD_CHANNEL(instance, channel)) { - LOG_ERROR_IN_IRQ( - instance, + LOG_ERROR_IN_IRQ(instance, "hno:%u check channel[%u] is not pd channel\n", PS3_HOST(instance), channel); goto l_out; } } else { - LOG_ERROR_IN_IRQ(instance, "hno:%u dev id[%u:%u] channel err\n", - PS3_HOST(instance), channel, target_id); + LOG_ERROR_IN_IRQ(instance, + "hno:%u dev id[%u:%u] channel err\n", + PS3_HOST(instance), channel, target_id); goto l_out; } + INJECT_START(PS3_ERR_IJ_FORCE_MOD_TARGET, &target_id); if (unlikely(target_id >= p_dev_ctx->max_dev_in_channel[channel])) { - LOG_ERROR_IN_IRQ( - instance, + LOG_ERROR_IN_IRQ(instance, "hno:%u check disk[%u:%u] target >= max[%u]\n", PS3_HOST(instance), channel, target_id, p_dev_ctx->max_dev_in_channel[channel]); @@ -1188,96 +1140,91 @@ unsigned char ps3_dev_id_valid_check(struct ps3_instance *instance, return ret; } -unsigned char ps3_get_vd_raid_level(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id) +U8 ps3_get_vd_raid_level(struct ps3_instance *instance, + U8 channel, U16 target_id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_table = &p_dev_ctx->vd_table[vd_table_idx]; + U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_table = + &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; struct PS3VDEntry *p_entry = NULL; - unsigned char ret = RAID_UNKNOWN; - unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; + U8 ret = RAID_UNKNOWN; + U16 virtDiskIdx = PS3_INVALID_DEV_ID; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_VD)) { + PS3_DISK_TYPE_VD)) { goto l_out; } - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), - p_table->vd_idxs[channel][target_id]); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), p_table->vd_idxs[channel][target_id]); p_entry = &p_vd_array[virtDiskIdx]; - if (p_entry == NULL) + if (p_entry == NULL) { goto l_out; + } - LOG_DEBUG("hno:%u, vd[%u:%u] raid level is:%d\n", PS3_HOST(instance), - channel, target_id, p_entry->raidLevel); + LOG_DEBUG("hno:%u, vd[%u:%u] raid level is:%d\n", + PS3_HOST(instance), channel, target_id, p_entry->raidLevel); ret = p_entry->raidLevel; l_out: return ret; } -struct ps3_scsi_priv_data * -ps3_dev_mgr_lookup_vd_pri_data(struct ps3_instance *instance, - unsigned char channel, unsigned short target_id) +struct ps3_scsi_priv_data *ps3_dev_mgr_lookup_vd_pri_data( + struct ps3_instance *instance, U8 channel, U16 target_id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_scsi_priv_data *ret = NULL; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_VD)) { + PS3_DISK_TYPE_VD)) { goto l_out; } - ret = p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs[channel][target_id]; + ret = p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs[channel] + [target_id]; l_out: return ret; } -static inline unsigned char ps3_dev_is_valid(struct PS3DiskDevPos *diskPos, - unsigned char channel, - unsigned short target_id) +static inline Bool ps3_dev_is_valid(struct PS3DiskDevPos *diskPos, U8 channel, U16 target_id) { - if (PS3_DEV_INVALID(*diskPos) || PS3_CHANNEL(diskPos) != channel || - PS3_TARGET(diskPos) != target_id) { + if (PS3_DEV_INVALID(*diskPos) || PS3_CHANNEL(diskPos) != channel || PS3_TARGET(diskPos) != target_id) return PS3_FALSE; - } return PS3_TRUE; } -struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id) +struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info( + struct ps3_instance *instance, U8 channel, U16 target_id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_table = &p_dev_ctx->vd_table[vd_table_idx]; + U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_table = + &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; struct PS3VDEntry *p_entry = NULL; - unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; + U16 virtDiskIdx = PS3_INVALID_DEV_ID; - LOG_DEBUG("hno:%u cur_vd_idx[%d]\n", PS3_HOST(instance), - p_dev_ctx->vd_table_idx); + LOG_DEBUG("hno:%u cur_vd_idx[%d]\n", + PS3_HOST(instance), p_dev_ctx->vd_table_idx); if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_VD)) { + PS3_DISK_TYPE_VD)) { goto l_out; } - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), - p_table->vd_idxs[channel][target_id]); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), p_table->vd_idxs[channel][target_id]); p_entry = &p_vd_array[virtDiskIdx]; - if (ps3_dev_is_valid(&p_entry->diskPos, channel, target_id) != - PS3_TRUE) { + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS, &p_entry->diskPos.diskDev.diskID); + if (ps3_dev_is_valid(&p_entry->diskPos, channel, target_id) != PS3_TRUE) { p_entry = NULL; goto l_out; } @@ -1285,25 +1232,24 @@ struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info(struct ps3_instance *instance, return p_entry; } -struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id) +struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info( + struct ps3_instance *instance, U8 channel, U16 target_id) { struct ps3_pd_table *p_table = &instance->dev_context.pd_table; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_pd_entry *p_entry = NULL; - unsigned short disk_idx = 0; + U16 disk_idx = 0; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_PD)) { + PS3_DISK_TYPE_PD)) { goto l_out; } disk_idx = p_table->pd_idxs[channel][target_id]; p_entry = &p_dev_ctx->pd_entries_array[disk_idx]; - if (ps3_dev_is_valid(&p_entry->disk_pos, channel, target_id) != - PS3_TRUE) { + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS, &p_entry->disk_pos.diskDev.diskID); + if (ps3_dev_is_valid(&p_entry->disk_pos, channel, target_id) != PS3_TRUE) { p_entry = NULL; goto l_out; } @@ -1311,26 +1257,23 @@ struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info(struct ps3_instance *instance, return p_entry; } -struct PS3VDEntry * -ps3_dev_mgr_lookup_vd_info_by_id(struct ps3_instance *instance, - unsigned short disk_id) +struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info_by_id( + struct ps3_instance *instance, U16 disk_id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; + U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; struct PS3VDEntry *p_entry = NULL; - unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; + U16 virtDiskIdx = PS3_INVALID_DEV_ID; - LOG_DEBUG("hno:%u cur_vd_idx[%d]\n", PS3_HOST(instance), - p_dev_ctx->vd_table_idx); + LOG_DEBUG("hno:%u cur_vd_idx[%d]\n", + PS3_HOST(instance), p_dev_ctx->vd_table_idx); virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_id); if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(instance))) { - LOG_ERROR_IN_IRQ( - instance, - "hno:%u , dev mgr lookup vd info disk id > max count:%d>%d\n", + LOG_ERROR_IN_IRQ(instance, "hno:%u , dev mgr lookup vd info disk id > max count:%d>%d\n", PS3_HOST(instance), disk_id, PS3_MAX_VD_COUNT(instance)); @@ -1341,9 +1284,7 @@ ps3_dev_mgr_lookup_vd_info_by_id(struct ps3_instance *instance, p_entry = &p_vd_array[virtDiskIdx]; if (PS3_DEV_INVALID(p_entry->diskPos)) { - LOG_INFO_IN_IRQ( - instance, - "hno:%u idx[%d], virDisk[%d] dev id is invalid\n", + LOG_INFO_IN_IRQ(instance, "hno:%u idx[%d], virDisk[%d] dev id is invalid\n", PS3_HOST(instance), p_dev_ctx->vd_table_idx, disk_id); p_entry = NULL; goto l_out; @@ -1352,17 +1293,14 @@ ps3_dev_mgr_lookup_vd_info_by_id(struct ps3_instance *instance, return p_entry; } -struct ps3_pd_entry * -ps3_dev_mgr_lookup_pd_info_by_id(struct ps3_instance *instance, - unsigned short disk_id) +struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info_by_id( + struct ps3_instance *instance, U16 disk_id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_pd_entry *p_entry = NULL; if (unlikely(disk_id > PS3_MAX_PD_COUNT(instance))) { - LOG_ERROR_IN_IRQ( - instance, - "hno:%u, dev mgr lookup pd info disk id > max count:%d>%d\n", + LOG_ERROR_IN_IRQ(instance, "hno:%u, dev mgr lookup pd info disk id > max count:%d>%d\n", PS3_HOST(instance), disk_id, PS3_MAX_PD_COUNT(instance)); PS3_BUG(); @@ -1372,12 +1310,11 @@ ps3_dev_mgr_lookup_pd_info_by_id(struct ps3_instance *instance, p_entry = &p_dev_ctx->pd_entries_array[disk_id]; if (PS3_DEV_INVALID(p_entry->disk_pos) || - p_entry->config_flag == MIC_PD_STATE_UNKNOWN) { - LOG_INFO_IN_IRQ( - instance, - "hno:%u pdid[%d] dev[%x] id is invalid, config_flag[%d]\n", + p_entry->config_flag == MIC_PD_STATE_UNKNOWN) { + LOG_INFO_IN_IRQ(instance, "hno:%u pdid[%d] dev[%x] id is invalid, config_flag[%d]\n", PS3_HOST(instance), disk_id, - PS3_DISKID(&p_entry->disk_pos), p_entry->config_flag); + PS3_DISKID(&p_entry->disk_pos), + p_entry->config_flag); p_entry = NULL; goto l_out; } @@ -1385,16 +1322,15 @@ ps3_dev_mgr_lookup_pd_info_by_id(struct ps3_instance *instance, return p_entry; } -union PS3Device *ps3_dev_mgr_lookup_vd_list(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id) +union PS3Device* ps3_dev_mgr_lookup_vd_list( + struct ps3_instance *instance, U8 channel, U16 target_id) { struct ps3_dev_pool *p_vd_pool = &instance->dev_context.vd_pool; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; union PS3Device *p_vd = NULL; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_VD)) { + PS3_DISK_TYPE_VD)) { goto l_out; } @@ -1402,8 +1338,8 @@ union PS3Device *ps3_dev_mgr_lookup_vd_list(struct ps3_instance *instance, if (PS3_DEV_INVALID(p_vd->vd.diskPos)) { LOG_INFO("hno:%u idx[%d], dev[%u:%u] dev id is invalid\n", - PS3_HOST(instance), p_dev_ctx->vd_table_idx, channel, - target_id); + PS3_HOST(instance), p_dev_ctx->vd_table_idx, channel, + target_id); p_vd = NULL; goto l_out; } @@ -1411,36 +1347,40 @@ union PS3Device *ps3_dev_mgr_lookup_vd_list(struct ps3_instance *instance, return p_vd; } -union PS3Device *ps3_dev_mgr_lookup_pd_list(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id) +union PS3Device* ps3_dev_mgr_lookup_pd_list( + struct ps3_instance *instance, U8 channel, U16 target_id) { struct ps3_dev_pool *p_pd_pool = &instance->dev_context.pd_pool; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; union PS3Device *p_pd = NULL; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_PD)) { + PS3_DISK_TYPE_PD)) { goto l_out; } p_pd = &p_pd_pool->devs[channel][target_id]; if (PS3_DEV_INVALID(p_pd->pd.diskPos)) { +#if 0 + LOG_INFO("hno:%u idx[%d], dev[%u:%u] dev id is invalid\n", + PS3_HOST(instance), p_dev_ctx->vd_table_idx, channel, + target_id); +#endif p_pd = NULL; goto l_out; } LOG_INFO("hno:%u idx[%d], dev[%u:%u] dev id is valid\n", - PS3_HOST(instance), p_dev_ctx->vd_table_idx, channel, - target_id); + PS3_HOST(instance), p_dev_ctx->vd_table_idx, channel, + target_id); l_out: return p_pd; } -int ps3_adjust_queue_depth(struct ps3_instance *instance, - unsigned char dev_type, unsigned int queue_depth) +S32 ps3_adjust_queue_depth(struct ps3_instance *instance, + U8 dev_type, U32 queue_depth) { - int dev_queue_depth = PS3_QUEUE_DEPTH_DEFAULT; + S32 dev_queue_depth = PS3_QUEUE_DEPTH_DEFAULT; switch (dev_type) { case PS3_DEV_TYPE_SAS_HDD: @@ -1459,40 +1399,37 @@ int ps3_adjust_queue_depth(struct ps3_instance *instance, break; } - if (queue_depth != 0 && - (int)queue_depth <= instance->cmd_attr.cur_can_que) { + if (queue_depth != 0 && (S32)queue_depth <= + instance->cmd_attr.cur_can_que) { dev_queue_depth = queue_depth; } return dev_queue_depth; } -static inline int ps3_adjust_device_queue_depth(struct scsi_device *sdev, - struct ps3_instance *instance, - int q_depth) +static inline S32 ps3_adjust_device_queue_depth(struct scsi_device *sdev, + struct ps3_instance *instance, S32 q_depth) { - int queue_depth = q_depth; + S32 queue_depth = q_depth; struct ps3_pd_entry *p_pd_entry = NULL; - if (PS3_IS_PD_CHANNEL(instance, sdev->channel)) { - p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, sdev->channel, - sdev->id); + p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, + sdev->channel, sdev->id); if (p_pd_entry == NULL) { - LOG_WARN_IN_IRQ( - instance, - "hno:%u cannot found PD[%u:%u] device info\n", + LOG_WARN_IN_IRQ(instance, "hno:%u cannot found PD[%u:%u] device info\n", PS3_HOST(instance), sdev->channel, sdev->id); goto l_out; } if ((p_pd_entry->dev_type == PS3_DEV_TYPE_SATA_HDD) || - (p_pd_entry->dev_type == PS3_DEV_TYPE_SATA_SSD)) { - if (q_depth > PS3_QUEUE_DEPTH_SATA) + (p_pd_entry->dev_type == PS3_DEV_TYPE_SATA_SSD)) { + if (q_depth > PS3_QUEUE_DEPTH_SATA) { queue_depth = PS3_QUEUE_DEPTH_SATA; + } } } l_out: -#if defined(PS3_CHANGE_QUEUE_DEPTH) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), queue_depth); #else scsi_change_queue_depth(sdev, queue_depth); @@ -1501,56 +1438,56 @@ static inline int ps3_adjust_device_queue_depth(struct scsi_device *sdev, } #ifndef _WINDOWS -#if defined(PS3_CHANGE_QUEUE_DEPTH) -int ps3_change_queue_depth(struct scsi_device *sdev, int queue_depth, - int reason) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) +S32 ps3_change_queue_depth(struct scsi_device *sdev, + S32 queue_depth, S32 reason) { - int ret = -EOPNOTSUPP; + S32 ret = -EOPNOTSUPP; struct ps3_instance *instance = NULL; - - instance = (struct ps3_instance *)sdev->host->hostdata; + instance = (struct ps3_instance*)sdev->host->hostdata; if (instance == NULL) { - LOG_ERROR_IN_IRQ(instance, "hno:%u have no host\n", - sdev->host->host_no); + LOG_ERROR_IN_IRQ(instance,"hno:%u have no host\n", + sdev->host->host_no); goto l_out; } - if (queue_depth > sdev->host->can_queue) + if (queue_depth > sdev->host->can_queue) { queue_depth = sdev->host->can_queue; + } if (reason == SCSI_QDEPTH_DEFAULT || reason == SCSI_QDEPTH_RAMP_UP) { - ret = ps3_adjust_device_queue_depth(sdev, instance, - queue_depth); + ret = ps3_adjust_device_queue_depth(sdev, instance, queue_depth); } else if (reason == SCSI_QDEPTH_QFULL) { scsi_track_queue_full(sdev, queue_depth); ret = sdev->queue_depth; } - LOG_INFO_IN_IRQ( - instance, - "hno:%u change dev[%u:%u] queue depth to [%d] reason [%d]\n", + LOG_INFO_IN_IRQ(instance,"hno:%u change dev[%u:%u] queue depth to [%d] reason [%d]\n", PS3_HOST(instance), sdev->channel, sdev->id, ret, reason); l_out: return ret; } #else -int ps3_change_queue_depth(struct scsi_device *sdev, int queue_depth) +S32 ps3_change_queue_depth(struct scsi_device *sdev, + S32 queue_depth) { - int ret = sdev->queue_depth; + S32 ret = sdev->queue_depth; struct ps3_instance *instance = NULL; - instance = (struct ps3_instance *)sdev->host->hostdata; + instance = (struct ps3_instance*)sdev->host->hostdata; if (instance == NULL) { - LOG_ERROR("hno:%u have no host\n", sdev->host->host_no); + LOG_ERROR("hno:%u have no host\n", + sdev->host->host_no); goto l_out; } - if (queue_depth > sdev->host->can_queue) + if (queue_depth > sdev->host->can_queue) { queue_depth = sdev->host->can_queue; + } ret = ps3_adjust_device_queue_depth(sdev, instance, queue_depth); LOG_INFO("hno:%u change dev[%u:%u] queue depth to [%d]\n", - PS3_HOST(instance), sdev->channel, sdev->id, ret); + PS3_HOST(instance), sdev->channel, sdev->id, ret); l_out: return ret; @@ -1559,63 +1496,60 @@ int ps3_change_queue_depth(struct scsi_device *sdev, int queue_depth) #endif static inline void ps3_init_vd_stream(struct ps3_vd_stream_detect *vdsd) { - unsigned int index = 0; - unsigned char tyepIndex = 0; - - for (tyepIndex = PS3_SCSI_CMD_TYPE_READ; - tyepIndex < PS3_SCSI_CMD_TYPE_WRITE; tyepIndex++) { - vdsd[tyepIndex - PS3_SCSI_CMD_TYPE_READ].mru_bit_map = - MR_STREM_BITMAP; - ps3_spin_lock_init(&vdsd[tyepIndex - PS3_SCSI_CMD_TYPE_READ] - .ps3_sequence_stream_lock); - - for (index = 0; index < PS3_IO_MAX_STREAMS_TRACKED; index++) { - vdsd[tyepIndex - PS3_SCSI_CMD_TYPE_READ] - .stream_track[index] - .next_seq_lba = 0; - vdsd[tyepIndex - PS3_SCSI_CMD_TYPE_READ] - .stream_track[index] - .rw_type = tyepIndex; - } - } + U32 index = 0; + U8 tyepIndex = 0; + for(tyepIndex = PS3_SCSI_CMD_TYPE_READ;tyepIndex < PS3_SCSI_CMD_TYPE_WRITE;tyepIndex++){ + vdsd[tyepIndex-PS3_SCSI_CMD_TYPE_READ].mru_bit_map = MR_STREM_BITMAP; + ps3_spin_lock_init(&vdsd[tyepIndex-PS3_SCSI_CMD_TYPE_READ].ps3_sequence_stream_lock); + + for(index = 0;index < PS3_IO_MAX_STREAMS_TRACKED;index++){ + vdsd[tyepIndex-PS3_SCSI_CMD_TYPE_READ].stream_track[index].next_seq_lba = 0; + vdsd[tyepIndex-PS3_SCSI_CMD_TYPE_READ].stream_track[index].rw_type = tyepIndex; + } + } + return; } -int ps3_scsi_private_init_pd(struct scsi_device *sdev) +S32 ps3_scsi_private_init_pd(struct scsi_device *sdev) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; struct ps3_pd_entry *p_pd_entry = NULL; struct ps3_qos_pd_mgr *p_qos_pd_mgr = NULL; struct ps3_instance *instance = - (struct ps3_instance *)sdev->host->hostdata; + (struct ps3_instance*)sdev->host->hostdata; - p_pd_entry = - ps3_dev_mgr_lookup_pd_info(instance, sdev->channel, sdev->id); + p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, + sdev->channel, sdev->id); + INJECT_START(PS3_ERR_IJ_FORCE_PD_ENTRY_NULL1, &p_pd_entry); if (p_pd_entry == NULL) { LOG_WARN("hno:%u cannot found PD[%u:%u] device info\n", - PS3_HOST(instance), sdev->channel, sdev->id); + PS3_HOST(instance), sdev->channel, sdev->id); ret = -ENXIO; goto l_out; } - if (!ps3_pd_scsi_visible_check( - instance, &p_pd_entry->disk_pos, p_pd_entry->dev_type, - p_pd_entry->config_flag, p_pd_entry->state)) { + INJECT_START(PS3_ERR_IJ_FORCE_PD_STATE_ERROR, &p_pd_entry->state); + if (! ps3_pd_scsi_visible_check(instance, &p_pd_entry->disk_pos, + p_pd_entry->dev_type, p_pd_entry->config_flag, + p_pd_entry->state)) { ret = -ENXIO; LOG_WARN("hno:%u pd was blocked: chan[%d] id[%d]\n", - PS3_HOST(instance), sdev->channel, sdev->id); + PS3_HOST(instance), sdev->channel, sdev->id); goto l_out; } LOG_DEBUG("hno:%u found PD[%u:%u:%u] magic[%#x] device info\n", - PS3_HOST(instance), sdev->channel, sdev->id, - PS3_PDID(&p_pd_entry->disk_pos), - p_pd_entry->disk_pos.diskMagicNum); + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_PDID(&p_pd_entry->disk_pos), + p_pd_entry->disk_pos.diskMagicNum); - p_priv_data = (struct ps3_scsi_priv_data *)ps3_kzalloc( - instance, sizeof(struct ps3_scsi_priv_data)); + p_priv_data = (struct ps3_scsi_priv_data*)ps3_kzalloc(instance, + sizeof(struct ps3_scsi_priv_data)); + INJECT_START(PS3_ERR_IJ_FORCE_PRIV_DATA_NULL2, &p_priv_data); if (p_priv_data == NULL) { - LOG_ERROR("hno:%u pd[%u:%u:%u] Failed to allocate scsi device private data\n", - PS3_HOST(instance), sdev->channel, sdev->id, - PS3_PDID(&p_pd_entry->disk_pos)); + LOG_ERROR("hno:%u pd[%u:%u:%u] Failed" + " to allocate scsi device private data\n", + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_PDID(&p_pd_entry->disk_pos)); ret = -ENOMEM; goto l_out; } @@ -1623,22 +1557,20 @@ int ps3_scsi_private_init_pd(struct scsi_device *sdev) p_priv_data->disk_pos = p_pd_entry->disk_pos; p_priv_data->dev_type = p_pd_entry->dev_type; p_priv_data->is_taskmgmt_enable = PS3_DRV_TRUE; - p_priv_data->task_abort_timeout = p_pd_entry->task_abort_timeout; - p_priv_data->task_reset_timeout = p_pd_entry->task_reset_timeout; + p_priv_data->task_abort_timeout = + p_pd_entry->task_abort_timeout; + p_priv_data->task_reset_timeout = + p_pd_entry->task_reset_timeout; p_priv_data->task_manager_busy = 0; p_priv_data->encl_id = p_pd_entry->encl_id; p_priv_data->phy_id = p_pd_entry->phy_id; ps3_atomic_set(&p_priv_data->rd_io_outstand, PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&p_priv_data->wr_io_outstand, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_total_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_res_cnt, - PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_total_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_res_cnt, PS3_CMD_STAT_INIT_VALUE); p_qos_pd_mgr = ps3_qos_pd_mgr_init(instance, p_pd_entry); - if (p_qos_pd_mgr != NULL && - p_qos_pd_mgr->dev_type != p_pd_entry->dev_type) { + if (p_qos_pd_mgr != NULL && p_qos_pd_mgr->dev_type != p_pd_entry->dev_type) ps3_qos_pd_rsc_init(p_qos_pd_mgr, p_pd_entry); - } p_priv_data->dev_deling = PS3_FALSE; p_priv_data->swap_flag = PS3_FALSE; sdev->hostdata = p_priv_data; @@ -1648,48 +1580,52 @@ int ps3_scsi_private_init_pd(struct scsi_device *sdev) void ps3_vd_busy_scale_get(struct PS3VDEntry *vd_entry) { - unsigned short scale = 0; - unsigned int strip_size_shift = 0; + U16 scale = 0; + U32 strip_size_shift = 0; strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); - scale = vd_entry->span[0].spanStripeDataSize >> strip_size_shift; - if ((vd_entry->raidLevel == RAID1E || vd_entry->raidLevel == RAID10) && - (vd_entry->span[0].spanPdNum & 1)) { + scale = vd_entry->span[0].spanStripeDataSize >> strip_size_shift;; + if ((vd_entry->raidLevel == RAID1E || + vd_entry->raidLevel == RAID10) && + (vd_entry->span[0].spanPdNum & 1)) { scale = scale >> 1; } vd_entry->dev_busy_scale = scale; + return; } -int ps3_scsi_private_init_vd(struct scsi_device *sdev) +S32 ps3_scsi_private_init_vd(struct scsi_device *sdev) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; struct PS3VDEntry *p_vd_entry = NULL; struct ps3_instance *instance = - (struct ps3_instance *)sdev->host->hostdata; - struct ps3_pri_data_table *p_vd_pri_data_table = - &instance->dev_context.vd_pri_data_table; + (struct ps3_instance*)sdev->host->hostdata; + struct ps3_pri_data_table *p_vd_pri_data_table = &instance->dev_context.vd_pri_data_table; - p_vd_entry = - ps3_dev_mgr_lookup_vd_info(instance, sdev->channel, sdev->id); + p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, + sdev->channel, sdev->id); + INJECT_START(PS3_ERR_IJ_FORCE_VD_ENTRY_NULL1, &p_vd_entry); if (p_vd_entry == NULL) { LOG_WARN("hno:%u cannot found VD[%u:%u] device info\n", - PS3_HOST(instance), sdev->channel, sdev->id); + PS3_HOST(instance), sdev->channel, sdev->id); ret = -ENXIO; goto l_out; } LOG_DEBUG("hno:%u found VD[%u:%u:%u] magic[%#x] device info\n", - PS3_HOST(instance), sdev->channel, sdev->id, - PS3_VDID(&p_vd_entry->diskPos), - p_vd_entry->diskPos.diskMagicNum); + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_VDID(&p_vd_entry->diskPos), + p_vd_entry->diskPos.diskMagicNum); - p_priv_data = (struct ps3_scsi_priv_data *)ps3_kzalloc( - instance, sizeof(struct ps3_scsi_priv_data)); + p_priv_data = (struct ps3_scsi_priv_data*)ps3_kzalloc(instance, + sizeof(struct ps3_scsi_priv_data)); + INJECT_START(PS3_ERR_IJ_FORCE_PRIV_DATA_NULL, &p_priv_data); if (p_priv_data == NULL) { - LOG_ERROR("hno:%u vd[%u:%u:%u] Failed to allocate scsi device private data\n", - PS3_HOST(instance), sdev->channel, sdev->id, - PS3_VDID(&p_vd_entry->diskPos)); + LOG_ERROR("hno:%u vd[%u:%u:%u] Failed" + " to allocate scsi device private data\n", + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_VDID(&p_vd_entry->diskPos)); ret = -ENOMEM; goto l_out; } @@ -1702,20 +1638,17 @@ int ps3_scsi_private_init_vd(struct scsi_device *sdev) p_priv_data->task_manager_busy = 0; ps3_atomic_set(&p_priv_data->rd_io_outstand, PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&p_priv_data->wr_io_outstand, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_total_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_res_cnt, - PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_total_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_res_cnt, PS3_CMD_STAT_INIT_VALUE); p_priv_data->dev_deling = PS3_FALSE; p_priv_data->swap_flag = PS3_FALSE; ps3_vd_busy_scale_get(p_vd_entry); ps3_init_vd_stream(p_priv_data->vd_sd); - p_priv_data->r1x_rb_info = - (struct ps3_r1x_read_balance_info *)ps3_kzalloc( - instance, sizeof(struct ps3_r1x_read_balance_info)); + p_priv_data->r1x_rb_info = (struct ps3_r1x_read_balance_info *)ps3_kzalloc(instance, + sizeof(struct ps3_r1x_read_balance_info)); + INJECT_START(PS3_ERR_IJ_FORCE_RB_INFO_NULL, &p_priv_data->r1x_rb_info); if (p_priv_data->r1x_rb_info == NULL) { - LOG_ERROR( - "hno:%u vd[%u:%u:%u] Failed to allocate r1x_lb_info\n", + LOG_ERROR("hno:%u vd[%u:%u:%u] Failed to allocate r1x_lb_info\n", PS3_HOST(instance), sdev->channel, sdev->id, PS3_VDID(&p_vd_entry->diskPos)); ret = -ENOMEM; @@ -1725,22 +1658,22 @@ int ps3_scsi_private_init_vd(struct scsi_device *sdev) sdev->hostdata = p_priv_data; ret = ps3_r1x_lock_prepare_for_vd(instance, sdev, - p_vd_entry->raidLevel); - if (unlikely(ret != PS3_SUCCESS)) { + p_vd_entry->raidLevel); + if(unlikely(PS3_SUCCESS != ret)){ ps3_kfree(instance, p_priv_data->r1x_rb_info); p_priv_data->r1x_rb_info = NULL; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); - LOG_ERROR("hno:%u vd[%u:%u:%u] Failed to allocate raid1x write lock mgr\n", - PS3_HOST(instance), sdev->channel, sdev->id, - PS3_VDID(&p_vd_entry->diskPos)); + LOG_ERROR("hno:%u vd[%u:%u:%u] Failed" + " to allocate raid1x write lock mgr\n", + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_VDID(&p_vd_entry->diskPos)); ret = -ENOMEM; goto l_err; } ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); p_vd_pri_data_table->vd_pri_data_idxs[PS3_SDEV_CHANNEL(sdev)] - [PS3_SDEV_TARGET(sdev)] = - p_priv_data; + [PS3_SDEV_TARGET(sdev)] = p_priv_data; ps3_qos_vd_init(instance, p_vd_entry); @@ -1757,42 +1690,46 @@ int ps3_scsi_private_init_vd(struct scsi_device *sdev) return ret; } -int ps3_scsi_slave_alloc(struct scsi_device *sdev) +S32 ps3_scsi_slave_alloc(struct scsi_device *sdev) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; struct ps3_instance *instance = NULL; struct PS3VDEntry *p_vd_entry = NULL; struct ps3_pd_entry *p_pd_entry = NULL; - unsigned int dma_addr_alignment = 0; - unsigned int dma_len_alignment = 0; - unsigned char dev_type = PS3_DISK_TYPE_UNKNOWN; - struct PS3DiskDevPos *p_diskPos = NULL; - - LOG_DEBUG("enter, [%u:%u:%llu]\n", sdev->channel, sdev->id, - (unsigned long long)sdev->lun); + U32 dma_addr_alignment = 0; + U32 dma_len_alignment = 0; + U8 dev_type = PS3_DISK_TYPE_UNKNOWN; + struct PS3DiskDevPos* p_diskPos = NULL; + + LOG_DEBUG("enter, [%u:%u:%llu]\n", + sdev->channel, sdev->id, (U64)sdev->lun); + INJECT_START(PS3_ERR_IJ_FORCE_LUN_ERROR, &sdev->lun); if (sdev->lun != 0) { ret = -ENXIO; goto l_out; } - instance = (struct ps3_instance *)sdev->host->hostdata; + instance = (struct ps3_instance*)sdev->host->hostdata; + INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_NULL, &instance); if (instance == NULL) { - LOG_ERROR("hno:%u have no host\n", sdev->host->host_no); + LOG_ERROR("hno:%u have no host\n", + sdev->host->host_no); ret = -ENXIO; goto l_out; } sdev->hostdata = NULL; + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_FORCE_WAIT, sdev); ret = -ENXIO; if (PS3_IS_VD_CHANNEL(instance, sdev->channel)) { dev_type = PS3_DISK_TYPE_VD; p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, sdev->channel, - sdev->id); + sdev->id); + INJECT_START(PS3_ERR_IJ_FORCE_VD_ENTRY_NULL, &p_vd_entry); if (p_vd_entry == NULL) { - LOG_ERROR( - "hno:%u, cannot found VD[%u:%u] device info\n", + LOG_ERROR("hno:%u, cannot found VD[%u:%u] device info\n", PS3_HOST(instance), sdev->channel, sdev->id); goto l_out; @@ -1803,10 +1740,10 @@ int ps3_scsi_slave_alloc(struct scsi_device *sdev) } else if (PS3_IS_PD_CHANNEL(instance, sdev->channel)) { dev_type = PS3_DISK_TYPE_PD; p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, sdev->channel, - sdev->id); + sdev->id); + INJECT_START(PS3_ERR_IJ_FORCE_PD_ENTRY_NULL, &p_pd_entry); if (p_pd_entry == NULL) { - LOG_ERROR( - "hno:%u, cannot found PD[%u:%u] device info\n", + LOG_ERROR("hno:%u, cannot found PD[%u:%u] device info\n", PS3_HOST(instance), sdev->channel, sdev->id); goto l_out; @@ -1815,72 +1752,78 @@ int ps3_scsi_slave_alloc(struct scsi_device *sdev) p_diskPos = &p_pd_entry->disk_pos; } else { LOG_ERROR("hno:%u dev channel[%u] type NOK\n", - PS3_HOST(instance), sdev->channel); + PS3_HOST(instance), sdev->channel); goto l_out; } - if (dev_type == PS3_DISK_TYPE_VD) + if (dev_type == PS3_DISK_TYPE_VD) { ret = ps3_scsi_private_init_vd(sdev); - else + } else { ret = ps3_scsi_private_init_pd(sdev); + } - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_dev_done; + } - p_priv_data = (struct ps3_scsi_priv_data *)sdev->hostdata; + p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; - ret = ps3_scsi_add_device_ack(instance, p_diskPos, dev_type); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_FORCE_WAIT, NULL); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, NULL); + ret = ps3_scsi_add_device_ack(instance, p_diskPos, + dev_type); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL3, &ret); if (unlikely(ret != PS3_SUCCESS)) { ret = -ENXIO; goto l_dev_ack_failed; } - LOG_INFO("[%u:%u:%llu], dev_type[%s]\n", sdev->channel, sdev->id, - (unsigned long long)sdev->lun, - namePS3DevType((enum PS3DevType)p_priv_data->dev_type)); + LOG_INFO("[%u:%u:%llu], dev_type[%s]\n", + sdev->channel, sdev->id, (U64)sdev->lun, + namePS3DevType((enum PS3DevType)p_priv_data->dev_type)); - if (p_priv_data->task_abort_timeout == 0) + if (p_priv_data->task_abort_timeout == 0) { p_priv_data->task_abort_timeout = PS3_DEFAULT_TASK_MGR_TIMEOUT; + } - if (p_priv_data->task_reset_timeout == 0) + if (p_priv_data->task_reset_timeout == 0) { p_priv_data->task_reset_timeout = PS3_DEFAULT_TASK_MGR_TIMEOUT; + } -#if defined(PS3_CHANGE_QUEUE_DEPTH) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) sdev->tagged_supported = 1; scsi_activate_tcq(sdev, sdev->queue_depth); #endif if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { - dma_addr_alignment = ps3_pd_dma_alignment_calc( - p_vd_entry->dmaAddrAlignShift); - dma_len_alignment = - ps3_pd_dma_alignment_calc(p_vd_entry->dmaLenAlignShift); + dma_addr_alignment = ps3_pd_dma_alignment_calc(p_vd_entry->dmaAddrAlignShift); + dma_len_alignment = ps3_pd_dma_alignment_calc(p_vd_entry->dmaLenAlignShift); } else { dma_addr_alignment = p_pd_entry->dma_addr_alignment; dma_len_alignment = p_pd_entry->dma_len_alignment; } blk_queue_dma_alignment(sdev->request_queue, PS3_SCSI_ALINNMENT_MASK); - if (dma_addr_alignment) { - blk_queue_dma_alignment(sdev->request_queue, - dma_addr_alignment - 1); + if(dma_addr_alignment){ + blk_queue_dma_alignment(sdev->request_queue, dma_addr_alignment - 1); } - if (dma_len_alignment) { -#if defined(PS3_BLK_DMA_PAD) + if(dma_len_alignment){ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) blk_queue_dma_pad(sdev->request_queue, dma_len_alignment - 1); #else - blk_queue_update_dma_pad(sdev->request_queue, - dma_len_alignment - 1); + blk_queue_update_dma_pad(sdev->request_queue, dma_len_alignment - 1); #endif + } LOG_INFO("slave_alloc,dma_addr_alignment[%d] dma_len_alignment[%d]\n", - dma_addr_alignment, dma_len_alignment); + dma_addr_alignment, dma_len_alignment); goto l_out; l_dev_ack_failed: ps3_scsi_slave_destroy(sdev); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_FORCE_WAIT, sdev); l_dev_done: ps3_scsi_remove_device_done(instance, p_diskPos, dev_type); l_out: @@ -1890,50 +1833,48 @@ int ps3_scsi_slave_alloc(struct scsi_device *sdev) void ps3_scsi_slave_destroy(struct scsi_device *sdev) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; struct ps3_instance *instance = - (struct ps3_instance *)sdev->host->hostdata; - struct ps3_pri_data_table *p_vd_pri_data_table = - &instance->dev_context.vd_pri_data_table; + (struct ps3_instance*)sdev->host->hostdata; + struct ps3_pri_data_table *p_vd_pri_data_table = &instance->dev_context.vd_pri_data_table; + INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_NULL2, &instance); if (instance == NULL) { - LOG_ERROR("hno:%u have no host\n", sdev->host->host_no); + LOG_ERROR("hno:%u have no host\n",sdev->host->host_no); goto l_out; } LOG_DEBUG("hno:%u enter, max_chan[%u], max_id[%u], max_lun[%llu]\n", - PS3_HOST(instance), sdev->host->max_channel, - sdev->host->max_id, (unsigned long long)sdev->host->max_lun); + PS3_HOST(instance), sdev->host->max_channel, + sdev->host->max_id, (U64)sdev->host->max_lun); - p_priv_data = (struct ps3_scsi_priv_data *)sdev->hostdata; + p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; if (p_priv_data != NULL) { if (PS3_IS_VD_CHANNEL(instance, sdev->channel)) { - LOG_INFO("hno[%u], vd[%u:%u] r1x conflict destroy\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + LOG_INFO("hno[%u], vd[%u:%u] r1x conflict destory\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); + INJECT_AT_TIMES(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - ps3_r1x_lock_destroy_for_vd(instance, - &p_priv_data->lock_mgr); - ps3_qos_vd_reset(instance, - PS3_VDID(&p_priv_data->disk_pos)); - p_vd_pri_data_table->vd_pri_data_idxs[PS3_SDEV_CHANNEL( - sdev)][PS3_SDEV_TARGET(sdev)] = NULL; + ps3_r1x_lock_destory_for_vd(instance, &p_priv_data->lock_mgr); + ps3_qos_vd_reset(instance, PS3_VDID(&p_priv_data->disk_pos)); + p_vd_pri_data_table->vd_pri_data_idxs + [PS3_SDEV_CHANNEL(sdev)] + [PS3_SDEV_TARGET(sdev)] = NULL; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); if (p_priv_data->r1x_rb_info != NULL) { ps3_kfree(instance, p_priv_data->r1x_rb_info); p_priv_data->r1x_rb_info = NULL; } } else if (PS3_IS_PD_CHANNEL(instance, sdev->channel)) { - ps3_qos_pd_mgr_reset(instance, - PS3_PDID(&p_priv_data->disk_pos)); + ps3_qos_pd_mgr_reset(instance, PS3_PDID(&p_priv_data->disk_pos)); } - ret = ps3_scsi_remove_device_done( - instance, &p_priv_data->disk_pos, - ps3_disk_type((enum PS3DevType)p_priv_data->dev_type)); + ret = ps3_scsi_remove_device_done(instance, &p_priv_data->disk_pos, + ps3_disk_type((enum PS3DevType) p_priv_data->dev_type)); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL5, &ret); if (ret != PS3_SUCCESS) { - LOG_INFO( - "hno:%u dev[%u:%u:%u] magic[%#x] dev del done error %d\n", + LOG_INFO("hno:%u dev[%u:%u:%u] magic[%#x] dev del done error %d\n", PS3_HOST(instance), PS3_CHANNEL(&p_priv_data->disk_pos), PS3_TARGET(&p_priv_data->disk_pos), @@ -1941,8 +1882,9 @@ void ps3_scsi_slave_destroy(struct scsi_device *sdev) p_priv_data->disk_pos.diskMagicNum, ret); } ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - if (sdev->hostdata != NULL) + if(sdev->hostdata != NULL) { ps3_kfree(instance, sdev->hostdata); + } sdev->hostdata = NULL; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); } @@ -1951,12 +1893,10 @@ void ps3_scsi_slave_destroy(struct scsi_device *sdev) LOG_DEBUG("exit, hno:%u\n", sdev->host->host_no); } -static unsigned char ps3_is_nvme_device(struct ps3_instance *instance, - unsigned char dev_type, - unsigned char channel, - unsigned short target_id) +static Bool ps3_is_nvme_device(struct ps3_instance *instance, U8 dev_type, + U8 channel, U16 target_id) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; struct PS3VDEntry *vd_entry = NULL; if (dev_type == PS3_DEV_TYPE_NVME_SSD) { @@ -1965,11 +1905,10 @@ static unsigned char ps3_is_nvme_device(struct ps3_instance *instance, } if (dev_type == PS3_DEV_TYPE_VD) { - vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, - target_id); + vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, target_id); if (vd_entry == NULL) { LOG_ERROR("hno:%u cannot found VD[%u:%u] device\n", - PS3_HOST(instance), channel, target_id); + PS3_HOST(instance), channel, target_id); ret = PS3_FALSE; goto l_out; } @@ -1986,14 +1925,13 @@ static unsigned char ps3_is_nvme_device(struct ps3_instance *instance, } static void ps3_nvme_attr_set(const struct ps3_instance *instance, - struct scsi_device *sdev) + struct scsi_device *sdev) { - unsigned int page_size = instance->cmd_attr.nvme_page_size; - unsigned int align_mask = - (page_size == 0) ? page_size : (page_size - 1); + U32 page_size = instance->cmd_attr.nvme_page_size; + U32 align_mask = (page_size == 0) ? page_size : (page_size- 1); LOG_INFO("nvme page size is %u\n", page_size); -#if defined(PS3_BLK_EH_NOT_HANDLED) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,16,0) queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, sdev->request_queue); #else blk_queue_flag_set(QUEUE_FLAG_NOMERGES, sdev->request_queue); @@ -2002,163 +1940,160 @@ static void ps3_nvme_attr_set(const struct ps3_instance *instance, } static inline void ps3_nvme_pd_attr_set(struct scsi_device *sdev, - const struct ps3_pd_entry *p_pd_entry) + const struct ps3_pd_entry *p_pd_entry) { - struct ps3_instance *instance = - (struct ps3_instance *)sdev->host->hostdata; - unsigned int sector_count = 0; + struct ps3_instance *instance = (struct ps3_instance *)sdev->host->hostdata; + U32 sector_count = 0; if (p_pd_entry->max_io_size != 0 && p_pd_entry->sector_size != 0) { sector_count = p_pd_entry->max_io_size >> PS3_512B_SHIFT; blk_queue_max_hw_sectors(sdev->request_queue, sector_count); } - LOG_INFO( - "nvme attr max_io_size[%u], sector_size[%u], sector_count[%u]\n", + LOG_INFO("nvme attr max_io_size[%u], sector_size[%u], sector_count[%u]\n", p_pd_entry->max_io_size, p_pd_entry->sector_size, sector_count); ps3_nvme_attr_set(instance, sdev); } -static inline void ps3_set_queue_depth(struct scsi_device *sdev, - unsigned char dev_type, - unsigned int queue_depth) +static inline void ps3_set_queue_depth(struct scsi_device *sdev, U8 dev_type, + U32 queue_depth) { - int dev_queue_depth = queue_depth; - struct ps3_instance *instance = - (struct ps3_instance *)sdev->host->hostdata; + S32 dev_queue_depth = queue_depth; + struct ps3_instance *instance = (struct ps3_instance *)sdev->host->hostdata; - dev_queue_depth = - ps3_adjust_queue_depth(instance, dev_type, queue_depth); + dev_queue_depth = ps3_adjust_queue_depth(instance, dev_type, queue_depth); -#if defined(PS3_CHANGE_QUEUE_DEPTH) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), dev_queue_depth); #else scsi_change_queue_depth(sdev, dev_queue_depth); #endif } -void ps3_sdev_bdi_stable_writes_set(struct ps3_instance *instance, - struct scsi_device *sdev) +void ps3_sdev_bdi_stable_writes_set(struct ps3_instance *instance, struct scsi_device *sdev) { -#if defined(PS3_BLK_QUEUE_FLAG_CLEAR) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR >= 8) && (RHEL_MINOR >= 6))) (void)instance; - blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, sdev->request_queue); + blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, + sdev->request_queue); #else -#if defined(PS3_BACK_DEV_INFO) - sdev->request_queue->backing_dev_info.capabilities |= - BDI_CAP_STABLE_WRITES; - LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", - PS3_HOST(instance), sdev->channel, sdev->id, - sdev->request_queue->backing_dev_info.capabilities); -#else - sdev->request_queue->backing_dev_info->capabilities |= - BDI_CAP_STABLE_WRITES; - LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", - PS3_HOST(instance), sdev->channel, sdev->id, - sdev->request_queue->backing_dev_info->capabilities); -#endif + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) + sdev->request_queue->backing_dev_info.capabilities + |= BDI_CAP_STABLE_WRITES; + LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(instance), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info.capabilities); + #else + sdev->request_queue->backing_dev_info->capabilities + |= BDI_CAP_STABLE_WRITES; + LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(instance), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info->capabilities); + #endif #endif } -int ps3_sdev_bdi_stable_writes_get(struct scsi_device *sdev) +S32 ps3_sdev_bdi_stable_writes_get(struct scsi_device *sdev) { -#if defined(PS3_BLK_QUEUE_FLAG_CLEAR) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR >= 8) && (RHEL_MINOR >= 6))) return blk_queue_stable_writes(sdev->request_queue); #else -#if defined(PS3_BACK_DEV_INFO) - return ((sdev->request_queue->backing_dev_info.capabilities & - BDI_CAP_STABLE_WRITES) == BDI_CAP_STABLE_WRITES); -#else - return ((sdev->request_queue->backing_dev_info->capabilities & - BDI_CAP_STABLE_WRITES) == BDI_CAP_STABLE_WRITES); -#endif + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) + return ((sdev->request_queue->backing_dev_info.capabilities & + BDI_CAP_STABLE_WRITES) == BDI_CAP_STABLE_WRITES); + #else + return ((sdev->request_queue->backing_dev_info->capabilities & + BDI_CAP_STABLE_WRITES) == BDI_CAP_STABLE_WRITES); + #endif #endif } -void ps3_sdev_bdi_stable_writes_clear(struct ps3_instance *instance, - struct scsi_device *sdev) +void ps3_sdev_bdi_stable_writes_clear(struct ps3_instance *instance, struct scsi_device *sdev) { -#if defined(PS3_BLK_QUEUE_FLAG_CLEAR) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR >= 8) && (RHEL_MINOR >= 6))) (void)instance; - blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, sdev->request_queue); + blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, + sdev->request_queue); #else -#if defined(PS3_BACK_DEV_INFO) - sdev->request_queue->backing_dev_info.capabilities &= - ~BDI_CAP_STABLE_WRITES; - ; - LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", - PS3_HOST(instance), sdev->channel, sdev->id, - sdev->request_queue->backing_dev_info.capabilities); -#else - sdev->request_queue->backing_dev_info->capabilities &= - ~BDI_CAP_STABLE_WRITES; - ; - LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", - PS3_HOST(instance), sdev->channel, sdev->id, - sdev->request_queue->backing_dev_info->capabilities); -#endif + #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) + sdev->request_queue->backing_dev_info.capabilities + &= ~BDI_CAP_STABLE_WRITES;; + LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(instance), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info.capabilities); + #else + sdev->request_queue->backing_dev_info->capabilities + &= ~BDI_CAP_STABLE_WRITES;; + LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(instance), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info->capabilities); + #endif #endif } -int ps3_scsi_slave_configure(struct scsi_device *sdev) +S32 ps3_scsi_slave_configure(struct scsi_device *sdev) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; struct ps3_pd_entry *p_pd_entry = NULL; struct PS3VDEntry *p_vd_entry = NULL; - unsigned int queue_depth = 0; - unsigned int dma_addr_alignment = 0; - unsigned int dma_len_alignment = 0; - unsigned char io_tmo = PS3_SCSI_CMD_TIMEOUT_DEFAULT; + U32 queue_depth = 0; + U32 dma_addr_alignment = 0; + U32 dma_len_alignment = 0; + U8 io_tmo = PS3_SCSI_CMD_TIMEOUT_DEFAULT; struct ps3_instance *instance = - (struct ps3_instance *)sdev->host->hostdata; + (struct ps3_instance*)sdev->host->hostdata; + INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_NULL1, &instance); if (unlikely(instance == NULL)) { LOG_ERROR("hno:%u slave configure have no host instance\n", - sdev->host->host_no); + sdev->host->host_no); PS3_BUG(); ret = -ENXIO; goto l_out; } - p_priv_data = (struct ps3_scsi_priv_data *)sdev->hostdata; + p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; + INJECT_START(PS3_ERR_IJ_FORCE_PRIV_DATA_NULL1, &p_priv_data); if (unlikely(p_priv_data == NULL)) { - LOG_ERROR( - "hno:%u, slave configure have no private data, [%u:%u]\n", + LOG_ERROR("hno:%u, slave configure have no private data, [%u:%u]\n", PS3_HOST(instance), sdev->channel, sdev->id); PS3_BUG(); ret = -ENXIO; goto l_out; } + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DEV_TYPE, &p_priv_data->dev_type); if (unlikely(p_priv_data->dev_type == PS3_DEV_TYPE_UNKNOWN)) { LOG_ERROR("hno:%u, dev type[%u:%u] is PS3_DEV_TYPE_UNKNOWN\n", - PS3_HOST(instance), sdev->channel, sdev->id); + PS3_HOST(instance), sdev->channel, sdev->id); ret = -ENXIO; goto l_out; } if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, sdev->channel, - sdev->id); + sdev->id); + INJECT_START(PS3_ERR_IJ_FORCE_VD_ENTRY_NULL2, &p_vd_entry); if (p_vd_entry == NULL) { - LOG_ERROR( - "hno:%u, cannot found VD[%u:%u] device info\n", + LOG_ERROR("hno:%u, cannot found VD[%u:%u] device info\n", PS3_HOST(instance), sdev->channel, sdev->id); ret = -ENXIO; goto l_out; } queue_depth = p_vd_entry->devQueDepth; - dma_addr_alignment = ps3_pd_dma_alignment_calc( - p_vd_entry->dmaAddrAlignShift); - dma_len_alignment = - ps3_pd_dma_alignment_calc(p_vd_entry->dmaLenAlignShift); - if (p_vd_entry->bdev_bdi_cap & PS3_STABLE_WRITES_MASK) + dma_addr_alignment = ps3_pd_dma_alignment_calc(p_vd_entry->dmaAddrAlignShift); + dma_len_alignment = ps3_pd_dma_alignment_calc(p_vd_entry->dmaLenAlignShift); + if (p_vd_entry->bdev_bdi_cap & PS3_STABLE_WRITES_MASK) { ps3_sdev_bdi_stable_writes_set(instance, sdev); + } } else { p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, sdev->channel, - sdev->id); + sdev->id); + INJECT_START(PS3_ERR_IJ_FORCE_PD_ENTRY_NULL2, &p_pd_entry); if (p_pd_entry == NULL) { - LOG_ERROR( - "hno:%u, cannot found PD[%u:%u] device info\n", + LOG_ERROR("hno:%u, cannot found PD[%u:%u] device info\n", PS3_HOST(instance), sdev->channel, sdev->id); ret = -ENXIO; goto l_out; @@ -2169,27 +2104,27 @@ int ps3_scsi_slave_configure(struct scsi_device *sdev) } blk_queue_dma_alignment(sdev->request_queue, PS3_SCSI_ALINNMENT_MASK); - if (dma_addr_alignment) { - blk_queue_dma_alignment(sdev->request_queue, - dma_addr_alignment - 1); + if(dma_addr_alignment){ + blk_queue_dma_alignment(sdev->request_queue, dma_addr_alignment - 1); } - if (dma_len_alignment) { -#if defined(PS3_BLK_DMA_PAD) + if(dma_len_alignment){ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) blk_queue_dma_pad(sdev->request_queue, dma_len_alignment - 1); #else - blk_queue_update_dma_pad(sdev->request_queue, - dma_len_alignment - 1); + blk_queue_update_dma_pad(sdev->request_queue, dma_len_alignment - 1); #endif } - if (instance->ctrl_info.ioTimeOut != 0) + if (instance->ctrl_info.ioTimeOut != 0) { io_tmo = instance->ctrl_info.ioTimeOut; - if (ps3_scsi_cmd_timeout_query() != 0) + } + if (ps3_scsi_cmd_timeout_query() != 0) { io_tmo = ps3_scsi_cmd_timeout_query(); + } - LOG_INFO("slave_configure, dma_addr_alignment[%d]\n" - "\tdma_len_alignment[%d], io_timeout[%u], queue_depth[%u]\n", - dma_addr_alignment, dma_len_alignment, io_tmo, queue_depth); + LOG_INFO("slave_configure, dma_addr_alignment[%d], " + "dma_len_alignment[%d], io_timeout[%u], queue_depth[%u]\n", + dma_addr_alignment, dma_len_alignment, io_tmo, queue_depth); blk_queue_rq_timeout(sdev->request_queue, io_tmo * HZ); @@ -2198,43 +2133,32 @@ int ps3_scsi_slave_configure(struct scsi_device *sdev) if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { if (p_vd_entry->maxIOSize != 0) { if (p_vd_entry->sectorSize == PS3_SECTORSIZE_512B) { - blk_queue_max_hw_sectors(sdev->request_queue, - p_vd_entry->maxIOSize); + blk_queue_max_hw_sectors(sdev->request_queue, p_vd_entry->maxIOSize); } else { - blk_queue_max_hw_sectors( - sdev->request_queue, - p_vd_entry->maxIOSize - << (ilog2(p_vd_entry - ->sectorSize) - - PS3_512B_SHIFT)); + blk_queue_max_hw_sectors(sdev->request_queue, + p_vd_entry->maxIOSize << (ilog2(p_vd_entry->sectorSize) - PS3_512B_SHIFT)); } } else { - LOG_DEBUG( - "hno:%u vd[%u:%u] update max sector num is:0\n", + LOG_DEBUG("hno:%u vd[%u:%u] update max sector num is:0\n", PS3_HOST(instance), sdev->channel, sdev->id); } if (ps3_is_nvme_device(instance, p_priv_data->dev_type, - sdev->channel, sdev->id)) { + sdev->channel, sdev->id)) { ps3_nvme_attr_set(instance, sdev); } else { -#if defined(PS3_BLK_DMA_PAD) - blk_queue_dma_pad(sdev->request_queue, - dma_len_alignment - 1); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) + blk_queue_dma_pad(sdev->request_queue, dma_len_alignment - 1); #else - blk_queue_update_dma_pad(sdev->request_queue, - dma_len_alignment - 1); + blk_queue_update_dma_pad(sdev->request_queue, dma_len_alignment - 1); #endif } } else if (p_pd_entry != NULL) { if (p_priv_data->dev_type == PS3_DEV_TYPE_NVME_SSD) { ps3_nvme_pd_attr_set(sdev, p_pd_entry); } else if (PS3_IS_HAC_LIMIT_TYPE(p_priv_data->dev_type)) { - if (p_pd_entry->max_io_size != 0 && - p_pd_entry->sector_size != 0) { - blk_queue_max_hw_sectors( - sdev->request_queue, - p_pd_entry->max_io_size >> - PS3_512B_SHIFT); + if (p_pd_entry->max_io_size != 0 && p_pd_entry->sector_size != 0) { + blk_queue_max_hw_sectors(sdev->request_queue, + p_pd_entry->max_io_size >> PS3_512B_SHIFT); } } } @@ -2242,18 +2166,16 @@ int ps3_scsi_slave_configure(struct scsi_device *sdev) if (ps3_sas_is_support_smp(instance) && p_pd_entry != NULL) { if (ps3_check_pd_is_vd_member(p_pd_entry->config_flag)) { LOG_DEBUG("hno:%u, PD[%u:%u] is belong to vd device\n", - PS3_HOST(instance), sdev->channel, sdev->id); + PS3_HOST(instance), sdev->channel, sdev->id); sdev->no_uld_attach = 1; } if (p_priv_data->dev_type == PS3_DEV_TYPE_SAS_HDD || - p_priv_data->dev_type == PS3_DEV_TYPE_SAS_SSD || - p_priv_data->dev_type == PS3_DEV_TYPE_SES) { - LOG_DEBUG( - "hno:%u pd[%u:%u] dev_type[%s] ready read port mode page\n", + p_priv_data->dev_type == PS3_DEV_TYPE_SAS_SSD || + p_priv_data->dev_type == PS3_DEV_TYPE_SES) { + LOG_DEBUG("hno:%u pd[%u:%u] dev_type[%s] ready read port mode page\n", PS3_HOST(instance), sdev->channel, sdev->id, - namePS3DevType( - (enum PS3DevType)p_pd_entry->dev_type)); + namePS3DevType((enum PS3DevType)p_pd_entry->dev_type)); sas_read_port_mode_page(sdev); } } @@ -2263,7 +2185,7 @@ int ps3_scsi_slave_configure(struct scsi_device *sdev) } #else void ps3_nvme_attr_set(const struct ps3_instance *instance, - struct scsi_device *sdev) + struct scsi_device *sdev) { (void)instance; (void)sdev; diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_manager.h b/drivers/scsi/linkdata/ps3stor/ps3_device_manager.h index ee20d9e537a2..31b283937704 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_manager.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_manager.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_DEVICE_MANAGER_H_ #define _PS3_DEVICE_MANAGER_H_ @@ -14,52 +13,63 @@ #endif -#include "ps3_htp_meta.h" -#include "ps3_htp_dev_info.h" +#include "ps3_meta.h" +#include "ps3_dev_type.h" #include "ps3_htp.h" #include "ps3_err_def.h" -#include "ps3_kernel_version.h" - -#define PS3_QUEUE_DEPTH_DEFAULT (256) -#define PS3_QUEUE_DEPTH_SATA (32) -#define PS3_QUEUE_DEPTH_SAS (64) -#define PS3_QUEUE_DEPTH_NVME (32) - -#define PS3_INVALID_VALUE (0) -#define PS3_INVALID_DEV_ID (0) -#define PS3_INVALID_LIST_ID (0) -#define PS3_DMA_ALIGN_SHIFT_MAX (15) - -#define PS3_VD_TABLE_NUM (2) -#define PS3_SCSI_4B_ALINNMENT_MASK (4) -#define PS3_SCSI_ALINNMENT_MASK (0x3) -#define PS3_SCSI_32B_ALINNMENT_MASK (0x1f) -#define PS3_SCSI_512B_ALINNMENT_MASK (0x000001FF) -#define PS3_SCSI_4K_ALINNMENT_MASK (0xFFF) -#define PS3_512B_SHIFT (9) -#define PS3_SECTORSIZE_512B (512) - -#define PS3_MAX_VD_COUNT(instance) ((instance)->ctrl_info.maxVdCount) -#define PS3_MAX_PD_COUNT(instance) ((instance)->ctrl_info.maxPdCount) - -#define PS3_CHANNEL(pos) ((unsigned char)((pos)->diskDev.ps3Dev.softChan)) -#define PS3_TARGET(pos) ((unsigned short)((pos)->diskDev.ps3Dev.devID)) -#define PS3_DISKID(pos) ((pos)->diskDev.diskID) -#define PS3_PDID(pos) ((pos)->diskDev.ps3Dev.phyDiskID) -#define PS3_VDID(pos) ((pos)->diskDev.ps3Dev.virtDiskID) -#define PS3_DEV(pos) ((struct PS3Dev *)(&(pos)->diskDev.ps3Dev)) -#define PS3_VDID_OFFSET(instance) ((instance)->ctrl_info.offsetOfVDID) - -#define PS3_DEV_INVALID(pos) ((pos).diskDev.diskID == PS3_INVALID_DEV_ID) -#define PS3_PDID_INVALID(pos) (PS3_PDID(pos) == PS3_INVALID_DEV_ID) -#define PS3_VDID_INVALID(pos) (PS3_VDID(pos) == PS3_INVALID_DEV_ID) -#define PS3_IS_VD_CHANNEL(ins, chan) \ - ((ins->dev_context.vd_table[0].vd_idxs[chan] != NULL) ? PS3_DRV_TRUE : \ - PS3_DRV_FALSE) - -#define PS3_IS_PD_CHANNEL(ins, chan) \ - ((ins->dev_context.pd_table.pd_idxs[chan] != NULL) ? PS3_DRV_TRUE : \ - PS3_DRV_FALSE) + +#define PS3_QUEUE_DEPTH_DEFAULT (256) +#define PS3_QUEUE_DEPTH_SATA (32) +#define PS3_QUEUE_DEPTH_SAS (64) +#define PS3_QUEUE_DEPTH_NVME (32) + +#define PS3_INVALID_VALUE (0) +#define PS3_INVALID_DEV_ID (0) +#define PS3_INVALID_LIST_ID (0) +#define PS3_DMA_ALIGN_SHIFT_MAX (15) + +#define PS3_VD_TABLE_NUM (2) +#define PS3_SCSI_4B_ALINNMENT_MASK (4) +#define PS3_SCSI_ALINNMENT_MASK (0x3) +#define PS3_SCSI_32B_ALINNMENT_MASK (0x1f) +#define PS3_SCSI_512B_ALINNMENT_MASK (0x000001FF) +#define PS3_SCSI_4K_ALINNMENT_MASK (0xFFF) +#define PS3_512B_SHIFT (9) +#define PS3_SECTORSIZE_512B (512) + +#define PS3_MAX_VD_COUNT(instance) \ + ((instance)->ctrl_info.maxVdCount) +#define PS3_MAX_PD_COUNT(instance) \ + ((instance)->ctrl_info.maxPdCount) + +#define PS3_CHANNEL(pos) \ + ((U8)((pos)->diskDev.ps3Dev.softChan)) +#define PS3_TARGET(pos) \ + ((U16)((pos)->diskDev.ps3Dev.devID)) +#define PS3_DISKID(pos) \ + ((pos)->diskDev.diskID) +#define PS3_PDID(pos) \ + ((pos)->diskDev.ps3Dev.phyDiskID) +#define PS3_VDID(pos) \ + ((pos)->diskDev.ps3Dev.virtDiskID) +#define PS3_DEV(pos) \ + ((struct PS3Dev*)(&(pos)->diskDev.ps3Dev)) +#define PS3_VDID_OFFSET(instance) \ + ((instance)->ctrl_info.offsetOfVDID) + +#define PS3_DEV_INVALID(pos) \ + ((pos).diskDev.diskID == PS3_INVALID_DEV_ID) +#define PS3_PDID_INVALID(pos) \ + (PS3_PDID(pos) == PS3_INVALID_DEV_ID) +#define PS3_VDID_INVALID(pos) \ + (PS3_VDID(pos) == PS3_INVALID_DEV_ID) +#define PS3_IS_VD_CHANNEL(ins, chan) \ + ((ins->dev_context.vd_table[0].vd_idxs[chan] != NULL) ? \ + PS3_DRV_TRUE : PS3_DRV_FALSE) + +#define PS3_IS_PD_CHANNEL(ins, chan) \ + ((ins->dev_context.pd_table.pd_idxs[chan] != NULL) ? \ + PS3_DRV_TRUE : PS3_DRV_FALSE) #define PS3_MAX_PD_NUM_ONE_VD (PS3_MAX_PD_COUNT_IN_SPAN * PS3_MAX_SPAN_IN_VD) @@ -73,55 +83,57 @@ struct ps3_instance; #define ZERO_LAST_STREAM (0x0FFFFFFFFFFFFFFF) #define MAX_QUE_DEPTH (16) -#define TEST_IO_BLOCK_SIZE (8) -#define IO_STREAM_DETECT_RANGE (MAX_QUE_DEPTH * TEST_IO_BLOCK_SIZE) -#define PS3_IS_HAC_LIMIT_TYPE(type) \ - ((type) == PS3_DEV_TYPE_SAS_HDD || (type) == PS3_DEV_TYPE_SATA_HDD || \ - (type) == PS3_DEV_TYPE_SATA_SSD || (type) == PS3_DEV_TYPE_SAS_SSD || \ - (type) == PS3_DEV_TYPE_SES) +#define TEST_IO_BLOCK_SIZE (8) +#define IO_STREAM_DETECT_RANGE (MAX_QUE_DEPTH * TEST_IO_BLOCK_SIZE) +#define PS3_IS_HAC_LIMIT_TYPE(type) \ + ((type) == PS3_DEV_TYPE_SAS_HDD || \ + (type) == PS3_DEV_TYPE_SATA_HDD || \ + (type) == PS3_DEV_TYPE_SATA_SSD || \ + (type) == PS3_DEV_TYPE_SAS_SSD || \ + (type) == PS3_DEV_TYPE_SES) struct ps3_stream_detect { - unsigned long long next_seq_lba; - unsigned char rw_type; - unsigned char reserved[7]; + U64 next_seq_lba; + U8 rw_type; + U8 reserved[7]; }; struct ps3_vd_stream_detect { - spinlock_t ps3_sequence_stream_lock; - unsigned long long mru_bit_map; - struct ps3_stream_detect stream_track[PS3_IO_MAX_STREAMS_TRACKED]; + ps3_spinlock ps3_sequence_stream_lock; + U64 mru_bit_map; + struct ps3_stream_detect stream_track[PS3_IO_MAX_STREAMS_TRACKED]; }; enum PS3DevType { - PS3_DEV_TYPE_UNKNOWN = 0, - PS3_DEV_TYPE_VD = 1, - PS3_DEV_TYPE_SAS_HDD = 2, - PS3_DEV_TYPE_SATA_HDD = 3, - PS3_DEV_TYPE_SATA_SSD = 4, - PS3_DEV_TYPE_SAS_SSD = 5, - PS3_DEV_TYPE_NVME_SSD = 6, - PS3_DEV_TYPE_SES = 7, - PS3_DEV_TYPE_VEP = 8, + PS3_DEV_TYPE_UNKNOWN = 0, + PS3_DEV_TYPE_VD = 1, + PS3_DEV_TYPE_SAS_HDD = 2, + PS3_DEV_TYPE_SATA_HDD = 3, + PS3_DEV_TYPE_SATA_SSD = 4, + PS3_DEV_TYPE_SAS_SSD = 5, + PS3_DEV_TYPE_NVME_SSD = 6, + PS3_DEV_TYPE_SES = 7, + PS3_DEV_TYPE_VEP = 8, PS3_DEV_TYPE_COUNT, }; enum PS3DevTypeV1 { - PS3_DEV_TYPE_SAS_SATA = 0, - PS3_DEV_TYPE_NVME = 1, + PS3_DEV_TYPE_SAS_SATA = 0, + PS3_DEV_TYPE_NVME = 1, }; -static inline const char *namePS3DevType(enum PS3DevType e) +static inline const S8 *namePS3DevType(enum PS3DevType e) { - static const char * const myNames[] = { - [PS3_DEV_TYPE_UNKNOWN] = "DEV_T_UNKNOWN", - [PS3_DEV_TYPE_VD] = "DEV_T_VD", - [PS3_DEV_TYPE_SAS_HDD] = "DEV_T_SAS_HDD", - [PS3_DEV_TYPE_SATA_HDD] = "DEV_T_SATA_HDD", - [PS3_DEV_TYPE_SATA_SSD] = "DEV_T_SATA_SSD", - [PS3_DEV_TYPE_SAS_SSD] = "DEV_T_SAS_SSD", - [PS3_DEV_TYPE_NVME_SSD] = "DEV_T_NVME_SSD", - [PS3_DEV_TYPE_SES] = "DEV_T_SES", - [PS3_DEV_TYPE_VEP] = "DEV_T_VEP" + static const S8 *myNames[] = { + [PS3_DEV_TYPE_UNKNOWN] = "DEV_T_UNKNOWN", + [PS3_DEV_TYPE_VD] = "DEV_T_VD", + [PS3_DEV_TYPE_SAS_HDD] = "DEV_T_SAS_HDD", + [PS3_DEV_TYPE_SATA_HDD] = "DEV_T_SATA_HDD", + [PS3_DEV_TYPE_SATA_SSD] = "DEV_T_SATA_SSD", + [PS3_DEV_TYPE_SAS_SSD] = "DEV_T_SAS_SSD", + [PS3_DEV_TYPE_NVME_SSD] = "DEV_T_NVME_SSD", + [PS3_DEV_TYPE_SES] = "DEV_T_SES", + [PS3_DEV_TYPE_VEP] = "DEV_T_VEP" }; return myNames[e]; @@ -149,109 +161,115 @@ enum ps3_dev_io_stat_type { }; struct ps3_dev_io_statis { - atomic64_t read_send_cnt; - atomic64_t read_send_ok_cnt; - atomic64_t read_send_wait_cnt; - atomic64_t read_send_err_cnt; - atomic64_t read_recv_cnt; - atomic64_t read_recv_ok_cnt; - atomic64_t read_recv_err_cnt; - atomic64_t read_ok_bytes; - - atomic64_t write_send_cnt; - atomic64_t write_send_ok_cnt; - atomic64_t write_send_err_cnt; - atomic64_t write_send_wait_cnt; - atomic64_t write_recv_cnt; - atomic64_t write_recv_ok_cnt; - atomic64_t write_recv_err_cnt; - atomic64_t write_ok_bytes; - - atomic64_t qos_processing_cnt; + ps3_atomic64 read_send_cnt; + ps3_atomic64 read_send_ok_cnt; + ps3_atomic64 read_send_wait_cnt; + ps3_atomic64 read_send_err_cnt; + ps3_atomic64 read_recv_cnt; + ps3_atomic64 read_recv_ok_cnt; + ps3_atomic64 read_recv_err_cnt; + ps3_atomic64 read_ok_bytes; + + ps3_atomic64 write_send_cnt; + ps3_atomic64 write_send_ok_cnt; + ps3_atomic64 write_send_err_cnt; + ps3_atomic64 write_send_wait_cnt; + ps3_atomic64 write_recv_cnt; + ps3_atomic64 write_recv_ok_cnt; + ps3_atomic64 write_recv_err_cnt; + ps3_atomic64 write_ok_bytes; + + ps3_atomic64 qos_processing_cnt; }; -static inline unsigned char ps3_disk_type(enum PS3DevType e) +static inline U8 ps3_disk_type(enum PS3DevType e) { - unsigned char disk_type = PS3_DISK_TYPE_UNKNOWN; - - switch (e) { - case PS3_DEV_TYPE_VD: - disk_type = PS3_DISK_TYPE_VD; - break; - case PS3_DEV_TYPE_SAS_HDD: - case PS3_DEV_TYPE_SATA_HDD: - case PS3_DEV_TYPE_SATA_SSD: - case PS3_DEV_TYPE_SAS_SSD: - case PS3_DEV_TYPE_NVME_SSD: - case PS3_DEV_TYPE_SES: - case PS3_DEV_TYPE_VEP: - disk_type = PS3_DISK_TYPE_PD; - break; - default: - disk_type = PS3_DISK_TYPE_UNKNOWN; - break; + U8 disk_type = PS3_DISK_TYPE_UNKNOWN; + + switch(e) { + case PS3_DEV_TYPE_VD: + disk_type = PS3_DISK_TYPE_VD; + break; + case PS3_DEV_TYPE_SAS_HDD: + case PS3_DEV_TYPE_SATA_HDD: + case PS3_DEV_TYPE_SATA_SSD: + case PS3_DEV_TYPE_SAS_SSD: + case PS3_DEV_TYPE_NVME_SSD: + case PS3_DEV_TYPE_SES: + case PS3_DEV_TYPE_VEP: + disk_type = PS3_DISK_TYPE_PD; + break; + default: + disk_type = PS3_DISK_TYPE_UNKNOWN; + break; } return disk_type; } -static inline unsigned char ps3_is_fake_pd(unsigned char dev_type) +static inline Bool ps3_is_fake_pd(U8 dev_type) { return (dev_type == PS3_DEV_TYPE_SES || dev_type == PS3_DEV_TYPE_VEP); } struct ps3_r1x_read_balance_info { - atomic_t scsi_outstanding_cmds[PS3_MAX_PD_NUM_ONE_VD + 1]; - unsigned long long last_accessed_block[PS3_MAX_PD_NUM_ONE_VD + 1]; + ps3_atomic32 scsi_outstanding_cmds[PS3_MAX_PD_NUM_ONE_VD + 1]; + U64 last_accessed_block[PS3_MAX_PD_NUM_ONE_VD + 1]; }; struct ps3_r1x_lock_mgr { - int (*try_lock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); - int (*resend_try_lock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); + S32 (*try_lock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); + S32 (*resend_try_lock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); void (*unlock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); - spinlock_t mgr_lock; + ps3_spinlock mgr_lock; void *hash_mgr; - struct list_head conflict_cmd_list; + ps3_list_head conflict_cmd_list; struct task_struct *conflict_send_th; void *hash_mgr_conflict; - int force_ret_code; - unsigned int cmd_count_in_q; - unsigned char dev_deling; - unsigned char thread_stop; + S32 force_ret_code; + U32 cmd_count_in_q; + Bool dev_deling; + Bool thread_stop; #ifdef _WINDOWS KEVENT thread_sync; #else struct completion thread_sync; #endif + }; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) || \ + (defined(KYLIN_MAJOR) && defined(CONFIG_X86) && (KYLIN_MAJOR == 10 && KYLIN_MINOR == 4))) +#define DRIVER_SUPPORT_PRIV_BUSY +#endif + struct ps3_scsi_priv_data { struct PS3DiskDevPos disk_pos; struct ps3_dev_io_statis statis; struct ps3_vd_stream_detect vd_sd[2]; struct ps3_r1x_lock_mgr lock_mgr; struct ps3_r1x_read_balance_info *r1x_rb_info; - unsigned char is_taskmgmt_enable; - unsigned char task_manager_busy; - unsigned char dev_type; - unsigned char task_abort_timeout; - unsigned char task_reset_timeout; - unsigned char encl_id; - unsigned char phy_id; - unsigned char reserved; - atomic_t rd_io_outstand; - atomic_t wr_io_outstand; - atomic_t r1x_read_cmd_swap_total_cnt; - atomic_t r1x_read_cmd_swap_res_cnt; + U8 is_taskmgmt_enable; + U8 task_manager_busy; + U8 dev_type; + U8 task_abort_timeout; + U8 task_reset_timeout; + U8 encl_id; + U8 phy_id; + U8 reserved; + ps3_atomic32 rd_io_outstand; + ps3_atomic32 wr_io_outstand; + ps3_atomic32 r1x_read_cmd_swap_total_cnt; + ps3_atomic32 r1x_read_cmd_swap_res_cnt; #if defined DRIVER_SUPPORT_PRIV_BUSY - atomic_t sdev_priv_busy; + ps3_atomic32 sdev_priv_busy; #else - unsigned char reserved1[4]; + U8 reserved1[4]; #endif - unsigned long ata_cmd_busy; - unsigned char dev_deling; - unsigned char swap_flag; - unsigned short qmask_count; - unsigned char reserved2[6]; + ULong ata_cmd_busy; + Bool dev_deling; + Bool swap_flag; + U16 qmask_count; + U8 reserved2[6]; }; #ifdef _WINDOWS @@ -261,28 +279,34 @@ struct scsi_device_real { struct ps3_scsi_priv_data hostdata; }; -#define PS3_SDEV_PRI_DATA(sdev) \ - ((struct ps3_scsi_priv_data *)&( \ - ((struct scsi_device_real *)(sdev))->hostdata)) -#define PS3_SDEV_POS(sdev) (&(PS3_SDEV_PRI_DATA(sdev)->disk_pos)) -#define PS3_SDEV_CHANNEL(sdev) (PS3_CHANNEL(PS3_SDEV_POS(sdev))) -#define PS3_SDEV_TARGET(sdev) (PS3_TARGET(PS3_SDEV_POS(sdev))) -#define PS3_SDEV_PDID(sdev) (PS3_PDID(PS3_SDEV_POS(sdev))) -#define PS3_SDEV_MAGIC(sdev) (PS3_SDEV_POS(sdev)->diskMagicNum) +#define PS3_SDEV_PRI_DATA(sdev) \ + ((struct ps3_scsi_priv_data*)&(((struct scsi_device_real *)(sdev))->hostdata)) +#define PS3_SDEV_POS(sdev) \ + (&(PS3_SDEV_PRI_DATA(sdev)->disk_pos)) +#define PS3_SDEV_CHANNEL(sdev) \ + (PS3_CHANNEL(PS3_SDEV_POS(sdev))) +#define PS3_SDEV_TARGET(sdev) \ + (PS3_TARGET(PS3_SDEV_POS(sdev))) +#define PS3_SDEV_PDID(sdev) \ + (PS3_PDID(PS3_SDEV_POS(sdev))) +#define PS3_SDEV_MAGIC(sdev) \ + (PS3_SDEV_POS(sdev)->diskMagicNum) #else -#define PS3_SDEV_CHANNEL(sdev) ((sdev)->channel) -#define PS3_SDEV_TARGET(sdev) ((sdev)->id) +#define PS3_SDEV_CHANNEL(sdev) \ + ((sdev)->channel) +#define PS3_SDEV_TARGET(sdev) \ + ((sdev)->id) -#define PS3_SDEV_PRI_DATA(sdev) \ - ((struct ps3_scsi_priv_data *)((sdev)->hostdata)) +#define PS3_SDEV_PRI_DATA(sdev) \ + ((struct ps3_scsi_priv_data*)((sdev)->hostdata)) #endif struct ps3_channel { - unsigned char channel; - unsigned char reserved0; - unsigned short max_dev_num; - unsigned short channel_start_num; - unsigned char reserved1[2]; + U8 channel; + U8 reserved0; + U16 max_dev_num; + U16 channel_start_num; + U8 reserved1[2]; }; struct ps3_dev_pool { @@ -292,42 +316,42 @@ struct ps3_dev_pool { struct ps3_pd_entry { struct PS3DiskDevPos disk_pos; - unsigned char state; - unsigned char config_flag; - unsigned char RWCT; - unsigned char scsi_interface_type; - unsigned char task_abort_timeout; - unsigned char task_reset_timeout; - unsigned char dev_type; + U8 state; + U8 config_flag; + U8 RWCT; + U8 scsi_interface_type; + U8 task_abort_timeout; + U8 task_reset_timeout; + U8 dev_type; union { struct { - unsigned char support_ncq : 1; - unsigned char protect : 1; - unsigned char is_direct_disable : 1; - unsigned char reserved : 5; + U8 support_ncq:1; + U8 protect:1; + U8 is_direct_disable:1; + U8 reserved:5; }; - unsigned char pd_flags; + U8 pd_flags; }; - unsigned int max_io_size; - unsigned int dev_queue_depth; - unsigned char encl_id; - unsigned char phy_id; - unsigned short sector_size; - unsigned short dma_addr_alignment; - unsigned short dma_len_alignment; + U32 max_io_size; + U32 dev_queue_depth; + U8 encl_id; + U8 phy_id; + U16 sector_size; + U16 dma_addr_alignment; + U16 dma_len_alignment; struct sas_rphy *sas_rphy; - unsigned short normal_quota; - unsigned short direct_quota; + U16 normal_quota; + U16 direct_quota; }; struct ps3_pd_table { - unsigned short *pd_idxs_array; - unsigned short *pd_idxs[PS3_MAX_CHANNEL_NUM]; + U16 *pd_idxs_array; + U16 *pd_idxs[PS3_MAX_CHANNEL_NUM]; }; struct ps3_vd_table { - unsigned short *vd_idxs_array; - unsigned short *vd_idxs[PS3_MAX_CHANNEL_NUM]; + U16 *vd_idxs_array; + U16 *vd_idxs[PS3_MAX_CHANNEL_NUM]; }; struct ps3_pri_data_table { @@ -336,186 +360,180 @@ struct ps3_pri_data_table { }; struct ps3_dev_context { - struct ps3_vd_table vd_table[PS3_VD_TABLE_NUM]; - struct ps3_pd_table pd_table; - struct PS3VDEntry *vd_entries_array[PS3_VD_TABLE_NUM]; - struct ps3_pd_entry *pd_entries_array; + struct ps3_vd_table vd_table[PS3_VD_TABLE_NUM]; + struct ps3_pd_table pd_table; + struct PS3VDEntry *vd_entries_array[PS3_VD_TABLE_NUM]; + struct ps3_pd_entry *pd_entries_array; struct ps3_channel channel_pd[PS3_MAX_CHANNEL_NUM]; struct ps3_channel channel_vd[PS3_MAX_CHANNEL_NUM]; struct ps3_pri_data_table vd_pri_data_table; - unsigned short max_dev_in_channel[PS3_MAX_CHANNEL_NUM]; - atomic_t subwork; - unsigned char reserved[3]; - struct ps3_dev_pool vd_pool; - struct ps3_dev_pool pd_pool; - - dma_addr_t pd_list_buf_phys; - struct PS3DevList *pd_list_buf; - dma_addr_t vd_list_buf_phys; - struct PS3DevList *vd_list_buf; - dma_addr_t pd_info_buf_phys; - struct PS3PDInfo *pd_info_buf; - dma_addr_t vd_info_buf_phys_sync; - struct PS3VDInfo *vd_info_buf_sync; - dma_addr_t vd_info_buf_phys_async; - struct PS3VDInfo *vd_info_buf_async; - - struct ps3_cmd *vd_pending_cmd; - struct ps3_cmd *vdpending_abort_cmd; - atomic_t abort_vdpending_cmd; - atomic_t is_vdpending_abort; - - unsigned short total_vd_count; - unsigned short total_pd_count; - unsigned short max_dev_per_channel; - unsigned char vd_table_idx; - unsigned char pd_channel_count; - unsigned char vd_channel_count; - struct mutex dev_priv_lock; + U16 max_dev_in_channel[PS3_MAX_CHANNEL_NUM]; + volatile U8 subwork; + U8 reserved[3]; + struct ps3_dev_pool vd_pool; + struct ps3_dev_pool pd_pool; + + dma_addr_t pd_list_buf_phys; + struct PS3DevList *pd_list_buf; + dma_addr_t vd_list_buf_phys; + struct PS3DevList *vd_list_buf; + dma_addr_t pd_info_buf_phys; + struct PS3PDInfo *pd_info_buf; + dma_addr_t vd_info_buf_phys_sync; + struct PS3VDInfo *vd_info_buf_sync; + dma_addr_t vd_info_buf_phys_async; + struct PS3VDInfo *vd_info_buf_async; + + struct ps3_cmd *vd_pending_cmd; + struct ps3_cmd *vdpending_abort_cmd; + volatile U32 abort_vdpending_cmd; + ps3_atomic32 is_vdpending_abort; + + U16 total_vd_count; + U16 total_pd_count; + U16 max_dev_per_channel; + U8 vd_table_idx; + U8 pd_channel_count; + U8 vd_channel_count; + ps3_mutex dev_priv_lock; #ifdef _WINDOWS - unsigned char channel_map_rang_num; - unsigned char total_os_channel; + U8 channel_map_rang_num; + U8 total_os_channel; struct ps3_windows_private_table windows_table; - unsigned char reserved2[3]; + U8 reserved2[3]; KEVENT disk_sync; - spinlock_t dev_lock; + ps3_spinlock dev_lock; #else - unsigned char reserved2[7]; + U8 reserved2[7]; #endif - struct mutex dev_scan_lock; + ps3_mutex dev_scan_lock; }; -int ps3_dev_mgr_cli_register(void); +S32 ps3_dev_mgr_cli_register(void); -int ps3_device_mgr_init(struct ps3_instance *instance); +S32 ps3_device_mgr_init(struct ps3_instance *instance); void ps3_device_mgr_exit(struct ps3_instance *instance); -int ps3_device_mgr_data_init(struct ps3_instance *instance); +S32 ps3_device_mgr_data_init(struct ps3_instance *instance); -int ps3_device_mgr_data_exit(struct ps3_instance *instance); +S32 ps3_device_mgr_data_exit(struct ps3_instance *instance); -int ps3_dev_mgr_vd_info_subscribe(struct ps3_instance *instance); +S32 ps3_dev_mgr_vd_info_subscribe(struct ps3_instance *instance); -int ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance); -int ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance); +S32 ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance); +S32 ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance); void ps3_dev_mgr_vd_info_clear(struct ps3_instance *instance); -int ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, - unsigned short channel, unsigned short target_id, - unsigned short pd_id); +S32 ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, U16 channel, + U16 target_id, U16 pd_id); -struct ps3_pd_entry * -ps3_dev_mgr_pd_info_find_by_id(struct ps3_instance *instance, - unsigned short disk_id); +struct ps3_pd_entry *ps3_dev_mgr_pd_info_find_by_id( + struct ps3_instance *instance, U16 disk_id); -int ps3_dev_mgr_pd_list_get(struct ps3_instance *instance); +S32 ps3_dev_mgr_pd_list_get(struct ps3_instance *instance); -int ps3_dev_mgr_vd_list_get(struct ps3_instance *instance); +S32 ps3_dev_mgr_vd_list_get(struct ps3_instance *instance); -int ps3_vd_info_get_all(struct ps3_instance *instance); +S32 ps3_vd_info_get_all(struct ps3_instance *instance); -static inline unsigned short get_offset_of_vdid(unsigned short offsetOfVDID, - unsigned short virtDiskID) +static inline U16 get_offset_of_vdid(U16 offsetOfVDID, U16 virtDiskID) { - unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; + U16 virtDiskIdx = PS3_INVALID_DEV_ID; - if (virtDiskID >= offsetOfVDID) + if ( virtDiskID >= offsetOfVDID ) { virtDiskIdx = virtDiskID - offsetOfVDID; + } return virtDiskIdx; } -unsigned char ps3_dev_id_valid_check(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id, - unsigned char dev_type); +Bool ps3_dev_id_valid_check(struct ps3_instance *instance, U8 channel, + U16 target_id, U8 dev_type); -unsigned char ps3_get_vd_raid_level(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id); +U8 ps3_get_vd_raid_level( + struct ps3_instance *instance, U8 channel, U16 target_id); -struct ps3_scsi_priv_data * -ps3_dev_mgr_lookup_vd_pri_data(struct ps3_instance *instance, - unsigned char channel, unsigned short target_id); +struct ps3_scsi_priv_data *ps3_dev_mgr_lookup_vd_pri_data( + struct ps3_instance *instance, U8 channel, U16 target_id); -struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id); +struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info( + struct ps3_instance *instance, U8 channel, U16 target_id); -struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id); +struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info( + struct ps3_instance *instance, U8 channel, U16 target_id); -struct PS3VDEntry * -ps3_dev_mgr_lookup_vd_info_by_id(struct ps3_instance *instance, - unsigned short disk_id); +struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info_by_id( + struct ps3_instance *instance, U16 disk_id); -struct ps3_pd_entry * -ps3_dev_mgr_lookup_pd_info_by_id(struct ps3_instance *instance, - unsigned short disk_id); +struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info_by_id( + struct ps3_instance *instance, U16 disk_id); -union PS3Device *ps3_dev_mgr_lookup_vd_list(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id); +union PS3Device* ps3_dev_mgr_lookup_vd_list( + struct ps3_instance *instance, U8 channel, U16 target_id); -union PS3Device *ps3_dev_mgr_lookup_pd_list(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id); +union PS3Device* ps3_dev_mgr_lookup_pd_list( + struct ps3_instance *instance, U8 channel, U16 target_id); #ifndef _WINDOWS -#if defined(PS3_CHANGE_QUEUE_DEPTH) -int ps3_change_queue_depth(struct scsi_device *sdev, int queue_depth, - int reason); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) +S32 ps3_change_queue_depth(struct scsi_device *sdev, + S32 queue_depth, S32 reason); #else -int ps3_change_queue_depth(struct scsi_device *sdev, int queue_depth); +S32 ps3_change_queue_depth(struct scsi_device *sdev, + S32 queue_depth); #endif -int ps3_scsi_slave_alloc(struct scsi_device *sdev); +S32 ps3_scsi_slave_alloc(struct scsi_device *sdev); void ps3_scsi_slave_destroy(struct scsi_device *sdev); -int ps3_scsi_slave_configure(struct scsi_device *sdev); +S32 ps3_scsi_slave_configure(struct scsi_device *sdev); #endif -static inline unsigned char ps3_check_pd_is_vd_member(unsigned char config_flag) +static inline Bool ps3_check_pd_is_vd_member(U8 config_flag) { return (config_flag != MIC_PD_STATE_JBOD && config_flag != MIC_PD_STATE_READY && - config_flag != MIC_PD_STATE_UNKNOWN); + config_flag != MIC_PD_STATE_UNKNOWN + ); } -static inline unsigned char ps3_get_converted_dev_type(unsigned char driverType, - unsigned char mediumType) +static inline U8 ps3_get_converted_dev_type(U8 driverType, U8 mediumType) { - unsigned char dev_type = PS3_DEV_TYPE_UNKNOWN; + U8 dev_type = PS3_DEV_TYPE_UNKNOWN; switch (driverType) { case DRIVER_TYPE_SAS: - if (mediumType == DEVICE_TYPE_HDD) + if (mediumType == DEVICE_TYPE_HDD) { dev_type = PS3_DEV_TYPE_SAS_HDD; - else if (mediumType == DEVICE_TYPE_SSD) + } else if (mediumType == DEVICE_TYPE_SSD) { dev_type = PS3_DEV_TYPE_SAS_SSD; + } break; case DRIVER_TYPE_SATA: - if (mediumType == DEVICE_TYPE_HDD) + if (mediumType == DEVICE_TYPE_HDD) { dev_type = PS3_DEV_TYPE_SATA_HDD; - else if (mediumType == DEVICE_TYPE_SSD) + } else if (mediumType == DEVICE_TYPE_SSD) { dev_type = PS3_DEV_TYPE_SATA_SSD; + } break; case DRIVER_TYPE_SES: - if (mediumType == DEVICE_TYPE_ENCLOSURE) + if (mediumType == DEVICE_TYPE_ENCLOSURE) { dev_type = PS3_DEV_TYPE_SES; + } break; case DRIVER_TYPE_VEP: - if (mediumType == DEVICE_TYPE_ENCLOSURE) + if (mediumType == DEVICE_TYPE_ENCLOSURE) { dev_type = PS3_DEV_TYPE_VEP; + } break; case DRIVER_TYPE_NVME: - if (mediumType == DEVICE_TYPE_SSD) + if (mediumType == DEVICE_TYPE_SSD) { dev_type = PS3_DEV_TYPE_NVME_SSD; + } break; default: break; @@ -524,41 +542,35 @@ static inline unsigned char ps3_get_converted_dev_type(unsigned char driverType, }; void ps3_change_sdev_max_sector(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry); + struct PS3VDEntry *vd_entry); void ps3_vd_info_show(const struct ps3_instance *instance, - const struct PS3VDEntry *vd_entry); -int ps3_adjust_queue_depth(struct ps3_instance *instance, - unsigned char dev_type, unsigned int queue_depth); + const struct PS3VDEntry *vd_entry); +S32 ps3_adjust_queue_depth(struct ps3_instance *instance, + U8 dev_type, U32 queue_depth); -static inline const char * -ps3_get_vd_access_plolicy_str(enum VDAccessPolicy policy) +static inline const char *ps3_get_vd_access_plolicy_str(VDAccessPolicy_e policy) { - static const char *const vdAccessPolicyName[] = { - [VD_ACCESS_POLICY_READ_WRITE] = "RW", - [VD_ACCESS_POLICY_READ_ONLY] = "RO", - [VD_ACCESS_POLICY_BLOCK] = "BLOCK", - [VD_ACCESS_POLICY_REMOVE_ACCESS] = "REMOVE_ACCESS", + static const char *vdAccessPolicyName[] = { + [VD_ACCESS_POLICY_READ_WRITE] = "RW", + [VD_ACCESS_POLICY_READ_ONLY] = "RO", + [VD_ACCESS_POLICY_BLOCK] = "BLOCK", + [VD_ACCESS_POLICY_REMOVE_ACCESS] = "REMOVE_ACCESS", }; return (policy < ARRAY_SIZE(vdAccessPolicyName)) ? - vdAccessPolicyName[policy] : - "Unknown"; + vdAccessPolicyName[policy] : "Unknown"; } -static inline unsigned char ps3_is_hdd_pd(unsigned char dev_type) +static inline Bool ps3_is_hdd_pd(U8 dev_type) { - return (dev_type == PS3_DEV_TYPE_SAS_HDD || - dev_type == PS3_DEV_TYPE_SATA_HDD); + return (dev_type == PS3_DEV_TYPE_SAS_HDD || dev_type == PS3_DEV_TYPE_SATA_HDD); } void ps3_vd_busy_scale_get(struct PS3VDEntry *vd_entry); -void ps3_sdev_bdi_stable_writes_set(struct ps3_instance *instance, - struct scsi_device *sdev); - -void ps3_sdev_bdi_stable_writes_clear(struct ps3_instance *instance, - struct scsi_device *sdev); +void ps3_sdev_bdi_stable_writes_set(struct ps3_instance *instance, struct scsi_device *sdev); -int ps3_sdev_bdi_stable_writes_get(struct scsi_device *sdev); +void ps3_sdev_bdi_stable_writes_clear(struct ps3_instance *instance, struct scsi_device *sdev); +S32 ps3_sdev_bdi_stable_writes_get(struct scsi_device *sdev); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.c b/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.c index 25657b9334af..00eebbd85bf1 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #ifndef _WINDOWS #include @@ -20,91 +18,81 @@ #include "ps3_util.h" #include "ps3_mgr_cmd.h" -static int ps3_sas_expander_event_update(struct ps3_instance *instance, - unsigned char encl_id); +static S32 ps3_sas_expander_event_update(struct ps3_instance *instance, U8 encl_id); -unsigned char ps3_sas_is_support_smp(struct ps3_instance *instance) +Bool ps3_sas_is_support_smp(struct ps3_instance *instance) { return instance->sas_dev_context.is_support_smp; } -static inline unsigned char -ps3_is_sata_end_device(struct ps3_pd_entry *pd_entry) +static inline Bool ps3_is_sata_end_device(struct ps3_pd_entry *pd_entry) { return (pd_entry->dev_type == PS3_DEV_TYPE_SATA_HDD || - pd_entry->dev_type == PS3_DEV_TYPE_SATA_SSD); + pd_entry->dev_type == PS3_DEV_TYPE_SATA_SSD); } -int ps3_sas_rphy_slot_get(struct ps3_instance *instance, - unsigned long long sas_addr, unsigned int *slot_id) +S32 ps3_sas_rphy_slot_get(struct ps3_instance *instance, U64 sas_addr, U32 *slot_id) { - int ret = -PS3_FAILED; - struct ps3_sas_node *ps3_sas_node = - &instance->sas_dev_context.ps3_hba_sas; + S32 ret = -PS3_FAILED; + struct ps3_sas_node *ps3_sas_node = &instance->sas_dev_context.ps3_hba_sas; struct ps3_sas_port *ps3_sas_port = NULL; - unsigned long flags = 0; + ULong flags = 0; spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(ps3_sas_port, &ps3_sas_node->sas_port_list, list) { - if (ps3_sas_port->remote_identify.sas_address == sas_addr) { - *slot_id = ps3_sas_node - ->phys[ps3_sas_port->remote_identify - .phy_identifier] - .slot_id; + if (ps3_sas_port->remote_identify.sas_address == + sas_addr) { + *slot_id = ps3_sas_node->phys[ps3_sas_port-> + remote_identify.phy_identifier].slot_id; ret = PS3_SUCCESS; + INJECT_START(PS3_ERR_IJ_SAS_RPHY_SLOT_GET_FAILED, &ret) goto l_out; } } list_for_each_entry(ps3_sas_node, - &instance->sas_dev_context.ps3_sas_node_list, - list) { - list_for_each_entry(ps3_sas_port, &ps3_sas_node->sas_port_list, - list) { + &instance->sas_dev_context.ps3_sas_node_list, list) { + list_for_each_entry(ps3_sas_port, + &ps3_sas_node->sas_port_list, list) { if (ps3_sas_port->remote_identify.sas_address == - sas_addr) { - *slot_id = - ps3_sas_node - ->phys[ps3_sas_port - ->remote_identify - .phy_identifier] - .slot_id; + sas_addr) { + *slot_id = ps3_sas_node->phys[ps3_sas_port-> + remote_identify.phy_identifier].slot_id; ret = PS3_SUCCESS; + INJECT_START(PS3_ERR_IJ_SAS_EXP_RPHY_SLOT_GET_FAILED, &ret) goto l_out; } } } l_out: - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); return ret; } -unsigned long long -ps3_sas_rphy_parent_sas_addr_get(struct ps3_instance *instance, - unsigned long long sas_addr) +U64 ps3_sas_rphy_parent_sas_addr_get(struct ps3_instance *instance, U64 sas_addr) { struct ps3_sas_node *ps3_sas_node = NULL; struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_phy *ps3_sas_phy = NULL; - unsigned long long encl_id = PS3_SAS_INVALID_SAS_ADDR; - unsigned long flags = 0; + U64 encl_id = PS3_SAS_INVALID_SAS_ADDR; + ULong flags = 0; spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); - list_for_each_entry( - ps3_sas_port, - &instance->sas_dev_context.ps3_hba_sas.sas_port_list, list) { - if (ps3_sas_port->remote_identify.sas_address != sas_addr) + list_for_each_entry(ps3_sas_port, + &instance->sas_dev_context.ps3_hba_sas.sas_port_list, list) { + if (ps3_sas_port->remote_identify.sas_address != + sas_addr) { continue; + } - list_for_each_entry(ps3_sas_phy, &ps3_sas_port->phy_list, - port_siblings) { + list_for_each_entry(ps3_sas_phy, + &ps3_sas_port->phy_list, port_siblings) { if (ps3_sas_phy->remote_identify.sas_address == - sas_addr) { + sas_addr) { encl_id = ps3_sas_phy->identify.sas_address; goto l_out; } @@ -112,56 +100,51 @@ ps3_sas_rphy_parent_sas_addr_get(struct ps3_instance *instance, } list_for_each_entry(ps3_sas_node, - &instance->sas_dev_context.ps3_sas_node_list, - list) { - list_for_each_entry(ps3_sas_port, &ps3_sas_node->sas_port_list, - list) { + &instance->sas_dev_context.ps3_sas_node_list, list) { + list_for_each_entry(ps3_sas_port, + &ps3_sas_node->sas_port_list, list) { if (ps3_sas_port->remote_identify.sas_address == - sas_addr) { + sas_addr) { encl_id = ps3_sas_node->sas_address; goto l_out; } } } l_out: - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); return encl_id; } -unsigned char ps3_sas_encl_id_get(struct ps3_instance *instance, - unsigned long long sas_addr) +U8 ps3_sas_encl_id_get(struct ps3_instance *instance, U64 sas_addr) { - unsigned char encl_id = PS3_SAS_INVALID_ID; + U8 encl_id = PS3_SAS_INVALID_ID; struct ps3_sas_node *ps3_sas_node = NULL; - unsigned long flags = 0; - unsigned char i = 0; + ULong flags = 0; + U8 i = 0; for (i = 0; i < PS3_SAS_HBA_MAX_SAS_NUM; i++) { - if (instance->sas_dev_context.ps3_hba_sas_addr[i] == sas_addr) + if (instance->sas_dev_context.ps3_hba_sas_addr[i] == sas_addr) { return instance->sas_dev_context.ps3_hba_sas.encl_id; + } } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(ps3_sas_node, - &instance->sas_dev_context.ps3_sas_node_list, - list) { + &instance->sas_dev_context.ps3_sas_node_list, list) { if (ps3_sas_node->sas_address == sas_addr) { encl_id = ps3_sas_node->encl_id; goto l_out; } } l_out: - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); return encl_id; } static void ps3_sas_node_phy_init(struct ps3_sas_phy *ps3_phy, - struct ps3_sas_node *sas_node, - struct PS3PhyInfo *phy_info) + struct ps3_sas_node *sas_node, struct PS3PhyInfo *phy_info) { ps3_phy->phy_id = phy_info->phyId; ps3_phy->encl_id = sas_node->encl_id; @@ -171,13 +154,13 @@ static void ps3_sas_node_phy_init(struct ps3_sas_phy *ps3_phy, ps3_phy->identify.sas_address = le64_to_cpu(phy_info->sasAddr); ps3_phy->identify.initiator_port_protocols = phy_info->initiatorPortProtocol; - ps3_phy->identify.target_port_protocols = phy_info->targetPortProtocols; + ps3_phy->identify.target_port_protocols = + phy_info->targetPortProtocols; ps3_phy->identify.phy_identifier = phy_info->phyId; if (phy_info->attachedSasAddr != PS3_SAS_INVALID_SAS_ADDR) { ps3_phy->remote_identify.device_type = phy_info->attachDevType; - ps3_phy->remote_identify.sas_address = - le64_to_cpu(phy_info->attachedSasAddr); + ps3_phy->remote_identify.sas_address = le64_to_cpu(phy_info->attachedSasAddr); ps3_phy->remote_identify.initiator_port_protocols = phy_info->attachInitiatorPortProtocol; ps3_phy->remote_identify.target_port_protocols = @@ -186,20 +169,20 @@ static void ps3_sas_node_phy_init(struct ps3_sas_phy *ps3_phy, } } -static int ps3_sas_node_phy_add(struct ps3_instance *instance, - struct ps3_sas_phy *ps3_phy, - struct ps3_sas_node *sas_node, - struct PS3PhyInfo *phy_info) +static S32 ps3_sas_node_phy_add(struct ps3_instance *instance, + struct ps3_sas_phy *ps3_phy, struct ps3_sas_node *sas_node, + struct PS3PhyInfo *phy_info) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct sas_phy *sas_phy = NULL; INIT_LIST_HEAD(&ps3_phy->port_siblings); sas_phy = sas_phy_alloc(sas_node->dev, phy_info->phyId); + INJECT_START(PS3_ERR_IJ_SAS_ALLOC_PHY_NULL1, &sas_phy); if (sas_phy == NULL) { LOG_ERROR("hno:%u alloc node[%d] phys[%d] buffer failed !\n", - PS3_HOST(instance), sas_node->encl_id, - phy_info->phyId); + PS3_HOST(instance), sas_node->encl_id, + phy_info->phyId); ret = -PS3_ENOMEM; goto l_out; } @@ -213,15 +196,15 @@ static int ps3_sas_node_phy_add(struct ps3_instance *instance, sas_phy->minimum_linkrate_hw = phy_info->minLinkRateHw; sas_phy->maximum_linkrate_hw = phy_info->maxLinkRateHw; - LOG_INFO( - "hno:%u phy %d in encl[%d], dev_type[%d]\n" - "\tsas_addr[%016llx], n_linkrate[%d], slot_id[%d], i_prol[%d], t_prol[%d]\n" - "\tremote_dev_type[%d], remote_sas_addr[%016llx], i_prol[%d], t_prol[%d]\n" - "\tmin_linkr[%u:%u], max_linikr[%u:%u] !\n", + LOG_INFO("hno:%u phy %d in encl[%d], dev_type[%d]," + "sas_addr[%016llx], n_linkrate[%d], slot_id[%d], i_prol[%d], t_prol[%d], " + "remote_dev_type[%d], remote_sas_addr[%016llx], i_prol[%d], t_prol[%d]" + " min_linkr[%u:%u], max_linikr[%u:%u] !\n", PS3_HOST(instance), sas_phy->identify.phy_identifier, sas_node->encl_id, sas_phy->identify.device_type, - sas_phy->identify.sas_address, sas_phy->negotiated_linkrate, - phy_info->slotId, sas_phy->identify.initiator_port_protocols, + sas_phy->identify.sas_address, + sas_phy->negotiated_linkrate, phy_info->slotId, + sas_phy->identify.initiator_port_protocols, sas_phy->identify.target_port_protocols, ps3_phy->remote_identify.device_type, ps3_phy->remote_identify.sas_address, @@ -231,10 +214,11 @@ static int ps3_sas_node_phy_add(struct ps3_instance *instance, sas_phy->maximum_linkrate, sas_phy->maximum_linkrate_hw); ret = sas_phy_add(sas_phy); + INJECT_START(PS3_ERR_IJ_SAS_PHY_ADD_FAILED1, &ret); if (ret != 0) { LOG_ERROR("hno:%u add node[%d]-phys[%d] failed ret[%d] !\n", - PS3_HOST(instance), sas_node->encl_id, - phy_info->phyId, ret); + PS3_HOST(instance), sas_node->encl_id, + phy_info->phyId, ret); sas_phy_free(sas_phy); goto l_out; } @@ -244,21 +228,27 @@ static int ps3_sas_node_phy_add(struct ps3_instance *instance, return ret; } -void ps3_sas_node_phy_update(struct ps3_instance *instance, - struct ps3_sas_phy *ps3_phy, - struct PS3PhyInfo *phy_info) +void ps3_sas_node_phy_update(struct ps3_instance *instance, struct ps3_sas_phy *ps3_phy, + struct PS3PhyInfo *phy_info) { (void)instance; ps3_phy->identify.initiator_port_protocols = phy_info->initiatorPortProtocol; - ps3_phy->identify.target_port_protocols = phy_info->targetPortProtocols; - ps3_phy->remote_identify.device_type = phy_info->attachDevType; - ps3_phy->remote_identify.sas_address = phy_info->attachedSasAddr; - ps3_phy->remote_identify.initiator_port_protocols = - phy_info->attachInitiatorPortProtocol; - ps3_phy->remote_identify.target_port_protocols = - phy_info->attachTargetPortProtocols; - ps3_phy->remote_identify.phy_identifier = phy_info->phyId; + ps3_phy->identify.target_port_protocols = + phy_info->targetPortProtocols; +#if 0 + if (phy_info->attachedSasAddr != PS3_SAS_INVALID_SAS_ADDR) { +#endif + ps3_phy->remote_identify.device_type = phy_info->attachDevType; + ps3_phy->remote_identify.sas_address = phy_info->attachedSasAddr; + ps3_phy->remote_identify.initiator_port_protocols = + phy_info->attachInitiatorPortProtocol; + ps3_phy->remote_identify.target_port_protocols = + phy_info->attachTargetPortProtocols; + ps3_phy->remote_identify.phy_identifier = phy_info->phyId; +#if 0 + } +#endif ps3_phy->phy->identify = ps3_phy->identify; ps3_phy->phy->negotiated_linkrate = phy_info->negLinkRate; @@ -268,14 +258,13 @@ void ps3_sas_node_phy_update(struct ps3_instance *instance, ps3_phy->phy->minimum_linkrate_hw = phy_info->minLinkRateHw; ps3_phy->phy->maximum_linkrate_hw = phy_info->maxLinkRateHw; - LOG_INFO_IN_IRQ( - instance, - "update phy %d, dev_type[%d], enable[%d]\n" - "\tsas_addr[%016llx], n_linkrate[%d], slot_id[%d], i_prol[%d], t_prol[%d]\n" - "\tremote_dev_type[%d], remote_sas_addr[%016llx], i_prol[%d], t_prol[%d]\n" - "\tmin_linkr[%u:%u], max_linikr[%u:%u] !\n", + LOG_INFO_IN_IRQ(instance, "update phy %d, dev_type[%d], enable[%d]" + "sas_addr[%016llx], n_linkrate[%d], slot_id[%d], i_prol[%d], t_prol[%d], " + "remote_dev_type[%d], remote_sas_addr[%016llx], i_prol[%d], t_prol[%d]" + " min_linkr[%u:%u], max_linikr[%u:%u] !\n", ps3_phy->phy->identify.phy_identifier, - ps3_phy->phy->identify.device_type, ps3_phy->phy->enabled, + ps3_phy->phy->identify.device_type, + ps3_phy->phy->enabled, ps3_phy->phy->identify.sas_address, ps3_phy->phy->negotiated_linkrate, phy_info->slotId, ps3_phy->phy->identify.initiator_port_protocols, @@ -291,119 +280,103 @@ void ps3_sas_node_phy_update(struct ps3_instance *instance, } static void ps3_sas_port_phy_update(struct ps3_instance *instance, - struct ps3_sas_node *sas_node) + struct ps3_sas_node *sas_node) { struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_port *ps3_sas_port_next = NULL; - unsigned char i = 0; - unsigned long flags = 0; + U8 i = 0; + ULong flags = 0; for (i = 0; i < sas_node->phy_count; i++) { if (sas_node->phys[i].remote_identify.sas_address == 0 || - sas_node->phys[i].remote_identify.device_type == - SAS_END_DEVICE) { + sas_node->phys[i].remote_identify.device_type == SAS_END_DEVICE) { continue; } - if (sas_node->phys[i].attach_port != NULL) + if (sas_node->phys[i].attach_port != NULL) { continue; + } list_for_each_entry_safe(ps3_sas_port, ps3_sas_port_next, - &sas_node->sas_port_list, list) { + &sas_node->sas_port_list, list) { if (sas_node->phys[i].remote_identify.sas_address == - ps3_sas_port->remote_identify.sas_address) { - spin_lock_irqsave(&instance->sas_dev_context - .ps3_sas_node_lock, - flags); - list_add_tail(&sas_node->phys[i].port_siblings, - &ps3_sas_port->phy_list); + ps3_sas_port->remote_identify.sas_address) { + spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); + list_add_tail(&sas_node->phys[i].port_siblings, &ps3_sas_port->phy_list); sas_node->phys[i].attach_port = ps3_sas_port; - spin_unlock_irqrestore( - &instance->sas_dev_context - .ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); ps3_sas_port->phy_count++; - sas_port_add_phy(ps3_sas_port->port, - sas_node->phys[i].phy); + sas_port_add_phy(ps3_sas_port->port, sas_node->phys[i].phy); } } } } -static struct ps3_sas_port *ps3_sas_port_find(struct ps3_instance *instance, - struct ps3_sas_node *exp_node, - unsigned long long sas_addr) +static struct ps3_sas_port* ps3_sas_port_find(struct ps3_instance *instance, + struct ps3_sas_node *exp_node, U64 sas_addr) { struct ps3_sas_port *ps3_sas_port = NULL; - unsigned long flags = 0; + ULong flags = 0; spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(ps3_sas_port, &exp_node->sas_port_list, list) { if (ps3_sas_port->remote_identify.sas_address == sas_addr) { - spin_unlock_irqrestore( - &instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); return ps3_sas_port; } } - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); return NULL; } static void ps3_sas_port_phy_add(struct ps3_instance *instance, - struct ps3_sas_port *ps3_sas_port, - struct ps3_sas_phy *ps3_phy) + struct ps3_sas_port *ps3_sas_port, struct ps3_sas_phy *ps3_phy) { struct ps3_sas_phy *tmp_phy = NULL; - unsigned long flags = 0; + ULong flags = 0; spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(tmp_phy, &ps3_sas_port->phy_list, port_siblings) { if (tmp_phy == ps3_phy) { - spin_unlock_irqrestore( - &instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); return; } } list_add_tail(&ps3_phy->port_siblings, &ps3_sas_port->phy_list); ps3_phy->attach_port = ps3_sas_port; - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); ps3_sas_port->phy_count++; sas_port_add_phy(ps3_sas_port->port, ps3_phy->phy); } -static struct sas_port * -ps3_sas_sas_port_create(struct ps3_instance *instance, - struct ps3_sas_node *parent_node, - struct list_head *phy_list) +static struct sas_port* ps3_sas_sas_port_create(struct ps3_instance *instance, + struct ps3_sas_node *parent_node, struct list_head *phy_list) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct sas_port *sas_port = NULL; struct ps3_sas_phy *ps3_phy = NULL; sas_port = sas_port_alloc_num(parent_node->dev); + INJECT_START(PS3_ERR_IJ_SAS_ALLOC_NUM_NULL, &sas_port); if (sas_port == NULL) { LOG_ERROR("hno:%u alloc sas_port on node[%d] failed !\n", - PS3_HOST(instance), parent_node->encl_id); + PS3_HOST(instance), parent_node->encl_id); goto l_out; } ret = sas_port_add(sas_port); + INJECT_START(PS3_ERR_IJ_SAS_PORT_ADD_FAILED, &ret); if (ret != 0) { LOG_ERROR("hno:%u add sas_port on node[%d] failed !\n", - PS3_HOST(instance), parent_node->encl_id); + PS3_HOST(instance), parent_node->encl_id); goto l_failed; } list_for_each_entry(ps3_phy, phy_list, port_siblings) { - LOG_DEBUG( - "hno:%u add phy[%d] in sas_port[%016llx] on node[%d] !\n", + LOG_DEBUG("hno:%u add phy[%d] in sas_port[%016llx] on node[%d] !\n", PS3_HOST(instance), ps3_phy->phy_id, ps3_phy->remote_identify.sas_address, parent_node->encl_id); @@ -417,12 +390,11 @@ ps3_sas_sas_port_create(struct ps3_instance *instance, return NULL; } -static int ps3_sas_end_device_add_past(struct ps3_instance *instance, - struct ps3_sas_port *ps3_sas_port, - struct ps3_pd_entry *pd_entry, - struct sas_rphy *sas_rphy) +static S32 ps3_sas_end_device_add_past(struct ps3_instance *instance, + struct ps3_sas_port *ps3_sas_port, struct ps3_pd_entry *pd_entry, + struct sas_rphy *sas_rphy) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; if (ps3_sas_port->remote_identify.device_type != SAS_END_DEVICE) { ret = PS3_SUCCESS; @@ -431,50 +403,40 @@ static int ps3_sas_end_device_add_past(struct ps3_instance *instance, sas_rphy->identify = ps3_sas_port->remote_identify; ret = ps3_scsi_add_device_ack(instance, &pd_entry->disk_pos, - PS3_DISK_TYPE_PD); + PS3_DISK_TYPE_PD); + INJECT_START(PS3_ERR_IJ_SAS_ADD_ACK_FAILED, &ret); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR("hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u]\n" - "\tmagic[%#x] add scsi device ack NOK, ret %d\n", - PS3_HOST(instance), - ps3_sas_port->remote_identify.sas_address, - PS3_CHANNEL(&pd_entry->disk_pos), - PS3_TARGET(&pd_entry->disk_pos), - PS3_PDID(&pd_entry->disk_pos), - pd_entry->disk_pos.diskMagicNum, ret); + LOG_ERROR("hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] " + "magic[%#x] add scsi device ack NOK, ret %d\n", + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address, + PS3_CHANNEL(&pd_entry->disk_pos), PS3_TARGET(&pd_entry->disk_pos), + PS3_PDID(&pd_entry->disk_pos), + pd_entry->disk_pos.diskMagicNum, ret); ret = -PS3_ACTIVE_ERR; } else { - LOG_WARN( - "hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] add begin\n", - PS3_HOST(instance), - ps3_sas_port->remote_identify.sas_address, - PS3_CHANNEL(&pd_entry->disk_pos), - PS3_TARGET(&pd_entry->disk_pos), + LOG_WARN("hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] add begin\n", + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address, + PS3_CHANNEL(&pd_entry->disk_pos), PS3_TARGET(&pd_entry->disk_pos), PS3_PDID(&pd_entry->disk_pos)); - scsi_scan_target(&sas_rphy->dev, - PS3_CHANNEL(&pd_entry->disk_pos), - PS3_TARGET(&pd_entry->disk_pos), 0, - SCSI_SCAN_INITIAL); - LOG_WARN( - "hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] add end\n", - PS3_HOST(instance), - ps3_sas_port->remote_identify.sas_address, - PS3_CHANNEL(&pd_entry->disk_pos), - PS3_TARGET(&pd_entry->disk_pos), + scsi_scan_target(&sas_rphy->dev, PS3_CHANNEL(&pd_entry->disk_pos), + PS3_TARGET(&pd_entry->disk_pos), 0, SCSI_SCAN_INITIAL); + LOG_WARN("hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] add end\n", + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address, + PS3_CHANNEL(&pd_entry->disk_pos), PS3_TARGET(&pd_entry->disk_pos), PS3_PDID(&pd_entry->disk_pos)); } l_out: return ret; } -static int ps3_sas_port_rphy_create(struct ps3_instance *instance, - struct ps3_sas_port *ps3_sas_port) +static S32 ps3_sas_port_rphy_create(struct ps3_instance *instance, + struct ps3_sas_port *ps3_sas_port) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct sas_rphy *sas_rphy = NULL; struct ps3_pd_entry *pd_entry = NULL; - LOG_DEBUG( - "hno:%u enter port rphy create, type[%d], pdflatid[%d], sas_addr[%016llx]\n", + LOG_DEBUG("hno:%u enter port rphy create, type[%d], pdflatid[%d], sas_addr[%016llx]\n", PS3_HOST(instance), ps3_sas_port->remote_identify.device_type, ps3_sas_port->pd_flat_id, ps3_sas_port->remote_identify.sas_address); @@ -482,16 +444,13 @@ static int ps3_sas_port_rphy_create(struct ps3_instance *instance, if (ps3_sas_port->remote_identify.device_type == SAS_END_DEVICE) { sas_rphy = sas_end_device_alloc(ps3_sas_port->port); } else { - sas_rphy = sas_expander_alloc( - ps3_sas_port->port, - (enum sas_device_type) - ps3_sas_port->remote_identify.device_type); + sas_rphy = sas_expander_alloc(ps3_sas_port->port, + (enum sas_device_type)ps3_sas_port->remote_identify.device_type); } + INJECT_START(PS3_ERR_IJ_SAS_ALLOC_PHY_NULL, &sas_rphy); if (unlikely(sas_rphy == NULL)) { - LOG_ERROR( - "hno:%u alloc SAS rphy for sas_addr[%016llx] failed !\n", - PS3_HOST(instance), - ps3_sas_port->remote_identify.sas_address); + LOG_ERROR("hno:%u alloc SAS rphy for sas_addr[%016llx] failed !\n", + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); goto l_out; } @@ -499,46 +458,40 @@ static int ps3_sas_port_rphy_create(struct ps3_instance *instance, if (ps3_sas_port->remote_identify.device_type == SAS_END_DEVICE) { sas_rphy->identify.target_port_protocols = SAS_PROTOCOL_NONE; - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( - instance, ps3_sas_port->pd_flat_id); + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, + ps3_sas_port->pd_flat_id); if (unlikely(pd_entry == NULL)) { - LOG_ERROR( - "hno:%u cannot find pd entry by pd_flat_id[%d] !\n", + LOG_ERROR("hno:%u cannot find pd entry by pd_flat_id[%d] !\n", PS3_HOST(instance), ps3_sas_port->pd_flat_id); goto l_out; } } ret = sas_rphy_add(sas_rphy); + INJECT_START(PS3_ERR_IJ_SAS_PHY_ADD_FAILED, &ret); if (unlikely(ret != 0)) { - LOG_ERROR( - "hno:%u add SAS rphy for sas_addr[%016llx] failed !\n", - PS3_HOST(instance), - ps3_sas_port->remote_identify.sas_address); + LOG_ERROR("hno:%u add SAS rphy for sas_addr[%016llx] failed !\n", + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); goto l_out; } - ret = ps3_sas_end_device_add_past(instance, ps3_sas_port, pd_entry, - sas_rphy); + ret = ps3_sas_end_device_add_past(instance, ps3_sas_port, pd_entry, sas_rphy); l_out: ps3_sas_port->rphy = sas_rphy; - LOG_DEBUG( - "hno:%u quit port rphy create, type[%d], pdflatid[%d], sas_addr[%016llx]\n", + LOG_DEBUG("hno:%u quit port rphy create, type[%d], pdflatid[%d], sas_addr[%016llx]\n", PS3_HOST(instance), ps3_sas_port->remote_identify.device_type, - ps3_sas_port->pd_flat_id, - ps3_sas_port->remote_identify.sas_address); + ps3_sas_port->pd_flat_id, ps3_sas_port->remote_identify.sas_address); return ret; } -struct ps3_sas_node * -ps3_sas_find_node_by_sas_addr(struct ps3_instance *instance, - unsigned long long sas_addr) +struct ps3_sas_node* ps3_sas_find_node_by_sas_addr( + struct ps3_instance *instance, U64 sas_addr) { struct ps3_sas_node *ps3_sas_node = NULL; struct ps3_sas_node *ret_node = NULL; - unsigned long flags = 0; - unsigned char i = 0; + ULong flags = 0; + U8 i = 0; for (i = 0; i < PS3_SAS_HBA_MAX_SAS_NUM; i++) { if (instance->sas_dev_context.ps3_hba_sas_addr[i] == sas_addr) { @@ -549,127 +502,109 @@ ps3_sas_find_node_by_sas_addr(struct ps3_instance *instance, spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(ps3_sas_node, - &instance->sas_dev_context.ps3_sas_node_list, - list) { + &instance->sas_dev_context.ps3_sas_node_list, list) { if (ps3_sas_node->sas_address == sas_addr) { ret_node = ps3_sas_node; break; } } - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); l_out: return ret_node; } static void ps3_sanity_check_clean(struct ps3_instance *instance, - struct ps3_sas_node *sas_node, - unsigned long long sas_address, - struct ps3_sas_port *sas_port) + struct ps3_sas_node *sas_node, U64 sas_address, struct ps3_sas_port *sas_port) { struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_port *ps3_sas_port_next = NULL; struct ps3_sas_phy *ps3_sas_phy = NULL; struct ps3_sas_phy *ps3_sas_phy_next = NULL; struct ps3_sas_node *exp_node = NULL; - unsigned long flags = 0; + ULong flags = 0; struct ps3_pd_entry *pd_entry = NULL; list_for_each_entry_safe(ps3_sas_port, ps3_sas_port_next, - &sas_node->sas_port_list, list) { - if (ps3_sas_port == sas_port) + &sas_node->sas_port_list, list) { + if (ps3_sas_port == sas_port) { continue; + } list_for_each_entry_safe(ps3_sas_phy, ps3_sas_phy_next, - &ps3_sas_port->phy_list, - port_siblings) { + &ps3_sas_port->phy_list, port_siblings) { if (ps3_sas_phy->remote_identify.sas_address != - sas_address) { + sas_address) { continue; } - LOG_WARN( - "hno:%u phy[%d] sas_addr[%016llx] == new device SAS addr\n", + LOG_WARN("hno:%u phy[%d] sas_addr[%016llx] == new device SAS addr\n", PS3_HOST(instance), ps3_sas_phy->phy_id, ps3_sas_port->remote_identify.sas_address); - spin_lock_irqsave( - &instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_del(&ps3_sas_phy->port_siblings); ps3_sas_phy->attach_port = NULL; - spin_unlock_irqrestore( - &instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); ps3_sas_port->phy_count--; - sas_port_delete_phy(ps3_sas_port->port, - ps3_sas_phy->phy); + sas_port_delete_phy(ps3_sas_port->port, ps3_sas_phy->phy); } - if (ps3_sas_port->phy_count != 0) + if (ps3_sas_port->phy_count != 0){ continue; + } if (ps3_sas_port->remote_identify.device_type == - SAS_EDGE_EXPANDER_DEVICE || - ps3_sas_port->remote_identify.device_type == - SAS_FANOUT_EXPANDER_DEVICE) { - exp_node = ps3_sas_find_node_by_sas_addr( - instance, + SAS_EDGE_EXPANDER_DEVICE || + ps3_sas_port->remote_identify.device_type == + SAS_FANOUT_EXPANDER_DEVICE) { + + exp_node = ps3_sas_find_node_by_sas_addr(instance, ps3_sas_port->remote_identify.sas_address); if (exp_node == NULL) { - LOG_ERROR( - "hno:%u cannot find node sas_addr[%016llx] !\n", - PS3_HOST(instance), - ps3_sas_port->remote_identify - .sas_address); + LOG_ERROR("hno:%u cannot find node sas_addr[%016llx] !\n", + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); PS3_BUG(); continue; } ps3_sas_expander_node_del(instance, exp_node); - } else if (ps3_sas_port->remote_identify.device_type == - SAS_END_DEVICE) { - spin_lock_irqsave( - &instance->sas_dev_context.ps3_sas_node_lock, - flags); + }else if (ps3_sas_port->remote_identify.device_type == + SAS_END_DEVICE) { + + spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_del(&ps3_sas_port->list); - spin_unlock_irqrestore( - &instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); - LOG_INFO( - "hno:%u sas_port pdid[%u] delete start, by r SAS addr[0x%llx], change\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, - sas_address); + LOG_INFO("hno:%u sas_port pdid[%u] delete start, by r SAS addr[0x%llx], change\n", + PS3_HOST(instance), ps3_sas_port->pd_flat_id, sas_address); sas_port_delete(ps3_sas_port->port); - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( - instance, ps3_sas_port->pd_flat_id); - if (pd_entry != NULL) + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, ps3_sas_port->pd_flat_id); + if (pd_entry != NULL) { pd_entry->sas_rphy = NULL; + } - LOG_INFO( - "hno:%u sas_port pdid[%u] delete end, by r SAS addr[0x%llx], change\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, - sas_address); + LOG_INFO("hno:%u sas_port pdid[%u] delete end, by r SAS addr[0x%llx], change\n", + PS3_HOST(instance), ps3_sas_port->pd_flat_id, sas_address); kfree(ps3_sas_port); } } + } -static int ps3_sas_port_create(struct ps3_instance *instance, - struct ps3_sas_node *sas_node, - struct ps3_sas_port *ps3_sas_port) +static S32 ps3_sas_port_create(struct ps3_instance *instance, + struct ps3_sas_node *sas_node, struct ps3_sas_port *ps3_sas_port) { - int ret = -PS3_FAILED; - unsigned long flags = 0; + S32 ret = -PS3_FAILED; + ULong flags = 0; ps3_sas_port->port = ps3_sas_sas_port_create(instance, sas_node, - &ps3_sas_port->phy_list); + &ps3_sas_port->phy_list); + INJECT_START(PS3_ERR_IJ_SAS_PORT_CREATE_FAIL, ps3_sas_port); if (unlikely(ps3_sas_port->port == NULL)) { LOG_ERROR("hno:%u cannot add port on parent[%d] !\n", - PS3_HOST(instance), sas_node->encl_id); + PS3_HOST(instance), sas_node->encl_id); goto l_out; } @@ -677,16 +612,14 @@ static int ps3_sas_port_create(struct ps3_instance *instance, ret = ps3_sas_port_rphy_create(instance, ps3_sas_port); if (unlikely(ret != PS3_SUCCESS)) { LOG_ERROR("hno:%u create rphy[%016llx] on parent[%d] NOK!\n", - PS3_HOST(instance), - ps3_sas_port->remote_identify.sas_address, - sas_node->encl_id); + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address, + sas_node->encl_id); goto l_failed; } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_add_tail(&ps3_sas_port->list, &sas_node->sas_port_list); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); goto l_out; l_failed: @@ -699,22 +632,22 @@ static int ps3_sas_port_create(struct ps3_instance *instance, } static void ps3_sas_port_del(struct ps3_instance *instance, - struct ps3_sas_port *ps3_sas_port) + struct ps3_sas_port *ps3_sas_port) { struct ps3_sas_phy *ps3_sas_phy = NULL; struct ps3_sas_phy *ps3_sas_phy_next = NULL; - unsigned long flags = 0; + ULong flags = 0; struct ps3_pd_entry *pd_entry = NULL; (void)instance; spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_del(&ps3_sas_port->list); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry_safe(ps3_sas_phy, ps3_sas_phy_next, - &ps3_sas_port->phy_list, port_siblings) { + &ps3_sas_port->phy_list, port_siblings) { + sas_port_delete_phy(ps3_sas_port->port, ps3_sas_phy->phy); list_del(&ps3_sas_phy->port_siblings); @@ -723,52 +656,45 @@ static void ps3_sas_port_del(struct ps3_instance *instance, } LOG_INFO("hno:%u sas_port pdid[%u] phy_count[%u] delete start\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, - ps3_sas_port->phy_count); + PS3_HOST(instance), ps3_sas_port->pd_flat_id, ps3_sas_port->phy_count); sas_port_delete(ps3_sas_port->port); - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, - ps3_sas_port->pd_flat_id); - if (pd_entry != NULL) + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, ps3_sas_port->pd_flat_id); + if (pd_entry != NULL) { pd_entry->sas_rphy = NULL; + } LOG_WARN("hno:%u sas_port pdid[%u] phy_count[%u] delete end\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, - ps3_sas_port->phy_count); + PS3_HOST(instance), ps3_sas_port->pd_flat_id, ps3_sas_port->phy_count); kfree(ps3_sas_port); + } -static int ps3_sas_end_device_try_add(struct ps3_instance *instance, - struct ps3_sas_node *sas_node, - struct ps3_sas_phy *ps3_phy, - struct ps3_pd_entry *pd_entry) +static S32 ps3_sas_end_device_try_add(struct ps3_instance *instance, + struct ps3_sas_node *sas_node, struct ps3_sas_phy *ps3_phy, + struct ps3_pd_entry *pd_entry) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_sas_port *ps3_sas_port = NULL; LOG_DEBUG("hno:%u ready add end device[%016llx] on node[%d]\n", - PS3_HOST(instance), ps3_phy->remote_identify.sas_address, - sas_node->encl_id); + PS3_HOST(instance), ps3_phy->remote_identify.sas_address, + sas_node->encl_id); ps3_sas_port = ps3_sas_port_find(instance, sas_node, - ps3_phy->remote_identify.sas_address); + ps3_phy->remote_identify.sas_address); - ps3_sanity_check_clean(instance, sas_node, - ps3_phy->remote_identify.sas_address, - ps3_sas_port); + ps3_sanity_check_clean(instance, sas_node, ps3_phy->remote_identify.sas_address, ps3_sas_port); if (ps3_sas_port != NULL) { LOG_DEBUG("hno:%u find exist port[%016llx] on node[%d]\n", - PS3_HOST(instance), - ps3_phy->remote_identify.sas_address, - sas_node->encl_id); + PS3_HOST(instance), ps3_phy->remote_identify.sas_address, + sas_node->encl_id); if (ps3_is_sata_end_device(pd_entry) && - ps3_sas_port->pd_flat_id != PS3_PDID(&pd_entry->disk_pos)) { - LOG_INFO( - "hno:%u sata end device [%u:%u] not exist but in port\n", - PS3_HOST(instance), - PS3_CHANNEL(&pd_entry->disk_pos), + ps3_sas_port->pd_flat_id != PS3_PDID(&pd_entry->disk_pos)) { + LOG_INFO("hno:%u sata end device [%u:%u] not exist but in port\n", + PS3_HOST(instance), PS3_CHANNEL(&pd_entry->disk_pos), PS3_TARGET(&pd_entry->disk_pos)); ps3_sas_port_del(instance, ps3_sas_port); ps3_sas_port = NULL; @@ -778,11 +704,11 @@ static int ps3_sas_end_device_try_add(struct ps3_instance *instance, } } - ps3_sas_port = (struct ps3_sas_port *)ps3_kzalloc( - instance, sizeof(struct ps3_sas_port)); + ps3_sas_port = (struct ps3_sas_port *)ps3_kzalloc(instance, sizeof(struct ps3_sas_port)); + INJECT_START(PS3_ERR_IJ_SAS_PORT_ALLOC_NULL, &ps3_sas_port); if (ps3_sas_port == NULL) { LOG_ERROR("hno:%u alloc PS3 port on node[%d] failed !\n", - PS3_HOST(instance), sas_node->encl_id); + PS3_HOST(instance), sas_node->encl_id); ret = -PS3_FAILED; goto l_out; } @@ -795,11 +721,8 @@ static int ps3_sas_end_device_try_add(struct ps3_instance *instance, ps3_sas_port->pd_flat_id = pd_entry->disk_pos.diskDev.ps3Dev.phyDiskID; ret = ps3_sas_port_create(instance, sas_node, ps3_sas_port); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u create end device rphy[%016llx] on parent[%d] NOK!\n", - PS3_HOST(instance), - ps3_phy->remote_identify.sas_address, - sas_node->encl_id); + LOG_ERROR("hno:%u create end device rphy[%016llx] on parent[%d] NOK!\n", + PS3_HOST(instance), ps3_phy->remote_identify.sas_address, sas_node->encl_id); goto l_failed; } pd_entry->sas_rphy = ps3_sas_port->rphy; @@ -812,20 +735,19 @@ static int ps3_sas_end_device_try_add(struct ps3_instance *instance, l_out: LOG_DEBUG("hno:%u add end device[%016llx] on node[%d] end\n", - PS3_HOST(instance), ps3_phy->remote_identify.sas_address, - sas_node->encl_id); + PS3_HOST(instance), ps3_phy->remote_identify.sas_address, + sas_node->encl_id); return ret; } -static int ps3_sas_node_all_phys_add(struct ps3_instance *instance, - struct ps3_sas_node *sas_node) +static S32 ps3_sas_node_all_phys_add(struct ps3_instance *instance, + struct ps3_sas_node *sas_node) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct PS3SasMgr sas_req_param; - struct PS3PhyInfo *phy_info = - instance->sas_dev_context.ps3_sas_phy_buff; - unsigned char i = 0; + struct PS3PhyInfo *phy_info = instance->sas_dev_context.ps3_sas_phy_buff; + U8 i = 0; memset(&sas_req_param, 0, sizeof(sas_req_param)); sas_req_param.enclID = sas_node->encl_id; @@ -835,32 +757,50 @@ static int ps3_sas_node_all_phys_add(struct ps3_instance *instance, memset(phy_info, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_phy_get(instance, &sas_req_param); + INJECT_START(PS3_ERR_IJ_SAS_PHY_GET_ERR1, &ret); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u get encl[%d] all phys info NOK\n", - PS3_HOST(instance), sas_req_param.enclID); + PS3_HOST(instance), sas_req_param.enclID); goto l_out; } for (i = 0; i < sas_node->phy_count; i++) { ret = ps3_sas_node_phy_add(instance, &sas_node->phys[i], - sas_node, &phy_info[i]); + sas_node, &phy_info[i]); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u add node[%d]-phys[%d] NOK !\n", - PS3_HOST(instance), sas_node->encl_id, i); + PS3_HOST(instance), sas_node->encl_id, i); goto l_out; } +#if 0 + 不能再此添加,需要通过scsi那边进行添加,否则无法定序,分配正确的channel + if ((phy_info[i].attachedSasAddr != PS3_SAS_INVALID_SAS_ADDR && + phy_info[i].attachDevType == SAS_END_DEVICE) && + phy_info[i].attachedSasAddr != + sas_node->parent_sas_address) { + ret = ps3_sas_end_device_try_add(instance, sas_node, + &sas_node->phys[i]); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u add end device[%016llx] on node[%d]-phys[%d] failed !\n", + PS3_HOST(instance), + phy_info[i].attachedSasAddr, + sas_node->encl_id, i); + goto l_out; + } + } +#endif } l_out: return ret; } -static int ps3_sas_hba_node_init(struct ps3_instance *instance, - struct PS3ExpanderInfo *exp_info, - unsigned long long *hba_sas_addr) +static S32 ps3_sas_hba_node_init(struct ps3_instance *instance, + struct PS3ExpanderInfo *exp_info, U64 *hba_sas_addr) { - int ret = PS3_SUCCESS; - unsigned char i = 0; - struct ps3_sas_node *hba_node = &instance->sas_dev_context.ps3_hba_sas; + S32 ret = PS3_SUCCESS; + U8 i = 0; + struct ps3_sas_node *hba_node = + &instance->sas_dev_context.ps3_hba_sas; LOG_DEBUG("hno:%u enter !\n", PS3_HOST(instance)); @@ -868,8 +808,8 @@ static int ps3_sas_hba_node_init(struct ps3_instance *instance, instance->sas_dev_context.ps3_hba_sas_addr[i] = le64_to_cpu(hba_sas_addr[i]); LOG_INFO("hno:%u hba SAS addr[%d] is [%016llx] !\n", - PS3_HOST(instance), i, - instance->sas_dev_context.ps3_hba_sas_addr[i]); + PS3_HOST(instance), i, + instance->sas_dev_context.ps3_hba_sas_addr[i]); } hba_node->encl_id = exp_info->enclID; @@ -877,23 +817,23 @@ static int ps3_sas_hba_node_init(struct ps3_instance *instance, hba_node->dev_type = exp_info->devType; LOG_INFO("hno:%u hba encl_id[%d], phy_count[%d], dev_type[%d] !\n", - PS3_HOST(instance), hba_node->encl_id, hba_node->phy_count, - hba_node->dev_type); + PS3_HOST(instance), hba_node->encl_id, hba_node->phy_count, + hba_node->dev_type); if (hba_node->phys == NULL) { - hba_node->phys = (struct ps3_sas_phy *)ps3_kcalloc( - instance, hba_node->phy_count, + hba_node->phys = (struct ps3_sas_phy*)ps3_kcalloc(instance, hba_node->phy_count, sizeof(struct ps3_sas_phy)); } if (hba_node->phys == NULL) { LOG_ERROR("hno:%u alloc hba phys buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ret = ps3_sas_node_all_phys_add(instance, hba_node); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u hba add phys NOK !\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u hba add phys NOK !\n", + PS3_HOST(instance)); goto l_out; } @@ -902,61 +842,55 @@ static int ps3_sas_hba_node_init(struct ps3_instance *instance, return ret; } -static struct ps3_sas_node * -ps3_sas_find_node_by_id(struct ps3_instance *instance, unsigned char encl_id) +static struct ps3_sas_node* ps3_sas_find_node_by_id(struct ps3_instance *instance, + U8 encl_id) { struct ps3_sas_node *ps3_sas_node = NULL; - unsigned long flags = 0; + ULong flags = 0; - if (instance->sas_dev_context.ps3_hba_sas.encl_id == encl_id) + if (instance->sas_dev_context.ps3_hba_sas.encl_id == encl_id) { return &instance->sas_dev_context.ps3_hba_sas; + } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(ps3_sas_node, - &instance->sas_dev_context.ps3_sas_node_list, - list) { + &instance->sas_dev_context.ps3_sas_node_list, list) { if (ps3_sas_node->encl_id == encl_id) { - spin_unlock_irqrestore( - &instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); return ps3_sas_node; } } - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); return NULL; } -static struct ps3_sas_port * -ps3_sas_expander_parent_attach(struct ps3_instance *instance, - struct ps3_sas_node *exp_node) +static struct ps3_sas_port* ps3_sas_expander_parent_attach(struct ps3_instance *instance, + struct ps3_sas_node *exp_node) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct ps3_sas_node *parent_node = NULL; struct ps3_sas_port *ps3_sas_port = NULL; - unsigned char i = 0; - unsigned long flags = 0; - unsigned char is_exist_port = PS3_TRUE; + U8 i = 0; + ULong flags = 0; + Bool is_exist_port = PS3_TRUE; struct ps3_sas_phy *sas_phy = NULL; struct ps3_sas_phy *sas_phy_next = NULL; - parent_node = - ps3_sas_find_node_by_id(instance, exp_node->parent_encl_id); + parent_node = ps3_sas_find_node_by_id(instance, + exp_node->parent_encl_id); if (parent_node == NULL) { LOG_ERROR("hno:%u cannot find parent node[%d] !\n", - PS3_HOST(instance), exp_node->parent_encl_id); + PS3_HOST(instance), exp_node->parent_encl_id); goto l_out; } - ps3_sas_port = - ps3_sas_port_find(instance, parent_node, exp_node->sas_address); + ps3_sas_port = ps3_sas_port_find(instance, parent_node, exp_node->sas_address); if (ps3_sas_port == NULL) { - ps3_sas_port = (struct ps3_sas_port *)ps3_kzalloc( - instance, sizeof(struct ps3_sas_port)); + ps3_sas_port = (struct ps3_sas_port*)ps3_kzalloc(instance, sizeof(struct ps3_sas_port)); + INJECT_START(PS3_ERR_IJ_SAS_PORT_ALLOC_NULL1, &ps3_sas_port); if (ps3_sas_port == NULL) { - LOG_ERROR( - "hno:%u alloc PS3 port on node[%d] failed !\n", + LOG_ERROR("hno:%u alloc PS3 port on node[%d] failed !\n", PS3_HOST(instance), parent_node->encl_id); goto l_out; } @@ -964,44 +898,39 @@ ps3_sas_expander_parent_attach(struct ps3_instance *instance, is_exist_port = PS3_FALSE; } - ps3_sanity_check_clean(instance, parent_node, exp_node->sas_address, - ps3_sas_port); + ps3_sanity_check_clean(instance, parent_node, exp_node->sas_address, ps3_sas_port); spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); for (i = 0; i < parent_node->phy_count; i++) { if ((parent_node->phys[i].remote_identify.sas_address == - exp_node->sas_address) && - (parent_node->phys[i].attach_port == NULL)) { + exp_node->sas_address) && + (parent_node->phys[i].attach_port == NULL)) { if (ps3_sas_port->phy_count == 0) { ps3_sas_port->remote_identify = parent_node->phys[i].remote_identify; } list_add_tail(&parent_node->phys[i].port_siblings, - &ps3_sas_port->phy_list); + &ps3_sas_port->phy_list); parent_node->phys[i].attach_port = ps3_sas_port; ps3_sas_port->phy_count++; if (is_exist_port && ps3_sas_port->port != NULL) { - sas_port_add_phy(ps3_sas_port->port, - parent_node->phys[i].phy); + sas_port_add_phy(ps3_sas_port->port, parent_node->phys[i].phy); } } } - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); if (!is_exist_port) { if (ps3_sas_port->phy_count == 0) { LOG_ERROR("hno:%u cannot find phy in parent[%d] !\n", - PS3_HOST(instance), parent_node->encl_id); + PS3_HOST(instance), parent_node->encl_id); goto l_failed; } ret = ps3_sas_port_create(instance, parent_node, ps3_sas_port); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u create rphy on parent[%d] for exp[%d] !\n", - PS3_HOST(instance), parent_node->encl_id, - exp_node->encl_id); + LOG_ERROR("hno:%u create rphy on parent[%d] for exp[%d] !\n", + PS3_HOST(instance), parent_node->encl_id, exp_node->encl_id); goto l_failed; } @@ -1012,7 +941,7 @@ ps3_sas_expander_parent_attach(struct ps3_instance *instance, l_failed: list_for_each_entry_safe(sas_phy, sas_phy_next, - &ps3_sas_port->phy_list, port_siblings) { + &ps3_sas_port->phy_list, port_siblings) { sas_phy->attach_port = NULL; list_del(&sas_phy->port_siblings); } @@ -1021,27 +950,27 @@ ps3_sas_expander_parent_attach(struct ps3_instance *instance, return NULL; } -static int ps3_sas_expander_node_add(struct ps3_instance *instance, - struct PS3ExpanderInfo *exp_info) +static S32 ps3_sas_expander_node_add(struct ps3_instance *instance, + struct PS3ExpanderInfo *exp_info) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_sas_node *exp_node = NULL; struct ps3_sas_port *ps3_sas_port = NULL; - unsigned char is_exist_expander = PS3_TRUE; - unsigned long flags = 0; - unsigned char old_parent_id = PS3_SAS_INVALID_ID; + Bool is_exist_expander = PS3_TRUE; + ULong flags = 0; + U8 old_parent_id = PS3_SAS_INVALID_ID; LOG_DEBUG("hno:%u enter !\n", PS3_HOST(instance)); - exp_node = ps3_sas_find_node_by_id(instance, exp_info->enclID); - if (exp_node != NULL && - unlikely(exp_node->parent_sas_address != exp_info->parentSasAddr || - exp_node->parent_encl_id != exp_info->parentId)) { - LOG_WARN( - "hno:%u SAS node encl_id[%d], change place\n" - "\tpar_sas_addr old[0x%016llx]-new[0x%016llx], par_encl_id old[%d]=new[%d]\n", + + if ((exp_node = ps3_sas_find_node_by_id(instance, exp_info->enclID)) != NULL && + unlikely(exp_node->parent_sas_address != exp_info->parentSasAddr || + exp_node->parent_encl_id != exp_info->parentId)) { + LOG_WARN("hno:%u SAS node encl_id[%d], change place, " + "parent sas_addr old[0x%016llx]-new[0x%016llx], parent_encl_id old[%d]=new[%d]\n", PS3_HOST(instance), exp_info->enclID, - exp_node->parent_sas_address, exp_info->parentSasAddr, - exp_node->parent_encl_id, exp_info->parentId); + exp_node->parent_sas_address, + exp_info->parentSasAddr, exp_node->parent_encl_id, + exp_info->parentId); old_parent_id = exp_node->parent_encl_id; ps3_sas_expander_node_del(instance, exp_node); ps3_sas_expander_event_update(instance, old_parent_id); @@ -1049,11 +978,11 @@ static int ps3_sas_expander_node_add(struct ps3_instance *instance, } if (exp_node == NULL) { - exp_node = (struct ps3_sas_node *)ps3_kzalloc( - instance, sizeof(struct ps3_sas_node)); + exp_node = (struct ps3_sas_node*)ps3_kzalloc(instance, sizeof(struct ps3_sas_node)); + INJECT_START(PS3_ERR_IJ_ALLOC_EXP_NODE_NULL, &exp_node); if (exp_node == NULL) { LOG_ERROR("hno:%u alloc node[%d] failed !\n", - PS3_HOST(instance), exp_info->enclID); + PS3_HOST(instance), exp_info->enclID); goto l_out; } @@ -1062,32 +991,31 @@ static int ps3_sas_expander_node_add(struct ps3_instance *instance, exp_node->phy_count = exp_info->phyCount; exp_node->dev_type = exp_info->devType; exp_node->parent_encl_id = exp_info->parentId; - exp_node->parent_sas_address = - le64_to_cpu(exp_info->parentSasAddr); + exp_node->parent_sas_address = le64_to_cpu(exp_info->parentSasAddr); - exp_node->phys = (struct ps3_sas_phy *)ps3_kcalloc( - instance, exp_node->phy_count, + exp_node->phys = (struct ps3_sas_phy*)ps3_kcalloc(instance, exp_node->phy_count, sizeof(struct ps3_sas_phy)); + INJECT_START(PS3_ERR_IJ_ALLOC_EXP_PHYS_NULL, &exp_node->phys); if (exp_node->phys == NULL) { LOG_ERROR("hno:%u alloc exp[%d] phys buffer failed !\n", - PS3_HOST(instance), exp_node->encl_id); + PS3_HOST(instance), exp_node->encl_id); goto l_failed; } INIT_LIST_HEAD(&exp_node->sas_port_list); is_exist_expander = PS3_FALSE; } - LOG_INFO("hno:%u ready add exp_node sas_address[0x%016llx]\n" - "\tencl_id[%d], phy_count[%d], parent_encl_id[%d]\n" - "\tparent_sas_address[0x%016llx] !\n", - PS3_HOST(instance), exp_node->sas_address, exp_node->encl_id, - exp_node->phy_count, exp_node->parent_encl_id, - exp_node->parent_sas_address); + LOG_INFO("hno:%u ready add exp_node sas_address[0x%016llx]," + " encl_id[%d], phy_count[%d], parent_encl_id[%d]," + " parent_sas_address[0x%016llx] !\n", + PS3_HOST(instance), exp_node->sas_address, exp_node->encl_id, + exp_node->phy_count, exp_node->parent_encl_id, + exp_node->parent_sas_address); ps3_sas_port = ps3_sas_expander_parent_attach(instance, exp_node); if (ps3_sas_port == NULL) { LOG_ERROR("hno:%u attch exp[%d] on parent NOK !\n", - PS3_HOST(instance), exp_node->encl_id); + PS3_HOST(instance), exp_node->encl_id); ret = -PS3_FAILED; goto l_failed; } @@ -1095,23 +1023,19 @@ static int ps3_sas_expander_node_add(struct ps3_instance *instance, ret = ps3_sas_node_all_phys_add(instance, exp_node); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u expander[%d] add phys NOK !\n", - PS3_HOST(instance), exp_node->encl_id); + PS3_HOST(instance), exp_node->encl_id); goto l_failed; } - spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, - flags); - list_add_tail(&exp_node->list, - &instance->sas_dev_context.ps3_sas_node_list); - spin_unlock_irqrestore( - &instance->sas_dev_context.ps3_sas_node_lock, flags); - LOG_WARN("hno:%u add exp_node sas_address[0x%016llx]\n" - "\tencl_id[%d], phy_count[%d], parent_encl_id[%d]\n" - "\tparent_sas_address[0x%016llx] end!\n", - PS3_HOST(instance), exp_node->sas_address, - exp_node->encl_id, exp_node->phy_count, - exp_node->parent_encl_id, - exp_node->parent_sas_address); + spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); + list_add_tail(&exp_node->list,&instance->sas_dev_context.ps3_sas_node_list); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + LOG_WARN("hno:%u add exp_node sas_address[0x%016llx]," + " encl_id[%d], phy_count[%d], parent_encl_id[%d]," + " parent_sas_address[0x%016llx] end!\n", + PS3_HOST(instance), exp_node->sas_address, exp_node->encl_id, + exp_node->phy_count, exp_node->parent_encl_id, + exp_node->parent_sas_address); } goto l_out; @@ -1136,20 +1060,19 @@ static int ps3_sas_expander_node_add(struct ps3_instance *instance, } static void ps3_sas_expander_del_list_build(struct ps3_instance *instance, - struct list_head *node_del_list) + struct list_head *node_del_list) { struct ps3_sas_node *exp_node = NULL; struct ps3_sas_node *child_exp_node = NULL; struct ps3_sas_port *ps3_sas_port = NULL; - unsigned long flags = 0; + ULong flags = 0; list_for_each_entry(exp_node, node_del_list, list) { - list_for_each_entry(ps3_sas_port, &exp_node->sas_port_list, - list) { + list_for_each_entry(ps3_sas_port, &exp_node->sas_port_list, list) { if ((ps3_sas_port->remote_identify.device_type != - SAS_EDGE_EXPANDER_DEVICE) && - (ps3_sas_port->remote_identify.device_type != - SAS_FANOUT_EXPANDER_DEVICE)) { + SAS_EDGE_EXPANDER_DEVICE) && + (ps3_sas_port->remote_identify.device_type != + SAS_FANOUT_EXPANDER_DEVICE)) { continue; } @@ -1157,28 +1080,26 @@ static void ps3_sas_expander_del_list_build(struct ps3_instance *instance, instance, ps3_sas_port->remote_identify.sas_address); if (child_exp_node != NULL) { - spin_lock_irqsave(&instance->sas_dev_context - .ps3_sas_node_lock, - flags); + spin_lock_irqsave(&instance->sas_dev_context. + ps3_sas_node_lock, flags); list_move_tail(&child_exp_node->list, - node_del_list); - spin_unlock_irqrestore( - &instance->sas_dev_context - .ps3_sas_node_lock, - flags); + node_del_list); + spin_unlock_irqrestore(&instance->sas_dev_context. + ps3_sas_node_lock, flags); } } } } static void ps3_sas_node_del(struct ps3_instance *instance, - struct ps3_sas_node *exp_node) + struct ps3_sas_node *exp_node) { struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_port *tmp_port = NULL; list_for_each_entry_safe(ps3_sas_port, tmp_port, - &exp_node->sas_port_list, list) { + &exp_node->sas_port_list, list) { + ps3_sas_port_del(instance, ps3_sas_port); ps3_sas_port = NULL; } @@ -1186,17 +1107,15 @@ static void ps3_sas_node_del(struct ps3_instance *instance, kfree(exp_node->phys); } -static int ps3_sas_node_port_del(struct ps3_instance *instance, - struct ps3_sas_node *parent_node, - unsigned long long sas_addr) +static S32 ps3_sas_node_port_del(struct ps3_instance *instance, + struct ps3_sas_node *parent_node, U64 sas_addr) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_sas_port *ps3_port = NULL; - ps3_port = ps3_sas_port_find(instance, parent_node, sas_addr); if (ps3_port == NULL) { LOG_ERROR("hno:%u cannot find port[%016llx] in node[%d] !\n", - PS3_HOST(instance), sas_addr, parent_node->encl_id); + PS3_HOST(instance), sas_addr, parent_node->encl_id); ret = -PS3_FAILED; goto l_out; } @@ -1208,27 +1127,24 @@ static int ps3_sas_node_port_del(struct ps3_instance *instance, } void ps3_sas_expander_node_del(struct ps3_instance *instance, - struct ps3_sas_node *exp_node) + struct ps3_sas_node *exp_node) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_sas_node *parent_node = NULL; struct ps3_sas_node *del_exp_node = NULL; struct ps3_sas_node *tmp_exp_node = NULL; - struct list_head node_del_list = { NULL, NULL }; - unsigned long long sas_address = exp_node->sas_address; - unsigned long flags = 0; + struct list_head node_del_list = {NULL, NULL}; + U64 sas_address = exp_node->sas_address; + ULong flags = 0; - LOG_INFO( - "hno:%u enter !, encl_id[%d], parent_id[%d], sas_addr[%016llx]\n", - PS3_HOST(instance), exp_node->encl_id, exp_node->parent_encl_id, - exp_node->sas_address); + LOG_INFO("hno:%u enter !, encl_id[%d], parent_id[%d], sas_addr[%016llx]\n", PS3_HOST(instance), + exp_node->encl_id, exp_node->parent_encl_id, exp_node->sas_address); - parent_node = - ps3_sas_find_node_by_id(instance, exp_node->parent_encl_id); + parent_node = ps3_sas_find_node_by_id(instance, + exp_node->parent_encl_id); if (parent_node == NULL) { LOG_ERROR("hno:%u cannot find parent node[%d] !\n", - - PS3_HOST(instance), exp_node->parent_encl_id); + PS3_HOST(instance), exp_node->parent_encl_id); BUG(); goto l_out; } @@ -1236,28 +1152,27 @@ void ps3_sas_expander_node_del(struct ps3_instance *instance, INIT_LIST_HEAD(&node_del_list); spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_move_tail(&exp_node->list, &node_del_list); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); ps3_sas_expander_del_list_build(instance, &node_del_list); list_for_each_entry_safe_reverse(del_exp_node, tmp_exp_node, - &node_del_list, list) { - LOG_DEBUG("hno:%u remove encl_id[%d], sas_addr[%016llx]\n", - PS3_HOST(instance), del_exp_node->encl_id, - del_exp_node->sas_address); + &node_del_list, list) { + LOG_DEBUG("hno:%u remove encl_id[%d], sas_addr[%016llx]\n", PS3_HOST(instance), + del_exp_node->encl_id, del_exp_node->sas_address); ps3_sas_node_del(instance, del_exp_node); list_del(&del_exp_node->list); kfree(del_exp_node); } - LOG_WARN("hno:%u remove sas_addr[%016llx] from parent[%d]\n", - PS3_HOST(instance), sas_address, parent_node->encl_id); + LOG_WARN("hno:%u remove sas_addr[%016llx] from parent[%d]\n", PS3_HOST(instance), + sas_address, parent_node->encl_id); - ret = ps3_sas_node_port_del(instance, parent_node, sas_address); + ret = ps3_sas_node_port_del(instance, parent_node, + sas_address); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u cannot delete expander[%016llx] from parent[%d] !\n", - PS3_HOST(instance), sas_address, parent_node->encl_id); + LOG_ERROR("hno:%u cannot delete expander[%016llx] from parent[%d] !\n", + PS3_HOST(instance), sas_address, + parent_node->encl_id); BUG(); goto l_out; } @@ -1265,67 +1180,72 @@ void ps3_sas_expander_node_del(struct ps3_instance *instance, LOG_DEBUG("hno:%u quit !\n", PS3_HOST(instance)); } -int ps3_sas_device_data_init(struct ps3_instance *instance) +S32 ps3_sas_device_data_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct PS3Expanders *p_expanders = (struct PS3Expanders *)instance->sas_dev_context.ps3_sas_buff; struct PS3ExpanderInfo *exp_info = p_expanders->expanders; - unsigned char i = 0; + U8 i = 0; - if (!ps3_sas_is_support_smp(instance)) + if (!ps3_sas_is_support_smp(instance)) { goto l_out; + } - LOG_DEBUG("hno:%u ready get init expander enter\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u ready get init expander enter\n", + PS3_HOST(instance)); memset(p_expanders, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_expander_all_get(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init get expander NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u init get expander NOK\n", + PS3_HOST(instance)); goto l_out; } - LOG_INFO("hno:%u get expander list count[%d]\n", PS3_HOST(instance), - p_expanders->count); + LOG_INFO("hno:%u get expander list count[%d]\n", + PS3_HOST(instance), p_expanders->count); + INJECT_START(PS3_ERR_HBA_PHY_COUNT_ZERO, &p_expanders->count); if (p_expanders->count == 0) { LOG_ERROR("hno:%u expander init info count = 0\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; - ; } - ret = ps3_sas_hba_node_init(instance, exp_info, - p_expanders->hbaSasAddr); + ret = ps3_sas_hba_node_init(instance, exp_info, p_expanders->hbaSasAddr); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init hba info NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u init hba info NOK\n", + PS3_HOST(instance)); goto l_out; } for (i = 1; i < p_expanders->count; i++) { - if (ps3_sas_expander_node_add(instance, &exp_info[i]) != - PS3_SUCCESS) { + if (ps3_sas_expander_node_add(instance, &exp_info[i]) != PS3_SUCCESS) { LOG_WARN("hno:%u init add expander[%d] info NOK\n", - PS3_HOST(instance), exp_info[i].enclID); + PS3_HOST(instance), exp_info[i].enclID); } } - LOG_DEBUG("hno:%u SAS init end\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u SAS init end\n", + PS3_HOST(instance)); l_out: - return ret; + return ret ; } -int ps3_sas_device_data_exit(struct ps3_instance *instance) +S32 ps3_sas_device_data_exit(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - if (!ps3_sas_is_support_smp(instance)) + if (!ps3_sas_is_support_smp(instance)) { goto l_out; + } - LOG_INFO("hno:%u %s\n", PS3_HOST(instance), __func__); + LOG_INFO("hno:%u ps3_sas_device_data_exit\n", + PS3_HOST(instance)); (void)instance; @@ -1333,16 +1253,17 @@ int ps3_sas_device_data_exit(struct ps3_instance *instance) return ret; } -static int ps3_sas_expander_dma_buf_alloc(struct ps3_instance *instance) +static S32 ps3_sas_expander_dma_buf_alloc(struct ps3_instance *instance) { struct ps3_sas_dev_context *ps3_sas_ctx = &instance->sas_dev_context; - ps3_sas_ctx->ps3_sas_buff = ps3_dma_alloc_coherent( - instance, PS3_SAS_REQ_BUFF_LEN, - (unsigned long long *)&ps3_sas_ctx->ps3_sas_buff_dma_addr); + ps3_sas_ctx->ps3_sas_buff = ps3_dma_alloc_coherent(instance, + PS3_SAS_REQ_BUFF_LEN, + &ps3_sas_ctx->ps3_sas_buff_dma_addr); + INJECT_START(PS3_ERR_IJ_PS3_SAS_BUF_ALLOC, &ps3_sas_ctx->ps3_sas_buff); if (ps3_sas_ctx->ps3_sas_buff == NULL) { LOG_ERROR("hno:%u alloc SAS req buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_fail; } return PS3_SUCCESS; @@ -1356,25 +1277,25 @@ static void ps3_sas_expander_dma_buf_free(struct ps3_instance *instance) if (ps3_sas_ctx->ps3_sas_buff != NULL) { ps3_dma_free_coherent(instance, PS3_SAS_REQ_BUFF_LEN, - ps3_sas_ctx->ps3_sas_buff, - ps3_sas_ctx->ps3_sas_buff_dma_addr); + ps3_sas_ctx->ps3_sas_buff, + ps3_sas_ctx->ps3_sas_buff_dma_addr); ps3_sas_ctx->ps3_sas_buff = NULL; } } -static int ps3_sas_phy_dma_buf_alloc(struct ps3_instance *instance) +static S32 ps3_sas_phy_dma_buf_alloc(struct ps3_instance *instance) { struct ps3_sas_dev_context *ps3_sas_ctx = &instance->sas_dev_context; ps3_sas_ctx->ps3_sas_phy_buff = - (struct PS3PhyInfo *)ps3_dma_alloc_coherent( - instance, PS3_SAS_REQ_BUFF_LEN, - (unsigned long long *)&ps3_sas_ctx - ->ps3_sas_phy_buff_dma_addr); + (struct PS3PhyInfo *)ps3_dma_alloc_coherent(instance, + PS3_SAS_REQ_BUFF_LEN, + &ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); + INJECT_START(PS3_ERR_IJ_PS3_SAS_PHY_BUF_ALLOC, &ps3_sas_ctx->ps3_sas_phy_buff); if (ps3_sas_ctx->ps3_sas_phy_buff == NULL) { LOG_ERROR("hno:%u alloc SAS req buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_fail; } return PS3_SUCCESS; @@ -1388,17 +1309,17 @@ static void ps3_sas_phy_dma_buf_free(struct ps3_instance *instance) if (ps3_sas_ctx->ps3_sas_phy_buff != NULL) { ps3_dma_free_coherent(instance, PS3_SAS_REQ_BUFF_LEN, - ps3_sas_ctx->ps3_sas_phy_buff, - ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); + ps3_sas_ctx->ps3_sas_phy_buff, + ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); ps3_sas_ctx->ps3_sas_phy_buff = NULL; } } -int ps3_sas_device_mgr_init(struct ps3_instance *instance) +S32 ps3_sas_device_mgr_init(struct ps3_instance *instance) { - int ret = -PS3_FAILED; - unsigned char i = 0; + S32 ret = -PS3_FAILED; + U8 i = 0; if (instance->ioc_adpter->sas_transport_get != NULL) { instance->sas_dev_context.is_support_smp = PS3_TRUE; @@ -1406,7 +1327,7 @@ int ps3_sas_device_mgr_init(struct ps3_instance *instance) instance->sas_dev_context.is_support_smp = PS3_FALSE; ret = PS3_SUCCESS; LOG_INFO("hno:%u the IOC is not support SAS expander !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -1415,14 +1336,14 @@ int ps3_sas_device_mgr_init(struct ps3_instance *instance) ret = ps3_sas_expander_dma_buf_alloc(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u alloc SAS expander dma buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ret = ps3_sas_phy_dma_buf_alloc(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u alloc SAS phy dma buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -1430,7 +1351,7 @@ int ps3_sas_device_mgr_init(struct ps3_instance *instance) spin_lock_init(&instance->sas_dev_context.ps3_sas_node_lock); memset(&instance->sas_dev_context.ps3_hba_sas, 0, - sizeof(struct ps3_sas_node)); + sizeof(struct ps3_sas_node)); for (i = 0; i < PS3_SAS_HBA_MAX_SAS_NUM; i++) { instance->sas_dev_context.ps3_hba_sas_addr[i] = @@ -1445,10 +1366,10 @@ int ps3_sas_device_mgr_init(struct ps3_instance *instance) instance->sas_dev_context.ps3_hba_sas.dev = &instance->host->shost_gendev; l_out: - return ret; + return ret ; } -int ps3_sas_device_mgr_exit(struct ps3_instance *instance) +S32 ps3_sas_device_mgr_exit(struct ps3_instance *instance) { if (ps3_sas_is_support_smp(instance)) { ps3_sas_phy_dma_buf_free(instance); @@ -1460,55 +1381,39 @@ int ps3_sas_device_mgr_exit(struct ps3_instance *instance) static void ps3_sas_end_dev_del(struct ps3_instance *instance, - struct ps3_sas_node *parent_node, - unsigned char phy_id) + struct ps3_sas_node* parent_node, U8 phy_id) { struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_port *ps3_sas_port_next = NULL; struct ps3_sas_phy *ps3_sas_phy = NULL; struct ps3_sas_phy *ps3_sas_phy_next = NULL; - unsigned char del_finish = PS3_FALSE; - unsigned long flags = 0; + Bool del_finish = PS3_FALSE; + ULong flags = 0; struct ps3_pd_entry *pd_entry = NULL; (void)instance; - list_for_each_entry_safe(ps3_sas_port, ps3_sas_port_next, - &parent_node->sas_port_list, list) { - list_for_each_entry_safe(ps3_sas_phy, ps3_sas_phy_next, - &ps3_sas_port->phy_list, - port_siblings) { + list_for_each_entry_safe(ps3_sas_port, ps3_sas_port_next, &parent_node->sas_port_list, list) { + list_for_each_entry_safe(ps3_sas_phy, ps3_sas_phy_next, &ps3_sas_port->phy_list, port_siblings) { if (likely(ps3_sas_phy->phy_id == phy_id)) { - spin_lock_irqsave(&instance->sas_dev_context - .ps3_sas_node_lock, - flags); + spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_del(&ps3_sas_phy->port_siblings); ps3_sas_phy->attach_port = NULL; - spin_unlock_irqrestore( - &instance->sas_dev_context - .ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); - sas_port_delete_phy(ps3_sas_port->port, - ps3_sas_phy->phy); + sas_port_delete_phy(ps3_sas_port->port, ps3_sas_phy->phy); ps3_sas_port->phy_count--; - LOG_DEBUG( - "hno:%u sas_port pdid[%u] phy_count[%u]\n" - "\tencl[%u] phy_id[%u] sas_addr[%016llx]\n" - "\tsas_remote_addr[%016llx] sas_phy delete\n", - PS3_HOST(instance), - ps3_sas_port->pd_flat_id, - ps3_sas_port->phy_count, - ps3_sas_phy->encl_id, - ps3_sas_phy->phy_id, + LOG_DEBUG("hno:%u sas_port pdid[%u] phy_count[%u] -> " + "encl[%u] phy_id[%u] sas_addr[%016llx] sas_remote_addr[%016llx] sas_phy delete\n", + PS3_HOST(instance), ps3_sas_port->pd_flat_id, ps3_sas_port->phy_count, + ps3_sas_phy->encl_id, ps3_sas_phy->phy_id, ps3_sas_phy->identify.sas_address, - ps3_sas_phy->remote_identify - .sas_address); + ps3_sas_phy->remote_identify.sas_address); memset(&ps3_sas_phy->remote_identify, 0, - sizeof(struct sas_identify)); + sizeof(struct sas_identify)); del_finish = PS3_TRUE; break; } @@ -1516,33 +1421,22 @@ static void ps3_sas_end_dev_del(struct ps3_instance *instance, if (del_finish == PS3_TRUE) { if (ps3_sas_port->phy_count == 0) { - spin_lock_irqsave(&instance->sas_dev_context - .ps3_sas_node_lock, - flags); + spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_del(&ps3_sas_port->list); - spin_unlock_irqrestore( - &instance->sas_dev_context - .ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); - LOG_INFO( - "hno:%u sas_port pdid[%u] phy_count[%u] delete start\n", - PS3_HOST(instance), - ps3_sas_port->pd_flat_id, - ps3_sas_port->phy_count); + LOG_INFO("hno:%u sas_port pdid[%u] phy_count[%u] delete start\n", + PS3_HOST(instance), ps3_sas_port->pd_flat_id, ps3_sas_port->phy_count); sas_port_delete(ps3_sas_port->port); - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( - instance, ps3_sas_port->pd_flat_id); - if (pd_entry != NULL) + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, ps3_sas_port->pd_flat_id); + if (pd_entry != NULL) { pd_entry->sas_rphy = NULL; + } - LOG_INFO( - "hno:%u sas_port pdid[%u] phy_count[%u] delete end\n", - PS3_HOST(instance), - ps3_sas_port->pd_flat_id, - ps3_sas_port->phy_count); + LOG_INFO("hno:%u sas_port pdid[%u] phy_count[%u] delete end\n", + PS3_HOST(instance), ps3_sas_port->pd_flat_id, ps3_sas_port->phy_count); kfree(ps3_sas_port); } @@ -1551,14 +1445,15 @@ static void ps3_sas_end_dev_del(struct ps3_instance *instance, } } -static unsigned char ps3_sas_addr_is_exist(struct PS3Expanders *p_expanders, - unsigned long long sas_addr) +static Bool ps3_sas_addr_is_exist( + struct PS3Expanders *p_expanders, U64 sas_addr) { - unsigned char ret = PS3_FALSE; - unsigned char i = 0; + Bool ret = PS3_FALSE; + U8 i = 0; - if (p_expanders == NULL) + if (p_expanders == NULL) { goto l_out; + } for (i = 1; i < p_expanders->count; i++) { if (p_expanders->expanders[i].sasAddr == sas_addr) { ret = PS3_TRUE; @@ -1570,269 +1465,262 @@ static unsigned char ps3_sas_addr_is_exist(struct PS3Expanders *p_expanders, } static void ps3_sas_expander_port_clean(struct ps3_instance *instance, - struct ps3_sas_node *sas_node, - struct PS3Expanders *p_expanders) + struct ps3_sas_node *sas_node, struct PS3Expanders *p_expanders) { struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_port *ps3_sas_port_next = NULL; struct ps3_sas_phy *ps3_sas_phy = NULL; struct ps3_sas_phy *ps3_sas_phy_next = NULL; struct ps3_sas_node *exp_node = NULL; - unsigned char is_exist = PS3_FALSE; - unsigned char diff_phy_num = 0; + Bool is_exist = PS3_FALSE; + U8 diff_phy_num = 0; list_for_each_entry_safe(ps3_sas_port, ps3_sas_port_next, - &sas_node->sas_port_list, list) { + &sas_node->sas_port_list, list) { if (ps3_sas_port->remote_identify.device_type != - SAS_EDGE_EXPANDER_DEVICE && - ps3_sas_port->remote_identify.device_type != - SAS_FANOUT_EXPANDER_DEVICE) { + SAS_EDGE_EXPANDER_DEVICE && + ps3_sas_port->remote_identify.device_type != + SAS_FANOUT_EXPANDER_DEVICE) { continue; } - is_exist = ps3_sas_addr_is_exist( - p_expanders, ps3_sas_port->remote_identify.sas_address); + is_exist = ps3_sas_addr_is_exist(p_expanders, ps3_sas_port->remote_identify.sas_address); diff_phy_num = ps3_sas_port->phy_count; list_for_each_entry_safe(ps3_sas_phy, ps3_sas_phy_next, - &ps3_sas_port->phy_list, - port_siblings) { + &ps3_sas_port->phy_list, port_siblings) { + if ((ps3_sas_phy->remote_identify.sas_address == - ps3_sas_port->remote_identify.sas_address) || - (ps3_sas_phy->remote_identify.sas_address == 0 && - is_exist)) { + ps3_sas_port->remote_identify.sas_address) || + (ps3_sas_phy->remote_identify.sas_address == 0 && is_exist)) { continue; } diff_phy_num--; - LOG_WARN("hno:%u phy[%d]'s remote addr[%016llx] != expander\n" - "\tport's rphy addr[0x%016llx]!\n", - PS3_HOST(instance), ps3_sas_phy->phy_id, - ps3_sas_phy->remote_identify.sas_address, - ps3_sas_port->remote_identify.sas_address); + LOG_WARN("hno:%u phy[%d]'s remote " + "addr[%016llx] != expander " + "port's rphy addr[0x%016llx]!\n", + PS3_HOST(instance), ps3_sas_phy->phy_id, + ps3_sas_phy->remote_identify.sas_address, + ps3_sas_port->remote_identify.sas_address); } - if (diff_phy_num != 0) + if (diff_phy_num != 0) { continue; + } - exp_node = ps3_sas_find_node_by_sas_addr( - instance, ps3_sas_port->remote_identify.sas_address); + exp_node = ps3_sas_find_node_by_sas_addr(instance, + ps3_sas_port->remote_identify.sas_address); if (exp_node == NULL) { - LOG_ERROR( - "hno:%u cannot find node sas_addr[%016llx] !\n", - PS3_HOST(instance), - ps3_sas_port->remote_identify.sas_address); + LOG_ERROR("hno:%u cannot find node sas_addr[%016llx] !\n", + PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); PS3_BUG(); } else { - LOG_INFO( - "hno:%u del expander in sas port clean. encl_id[%d], sas_addr[%016llx]\n", - PS3_HOST(instance), exp_node->encl_id, - exp_node->sas_address); + LOG_INFO("hno:%u del expander in sas port clean. encl_id[%d], sas_addr[%016llx]\n", + PS3_HOST(instance), exp_node->encl_id, exp_node->sas_address); ps3_sas_expander_node_del(instance, exp_node); } } } -int ps3_sas_expander_phys_refresh(struct ps3_instance *instance, - struct ps3_sas_node *sas_node) +S32 ps3_sas_expander_phys_refresh(struct ps3_instance *instance, + struct ps3_sas_node *sas_node) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct PS3SasMgr sas_req_param; - struct PS3PhyInfo *phy_info = - instance->sas_dev_context.ps3_sas_phy_buff; - unsigned char i = 0; - unsigned long flags = 0; + struct PS3PhyInfo *phy_info = instance->sas_dev_context.ps3_sas_phy_buff; + U8 i = 0; + ULong flags = 0; memset(&sas_req_param, 0, sizeof(sas_req_param)); sas_req_param.enclID = sas_node->encl_id; - sas_req_param.sasAddr = cpu_to_le64(sas_node->sas_address); + sas_req_param.sasAddr =cpu_to_le64(sas_node->sas_address); sas_req_param.startPhyID = 0; sas_req_param.phyCount = sas_node->phy_count; LOG_DEBUG("hno:%u ready get phys[%d] of encl_id[%d] !\n", - PS3_HOST(instance), sas_req_param.phyCount, - sas_req_param.enclID); + PS3_HOST(instance), sas_req_param.phyCount, sas_req_param.enclID); memset(phy_info, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_phy_get(instance, &sas_req_param); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init get expander NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u init get expander NOK\n", + PS3_HOST(instance)); goto l_out; } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); - LOG_INFO_IN_IRQ(instance, - "hno:%u ready update %d phys of encl_id[%d]!\n", - PS3_HOST(instance), sas_req_param.phyCount, - sas_req_param.enclID); + LOG_INFO_IN_IRQ(instance, "hno:%u ready update %d phys of encl_id[%d]!\n", + PS3_HOST(instance), sas_req_param.phyCount, sas_req_param.enclID); for (i = 0; i < sas_node->phy_count; i++) { - ps3_sas_node_phy_update(instance, &sas_node->phys[i], - &phy_info[i]); + ps3_sas_node_phy_update(instance, &sas_node->phys[i], &phy_info[i]); +#if 0 + 所有的添加都应该通过scsi来触发 + if (phy_info[i].attachedSasAddr != PS3_SAS_INVALID_SAS_ADDR && + phy_info[i].attachDevType == SAS_END_DEVICE) { + ret = ps3_sas_end_device_try_add(instance, sas_node, + &sas_node->phys[i]); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u add end device[%016llx] on node[%d]-phys[%d] failed !\n", + PS3_HOST(instance), + phy_info[i].attachedSasAddr, + sas_node->encl_id, i); + goto l_out; + } + } +#endif } - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); ps3_sas_port_phy_update(instance, sas_node); l_out: return ret; } -static int ps3_sas_device_date_refresh(struct ps3_instance *instance) +static S32 ps3_sas_device_date_refresh(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - struct PS3Expanders *p_expanders = - (struct PS3Expanders *)instance->sas_dev_context.ps3_sas_buff; + S32 ret = PS3_SUCCESS; + struct PS3Expanders *p_expanders = (struct PS3Expanders*)instance->sas_dev_context.ps3_sas_buff; struct PS3ExpanderInfo *exp_info = p_expanders->expanders; struct ps3_sas_node *exp_node = NULL; - unsigned char i = 0; + U8 i = 0; - LOG_DEBUG("hno:%u SAS dev refresh enter\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u SAS dev refresh enter\n", + PS3_HOST(instance)); memset(p_expanders, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_expander_all_get(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init get expander NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u init get expander NOK\n", + PS3_HOST(instance)); goto l_out; } LOG_DEBUG("hno:%u ready refresh expander count[%d]\n", - PS3_HOST(instance), p_expanders->count); + PS3_HOST(instance), p_expanders->count); if (p_expanders->count == 0) { LOG_ERROR("hno:%u expander init info count = 0\n", - PS3_HOST(instance)); + PS3_HOST(instance)); BUG(); } LOG_DEBUG("hno:%u ready refresh HBA\n", PS3_HOST(instance)); - ret = ps3_sas_expander_phys_refresh( - instance, &instance->sas_dev_context.ps3_hba_sas); + ret = ps3_sas_expander_phys_refresh(instance, + &instance->sas_dev_context.ps3_hba_sas); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u refresh phys on HBA NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - ps3_sas_expander_port_clean( - instance, &instance->sas_dev_context.ps3_hba_sas, p_expanders); + ps3_sas_expander_port_clean(instance, &instance->sas_dev_context.ps3_hba_sas, p_expanders); LOG_DEBUG("hno:%u end refresh HBA\n", PS3_HOST(instance)); for (i = 1; i < p_expanders->count; i++) { - exp_node = - ps3_sas_find_node_by_id(instance, exp_info[i].enclID); + exp_node = ps3_sas_find_node_by_id(instance, exp_info[i].enclID); if (exp_node != NULL) { - if (likely(exp_node->parent_sas_address == - exp_info[i].parentSasAddr && - exp_node->parent_encl_id == - exp_info[i].parentId)) { + if (likely(exp_node->parent_sas_address == exp_info[i].parentSasAddr && + exp_node->parent_encl_id == exp_info[i].parentId)) { LOG_DEBUG("hno:%u ready refresh expander[%d]\n", - PS3_HOST(instance), - exp_info[i].enclID); - ret = ps3_sas_expander_phys_refresh(instance, - exp_node); + PS3_HOST(instance), exp_info[i].enclID); + ret = ps3_sas_expander_phys_refresh(instance, exp_node); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u refresh phys on expander[%d] NOK!\n", - PS3_HOST(instance), - exp_info[i].enclID); + LOG_ERROR("hno:%u refresh phys on expander[%d] NOK!\n", + PS3_HOST(instance), exp_info[i].enclID); goto l_out; } - ps3_sas_expander_port_clean(instance, exp_node, - p_expanders); + ps3_sas_expander_port_clean(instance, exp_node, p_expanders); LOG_DEBUG("hno:%u end refresh expander[%d]\n", - PS3_HOST(instance), - exp_info[i].enclID); + PS3_HOST(instance), exp_info[i].enclID); } } - LOG_DEBUG("hno:%u ready add expander[%d]\n", PS3_HOST(instance), - exp_info[i].enclID); + LOG_DEBUG("hno:%u ready add expander[%d]\n", + PS3_HOST(instance), exp_info[i].enclID); ret = ps3_sas_expander_node_add(instance, &exp_info[i]); LOG_DEBUG("hno:%u end add expander[%d], ret[%d]\n", - PS3_HOST(instance), exp_info[i].enclID, ret); + PS3_HOST(instance), exp_info[i].enclID, ret); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u init add expander[%d] info NOK\n", - PS3_HOST(instance), exp_info[i].enclID); + PS3_HOST(instance), exp_info[i].enclID); goto l_out; } } - LOG_DEBUG("hno:%u SAS refresh end\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u SAS refresh end\n", + PS3_HOST(instance)); l_out: - return ret; + return ret ; } -static int ps3_sas_expander_event_update(struct ps3_instance *instance, - unsigned char encl_id) +static S32 ps3_sas_expander_event_update(struct ps3_instance *instance, U8 encl_id) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct ps3_sas_node *sas_node = NULL; LOG_DEBUG("hno:%u enter SAS expander update encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); sas_node = ps3_sas_find_node_by_id(instance, encl_id); if (sas_node == NULL) { LOG_ERROR("hno:%u cannot find PS3 node[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); goto l_out; } ret = ps3_sas_expander_phys_refresh(instance, sas_node); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u refresh phys on node[%d] NOK!\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); goto l_out; } l_out: LOG_DEBUG("hno:%u quit SAS expander update encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); return ret; } -static int ps3_sas_expander_phy_update(struct ps3_instance *instance, - unsigned char encl_id, - unsigned char phy_id) +static S32 ps3_sas_expander_phy_update(struct ps3_instance *instance, U8 encl_id, U8 phy_id) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct ps3_sas_node *sas_node = NULL; struct PS3SasMgr sas_req_param; - struct PS3PhyInfo *phy_info = - instance->sas_dev_context.ps3_sas_phy_buff; - unsigned long flags = 0; + struct PS3PhyInfo *phy_info = instance->sas_dev_context.ps3_sas_phy_buff; + ULong flags = 0; LOG_DEBUG("hno:%u enter SAS expander update encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); sas_node = ps3_sas_find_node_by_id(instance, encl_id); if (sas_node == NULL) { LOG_ERROR("hno:%u cannot find PS3 node[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); goto l_out; } memset(&sas_req_param, 0, sizeof(sas_req_param)); sas_req_param.enclID = sas_node->encl_id; - sas_req_param.sasAddr = cpu_to_le64(sas_node->sas_address); + sas_req_param.sasAddr =cpu_to_le64(sas_node->sas_address); sas_req_param.startPhyID = phy_id; sas_req_param.phyCount = 1; memset(phy_info, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_phy_get(instance, &sas_req_param); + INJECT_START(PS3_ERR_IJ_SAS_PHY_GET_ERR, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init get expander NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u init get expander NOK\n", + PS3_HOST(instance)); goto l_out; } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); ps3_sas_node_phy_update(instance, &sas_node->phys[phy_id], phy_info); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); l_out: LOG_DEBUG("hno:%u quit sas expander update encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); return ret; } -static int ps3_sas_expander_event_add(struct ps3_instance *instance, - unsigned char encl_id) +static S32 ps3_sas_expander_event_add(struct ps3_instance *instance, U8 encl_id) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct PS3ExpanderInfo *exp_info = (struct PS3ExpanderInfo *)instance->sas_dev_context.ps3_sas_buff; struct PS3SasMgr sas_req_param; @@ -1841,13 +1729,13 @@ static int ps3_sas_expander_event_add(struct ps3_instance *instance, sas_req_param.enclID = encl_id; LOG_WARN("hno:%u enter sas expander add encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); memset(exp_info, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_expander_get(instance, &sas_req_param); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u get expander[%d] NOK\n", PS3_HOST(instance), - encl_id); + LOG_ERROR("hno:%u get expander[%d] NOK\n", + PS3_HOST(instance), encl_id); goto l_out; } @@ -1856,9 +1744,10 @@ static int ps3_sas_expander_event_add(struct ps3_instance *instance, ret = -PS3_FAILED; goto l_out; } + INJECT_START(PS3_ERR_EXP_ID_ERR, &encl_id); if (exp_info->enclID != encl_id) { LOG_ERROR("hno:%u got expander[%d] is not [%d]\n", - PS3_HOST(instance), exp_info->enclID, encl_id); + PS3_HOST(instance), exp_info->enclID, encl_id); PS3_BUG(); ret = -PS3_FAILED; goto l_out; @@ -1867,36 +1756,35 @@ static int ps3_sas_expander_event_add(struct ps3_instance *instance, ret = ps3_sas_expander_event_update(instance, exp_info->parentId); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u update parent encl[%d] NOK\n", - PS3_HOST(instance), exp_info->parentId); + PS3_HOST(instance), exp_info->parentId); goto l_out; } ret = ps3_sas_expander_node_add(instance, exp_info); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u add expander[%d] NOK\n", PS3_HOST(instance), - encl_id); + LOG_ERROR("hno:%u add expander[%d] NOK\n", + PS3_HOST(instance), encl_id); goto l_out; } l_out: LOG_WARN("hno:%u quit sas expander add encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); return ret; } -static int ps3_sas_expander_event_del(struct ps3_instance *instance, - unsigned char encl_id) +static S32 ps3_sas_expander_event_del(struct ps3_instance *instance, U8 encl_id) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_sas_node *exp_node = NULL; - unsigned char parentId = 0; + U8 parentId = 0; LOG_WARN("hno:%u enter sas expander del encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); exp_node = ps3_sas_find_node_by_id(instance, encl_id); if (exp_node == NULL) { - LOG_ERROR("hno:%u cannot find node[%d] !\n", PS3_HOST(instance), - encl_id); + LOG_ERROR("hno:%u cannot find node[%d] !\n", + PS3_HOST(instance), encl_id); ret = -PS3_FAILED; goto l_out; } @@ -1907,23 +1795,23 @@ static int ps3_sas_expander_event_del(struct ps3_instance *instance, ret = ps3_sas_expander_event_update(instance, parentId); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u update parent encl[%d] NOK\n", - PS3_HOST(instance), parentId); + PS3_HOST(instance), parentId); goto l_out; } l_out: LOG_WARN("hno:%u quit sas expander del encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); return ret; } -int ps3_sas_expander_event_refresh(struct ps3_instance *instance) +S32 ps3_sas_expander_event_refresh(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - + S32 ret = PS3_SUCCESS; ret = ps3_sas_device_date_refresh(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u refresh all SAS NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u refresh all SAS NOK\n", + PS3_HOST(instance)); goto l_out; } @@ -1931,85 +1819,77 @@ int ps3_sas_expander_event_refresh(struct ps3_instance *instance) return ret; } -int ps3_sas_update_detail_proc(struct ps3_instance *instance, - struct PS3EventDetail *event_detail, - unsigned int event_cnt) +S32 ps3_sas_update_detail_proc(struct ps3_instance *instance, + struct PS3EventDetail *event_detail, U32 event_cnt) { - int ret = PS3_SUCCESS; - int ret_map = PS3_SUCCESS; - unsigned int i = 0; + S32 ret = PS3_SUCCESS; + S32 ret_map = PS3_SUCCESS; + U32 i = 0; - LOG_DEBUG("hno:%u, event detail count[%d]\n", PS3_HOST(instance), - event_cnt); + LOG_DEBUG("hno:%u, event detail count[%d]\n", + PS3_HOST(instance), event_cnt); for (i = 0; i < event_cnt; i++) { - LOG_INFO( - "hno:%u, event detail %d eventCode is [%s], encl_Id[%d]\n", - PS3_HOST(instance), i, - mgrEvtCodeTrans(event_detail[i].eventCode), + LOG_INFO("hno:%u, event detail %d eventCode is [%s], encl_Id[%d]\n", + PS3_HOST(instance), i, mgrEvtCodeTrans(event_detail[i].eventCode), event_detail[i].EnclId); switch (event_detail[i].eventCode) { case PS3_EVT_CODE(MGR_EVT_SAS_EXPANDER_CHANGE): case PS3_EVT_CODE(MGR_EVT_SAS_EXPANDER_IN): - ret = ps3_sas_expander_event_add( - instance, event_detail[i].EnclId); + ret = ps3_sas_expander_event_add(instance, + event_detail[i].EnclId); break; case PS3_EVT_CODE(MGR_EVT_SAS_EXPANDER_OUT): - ret = ps3_sas_expander_event_del( - instance, event_detail[i].EnclId); + ret = ps3_sas_expander_event_del(instance, + event_detail[i].EnclId); break; case PS3_EVT_CODE(MGR_EVT_SAS_EXPANDER_UPDATE): - ret = ps3_sas_expander_event_update( - instance, event_detail[i].EnclId); + ret = ps3_sas_expander_event_update(instance, + event_detail[i].EnclId); break; default: break; } - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { ret_map |= event_detail[i].eventType; + } } return ret_map; } -int ps3_sas_add_device(struct ps3_instance *instance, - struct ps3_pd_entry *pd_entry) +S32 ps3_sas_add_device(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry) { - int ret = -PS3_FAILED; - struct ps3_sas_node *parent_node = NULL; + S32 ret = -PS3_FAILED; + struct ps3_sas_node* parent_node = NULL; struct sas_identify *remote_id = NULL; - unsigned int softChan = PS3_CHANNEL(&pd_entry->disk_pos); - unsigned int devID = PS3_TARGET(&pd_entry->disk_pos); - unsigned int phyDiskID = PS3_PDID(&pd_entry->disk_pos); + U32 softChan = PS3_CHANNEL(&pd_entry->disk_pos); + U32 devID = PS3_TARGET(&pd_entry->disk_pos); + U32 phyDiskID = PS3_PDID(&pd_entry->disk_pos); - LOG_DEBUG( - "hno:%u enter %s pd[%u:%u:%u] on encl[%u], phy[%u]!\n", - PS3_HOST(instance), __func__, softChan, devID, phyDiskID, + LOG_DEBUG("hno:%u enter ps3_sas_add_device pd[%u:%u:%u] on encl[%u], phy[%u]!\n", + PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->encl_id, pd_entry->phy_id); parent_node = ps3_sas_find_node_by_id(instance, pd_entry->encl_id); if (parent_node == NULL) { - LOG_ERROR( - "hno:%u add end device channel[%u:%u:%u] cannot found node[%d] !\n", + LOG_ERROR("hno:%u add end device channel[%u:%u:%u] cannot found node[%d] !\n", PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->encl_id); goto l_out; } if (pd_entry->phy_id >= parent_node->phy_count) { - LOG_ERROR( - "hno:%u add end device channel[%u:%u:%u] phyid[%u] exceed node phy_count[%u] !\n", + LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] exceed node phy_count[%u] !\n", PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->phy_id, parent_node->phy_count); goto l_out; } - ret = ps3_sas_expander_phy_update(instance, pd_entry->encl_id, - pd_entry->phy_id); + ret = ps3_sas_expander_phy_update(instance, pd_entry->encl_id, pd_entry->phy_id); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u update phy in add pd channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", + LOG_ERROR("hno:%u update phy in add pd channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->phy_id, parent_node->encl_id); goto l_out; @@ -2017,12 +1897,11 @@ int ps3_sas_add_device(struct ps3_instance *instance, remote_id = &parent_node->phys[pd_entry->phy_id].remote_identify; if (remote_id->sas_address == PS3_SAS_INVALID_SAS_ADDR || - remote_id->device_type != SAS_END_DEVICE || - remote_id->sas_address == parent_node->parent_sas_address) { - LOG_ERROR( - "hno:%u add end device channel[%u:%u:%u] phyid[%u]\n" - "\tinvalid SAS addr[%016llx] or dev_type[%d] != SAS_END_DEVICE or\n" - "\tSAS addr = parent SAS addr[%016llx]!\n", + remote_id->device_type != SAS_END_DEVICE || + remote_id->sas_address == parent_node->parent_sas_address) { + LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] " + "invalid SAS addr[%016llx] or dev_type[%d] != SAS_END_DEVICE or " + " SAS addr = parent SAS addr[%016llx]!\n", PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->phy_id, remote_id->sas_address, remote_id->device_type, @@ -2031,11 +1910,9 @@ int ps3_sas_add_device(struct ps3_instance *instance, } ret = ps3_sas_end_device_try_add(instance, parent_node, - &parent_node->phys[pd_entry->phy_id], - pd_entry); + &parent_node->phys[pd_entry->phy_id], pd_entry); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u add end device channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", + LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->phy_id, parent_node->encl_id); goto l_out; @@ -2045,47 +1922,43 @@ int ps3_sas_add_device(struct ps3_instance *instance, return ret; } -int ps3_sas_remove_device(struct ps3_instance *instance, - struct PS3DiskDevPos *diskPos, unsigned char encl_id, - unsigned char phy_id) +S32 ps3_sas_remove_device(struct ps3_instance *instance, + struct PS3DiskDevPos *diskPos, U8 encl_id, U8 phy_id) { - int ret = -PS3_FAILED; - struct ps3_sas_node *parent_node = NULL; + S32 ret = -PS3_FAILED; + struct ps3_sas_node* parent_node = NULL; struct sas_identify *remote_id = NULL; - unsigned int softChan = PS3_CHANNEL(diskPos); - unsigned int devID = PS3_TARGET(diskPos); - unsigned int phyDiskID = PS3_PDID(diskPos); + U32 softChan = PS3_CHANNEL(diskPos); + U32 devID = PS3_TARGET(diskPos); + U32 phyDiskID = PS3_PDID(diskPos); - LOG_WARN( - "hno:%u enter %s pd[%u:%u:%u] on encl[%u], phy[%u]!\n", - PS3_HOST(instance), __func__, softChan, devID, phyDiskID, encl_id, - phy_id); + LOG_WARN("hno:%u enter ps3_sas_remove_device pd[%u:%u:%u] on encl[%u], phy[%u]!\n", + PS3_HOST(instance), softChan, + devID, phyDiskID, encl_id, phy_id); parent_node = ps3_sas_find_node_by_id(instance, encl_id); if (parent_node == NULL) { - LOG_ERROR( - "hno:%u add end device channel[%u:%u:%u] cannot found node[%u] !\n", + LOG_ERROR("hno:%u add end device channel[%u:%u:%u] cannot found node[%u] !\n", PS3_HOST(instance), softChan, devID, phyDiskID, encl_id); goto l_out; } if (phy_id >= parent_node->phy_count) { - LOG_ERROR( - "hno:%u add end device channel[%u:%u:%u] phyid[%u] exceed node phy_count[%u] !\n", - PS3_HOST(instance), softChan, devID, phyDiskID, phy_id, - parent_node->phy_count); + LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] exceed node phy_count[%u] !\n", + PS3_HOST(instance), softChan, devID, phyDiskID, + phy_id, parent_node->phy_count); goto l_out; } remote_id = &parent_node->phys[phy_id].remote_identify; if (remote_id->sas_address != PS3_SAS_INVALID_SAS_ADDR && - remote_id->sas_address == parent_node->parent_sas_address) { - LOG_ERROR( - "hno:%u add end device channel[%u:%u:%u] phyid[%u]\n" - "\tSAS addr[%016llx] dev_type[%d] parent SAS addr[%016llx]!\n", - PS3_HOST(instance), softChan, devID, phyDiskID, phy_id, - remote_id->sas_address, remote_id->device_type, + remote_id->sas_address == parent_node->parent_sas_address) { + LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] " + "SAS addr[%016llx] dev_type[%d] parent SAS addr[%016llx]!\n", + PS3_HOST(instance), softChan, devID, phyDiskID, + phy_id, remote_id->sas_address, + remote_id->device_type, parent_node->parent_sas_address); goto l_out; } @@ -2094,60 +1967,49 @@ int ps3_sas_remove_device(struct ps3_instance *instance, ret = ps3_sas_expander_phy_update(instance, encl_id, phy_id); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u update phy in add pd channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", - PS3_HOST(instance), softChan, devID, phyDiskID, phy_id, - encl_id); + LOG_ERROR("hno:%u update phy in add pd channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", + PS3_HOST(instance), softChan, devID, phyDiskID, phy_id, encl_id); goto l_out; } l_out: - LOG_WARN( - "hno:%u %s pd[%u:%u:%u] on encl[%u], phy[%u] end, ret[%d]!\n", - PS3_HOST(instance), __func__, softChan, devID, phyDiskID, encl_id, phy_id, - ret); + LOG_WARN("hno:%u ps3_sas_remove_device pd[%u:%u:%u] on encl[%u], phy[%u] end, ret[%d]!\n", + PS3_HOST(instance), softChan, devID, phyDiskID, + encl_id, phy_id, ret); return ret; } -#if defined(PS3_SAS_LONG_LUN) -int ps3_sas_user_scan(struct Scsi_Host *host, unsigned int channel, - unsigned int id, unsigned int lun) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) + S32 ps3_sas_user_scan(struct Scsi_Host *host, U32 channel, U32 id, U32 lun) #else -int ps3_sas_user_scan(struct Scsi_Host *host, unsigned int channel, - unsigned int id, unsigned long long lun) + S32 ps3_sas_user_scan(struct Scsi_Host *host, U32 channel, U32 id, U64 lun) #endif { struct PS3ChannelInfo *channel_info = NULL; struct ps3_instance *instance = NULL; struct ps3_pd_entry *pd_entry = NULL; - unsigned short max_dev_num = 0; - unsigned char i = 0; - unsigned short j = 0; + U16 max_dev_num = 0; + U8 i = 0; + U16 j = 0; - if ((lun != 0) && (lun != SCAN_WILD_CARD)) + if ((lun != 0) && (lun != SCAN_WILD_CARD)) { goto l_out; + } instance = (struct ps3_instance *)shost_priv(host); channel_info = &instance->ctrl_info.channelInfo; + INJECT_START(PS3_ERR_IJ_PD_ATTR, NULL); ps3_mutex_lock(&instance->dev_context.dev_scan_lock); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_PD_ATTR_WAIT_PD_ATTR, PS3_ERR_IJ_PD_ATTR, NULL); for (i = 0; i < channel_info->channelNum; i++) { - if ((channel_info->channels[i].channelType == - PS3_CHAN_TYPE_PD) && - (channel == SCAN_WILD_CARD || channel == i)) { + if ((channel_info->channels[i].channelType == PS3_CHAN_TYPE_PD) && + (channel == SCAN_WILD_CARD || channel == i)) { max_dev_num = channel_info->channels[i].maxDevNum; for (j = 0; j < max_dev_num; j++) { - pd_entry = ps3_dev_mgr_lookup_pd_info(instance, - i, j); - if ((pd_entry != NULL) && - (pd_entry->sas_rphy != NULL)) { + pd_entry = ps3_dev_mgr_lookup_pd_info(instance, i, j); + if ((pd_entry != NULL) && (pd_entry->sas_rphy != NULL)) { if (id == SCAN_WILD_CARD || id == j) { - scsi_scan_target( - &pd_entry->sas_rphy->dev, - i, j, 0, - SCSI_SCAN_MANUAL); - LOG_DEBUG( - "hno:%u channel:%u target:%u scan\n", - PS3_HOST(instance), i, - j); + scsi_scan_target(&pd_entry->sas_rphy->dev, i, j, 0, SCSI_SCAN_MANUAL); + LOG_DEBUG("hno:%u channel:%u target:%u scan\n", PS3_HOST(instance), i, j); } } } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.h b/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.h index 4a3d1241c569..ec8c222c5317 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.h @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ #ifndef _WINDOWS #ifndef _PS3_DEVICE_MANAGER_SAS_H_ @@ -13,14 +11,13 @@ #include "ps3_htp_dev.h" #include "ps3_htp_event.h" #include "ps3_device_manager.h" -#include "ps3_kernel_version.h" -#define PS3_SAS_HBA_MAX_SAS_NUM 3 +#define PS3_SAS_HBA_MAX_SAS_NUM 3 -#define PS3_SAS_MAX_PHY_NUM (128) -#define PS3_SAS_INVALID_ID (0xFF) -#define PS3_SAS_INVALID_SAS_ADDR (0x0) -#define PS3_SAS_REQ_BUFF_LEN (4096) +#define PS3_SAS_MAX_PHY_NUM (128) +#define PS3_SAS_INVALID_ID (0xFF) +#define PS3_SAS_INVALID_SAS_ADDR (0x0) +#define PS3_SAS_REQ_BUFF_LEN (4096) struct ps3_instance; @@ -29,13 +26,13 @@ struct ps3_sas_node { struct device *dev; struct ps3_sas_phy *phys; struct list_head sas_port_list; - unsigned long long sas_address; - unsigned long long parent_sas_address; - unsigned char phy_count; - unsigned char encl_id; - unsigned char parent_encl_id; - unsigned char dev_type; - unsigned char reserved[4]; + U64 sas_address; + U64 parent_sas_address; + U8 phy_count; + U8 encl_id; + U8 parent_encl_id; + U8 dev_type; + U8 reserved[4]; }; struct ps3_sas_phy { @@ -44,10 +41,10 @@ struct ps3_sas_phy { struct sas_identify remote_identify; struct sas_phy *phy; struct ps3_sas_port *attach_port; - unsigned char phy_id; - unsigned char encl_id; - unsigned char slot_id; - unsigned char reserved[5]; + U8 phy_id; + U8 encl_id; + U8 slot_id; + U8 reserved[5]; }; struct ps3_sas_port { @@ -56,76 +53,66 @@ struct ps3_sas_port { struct sas_rphy *rphy; struct sas_port *port; struct list_head phy_list; - unsigned short pd_flat_id; - unsigned char phy_count; - unsigned char reserved[5]; + U16 pd_flat_id; + U8 phy_count; + U8 reserved[5]; }; struct ps3_sas_dev_context { - struct list_head ps3_sas_node_list; - spinlock_t ps3_sas_node_lock; - struct ps3_sas_node ps3_hba_sas; - unsigned long long ps3_hba_sas_addr[PS3_SAS_HBA_MAX_SAS_NUM]; - struct semaphore ps3_sas_smp_semaphore; - - dma_addr_t ps3_sas_buff_dma_addr; - dma_addr_t ps3_sas_phy_buff_dma_addr; - void *ps3_sas_buff; - struct PS3PhyInfo *ps3_sas_phy_buff; - unsigned char is_support_smp; - unsigned char reserved[7]; + struct list_head ps3_sas_node_list; + spinlock_t ps3_sas_node_lock; + struct ps3_sas_node ps3_hba_sas; + U64 ps3_hba_sas_addr[PS3_SAS_HBA_MAX_SAS_NUM]; + struct semaphore ps3_sas_smp_semaphore; + + dma_addr_t ps3_sas_buff_dma_addr; + dma_addr_t ps3_sas_phy_buff_dma_addr; + void *ps3_sas_buff; + struct PS3PhyInfo *ps3_sas_phy_buff; + Bool is_support_smp; + U8 reserved[7]; }; -unsigned char ps3_sas_is_support_smp(struct ps3_instance *instance); +Bool ps3_sas_is_support_smp(struct ps3_instance *instance); -int ps3_sas_device_mgr_init(struct ps3_instance *instance); +S32 ps3_sas_device_mgr_init(struct ps3_instance *instance); -int ps3_sas_device_mgr_exit(struct ps3_instance *instance); +S32 ps3_sas_device_mgr_exit(struct ps3_instance *instance); -int ps3_sas_device_data_init(struct ps3_instance *instance); +S32 ps3_sas_device_data_init(struct ps3_instance *instance); -int ps3_sas_device_data_exit(struct ps3_instance *instance); +S32 ps3_sas_device_data_exit(struct ps3_instance *instance); -int ps3_sas_rphy_slot_get(struct ps3_instance *instance, - unsigned long long sas_addr, unsigned int *slot_id); +S32 ps3_sas_rphy_slot_get(struct ps3_instance *instance, U64 sas_addr, U32 *slot_id); -unsigned long long -ps3_sas_rphy_parent_sas_addr_get(struct ps3_instance *instance, - unsigned long long sas_addr); +U64 ps3_sas_rphy_parent_sas_addr_get(struct ps3_instance *instance, U64 sas_addr); -unsigned char ps3_sas_encl_id_get(struct ps3_instance *instance, - unsigned long long sas_addr); +U8 ps3_sas_encl_id_get(struct ps3_instance *instance, U64 sas_addr); -int ps3_sas_expander_event_refresh(struct ps3_instance *instance); +S32 ps3_sas_expander_event_refresh(struct ps3_instance *instance); -int ps3_sas_update_detail_proc(struct ps3_instance *instance, - struct PS3EventDetail *event_detail, - unsigned int event_cnt); +S32 ps3_sas_update_detail_proc(struct ps3_instance *instance, + struct PS3EventDetail *event_detail, U32 event_cnt); -int ps3_sas_add_device(struct ps3_instance *instance, - struct ps3_pd_entry *pd_entry); +S32 ps3_sas_add_device(struct ps3_instance *instance, + struct ps3_pd_entry *pd_entry); -int ps3_sas_remove_device(struct ps3_instance *instance, - struct PS3DiskDevPos *diskPos, unsigned char encl_id, - unsigned char phy_id); +S32 ps3_sas_remove_device(struct ps3_instance *instance, + struct PS3DiskDevPos *diskPos, U8 encl_id, U8 phy_id); void ps3_sas_expander_node_del(struct ps3_instance *instance, - struct ps3_sas_node *exp_node); + struct ps3_sas_node *exp_node); -struct ps3_sas_node * -ps3_sas_find_node_by_sas_addr(struct ps3_instance *instance, - unsigned long long sas_addr); +struct ps3_sas_node* ps3_sas_find_node_by_sas_addr( + struct ps3_instance *instance, U64 sas_addr); -void ps3_sas_node_phy_update(struct ps3_instance *instance, - struct ps3_sas_phy *ps3_phy, - struct PS3PhyInfo *phy_info); +void ps3_sas_node_phy_update(struct ps3_instance *instance, struct ps3_sas_phy *ps3_phy, + struct PS3PhyInfo *phy_info); -#if defined(PS3_SAS_LONG_LUN) -int ps3_sas_user_scan(struct Scsi_Host *host, unsigned int channel, - unsigned int id, unsigned int lun); +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) + S32 ps3_sas_user_scan(struct Scsi_Host *host, U32 channel, U32 id, U32 lun); #else -int ps3_sas_user_scan(struct Scsi_Host *host, unsigned int channel, - unsigned int id, unsigned long long lun); + S32 ps3_sas_user_scan(struct Scsi_Host *host, U32 channel, U32 id, U64 lun); #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_update.c b/drivers/scsi/linkdata/ps3stor/ps3_device_update.c index 738deb0e416b..51406e902ecb 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_update.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_update.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include "ps3_device_update.h" @@ -25,7 +23,7 @@ #endif #include "ps3_event.h" -#include "ps3_htp_meta.h" +#include "ps3_meta.h" #include "ps3_htp_event.h" #include "ps3_mgr_cmd.h" #include "ps3_ioc_manager.h" @@ -35,25 +33,23 @@ #include "ps3_scsi_cmd_err.h" #include "ps3_r1x_write_lock.h" #include "ps3_ioc_state.h" -#include "ps3_kernel_version.h" -static int ps3_pd_del(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos, unsigned char config_flag); +static S32 ps3_pd_del(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos, U8 config_flag); -static int ps3_pd_add(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos); +static S32 ps3_pd_add(struct ps3_instance *instance, + struct PS3DiskDevPos* dev_pos); -unsigned int ps3_scsi_dev_magic(struct ps3_instance *instance, - struct scsi_device *sdev) +U32 ps3_scsi_dev_magic(struct ps3_instance *instance, struct scsi_device *sdev) { - unsigned int dev_magic_num = 0; + U32 dev_magic_num = 0; struct ps3_scsi_priv_data *p_priv_data = NULL; ps3_mutex_lock(&instance->dev_context.dev_priv_lock); p_priv_data = PS3_SDEV_PRI_DATA(sdev); if (p_priv_data != NULL) { if (PS3_IS_VD_CHANNEL(instance, PS3_SDEV_CHANNEL(sdev)) || - ps3_sas_is_support_smp(instance)) { + ps3_sas_is_support_smp(instance)) { dev_magic_num = p_priv_data->disk_pos.diskMagicNum; } else { dev_magic_num = p_priv_data->disk_pos.checkSum; @@ -64,163 +60,146 @@ unsigned int ps3_scsi_dev_magic(struct ps3_instance *instance, return dev_magic_num; } -unsigned char ps3_pd_scsi_visible_check(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, - unsigned char dev_type, - unsigned char config_flag, - unsigned char pd_state) +Bool ps3_pd_scsi_visible_check(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, U8 dev_type, U8 config_flag, + U8 pd_state) { - unsigned char visible = PS3_DRV_TRUE; + Bool visible = PS3_DRV_TRUE; if (pd_state == DEVICE_STATE_OUTING) { - LOG_INFO( - "hno:%u PD[%u:%u:%u], dev_type[%s] state[%s] is outing\n", + LOG_INFO("hno:%u PD[%u:%u:%u], dev_type[%s] state[%s] is outing\n", PS3_HOST(instance), PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_PDID(disk_pos), namePS3DevType((enum PS3DevType)dev_type), - getDeviceStateName((enum DeviceState)pd_state)); + getDeviceStateName((DeviceState_e)pd_state)); visible = PS3_DRV_FALSE; goto l_out; } if (ps3_is_fake_pd(dev_type)) { - LOG_DEBUG( - "hno:%u PD[%u:%u:%u], dev_type[%s] device is visible all time\n", + LOG_DEBUG("hno:%u PD[%u:%u:%u], dev_type[%s] device is visible all time\n", PS3_HOST(instance), PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_PDID(disk_pos), namePS3DevType((enum PS3DevType)dev_type)); goto l_out; } -#if defined(PS3_SUPPORT_LINX80) - if (!instance->is_support_jbod && - ps3_check_pd_is_vd_member(config_flag)) { - LOG_DEBUG( - "hno:%u PD[%u:%u:%u] is vd component, config_flag[%s]\n", - PS3_HOST(instance), PS3_CHANNEL(disk_pos), - PS3_TARGET(disk_pos), PS3_PDID(disk_pos), - getPdStateName((enum MicPdState)config_flag, - instance->is_raid)); - visible = PS3_DRV_FALSE; - goto l_out; - } +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) + if (!instance->is_support_jbod && + ps3_check_pd_is_vd_member(config_flag)) { + LOG_DEBUG("hno:%u PD[%u:%u:%u] is vd component, config_flag[%s]\n", + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_PDID(disk_pos), + getPdStateName((MicPdState_e)config_flag, instance->is_raid)); + visible = PS3_DRV_FALSE; + goto l_out; + } #endif - if (instance->is_support_jbod && config_flag != MIC_PD_STATE_JBOD) { - LOG_DEBUG( - "hno:%u PD[%u:%u:%u] config_flag is [%s], invisible\n", + if (instance->is_support_jbod && config_flag != + MIC_PD_STATE_JBOD) { + LOG_DEBUG("hno:%u PD[%u:%u:%u] config_flag is [%s], invisible \n", PS3_HOST(instance), PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_PDID(disk_pos), - getPdStateName((enum MicPdState)config_flag, - instance->is_raid)); + getPdStateName((MicPdState_e)config_flag, instance->is_raid)); visible = PS3_DRV_FALSE; goto l_out; } l_out: - LOG_DEBUG("hno:%u PD[%u:%u:%u] is %s\n", PS3_HOST(instance), - PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), - PS3_PDID(disk_pos), visible ? "visible" : "invisible"); + LOG_DEBUG("hno:%u PD[%u:%u:%u] is %s\n", + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_PDID(disk_pos), + visible ? "visible" : "invisible"); return visible; } -static inline unsigned char -ps3_vd_scsi_visible_check(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, - unsigned char is_hidden, unsigned char disk_state) +static inline Bool ps3_vd_scsi_visible_check(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, Bool is_hidden, U8 disk_state) { - unsigned char visible = PS3_DRV_TRUE; + Bool visible = PS3_DRV_TRUE; if (is_hidden) { - LOG_INFO("hno:%u vd[%u:%u:%u] is hidden\n", PS3_HOST(instance), - PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), - PS3_VDID(disk_pos)); + LOG_INFO("hno:%u vd[%u:%u:%u] is hidden\n", + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_VDID(disk_pos)); visible = PS3_DRV_FALSE; } if (disk_state == MIC_VD_STATE_OFFLINE) { LOG_INFO("hno:%u vd[%u:%u:%u] state offline\n", - PS3_HOST(instance), PS3_CHANNEL(disk_pos), - PS3_TARGET(disk_pos), PS3_VDID(disk_pos)); + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_VDID(disk_pos)); visible = PS3_DRV_FALSE; } return visible; } -static unsigned char ps3_scsi_visible_check(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id, - unsigned char disk_type) +static Bool ps3_scsi_visible_check(struct ps3_instance *instance, + U8 channel, U16 target_id, U8 disk_type) { struct PS3VDEntry *p_vd_entry = NULL; struct ps3_pd_entry *p_pd_entry = NULL; - unsigned char visible = PS3_DRV_FALSE; + Bool visible = PS3_DRV_FALSE; if (disk_type == PS3_DISK_TYPE_PD) { - p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, - target_id); + p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, target_id); if (p_pd_entry) { - visible = ps3_pd_scsi_visible_check( - instance, &p_pd_entry->disk_pos, - p_pd_entry->dev_type, p_pd_entry->config_flag, - p_pd_entry->state); + visible = ps3_pd_scsi_visible_check(instance, + &p_pd_entry->disk_pos, p_pd_entry->dev_type, + p_pd_entry->config_flag, p_pd_entry->state); } - } else if (disk_type == PS3_DISK_TYPE_VD) { - p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, - target_id); + } else if (disk_type == PS3_DISK_TYPE_VD){ + p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, target_id); if (p_vd_entry) { - visible = ps3_vd_scsi_visible_check( - instance, &p_vd_entry->diskPos, - p_vd_entry->isHidden, p_vd_entry->diskState); + visible = ps3_vd_scsi_visible_check(instance, + &p_vd_entry->diskPos, p_vd_entry->isHidden, p_vd_entry->diskState); } } if (p_pd_entry || p_vd_entry) { LOG_INFO("hno:%u dev[%u:%u] visible is %s\n", - PS3_HOST(instance), channel, target_id, - visible ? "PS3_TRUE" : "PS3_FALSE"); + PS3_HOST(instance), channel, target_id, + visible ? "PS3_TRUE" : "PS3_FALSE"); } return visible; } static inline void __ps3_scsi_add_device(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, - unsigned char dev_type) + struct PS3DiskDevPos *disk_pos, U8 dev_type) { - int ret = PS3_SUCCESS; - unsigned char channel = PS3_CHANNEL(disk_pos); - unsigned short id = PS3_TARGET(disk_pos); + S32 ret = PS3_SUCCESS; + U8 channel = PS3_CHANNEL(disk_pos); + U16 id = PS3_TARGET(disk_pos); ret = ps3_scsi_add_device_ack(instance, disk_pos, dev_type); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL2, &ret); if (ret != PS3_SUCCESS) { - LOG_WARN( - "hno:%u dev[%u:%u] magic[%#x] add scsi device ack NOK, ret %d\n", - PS3_HOST(instance), channel, id, disk_pos->diskMagicNum, - ret); + LOG_WARN("hno:%u dev[%u:%u] magic[%#x] add scsi device ack NOK, ret %d\n", + PS3_HOST(instance), channel, id, + disk_pos->diskMagicNum, ret); } else { LOG_INFO("hno:%u dev_type[%d] id[%u:%u] add device begin\n", - PS3_HOST(instance), dev_type, channel, id); + PS3_HOST(instance), dev_type, channel, id); ret = ps3_scsi_add_device(instance, channel, id, 0); LOG_INFO("hno:%u dev_type[%d] id[%u:%u] add end, add ret %d\n", - PS3_HOST(instance), dev_type, channel, id, ret); + PS3_HOST(instance), dev_type, channel, id, ret); } } static void _ps3_scsi_add_device(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, - unsigned char dev_type) + struct PS3DiskDevPos *disk_pos, U8 dev_type) { struct scsi_device *sdev = NULL; - unsigned char channel = PS3_CHANNEL(disk_pos); - unsigned short target_id = PS3_TARGET(disk_pos); - unsigned short disk_id = PS3_VDID(disk_pos); + U8 channel = PS3_CHANNEL(disk_pos); + U16 target_id = PS3_TARGET(disk_pos); + U16 disk_id = PS3_VDID(disk_pos); - LOG_DEBUG( - "hno:%u dev_type[%s] id[%u:%u] disk_id[%d] add scsi device start\n", + LOG_DEBUG("hno:%u dev_type[%s] id[%u:%u] disk_id[%d] add scsi device start\n", PS3_HOST(instance), namePS3DiskType((enum PS3DiskType)dev_type), channel, target_id, disk_id); @@ -229,37 +208,35 @@ static void _ps3_scsi_add_device(struct ps3_instance *instance, __ps3_scsi_add_device(instance, disk_pos, dev_type); } else { ps3_scsi_device_put(instance, sdev); - LOG_INFO( - "hno:%u channel[%u] target[%u] device already exists in os\n", + LOG_INFO("hno:%u channel[%u] target[%u] device already exists in os\n", PS3_HOST(instance), channel, target_id); } - LOG_DEBUG( - "hno:%u dev_type[%s] id[%u:%u] disk_id[%d] add scsi device end\n", + LOG_DEBUG("hno:%u dev_type[%s] id[%u:%u] disk_id[%d] add scsi device end\n", PS3_HOST(instance), namePS3DiskType((enum PS3DiskType)dev_type), channel, target_id, disk_id); } -static int _ps3_add_disk(struct ps3_instance *instance, unsigned char channel, - unsigned short target_id, unsigned char disk_type) +static S32 _ps3_add_disk(struct ps3_instance *instance, + U8 channel, U16 target_id, U8 disk_type) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_pd_entry *p_pd_entry = NULL; struct PS3VDEntry *p_vd_entry = NULL; struct PS3DiskDevPos *p_diskPos = NULL; - unsigned char dev_type = PS3_DISK_TYPE_UNKNOWN; + U8 dev_type = PS3_DISK_TYPE_UNKNOWN; - if (!ps3_scsi_visible_check(instance, channel, target_id, disk_type)) + if (!ps3_scsi_visible_check(instance, channel, target_id, disk_type)) { goto l_out; + } if (disk_type == PS3_DISK_TYPE_PD) { - p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, - target_id); + p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, target_id); if (p_pd_entry) { #ifndef _WINDOWS if (ps3_sas_is_support_smp(instance) && - p_pd_entry->dev_type != PS3_DEV_TYPE_NVME_SSD && - p_pd_entry->dev_type != PS3_DEV_TYPE_VEP) { + p_pd_entry->dev_type != PS3_DEV_TYPE_NVME_SSD && + p_pd_entry->dev_type != PS3_DEV_TYPE_VEP) { ps3_sas_add_device(instance, p_pd_entry); goto l_out; } else { @@ -270,9 +247,8 @@ static int _ps3_add_disk(struct ps3_instance *instance, unsigned char channel, } #endif } - } else if (disk_type == PS3_DISK_TYPE_VD) { - p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, - target_id); + } else if (disk_type == PS3_DISK_TYPE_VD){ + p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, target_id); if (p_vd_entry) { p_diskPos = &p_vd_entry->diskPos; dev_type = PS3_DISK_TYPE_VD; @@ -284,57 +260,55 @@ static int _ps3_add_disk(struct ps3_instance *instance, unsigned char channel, return ret; } #ifndef _WINDOWS -static unsigned char ps3_sd_available_check(struct scsi_device *sdev) -{ - unsigned char ret = PS3_TRUE; - if (dev_get_drvdata(&sdev->sdev_gendev) == NULL) +static Bool ps3_sd_available_check(struct scsi_device *sdev) +{ + Bool ret = PS3_TRUE; + if (dev_get_drvdata(&sdev->sdev_gendev) == NULL) { ret = PS3_FALSE; + } return ret; } void ps3_scsi_scan_host(struct ps3_instance *instance) { struct PS3ChannelInfo *channel_info = &instance->ctrl_info.channelInfo; - unsigned short timeout = instance->ctrl_info.isotoneTimeOut; - unsigned char channelType = 0; - unsigned short maxDevNum = 0; - unsigned char i = 0; - unsigned short j = 0; + U16 timeout = instance->ctrl_info.isotoneTimeOut; + U8 channelType = 0; + U16 maxDevNum = 0; + U8 i = 0; + U16 j = 0; struct scsi_device *sdev = NULL; - unsigned char bootdrv_ok = PS3_FALSE; - unsigned short count = 0; + Bool bootdrv_ok = PS3_FALSE; + U16 count = 0; LOG_WARN("hno:%u scan device begin, channel number %d\n", - PS3_HOST(instance), channel_info->channelNum); + PS3_HOST(instance), channel_info->channelNum); + INJECT_START(PS3_ERR_IJ_ADD_DISK_HOST_RESET, instance) for (i = 0; i < channel_info->channelNum; i++) { channelType = channel_info->channels[i].channelType; maxDevNum = channel_info->channels[i].maxDevNum; LOG_INFO("hno:%u channel[%u] is type %s,max dev num is:%d\n", - PS3_HOST(instance), i, - namePS3ChannelType((enum PS3ChannelType)channelType), - maxDevNum); + PS3_HOST(instance), i, + namePS3ChannelType((enum PS3ChannelType)channelType), + maxDevNum); for (j = 0; j < maxDevNum; j++) { _ps3_add_disk(instance, i, j, channelType); if (timeout != 0 && !bootdrv_ok && i == 0 && - ps3_scsi_visible_check(instance, i, j, - channelType)) { + ps3_scsi_visible_check(instance, i, j, channelType)) { for (count = 0; count < timeout; count++) { - sdev = ps3_scsi_device_lookup(instance, - i, j, 0); - if (sdev == NULL) + sdev = ps3_scsi_device_lookup(instance, i, j, 0); + if (sdev == NULL) { continue; + } if (!ps3_sd_available_check(sdev)) { - ps3_scsi_device_put(instance, - sdev); - ps3_msleep( - PS3_PS3_LOOP_TIME_INTERVAL_1000MS); + ps3_scsi_device_put(instance, sdev); + ps3_msleep(PS3_PS3_LOOP_TIME_INTERVAL_1000MS); continue; } ps3_scsi_device_put(instance, sdev); - LOG_WARN( - "hno:%u bootdrive disk[%u:%u] drive-letter add complete\n", + LOG_WARN("hno:%u bootdrive disk[%u:%u] drive-letter add complete\n", PS3_HOST(instance), i, j); break; } @@ -344,21 +318,21 @@ void ps3_scsi_scan_host(struct ps3_instance *instance) } LOG_WARN("hno:%u scan device end, channel number %d\n", - PS3_HOST(instance), channel_info->channelNum); + PS3_HOST(instance), channel_info->channelNum); } #endif -static inline int _ps3_del_disk(struct ps3_instance *instance, - struct scsi_device *sdev) +static inline S32 _ps3_del_disk(struct ps3_instance *instance, + struct scsi_device *sdev) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; - unsigned char dev_type = PS3_DISK_TYPE_UNKNOWN; - unsigned char channel = PS3_SDEV_CHANNEL(sdev); - unsigned short target_id = PS3_SDEV_TARGET(sdev); + U8 dev_type = PS3_DISK_TYPE_UNKNOWN; + U8 channel = PS3_SDEV_CHANNEL(sdev); + U16 target_id = PS3_SDEV_TARGET(sdev); struct PS3DiskDevPos disk_pos; - unsigned char encl_id = 0; - unsigned char phy_id = 0; + U8 encl_id = 0; + U8 phy_id = 0; if (PS3_IS_PD_CHANNEL(instance, channel)) { dev_type = PS3_DISK_TYPE_PD; @@ -366,122 +340,133 @@ static inline int _ps3_del_disk(struct ps3_instance *instance, dev_type = PS3_DISK_TYPE_VD; } else { LOG_ERROR("hno:%u dev id[%u:%u] channel NOK\n", - PS3_HOST(instance), channel, target_id); + PS3_HOST(instance), channel, + target_id); PS3_BUG(); goto l_out; } ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - p_priv_data = (struct ps3_scsi_priv_data *)sdev->hostdata; + p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; if (p_priv_data != NULL) { + INJECT_AT_TIMES(PS3_ERR_IJ_FORCE_WAIT, sdev); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_DEL_DEV_WAIT_OS_PRIV_DATA, + PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); ps3_qos_disk_del(instance, p_priv_data); - if (ps3_sas_is_support_smp(instance) && - dev_type == PS3_DISK_TYPE_PD && - p_priv_data->dev_type != PS3_DEV_TYPE_NVME_SSD && - p_priv_data->dev_type != PS3_DEV_TYPE_VEP) { + if (ps3_sas_is_support_smp(instance) && dev_type == PS3_DISK_TYPE_PD && + p_priv_data->dev_type != PS3_DEV_TYPE_NVME_SSD && + p_priv_data->dev_type != PS3_DEV_TYPE_VEP) { memset(&disk_pos, 0, sizeof(struct PS3DiskDevPos)); - memcpy(&disk_pos, &p_priv_data->disk_pos, - sizeof(struct PS3DiskDevPos)); + memcpy(&disk_pos, &p_priv_data->disk_pos, sizeof(struct PS3DiskDevPos)); encl_id = p_priv_data->encl_id; phy_id = p_priv_data->phy_id; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); - ps3_sas_remove_device(instance, &disk_pos, encl_id, - phy_id); + ps3_sas_remove_device(instance, &disk_pos, encl_id, phy_id); } else { if (p_priv_data->dev_type == PS3_DEV_TYPE_VD && - p_priv_data->lock_mgr.hash_mgr != NULL) { + p_priv_data->lock_mgr.hash_mgr != NULL) { p_priv_data->lock_mgr.dev_deling = PS3_TRUE; - ps3_r1x_conflict_queue_clean( - p_priv_data, - PS3_SCSI_RESULT_HOST_STATUS( - DID_NO_CONNECT)); + ps3_r1x_conflict_queue_clean(p_priv_data, + PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT)); } ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); - LOG_WARN("remove device channel[%u], id[%u] begin\n", - channel, target_id); + LOG_WARN("remove device channel[%u], id[%u] begin\n", channel, target_id); ps3_scsi_remove_device(instance, sdev); - LOG_WARN("remove device channel[%u], id[%u] end\n", - channel, target_id); + LOG_WARN("remove device channel[%u], id[%u] end\n", channel, target_id); } } else { + ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); LOG_DEBUG("hno:%u del disk, priv data NULL, [%u:%u],\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), PS3_SDEV_TARGET(sdev)); } l_out: return ret; } -static int ps3_del_disk(struct ps3_instance *instance, unsigned char channel, - unsigned short target_id) +static S32 ps3_del_disk(struct ps3_instance *instance, + U8 channel, U16 target_id) { struct scsi_device *sdev = NULL; - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; +#if 0 + LOG_INFO("hno:%u dev id[%u:%u] delete scsi device start\n", + PS3_HOST(instance), channel, target_id); +#endif #ifdef _WINDOWS sdev = ps3_scsi_device_lookup_win(instance, channel, target_id); if (sdev == NULL || sdev->add_ack != 1) { LOG_INFO("hno:%u dev[%p] id[%u:%u] not exist scsi device\n", - PS3_HOST(instance), sdev, channel, target_id); + PS3_HOST(instance), sdev, channel, target_id); goto l_out; } #else sdev = ps3_scsi_device_lookup(instance, channel, target_id, 0); - if (sdev == NULL) + if(sdev == NULL) { +#if 0 + LOG_INFO("hno:%u dev id[%u:%u] not exist scsi device\n", + PS3_HOST(instance), channel, target_id); +#endif goto l_out; + } #endif + INJECT_AT_TIMES(PS3_ERR_IJ_FORCE_WAIT, sdev); ret = _ps3_del_disk(instance, sdev); ps3_scsi_device_put(instance, sdev); l_out: +#if 0 + LOG_INFO("hno:%u dev id[%u:%u] " + "delete scsi device end\n", PS3_HOST(instance), + channel, target_id); +#endif return ret; } static struct PS3VDEntry *ps3_get_single_vd_info(struct ps3_instance *instance, - struct PS3Dev *dev) + struct PS3Dev *dev) { - int ret = -PS3_FAILED; - union PS3DiskDev vd_id = { 0 }; + S32 ret = -PS3_FAILED; + PS3DiskDev_u vd_id = {0}; struct PS3VDEntry *p_vd_entry = NULL; - unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; - + U16 virtDiskIdx = PS3_INVALID_DEV_ID; vd_id.ps3Dev.virtDiskID = dev->virtDiskID; vd_id.ps3Dev.softChan = dev->softChan; vd_id.ps3Dev.devID = dev->devID; ret = ps3_vd_info_sync_get(instance, vd_id.diskID, 1); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL1, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u, sync get VD info NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u, sync get VD info NOK\n", + PS3_HOST(instance)); goto l_out; } + INJECT_START(PS3_ERR_IJ_FORCE_VD_COUNT_ERR, &instance->dev_context.vd_info_buf_sync->count); if (instance->dev_context.vd_info_buf_sync->count != 1) { LOG_ERROR("hno:%u, single add VD, has no info\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } p_vd_entry = instance->dev_context.vd_info_buf_sync->vds; if (PS3_VDID_INVALID(&p_vd_entry->diskPos)) { LOG_WARN("hno:%u, init single vd info NOK, vdid is 0\n", - PS3_HOST(instance)); + PS3_HOST(instance)); p_vd_entry = NULL; goto l_out; } - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), - PS3_VDID(&p_vd_entry->diskPos)); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), PS3_VDID(&p_vd_entry->diskPos)); if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(instance))) { - LOG_WARN( - "hno:%u, init single vd info NOK, vir_id[%d] > max[%d]\n", - PS3_HOST(instance), virtDiskIdx, - PS3_MAX_VD_COUNT(instance)); + LOG_WARN("hno:%u, init single vd info NOK, vir_id[%d] > max[%d]\n", + PS3_HOST(instance), virtDiskIdx, PS3_MAX_VD_COUNT(instance)); p_vd_entry = NULL; goto l_out; } + INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN, dev); if (PS3_CHANNEL(&p_vd_entry->diskPos) != dev->softChan || - PS3_TARGET(&p_vd_entry->diskPos) != dev->devID) { - LOG_ERROR( - "hno:%u single add VD[%u:%u:%u] != req VD[%u:%u:%u] magic[%#x] unmatched\n", + PS3_TARGET(&p_vd_entry->diskPos) != dev->devID) { + LOG_ERROR("hno:%u single add VD[%u:%u:%u] != req VD[%u:%u:%u] magic[%#x] unmatched\n", PS3_HOST(instance), dev->softChan, dev->devID, dev->virtDiskID, PS3_CHANNEL(&p_vd_entry->diskPos), PS3_TARGET(&p_vd_entry->diskPos), @@ -493,71 +478,73 @@ static struct PS3VDEntry *ps3_get_single_vd_info(struct ps3_instance *instance, ps3_vd_busy_scale_get(p_vd_entry); LOG_DEBUG("hno:%u VD[%u:%u:%u] got single vd info success\n", - PS3_HOST(instance), dev->softChan, dev->devID, - dev->virtDiskID); + PS3_HOST(instance), dev->softChan, dev->devID, dev->virtDiskID); l_out: return p_vd_entry; } -static int ps3_update_single_vd_info(struct ps3_instance *instance, - struct PS3Dev *dev) +static S32 ps3_update_single_vd_info(struct ps3_instance *instance, + struct PS3Dev *dev) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct PS3VDEntry *p_vd_entry = NULL; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_vd_tb = &p_dev_ctx->vd_table[vd_table_idx]; + U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_vd_tb = + &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; - unsigned short virtDiskIdx = 0; + U16 virtDiskIdx = 0; p_vd_entry = ps3_get_single_vd_info(instance, dev); if (p_vd_entry == NULL) { - LOG_ERROR("hno:%u sync get VD info NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u sync get VD info NOK\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), - PS3_VDID(&p_vd_entry->diskPos)); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), PS3_VDID(&p_vd_entry->diskPos)); if (p_vd_entry->isHidden) { LOG_INFO("hno:%u single add VD[%u:%u] vd info is hidden\n", - PS3_HOST(instance), dev->softChan, dev->devID); + PS3_HOST(instance), dev->softChan, dev->devID); goto l_out; } ps3_qos_vd_init(instance, p_vd_entry); - memcpy(&p_vd_array[virtDiskIdx], p_vd_entry, sizeof(struct PS3VDEntry)); + memcpy(&p_vd_array[virtDiskIdx], + p_vd_entry, sizeof(struct PS3VDEntry)); p_vd_tb->vd_idxs[dev->softChan][dev->devID] = PS3_VDID(&p_vd_entry->diskPos); ps3_vd_info_show(instance, &p_vd_array[virtDiskIdx]); LOG_DEBUG("hno:%u, idx[%d], VD[%u:%u] single add, got vd info\n", - PS3_HOST(instance), p_dev_ctx->vd_table_idx, dev->softChan, - dev->devID); + PS3_HOST(instance), p_dev_ctx->vd_table_idx, dev->softChan, + dev->devID); l_out: return ret; } -static unsigned char _ps3_add_disk_prepare(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos) +static Bool _ps3_add_disk_prepare(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos) { - unsigned char is_need_add = PS3_TRUE; + Bool is_need_add = PS3_TRUE; struct scsi_device *sdev = NULL; - unsigned int sdev_magic = 0; - unsigned int new_magic = 0; - int ret = PS3_SUCCESS; + U32 sdev_magic = 0; + U32 new_magic = 0; + S32 ret = PS3_SUCCESS; sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), 0); - if (sdev == NULL) + PS3_TARGET(dev_pos), 0); + if (sdev == NULL) { goto l_out; + } sdev_magic = ps3_scsi_dev_magic(instance, sdev); if (PS3_IS_VD_CHANNEL(instance, PS3_SDEV_CHANNEL(sdev)) || - ps3_sas_is_support_smp(instance)) { + ps3_sas_is_support_smp(instance)) { new_magic = dev_pos->diskMagicNum; } else { new_magic = dev_pos->checkSum; @@ -565,18 +552,19 @@ static unsigned char _ps3_add_disk_prepare(struct ps3_instance *instance, if (new_magic == sdev_magic) { LOG_INFO("hno:%u check magic same [%u:%u] magic[%#x]\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev), sdev_magic); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), PS3_SDEV_TARGET(sdev), + sdev_magic); is_need_add = PS3_FALSE; } else { LOG_WARN("hno:%u check dev[%u:%u] magic is diff[%#x != %#x]\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev), new_magic, sdev_magic); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev), + new_magic, sdev_magic); ret = _ps3_del_disk(instance, sdev); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u del dev[%u:%u] unexpect ret[%d]\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev), ret); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev), ret); } } ps3_scsi_device_put(instance, sdev); @@ -585,29 +573,28 @@ static unsigned char _ps3_add_disk_prepare(struct ps3_instance *instance, } void ps3_check_vd_member_change(struct ps3_instance *instance, - struct ps3_pd_entry *local_entry) + struct ps3_pd_entry *local_entry) { struct scsi_device *sdev = NULL; - if (!ps3_sas_is_support_smp(instance)) + if (!ps3_sas_is_support_smp(instance)) { goto l_out; -#if defined(PS3_SUPPORT_LINX80) + } +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) (void)sdev; if (ps3_check_pd_is_vd_member(local_entry->config_flag)) { - LOG_WARN( - "hno:%u change ready to component, remove device channel[%u], id[%u], begin\n", - PS3_HOST(instance), PS3_CHANNEL(&local_entry->disk_pos), + LOG_WARN("hno:%u change ready to component, remove device channel[%u], id[%u], begin\n", + PS3_HOST(instance), + PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos)); - ps3_pd_del(instance, &local_entry->disk_pos, - local_entry->config_flag); - LOG_WARN( - "hno:%u change ready to component, remove device channel[%u], id[%u] end\n", - PS3_HOST(instance), PS3_CHANNEL(&local_entry->disk_pos), + ps3_pd_del(instance, &local_entry->disk_pos, local_entry->config_flag); + LOG_WARN("hno:%u change ready to component, remove device channel[%u], id[%u] end\n", + PS3_HOST(instance), + PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos)); } else { ps3_mutex_lock(&instance->dev_context.dev_scan_lock); - sdev = ps3_scsi_device_lookup( - instance, PS3_CHANNEL(&local_entry->disk_pos), + sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos), 0); if (sdev) { ps3_scsi_device_put(instance, sdev); @@ -616,52 +603,43 @@ void ps3_check_vd_member_change(struct ps3_instance *instance, ps3_mutex_unlock(&instance->dev_context.dev_scan_lock); ps3_linx80_vd_member_change(instance, local_entry); } - LOG_WARN( - "hno:%u change component to ready, add device channel[%u], id[%u], begin\n", - PS3_HOST(instance), PS3_CHANNEL(&local_entry->disk_pos), + LOG_WARN("hno:%u change component to ready, add device channel[%u], id[%u], begin\n", + PS3_HOST(instance), + PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos)); ps3_pd_add(instance, &local_entry->disk_pos); - LOG_WARN( - "hno:%u change component to ready, add device channel[%u], id[%u], end\n", - PS3_HOST(instance), PS3_CHANNEL(&local_entry->disk_pos), + LOG_WARN("hno:%u change component to ready, add device channel[%u], id[%u], end\n", + PS3_HOST(instance), + PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos)); } #else + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_PD_ATTR_WAIT_OS_SCAN, PS3_ERR_IJ_OS_SCAN, NULL); + INJECT_START(PS3_ERR_IJ_OS_SCAN, NULL); ps3_mutex_lock(&instance->dev_context.dev_scan_lock); - sdev = ps3_scsi_device_lookup(instance, - PS3_CHANNEL(&local_entry->disk_pos), - PS3_TARGET(&local_entry->disk_pos), 0); + sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(&local_entry->disk_pos), + PS3_TARGET(&local_entry->disk_pos), 0); if (sdev) { if (ps3_check_pd_is_vd_member(local_entry->config_flag)) { if (sdev->no_uld_attach != 1) { sdev->no_uld_attach = 1; - ps3_qos_vd_member_change(instance, local_entry, - sdev, PS3_TRUE); - LOG_WARN( - "hno:%u pd[%u:%u] change ready to component start\n", - PS3_HOST(instance), sdev->channel, - sdev->id); + ps3_qos_vd_member_change(instance, local_entry, sdev, PS3_TRUE); + LOG_WARN("hno:%u pd[%u:%u] change ready to component start\n", + PS3_HOST(instance), sdev->channel, sdev->id); PS3_WARN_ON(scsi_device_reprobe(sdev)); - LOG_WARN( - "hno:%u pd[%u:%u] change ready to component end\n", - PS3_HOST(instance), sdev->channel, - sdev->id); + LOG_WARN("hno:%u pd[%u:%u] change ready to component end\n", + PS3_HOST(instance), sdev->channel, sdev->id); } } else { if (sdev->no_uld_attach != 0) { sdev->no_uld_attach = 0; - ps3_qos_vd_member_change(instance, local_entry, - sdev, PS3_FALSE); - LOG_WARN( - "hno:%u pd[%u:%u] change component to ready start\n", - PS3_HOST(instance), sdev->channel, - sdev->id); + ps3_qos_vd_member_change(instance, local_entry, sdev, PS3_FALSE); + LOG_WARN("hno:%u pd[%u:%u] change component to ready start\n", + PS3_HOST(instance), sdev->channel, sdev->id); PS3_WARN_ON(scsi_device_reprobe(sdev)); - LOG_WARN( - "hno:%u pd[%u:%u] change component to ready end\n", - PS3_HOST(instance), sdev->channel, - sdev->id); + LOG_WARN("hno:%u pd[%u:%u] change component to ready end\n", + PS3_HOST(instance), sdev->channel, sdev->id); } } ps3_scsi_device_put(instance, sdev); @@ -672,88 +650,92 @@ void ps3_check_vd_member_change(struct ps3_instance *instance, return; } -static struct PS3DiskDevPos *ps3_get_info_pos(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id, - unsigned char disk_type) +static struct PS3DiskDevPos* ps3_get_info_pos( + struct ps3_instance *instance, U8 channel, U16 target_id, U8 disk_type) { struct PS3DiskDevPos *disk_Pos_ret = NULL; struct ps3_pd_entry *pd_entry = NULL; struct PS3VDEntry *vd_entry = NULL; if (disk_type == PS3_DISK_TYPE_PD) { - pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, - target_id); - if (pd_entry != NULL) + pd_entry = ps3_dev_mgr_lookup_pd_info(instance, + channel, target_id); + if (pd_entry != NULL) { disk_Pos_ret = &pd_entry->disk_pos; - } else if (disk_type == PS3_DISK_TYPE_VD) { - vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, - target_id); - if (vd_entry != NULL) + } + } + else if (disk_type == PS3_DISK_TYPE_VD) { + vd_entry = ps3_dev_mgr_lookup_vd_info(instance, + channel, target_id); + if (vd_entry != NULL) { disk_Pos_ret = &vd_entry->diskPos; + } } return disk_Pos_ret; } -static inline int ps3_add_disk(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos, - unsigned char disk_type) +static inline S32 ps3_add_disk(struct ps3_instance *instance, + struct PS3DiskDevPos* dev_pos, U8 disk_type) { - int ret = PS3_SUCCESS; - struct PS3DiskDevPos *dev_pos_newes = NULL; + S32 ret = PS3_SUCCESS; + struct PS3DiskDevPos* dev_pos_newes = NULL; if (disk_type == PS3_DISK_TYPE_PD) { - ret = ps3_dev_mgr_pd_info_get(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), - PS3_PDID(dev_pos)); - } else if (disk_type == PS3_DISK_TYPE_VD) { - ret = ps3_update_single_vd_info(instance, - &dev_pos->diskDev.ps3Dev); + ret = ps3_dev_mgr_pd_info_get(instance, + PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos), PS3_PDID(dev_pos)); + } + else if (disk_type == PS3_DISK_TYPE_VD) { + ret = ps3_update_single_vd_info(instance, &dev_pos->diskDev.ps3Dev); } if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u single add dev[%u:%u] get info NOK\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos)); + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); goto l_out; } dev_pos_newes = ps3_get_info_pos(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), disk_type); + PS3_TARGET(dev_pos), disk_type); if (dev_pos_newes == NULL) { ret = -PS3_FAILED; LOG_WARN("hno:%u update pos[%u:%u] invalid\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos)); + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); goto l_out; } - if (!_ps3_add_disk_prepare(instance, dev_pos_newes)) + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, + PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); + if (!_ps3_add_disk_prepare(instance, dev_pos_newes)) { goto l_out; + } + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, + PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); ret = _ps3_add_disk(instance, PS3_CHANNEL(dev_pos_newes), - PS3_TARGET(dev_pos_newes), disk_type); + PS3_TARGET(dev_pos_newes), disk_type); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u single add dev[%u:%u] NOK\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos_newes), - PS3_TARGET(dev_pos_newes)); + PS3_HOST(instance), PS3_CHANNEL(dev_pos_newes), + PS3_TARGET(dev_pos_newes)); goto l_out; } l_out: return ret; } -static int ps3_pd_add(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos) +static S32 ps3_pd_add(struct ps3_instance *instance, + struct PS3DiskDevPos* dev_pos) { - int ret = -PS3_FAILED; - + S32 ret = -PS3_FAILED; ps3_mutex_lock(&instance->dev_context.dev_scan_lock); - if (unlikely(!PS3_IS_PD_CHANNEL(instance, PS3_CHANNEL(dev_pos)))) { - LOG_ERROR( - "hno:%u pd[%u:%u] single add, but channel is not pd\n", + if (unlikely(!PS3_IS_PD_CHANNEL(instance, + PS3_CHANNEL(dev_pos)))) { + LOG_ERROR("hno:%u pd[%u:%u] single add, but channel is not pd\n", PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); PS3_BUG(); @@ -762,7 +744,8 @@ static int ps3_pd_add(struct ps3_instance *instance, ret = ps3_add_disk(instance, dev_pos, PS3_DISK_TYPE_PD); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u add PD NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u add PD NOK\n", + PS3_HOST(instance)); goto l_out; } l_out: @@ -771,39 +754,33 @@ static int ps3_pd_add(struct ps3_instance *instance, return ret; } -static unsigned char ps3_pd_ext_del_done_check(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos) +static Bool ps3_pd_ext_del_done_check(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos) { struct scsi_device *sdev = NULL; - unsigned char is_need_del_done = PS3_FALSE; - int ret = PS3_SUCCESS; + Bool is_need_del_done = PS3_FALSE; + S32 ret = PS3_SUCCESS; #ifdef _WINDOWS - sdev = ps3_scsi_device_lookup_win(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos)); - if (unlikely(sdev == NULL || sdev->add_ack != 1)) + sdev = ps3_scsi_device_lookup_win(instance, PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); + if (unlikely(sdev == NULL || sdev->add_ack != 1)) { is_need_del_done = TRUE; + } #else struct ps3_pd_entry *pd_entry = NULL; - sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), 0); - if (unlikely(sdev == NULL)) { + sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos), 0); + if(unlikely(sdev == NULL)) { if (ps3_sas_is_support_smp(instance)) { - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( - instance, PS3_PDID(dev_pos)); + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, + PS3_PDID(dev_pos)); if (pd_entry != NULL && pd_entry->sas_rphy != NULL) { - ps3_sas_remove_device(instance, - &pd_entry->disk_pos, - pd_entry->encl_id, - pd_entry->phy_id); + ps3_sas_remove_device(instance, &pd_entry->disk_pos, + pd_entry->encl_id, pd_entry->phy_id); } else { - LOG_ERROR( - "hno:%u, can not found PD [%u:%u:%u] pd_entry:%p or sas_rphy is NULL\n", - PS3_HOST(instance), - PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), PS3_PDID(dev_pos), - pd_entry); + LOG_ERROR("hno:%u, can not found PD [%u:%u:%u] pd_entry:%p or sas_rphy is NULL\n", + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos), PS3_PDID(dev_pos), pd_entry); } } is_need_del_done = PS3_TRUE; @@ -811,14 +788,13 @@ static unsigned char ps3_pd_ext_del_done_check(struct ps3_instance *instance, #endif if (is_need_del_done) { LOG_WARN("hno:%u dev id[%u:%u] not exist scsi device\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos)); + PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); ret = ps3_scsi_remove_device_done(instance, dev_pos, - PS3_DISK_TYPE_PD); + PS3_DISK_TYPE_PD); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL7, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u dev[%u:%u:%u] magic[%#x] dev del done NOK %d\n", + LOG_ERROR("hno:%u dev[%u:%u:%u] magic[%#x] dev del done NOK %d\n", PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos), PS3_PDID(dev_pos), dev_pos->diskMagicNum, ret); @@ -830,18 +806,18 @@ static unsigned char ps3_pd_ext_del_done_check(struct ps3_instance *instance, return is_need_del_done; } -static int ps3_pd_del(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos, unsigned char config_flag) +static S32 ps3_pd_del(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos, U8 config_flag) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - struct ps3_pd_table *p_pd_tb = &p_dev_ctx->pd_table; - unsigned short disk_idx = 0; + struct ps3_pd_table* p_pd_tb = &p_dev_ctx->pd_table; + U16 disk_idx = 0; ps3_mutex_lock(&instance->dev_context.dev_scan_lock); if (!ps3_dev_id_valid_check(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), PS3_DISK_TYPE_PD)) { + PS3_TARGET(dev_pos),PS3_DISK_TYPE_PD)) { PS3_BUG(); goto l_out; } @@ -852,34 +828,32 @@ static int ps3_pd_del(struct ps3_instance *instance, } ret = ps3_del_disk(instance, PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL8, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u unable to delete scsi device PD[%u:%u] ret %d\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), ret); + LOG_ERROR("hno:%u unable to delete scsi device PD[%u:%u] ret %d\n", + PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos), ret); goto l_out; } l_clean_again: disk_idx = p_pd_tb->pd_idxs[PS3_CHANNEL(dev_pos)][PS3_TARGET(dev_pos)]; - p_pd_tb->pd_idxs[PS3_CHANNEL(dev_pos)][PS3_TARGET(dev_pos)] = - PS3_INVALID_VALUE; + p_pd_tb->pd_idxs[PS3_CHANNEL(dev_pos)][PS3_TARGET(dev_pos)] = PS3_INVALID_VALUE; p_dev_ctx->pd_entries_array[disk_idx].config_flag = config_flag; l_out: ps3_mutex_unlock(&instance->dev_context.dev_scan_lock); return ret; + } -static int ps3_vd_add(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos) +static S32 ps3_vd_add(struct ps3_instance *instance, + struct PS3DiskDevPos* dev_pos) { - int ret = -PS3_FAILED; - struct PS3Dev *dev = &dev_pos->diskDev.ps3Dev; + S32 ret = -PS3_FAILED; + struct PS3Dev* dev = &dev_pos->diskDev.ps3Dev; if (unlikely(!PS3_IS_VD_CHANNEL(instance, dev->softChan))) { - LOG_ERROR( - "hno:%u VD[%u:%u] single add, but channel is not vd\n", + LOG_ERROR("hno:%u VD[%u:%u] single add, but channel is not vd\n", PS3_HOST(instance), dev->softChan, dev->devID); PS3_BUG(); goto l_out; @@ -887,28 +861,29 @@ static int ps3_vd_add(struct ps3_instance *instance, ret = ps3_add_disk(instance, dev_pos, PS3_DISK_TYPE_VD); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u add VD NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u add VD NOK\n", + PS3_HOST(instance)); goto l_out; } l_out: return ret; } -static int ps3_vd_del(struct ps3_instance *instance, unsigned char channel, - unsigned short target_id) +static S32 ps3_vd_del(struct ps3_instance *instance, + U8 channel, U16 target_id) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_VD)) { + PS3_DISK_TYPE_VD)) { PS3_BUG(); goto l_out; } ret = ps3_del_disk(instance, channel, target_id); + INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL4, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u unable to delete scsi device VD[%u:%u] ret %d\n", + LOG_ERROR("hno:%u unable to delete scsi device VD[%u:%u] ret %d\n", PS3_HOST(instance), channel, target_id, ret); goto l_out; } @@ -917,16 +892,17 @@ static int ps3_vd_del(struct ps3_instance *instance, unsigned char channel, return ret; } -static int ps3_vd_hidden_change(struct ps3_instance *instance, - struct PS3Dev *dev) +static S32 ps3_vd_hidden_change(struct ps3_instance *instance, + struct PS3Dev* dev) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct PS3VDEntry *p_vd_entry = NULL; struct PS3DiskDevPos disk_pos; p_vd_entry = ps3_get_single_vd_info(instance, dev); if (unlikely(p_vd_entry == NULL)) { - LOG_ERROR("hno:%u sync get VD info NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u sync get VD info NOK\n", + PS3_HOST(instance)); goto l_out; } @@ -934,13 +910,11 @@ static int ps3_vd_hidden_change(struct ps3_instance *instance, disk_pos = p_vd_entry->diskPos; ret = ps3_vd_add(instance, &disk_pos); } else { - ret = ps3_vd_del(instance, (unsigned char)dev->softChan, - dev->devID); + ret = ps3_vd_del(instance, (U8)dev->softChan, dev->devID); } if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u vd hidden change NOK, dev[%u:%u:%u], ret[%d]\n", + LOG_ERROR("hno:%u vd hidden change NOK, dev[%u:%u:%u], ret[%d]\n", PS3_HOST(instance), dev->softChan, dev->devID, dev->virtDiskID, ret); ret = -PS3_FAILED; @@ -950,24 +924,21 @@ static int ps3_vd_hidden_change(struct ps3_instance *instance, return ret; } -static inline unsigned char -ps3_check_pd_is_same(struct ps3_instance *instance, - struct PS3DiskDevPos *src_dev_pos, - struct PS3DiskDevPos *dest_dev_pos) +static inline Bool ps3_check_pd_is_same(struct ps3_instance *instance, + struct PS3DiskDevPos* src_dev_pos, struct PS3DiskDevPos* dest_dev_pos) { - unsigned char ret_valid = PS3_FALSE; + Bool ret_valid = PS3_FALSE; if (likely(dest_dev_pos->diskMagicNum == src_dev_pos->diskMagicNum && - PS3_DISKID(dest_dev_pos) == PS3_DISKID(src_dev_pos))) { + PS3_DISKID(dest_dev_pos) == PS3_DISKID(src_dev_pos))) { LOG_DEBUG("hno:%u check pd id same [%u:%u:%u] magic[%#x]\n", - PS3_HOST(instance), PS3_CHANNEL(dest_dev_pos), - PS3_TARGET(dest_dev_pos), PS3_PDID(dest_dev_pos), - src_dev_pos->diskMagicNum); + PS3_HOST(instance), PS3_CHANNEL(dest_dev_pos), + PS3_TARGET(dest_dev_pos), PS3_PDID(dest_dev_pos), + src_dev_pos->diskMagicNum); ret_valid = PS3_TRUE; } else { - LOG_FILE_WARN( - "hno:%u check mismatch, src dev[%u:%u:%u] magic[%#x]\n" - "\tdest dev[%u:%u:%u] magic[%#x]\n", + LOG_FILE_WARN("hno:%u check mismatch, src dev[%u:%u:%u] magic[%#x], " + "dest dev[%u:%u:%u] magic[%#x]\n", PS3_HOST(instance), PS3_CHANNEL(src_dev_pos), PS3_TARGET(src_dev_pos), PS3_PDID(src_dev_pos), src_dev_pos->diskMagicNum, PS3_CHANNEL(dest_dev_pos), @@ -977,17 +948,15 @@ ps3_check_pd_is_same(struct ps3_instance *instance, return ret_valid; } -static inline void -ps3_update_info_by_list_item(struct ps3_pd_entry *local_entry, - union PS3Device *list_item, unsigned char is_raid) +static inline void ps3_update_info_by_list_item(struct ps3_pd_entry *local_entry, + union PS3Device *list_item, Bool is_raid) { if (unlikely((local_entry->disk_pos.diskMagicNum != - list_item->pd.diskPos.diskMagicNum) || - (PS3_DISKID(&local_entry->disk_pos) != - PS3_DISKID(&list_item->pd.diskPos)))) { - LOG_ERROR( - "Device is mismatch, local entry device[%u:%u:%u]\n" - "\tand magic[%#x], new device[%u:%u:%u] and magic[%#x]\n", + list_item->pd.diskPos.diskMagicNum) || + (PS3_DISKID(&local_entry->disk_pos) != + PS3_DISKID(&list_item->pd.diskPos)))) { + LOG_ERROR("Device is mismatch, local entry device[%u:%u:%u] " + "and magic[%#x], new device[%u:%u:%u] and magic[%#x]\n", PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos), PS3_PDID(&local_entry->disk_pos), @@ -1002,24 +971,20 @@ ps3_update_info_by_list_item(struct ps3_pd_entry *local_entry, local_entry->config_flag = list_item->pd.configFlag; local_entry->state = list_item->pd.diskState; LOG_INFO("single pd info update PD[%u:%u] config_flag[%s], state[%s]\n", - PS3_CHANNEL(&list_item->pd.diskPos), - PS3_TARGET(&list_item->pd.diskPos), - getPdStateName((enum MicPdState)local_entry->config_flag, - is_raid), - getDeviceStateName((enum DeviceState)local_entry->state)); + PS3_CHANNEL(&list_item->pd.diskPos), PS3_TARGET(&list_item->pd.diskPos), + getPdStateName((MicPdState_e)local_entry->config_flag, is_raid), + getDeviceStateName((DeviceState_e)local_entry->state)); } -static int ps3_update_single_pd_info(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos, - union PS3Device *list_item) +static S32 ps3_update_single_pd_info(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos, union PS3Device *list_item) { - int ret = PS3_SUCCESS; - unsigned char channel = dev_pos->diskDev.ps3Dev.softChan; + S32 ret = PS3_SUCCESS; + U8 channel = dev_pos->diskDev.ps3Dev.softChan; struct ps3_pd_entry *p_pd_entry = NULL; - + INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN1, &channel); if (unlikely(!PS3_IS_PD_CHANNEL(instance, channel))) { - LOG_ERROR( - "hno:%u , PD[%u:%u] info update, but channel is not pd\n", + LOG_ERROR("hno:%u , PD[%u:%u] info update, but channel is not pd\n", PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); ret = -PS3_FAILED; @@ -1027,45 +992,41 @@ static int ps3_update_single_pd_info(struct ps3_instance *instance, goto l_out; } - p_pd_entry = - ps3_dev_mgr_lookup_pd_info_by_id(instance, PS3_PDID(dev_pos)); + p_pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, + PS3_PDID(dev_pos)); if (p_pd_entry == NULL) { - LOG_FILE_WARN( - "hno:%u single PD info update[%u:%u], cannot find entry\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), + LOG_FILE_WARN("hno:%u single PD info update[%u:%u], cannot find entry\n", + PS3_HOST(instance), + PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); } - if (p_pd_entry != NULL && - !ps3_check_pd_is_same(instance, &p_pd_entry->disk_pos, dev_pos) && - list_item) { - ps3_update_info_by_list_item(p_pd_entry, list_item, - instance->is_raid); + if (p_pd_entry != NULL && !ps3_check_pd_is_same(instance, + &p_pd_entry->disk_pos, dev_pos) && list_item) { + ps3_update_info_by_list_item(p_pd_entry, list_item, instance->is_raid); } else { ret = ps3_dev_mgr_pd_info_get(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), - PS3_PDID(dev_pos)); + PS3_TARGET(dev_pos), PS3_PDID(dev_pos)); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, single add get PD[%u:%u] info NOK\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos)); + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); goto l_out; } - p_pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( - instance, PS3_PDID(dev_pos)); + p_pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, + PS3_PDID(dev_pos)); if (p_pd_entry == NULL) { - LOG_WARN( - "hno:%u single PD info update[%u:%u], cannot find new entry\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), + LOG_WARN("hno:%u single PD info update[%u:%u], cannot find new entry\n", + PS3_HOST(instance), + PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); goto l_out; } } if (instance->ioc_adpter->check_vd_member_change != NULL) { - instance->ioc_adpter->check_vd_member_change(instance, - p_pd_entry); + instance->ioc_adpter->check_vd_member_change(instance, p_pd_entry); } l_out: @@ -1073,12 +1034,12 @@ static int ps3_update_single_pd_info(struct ps3_instance *instance, } static void ps3_dev_update_pre_check(struct PS3EventDetail *event_detail, - unsigned int event_cnt) + U32 event_cnt) { - unsigned char i = 0; - unsigned char vd_count_idx = 0XFF; - unsigned char pd_count_idx = 0XFF; - unsigned char pd_info_idx = 0XFF; + U8 i = 0; + U8 vd_count_idx = 0XFF; + U8 pd_count_idx = 0XFF; + U8 pd_info_idx = 0XFF; for (i = 0; i < event_cnt; i++) { switch (event_detail[i].eventCode) { @@ -1101,20 +1062,18 @@ static void ps3_dev_update_pre_check(struct PS3EventDetail *event_detail, } if (pd_count_idx == 0xFF && vd_count_idx == 0xFF && - pd_info_idx == 0xFF) { + pd_info_idx == 0xFF) { return; } - LOG_DEBUG( - "detail update pd_count_idx[%d], vd_count_idx[%d], pd_info_idx[%d]\n", + LOG_DEBUG("detail update pd_count_idx[%d], vd_count_idx[%d], pd_info_idx[%d]\n", pd_count_idx, vd_count_idx, pd_info_idx); for (i = 0; i < event_cnt; i++) { switch (event_detail[i].eventType) { case PS3_EVT_PD_COUNT: - if (pd_count_idx != 0xFF && pd_count_idx != i) { - LOG_DEBUG( - "detail update remove %d eventCode[%d]\n", + if (pd_count_idx !=0xFF && pd_count_idx != i) { + LOG_DEBUG("detail update remove %d eventCode[%d]\n", i, event_detail[i].eventCode); event_detail[i].eventType = PS3_EVT_ILLEGAL_TYPE; @@ -1123,9 +1082,8 @@ static void ps3_dev_update_pre_check(struct PS3EventDetail *event_detail, } break; case PS3_EVT_VD_COUNT: - if (vd_count_idx != 0xFF && vd_count_idx != i) { - LOG_DEBUG( - "detail update remove %d eventCode[%d]\n", + if (vd_count_idx !=0xFF && vd_count_idx != i) { + LOG_DEBUG("detail update remove %d eventCode[%d]\n", i, event_detail[i].eventCode); event_detail[i].eventType = PS3_EVT_ILLEGAL_TYPE; @@ -1134,9 +1092,8 @@ static void ps3_dev_update_pre_check(struct PS3EventDetail *event_detail, } break; case PS3_EVT_PD_ATTR: - if (pd_info_idx != 0xFF && pd_info_idx != i) { - LOG_DEBUG( - "detail update remove %d eventCode[%d]\n", + if (pd_info_idx !=0xFF && pd_info_idx != i) { + LOG_DEBUG("detail update remove %d eventCode[%d]\n", i, event_detail[i].eventCode); event_detail[i].eventType = PS3_EVT_ILLEGAL_TYPE; @@ -1151,17 +1108,17 @@ static void ps3_dev_update_pre_check(struct PS3EventDetail *event_detail, } } -static unsigned char ps3_get_sdev_pose_by_chl_tid( - struct ps3_instance *instance, const unsigned char channel, - const unsigned short target_id, struct PS3DiskDevPos *disk_Pos) +static Bool ps3_get_sdev_pose_by_chl_tid(struct ps3_instance *instance, + const U8 channel, const U16 target_id, struct PS3DiskDevPos *disk_Pos) { struct scsi_device *sdev = NULL; struct ps3_scsi_priv_data *scsi_priv = NULL; - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; sdev = ps3_scsi_device_lookup(instance, channel, target_id, 0); - if (unlikely(sdev == NULL)) + if(unlikely(sdev == NULL)) { ret = PS3_FALSE; + } if (ret) { ps3_mutex_lock(&instance->dev_context.dev_priv_lock); scsi_priv = PS3_SDEV_PRI_DATA(sdev); @@ -1169,10 +1126,8 @@ static unsigned char ps3_get_sdev_pose_by_chl_tid( *disk_Pos = scsi_priv->disk_pos; } else { ret = PS3_FALSE; - LOG_DEBUG( - "hno:%u get sdev pos, priv data NULL, [%u:%u],\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + LOG_DEBUG("hno:%u get sdev pos, priv data NULL, [%u:%u],\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), PS3_SDEV_TARGET(sdev)); } ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ps3_scsi_device_put(instance, sdev); @@ -1181,40 +1136,38 @@ static unsigned char ps3_get_sdev_pose_by_chl_tid( return ret; } -static int _ps3_add_remove_multi_pd(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id) +static S32 _ps3_add_remove_multi_pd(struct ps3_instance *instance, + U8 channel, U16 target_id) { - int ret = PS3_SUCCESS; - int ret_tmp = PS3_SUCCESS; - union PS3Device *p_dev = NULL; + S32 ret = PS3_SUCCESS; + S32 ret_tmp = PS3_SUCCESS; + union PS3Device* p_dev = NULL; struct PS3DiskDevPos pd_Pos; - unsigned char config_flag = MIC_PD_STATE_UNKNOWN; + U8 config_flag = MIC_PD_STATE_UNKNOWN; p_dev = ps3_dev_mgr_lookup_pd_list(instance, channel, target_id); if (p_dev == NULL) { - if (ps3_get_sdev_pose_by_chl_tid(instance, channel, target_id, - &pd_Pos)) { + if (ps3_get_sdev_pose_by_chl_tid(instance, channel, + target_id, &pd_Pos)) { ret_tmp = ps3_pd_del(instance, &pd_Pos, - MIC_PD_STATE_UNKNOWN); + MIC_PD_STATE_UNKNOWN); } goto l_out; } - if (ps3_pd_scsi_visible_check( - instance, &p_dev->pd.diskPos, - ps3_get_converted_dev_type(p_dev->pd.driverType, - p_dev->pd.mediumType), - p_dev->pd.configFlag, p_dev->pd.diskState)) { + if (ps3_pd_scsi_visible_check(instance, &p_dev->pd.diskPos, + ps3_get_converted_dev_type(p_dev->pd.driverType, + p_dev->pd.mediumType), p_dev->pd.configFlag, + p_dev->pd.diskState)) { ret_tmp = ps3_pd_add(instance, &p_dev->pd.diskPos); } else { - ret_tmp = ps3_dev_mgr_pd_info_get(instance, channel, target_id, - PS3_PDID(&p_dev->pd.diskPos)); + + ret_tmp = ps3_dev_mgr_pd_info_get(instance, + channel, target_id, PS3_PDID(&p_dev->pd.diskPos)); if (ret_tmp != PS3_SUCCESS) { LOG_ERROR("hno:%u get pd info NOK, [%u:%u], ret[%d]\n", - PS3_HOST(instance), channel, target_id, - ret_tmp); + PS3_HOST(instance), channel, target_id, ret_tmp); ret = -PS3_FAILED; } config_flag = p_dev->pd.configFlag; @@ -1225,166 +1178,164 @@ static int _ps3_add_remove_multi_pd(struct ps3_instance *instance, if (ret_tmp != PS3_SUCCESS) { LOG_ERROR("hno:%u add or del pd NOK, [%u:%u], ret[%d]\n", - PS3_HOST(instance), channel, target_id, ret_tmp); + PS3_HOST(instance), channel, target_id, ret_tmp); ret = -PS3_FAILED; } return ret; } -static int ps3_add_remove_multi_pd(struct ps3_instance *instance) +static S32 ps3_add_remove_multi_pd(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - int ret_tmp = PS3_SUCCESS; - unsigned short i = 0; - unsigned short j = 0; - unsigned char chan_id = 0; + S32 ret = PS3_SUCCESS; + S32 ret_tmp = PS3_SUCCESS; + U16 i = 0; + U16 j = 0; + U8 chan_id = 0; struct ps3_channel *pd_chan = instance->dev_context.channel_pd; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; LOG_DEBUG("hno:%u, ready to update full pd count\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = ps3_dev_mgr_pd_list_get(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u get pd list NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u get pd list NOK\n", + PS3_HOST(instance)); goto l_out; } for (i = 0; i < p_dev_ctx->pd_channel_count; i++) { chan_id = pd_chan[i].channel; for (j = 0; j < pd_chan[i].max_dev_num; j++) { - ret_tmp = - _ps3_add_remove_multi_pd(instance, chan_id, j); - if (ret_tmp != PS3_SUCCESS) + ret_tmp = _ps3_add_remove_multi_pd(instance, chan_id, j); + if (ret_tmp != PS3_SUCCESS) { ret = -PS3_FAILED; + } } } l_out: - LOG_DEBUG("hno:%u, update full pd count end\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u, update full pd count end\n", + PS3_HOST(instance)); return ret; } -static int ps3_add_remove_multi_vd(struct ps3_instance *instance) +static S32 ps3_add_remove_multi_vd(struct ps3_instance *instance) { - int ret_tmp = PS3_SUCCESS; - int ret = PS3_SUCCESS; - unsigned short i = 0; - unsigned short j = 0; - unsigned char chan_id = 0; + S32 ret_tmp = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + U16 i = 0; + U16 j = 0; + U8 chan_id = 0; struct ps3_channel *vd_chan = instance->dev_context.channel_vd; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - union PS3Device *p_dev = NULL; + union PS3Device* p_dev = NULL; - LOG_DEBUG("hno:%u ready to update full vd count\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u ready to update full vd count\n", + PS3_HOST(instance)); ret = ps3_dev_mgr_vd_list_get(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u get vd list NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u get vd list NOK\n", + PS3_HOST(instance)); goto l_out; } for (i = 0; i < p_dev_ctx->vd_channel_count; i++) { chan_id = vd_chan[i].channel; for (j = 0; j < vd_chan[i].max_dev_num; j++) { - p_dev = ps3_dev_mgr_lookup_vd_list(instance, chan_id, - j); - if (p_dev != NULL && - ps3_vd_scsi_visible_check( - instance, &p_dev->vd.diskPos, - p_dev->vd.isHidden, p_dev->vd.diskState)) { - ret_tmp = ps3_vd_add(instance, - &p_dev->pd.diskPos); + + p_dev = ps3_dev_mgr_lookup_vd_list(instance, chan_id, j); + if (p_dev != NULL && ps3_vd_scsi_visible_check(instance, + &p_dev->vd.diskPos, p_dev->vd.isHidden, p_dev->vd.diskState)) { + ret_tmp = ps3_vd_add(instance, &p_dev->pd.diskPos); } else { ret_tmp = ps3_vd_del(instance, chan_id, j); } if (ret_tmp != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u update vd[%u:%u] count NOK, ret[%d]\n", - PS3_HOST(instance), chan_id, j, - ret_tmp); + LOG_ERROR("hno:%u update vd[%u:%u] count NOK, ret[%d]\n", + PS3_HOST(instance), chan_id, j, ret_tmp); ret = -PS3_FAILED; } } } l_out: - LOG_DEBUG("hno:%u update full vd count end\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u update full vd count end\n", + PS3_HOST(instance)); return ret; } -static int ps3_update_multi_pd_info(struct ps3_instance *instance) +static S32 ps3_update_multi_pd_info(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - int ret_tmp = PS3_SUCCESS; - unsigned short i = 0; + S32 ret = PS3_SUCCESS; + S32 ret_tmp = PS3_SUCCESS; + U16 i = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct PS3DevList *p_pd_list = p_dev_ctx->pd_list_buf; struct PS3Dev *p_dev = NULL; - LOG_DEBUG("hno:%u ready to update full pd info\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u ready to update full pd info\n", + PS3_HOST(instance)); ret = ps3_pd_list_get(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, dev mgr get pd list NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - LOG_INFO("hno:%u get pd list count is %d\n", PS3_HOST(instance), - p_pd_list->count); + LOG_INFO("hno:%u get pd list count is %d\n", + PS3_HOST(instance), p_pd_list->count); for (i = 0; i < p_pd_list->count; i++) { p_dev = PS3_DEV(&p_pd_list->devs[i].pd.diskPos); if (PS3_PDID_INVALID(&p_pd_list->devs[i].pd.diskPos)) { LOG_WARN("hno:%u check pd list %d dev pdid is 0\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); continue; } - if (!ps3_dev_id_valid_check(instance, - (unsigned char)p_dev->softChan, - p_dev->devID, PS3_DISK_TYPE_PD)) { + if (!ps3_dev_id_valid_check(instance, (U8)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_PD)) { PS3_BUG(); continue; } - LOG_INFO("hno:%u update pd info %d dev[%u:%u:%u], magic[%#x], state[%s]\n", - PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, - p_dev->phyDiskID, - p_pd_list->devs[i].pd.diskPos.diskMagicNum, - getDeviceStateName((enum DeviceState)p_pd_list->devs[i] - .pd.diskState)); + LOG_INFO("hno:%u ready update pd info by list" + " %d dev[%u:%u:%u], magic[%#x], state[%s]\n", + PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, + p_dev->phyDiskID, + p_pd_list->devs[i].pd.diskPos.diskMagicNum, + getDeviceStateName((DeviceState_e)p_pd_list->devs[i].pd.diskState)); - ret_tmp = ps3_update_single_pd_info( - instance, &p_pd_list->devs[i].pd.diskPos, + ret_tmp = ps3_update_single_pd_info(instance, &p_pd_list->devs[i].pd.diskPos, &p_pd_list->devs[i]); if (ret_tmp != PS3_SUCCESS) { LOG_ERROR("hno:%u NOK, %u:%u, ret[%d]\n", - PS3_HOST(instance), p_dev->softChan, - p_dev->devID, ret_tmp); + PS3_HOST(instance), p_dev->softChan, p_dev->devID, ret_tmp); ret = -PS3_FAILED; } } l_out: LOG_DEBUG("hno:%u update full pd info end ret[%d]\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); return ret; } -static inline int ps3_dev_evt_update_pd_count(struct ps3_instance *instance, - unsigned int eventCode, - struct PS3DiskDevPos *dev_pos) +static inline S32 ps3_dev_evt_update_pd_count(struct ps3_instance *instance, + U32 eventCode, struct PS3DiskDevPos *dev_pos) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - switch (eventCode) { + switch(eventCode) + { case PS3_EVT_CODE(MGR_EVT_DEVM_DISK_IN): case PS3_EVT_CODE(MGR_EVT_DEVM_JBOD): case PS3_EVT_CODE(MGR_EVT_DEVM_DISK_CHANGE): @@ -1405,11 +1356,10 @@ static inline int ps3_dev_evt_update_pd_count(struct ps3_instance *instance, return ret; } -static inline int ps3_dev_evt_update_vd_count(struct ps3_instance *instance, - unsigned int eventCode, - struct PS3DiskDevPos *dev_pos) +static inline S32 ps3_dev_evt_update_vd_count(struct ps3_instance *instance, + U32 eventCode, struct PS3DiskDevPos *dev_pos) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; switch (eventCode) { case PS3_EVT_CODE(MGR_EVT_VD_CREATED): @@ -1421,8 +1371,7 @@ static inline int ps3_dev_evt_update_vd_count(struct ps3_instance *instance, break; case PS3_EVT_CODE(MGR_EVT_VD_DELETED): case PS3_EVT_CODE(MGR_EVT_VD_OFFLINE): - ret = ps3_vd_del(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos)); + ret = ps3_vd_del(instance, PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); break; case PS3_EVT_CODE(MGR_EVT_VD_HIDDEN_CHANGE): ret = ps3_vd_hidden_change(instance, PS3_DEV(dev_pos)); @@ -1435,11 +1384,10 @@ static inline int ps3_dev_evt_update_vd_count(struct ps3_instance *instance, return ret; } -static inline int ps3_dev_evt_update_pd_attr(struct ps3_instance *instance, - unsigned int eventCode, - struct PS3DiskDevPos *dev_pos) +static inline S32 ps3_dev_evt_update_pd_attr(struct ps3_instance *instance, + U32 eventCode, struct PS3DiskDevPos *dev_pos) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; (void)eventCode; ret = ps3_update_single_pd_info(instance, dev_pos, NULL); @@ -1447,60 +1395,61 @@ static inline int ps3_dev_evt_update_pd_attr(struct ps3_instance *instance, return ret; } -int ps3_dev_update_detail_proc(struct ps3_instance *instance, - struct PS3EventDetail *event_detail, - unsigned int event_cnt) +S32 ps3_dev_update_detail_proc(struct ps3_instance *instance, + struct PS3EventDetail *event_detail, U32 event_cnt) { - int ret = PS3_SUCCESS; - int ret_map = PS3_SUCCESS; - unsigned int i = 0; + S32 ret = PS3_SUCCESS; + S32 ret_map = PS3_SUCCESS; + U32 i = 0; - LOG_INFO("hno:%u, event detail count[%d]\n", PS3_HOST(instance), - event_cnt); + LOG_INFO("hno:%u, event detail count[%d]\n", + PS3_HOST(instance), event_cnt); ps3_dev_update_pre_check(event_detail, event_cnt); for (i = 0; i < event_cnt; i++) { - LOG_INFO( - "hno:%u event detail %d event type[%s], eventCode is [%s], dev[%u:%u:%u]\n", - PS3_HOST(instance), i, - nameMgrEvtType(event_detail[i].eventType), - mgrEvtCodeTrans(event_detail[i].eventCode), - PS3_CHANNEL(&event_detail[i].devicePos), - PS3_TARGET(&event_detail[i].devicePos), - PS3_VDID(&event_detail[i].devicePos)); + + LOG_INFO("hno:%u event detail %d event type[%s]," + " eventCode is [%s], dev[%u:%u:%u]\n", + PS3_HOST(instance), i, + nameMgrEvtType(event_detail[i].eventType), + mgrEvtCodeTrans(event_detail[i].eventCode), + PS3_CHANNEL(&event_detail[i].devicePos), + PS3_TARGET(&event_detail[i].devicePos), + PS3_VDID(&event_detail[i].devicePos)); switch (event_detail[i].eventType) { case PS3_EVT_PD_COUNT: - ret = ps3_dev_evt_update_pd_count( - instance, event_detail[i].eventCode, + ret = ps3_dev_evt_update_pd_count(instance, + event_detail[i].eventCode, &event_detail[i].devicePos); break; case PS3_EVT_VD_COUNT: - ret = ps3_dev_evt_update_vd_count( - instance, event_detail[i].eventCode, + ret = ps3_dev_evt_update_vd_count(instance, + event_detail[i].eventCode, &event_detail[i].devicePos); break; case PS3_EVT_PD_ATTR: - ret = ps3_dev_evt_update_pd_attr( - instance, event_detail[i].eventCode, + ret = ps3_dev_evt_update_pd_attr(instance, + event_detail[i].eventCode, &event_detail[i].devicePos); break; default: break; } - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { ret_map |= event_detail[i].eventType; + } } return ret_map; } -int ps3_dev_update_full_proc(struct ps3_instance *instance, - enum MgrEvtType event_type) +S32 ps3_dev_update_full_proc(struct ps3_instance *instance, + MgrEvtType_e event_type) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; switch (event_type) { case PS3_EVT_PD_COUNT: @@ -1519,117 +1468,100 @@ int ps3_dev_update_full_proc(struct ps3_instance *instance, return ret; } -static int ps3_dev_vd_pending_resend(struct ps3_cmd *cmd) +static S32 ps3_dev_vd_pending_resend(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_dev_context *p_dev_ctx = &cmd->instance->dev_context; + memset(p_dev_ctx->vd_info_buf_async, + 0, sizeof(struct PS3VDInfo)); - memset(p_dev_ctx->vd_info_buf_async, 0, sizeof(struct PS3VDInfo)); - - ps3_vd_pending_filter_table_build( - (unsigned char *)p_dev_ctx->vd_info_buf_async); + ps3_vd_pending_filter_table_build((U8*) + p_dev_ctx->vd_info_buf_async); PS3_MGR_CMD_STAT_INC(cmd->instance, cmd); ret = ps3_async_cmd_send(cmd->instance, cmd); if (ret != PS3_SUCCESS) { - LOG_FILE_ERROR( - "trace_id[0x%llx], hno:%u re send vd pending cmd failed\n", + LOG_FILE_ERROR("trace_id[0x%llx], hno:%u re send vd pending cmd faild\n", cmd->trace_id, PS3_HOST(cmd->instance)); } return ret; + } -static unsigned char ps3_dev_vd_pending_data_switch(struct ps3_cmd *cmd) +static Bool ps3_dev_vd_pending_data_switch(struct ps3_cmd *cmd) { - int i = 0; - unsigned char ret = PS3_FALSE; + S32 i = 0; + Bool ret = PS3_FALSE; struct ps3_dev_context *p_dev_ctx = &cmd->instance->dev_context; - unsigned char new_vd_table_idx = (p_dev_ctx->vd_table_idx + 1) & 1; - struct ps3_vd_table *p_new_vd_tb = - &p_dev_ctx->vd_table[new_vd_table_idx]; - struct PS3VDEntry *p_new_vd_array = - p_dev_ctx->vd_entries_array[new_vd_table_idx]; - unsigned char old_vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_old_vd_tb = - &p_dev_ctx->vd_table[old_vd_table_idx]; - struct PS3VDEntry *p_old_vd_array = - p_dev_ctx->vd_entries_array[old_vd_table_idx]; + U8 new_vd_table_idx = (p_dev_ctx->vd_table_idx + 1) & 1; + struct ps3_vd_table *p_new_vd_tb = &p_dev_ctx->vd_table[new_vd_table_idx]; + struct PS3VDEntry *p_new_vd_array = p_dev_ctx->vd_entries_array[new_vd_table_idx]; + U8 old_vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_old_vd_tb = &p_dev_ctx->vd_table[old_vd_table_idx]; + struct PS3VDEntry *p_old_vd_array = p_dev_ctx->vd_entries_array[old_vd_table_idx]; struct PS3VDEntry *p_vd_entry = p_dev_ctx->vd_info_buf_async->vds; struct PS3VDEntry *vd_entry_old = NULL; struct PS3Dev *p_dev = NULL; - unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; + U16 virtDiskIdx = PS3_INVALID_DEV_ID; struct scsi_device *sdev = NULL; memcpy(p_new_vd_tb->vd_idxs_array, p_old_vd_tb->vd_idxs_array, - p_dev_ctx->total_vd_count * sizeof(unsigned short)); - memcpy(p_new_vd_array, p_old_vd_array, - (PS3_MAX_VD_COUNT(cmd->instance) + 1) * - sizeof(struct PS3VDEntry)); + p_dev_ctx->total_vd_count * sizeof(U16)); + memcpy(p_new_vd_array, p_old_vd_array, (PS3_MAX_VD_COUNT(cmd->instance) + 1) * + sizeof(struct PS3VDEntry)); for (i = 0; i < p_dev_ctx->vd_info_buf_async->count; i++) { if (PS3_VDID_INVALID(&p_vd_entry[i].diskPos)) { - LOG_WARN_IN_IRQ( - cmd->instance, + LOG_WARN_IN_IRQ(cmd->instance, "hno:%u, init %d of %d vd info NOK, vdid is 0\n", PS3_HOST(cmd->instance), i, p_dev_ctx->vd_info_buf_sync->count); continue; } p_dev = PS3_DEV(&p_vd_entry[i].diskPos); - if (!ps3_dev_id_valid_check(cmd->instance, - (unsigned char)p_dev->softChan, - p_dev->devID, PS3_DISK_TYPE_VD)) { - LOG_ERROR_IN_IRQ( - cmd->instance, - "tid[0x%llx], hno:%u vd pending %d err chan:%d, or devid>max, %d>%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), i, - p_dev->softChan, p_dev->devID, - p_dev_ctx->max_dev_in_channel[p_dev->softChan]); + if (!ps3_dev_id_valid_check(cmd->instance, (U8)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_VD)) { + LOG_ERROR_IN_IRQ(cmd->instance, + "trace_id[0x%llx], hno:%u vd pending " + "%d err softchan:%d, or dev id > max, %d>%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), + i, p_dev->softChan, p_dev->devID, + p_dev_ctx->max_dev_in_channel[p_dev->softChan]); PS3_BUG_NO_SYNC(); continue; } - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(cmd->instance), - p_dev->virtDiskID); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(cmd->instance), p_dev->virtDiskID); if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(cmd->instance))) { - LOG_WARN_IN_IRQ( - cmd->instance, - "hno:%u, init %d of %d vd info NOK, vir_id[%d] > max[%d]\n", + LOG_WARN_IN_IRQ(cmd->instance, "hno:%u, init %d of %d vd info NOK, vir_id[%d] > max[%d]\n", PS3_HOST(cmd->instance), i, - p_dev_ctx->vd_info_buf_sync->count, virtDiskIdx, - PS3_MAX_VD_COUNT(cmd->instance)); + p_dev_ctx->vd_info_buf_sync->count, + virtDiskIdx, PS3_MAX_VD_COUNT(cmd->instance)); continue; } - LOG_INFO_IN_IRQ(cmd->instance, "hno:%u update vd[%u:%u] info\n", - PS3_HOST(cmd->instance), p_dev->softChan, - p_dev->devID); + LOG_INFO_IN_IRQ(cmd->instance, + "hno:%u update vd[%u:%u] info\n", + PS3_HOST(cmd->instance), p_dev->softChan, p_dev->devID); ps3_qos_vd_init(cmd->instance, &p_vd_entry[i]); - vd_entry_old = ps3_dev_mgr_lookup_vd_info_by_id( - cmd->instance, p_dev->virtDiskID); - ps3_qos_vd_attr_change(cmd->instance, vd_entry_old, - &p_vd_entry[i]); + vd_entry_old = ps3_dev_mgr_lookup_vd_info_by_id(cmd->instance, p_dev->virtDiskID); + ps3_qos_vd_attr_change(cmd->instance, vd_entry_old, &p_vd_entry[i]); p_new_vd_tb->vd_idxs[p_dev->softChan][p_dev->devID] = p_dev->virtDiskID; memcpy(&p_new_vd_array[virtDiskIdx], &p_vd_entry[i], - sizeof(struct PS3VDEntry)); + sizeof(struct PS3VDEntry)); - sdev = ps3_scsi_device_lookup(cmd->instance, p_dev->softChan, - p_dev->devID, 0); - if (sdev != NULL) { + sdev = ps3_scsi_device_lookup(cmd->instance, p_dev->softChan, p_dev->devID, 0); + if(sdev != NULL) { ps3_vd_busy_scale_get(&p_new_vd_array[virtDiskIdx]); if (ps3_sdev_bdi_stable_writes_get(sdev)) { - if (!(p_vd_entry[i].bdev_bdi_cap & - PS3_STABLE_WRITES_MASK)) { - ps3_sdev_bdi_stable_writes_clear( - cmd->instance, sdev); + if (!(p_vd_entry[i].bdev_bdi_cap & PS3_STABLE_WRITES_MASK)) { + ps3_sdev_bdi_stable_writes_clear(cmd->instance, sdev); } } else { - if (p_vd_entry[i].bdev_bdi_cap & - PS3_STABLE_WRITES_MASK) { - ps3_sdev_bdi_stable_writes_set( - cmd->instance, sdev); + if (p_vd_entry[i].bdev_bdi_cap & PS3_STABLE_WRITES_MASK) { + ps3_sdev_bdi_stable_writes_set(cmd->instance, sdev); } } ps3_scsi_device_put(cmd->instance, sdev); @@ -1638,51 +1570,45 @@ static unsigned char ps3_dev_vd_pending_data_switch(struct ps3_cmd *cmd) ps3_vd_info_show(cmd->instance, &p_new_vd_array[virtDiskIdx]); #ifndef _WINDOWS if (p_vd_entry[i].maxIOSize != 0) { - ps3_change_sdev_max_sector(cmd->instance, - &p_vd_entry[i]); + ps3_change_sdev_max_sector(cmd->instance, &p_vd_entry[i]); } else { - LOG_DEBUG( - "hno:%u vd[%u:%u] update max sector num is:0\n", - PS3_HOST(cmd->instance), p_dev->softChan, - p_dev->devID); + LOG_DEBUG("hno:%u vd[%u:%u] update max sector num is:0\n", + PS3_HOST(cmd->instance), p_dev->softChan, p_dev->devID); } #endif } - mb(); /* in order to force CPU ordering */ - if (p_dev_ctx->vd_table_idx == (PS3_VD_TABLE_NUM - 1)) + mb(); + if ( p_dev_ctx->vd_table_idx == (PS3_VD_TABLE_NUM -1)) { p_dev_ctx->vd_table_idx = 0; - else + } else { p_dev_ctx->vd_table_idx++; - mb(); /* in order to force CPU ordering */ + } + mb(); - LOG_INFO_IN_IRQ( - cmd->instance, + LOG_INFO_IN_IRQ(cmd->instance, "trace_id[0x%llx], hno:%u vd pending change cur_idx to [%d]\n", - cmd->trace_id, PS3_HOST(cmd->instance), - p_dev_ctx->vd_table_idx); + cmd->trace_id, PS3_HOST(cmd->instance), p_dev_ctx->vd_table_idx); return ret; } -int ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, unsigned short reply_flags) +S32 ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, U16 reply_flags) { - unsigned long flags = 0; - unsigned long flags1 = 0; - int ret = PS3_SUCCESS; + ULong flags = 0; + ULong flags1 = 0; + S32 ret = PS3_SUCCESS; struct ps3_dev_context *p_dev_ctx = NULL; struct ps3_instance *instance = cmd->instance; - int cur_state = PS3_INSTANCE_STATE_INIT; + S32 cur_state = PS3_INSTANCE_STATE_INIT; p_dev_ctx = &instance->dev_context; - ps3_atomic_inc(&p_dev_ctx->subwork); - LOG_DEBUG( - "trace_id[0x%llx], hno:%u got a vd pending response, cur_idx[%d]\n", - cmd->trace_id, PS3_HOST(instance), p_dev_ctx->vd_table_idx); + p_dev_ctx->subwork += 1; + LOG_DEBUG("trace_id[0x%llx], hno:%u got a vd pending response, cur_idx[%d]\n", + cmd->trace_id, PS3_HOST(instance), p_dev_ctx->vd_table_idx); PS3_MGR_CMD_BACK_INC(instance, cmd, reply_flags); if (unlikely(reply_flags == PS3_REPLY_WORD_FLAG_FAIL)) { - LOG_ERROR_IN_IRQ( - instance, + LOG_ERROR_IN_IRQ(instance, "trace_id[0x%llx], hno:%u vd pending cmd return failed\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; @@ -1690,8 +1616,7 @@ int ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, unsigned short reply_flags) } if (p_dev_ctx->vd_pending_cmd == NULL) { - LOG_INFO_IN_IRQ( - instance, + LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx], hno:%u vd pending is unsubscribed!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; @@ -1699,8 +1624,7 @@ int ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, unsigned short reply_flags) } if (!instance->state_machine.is_load) { - LOG_INFO_IN_IRQ( - instance, + LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; @@ -1708,9 +1632,8 @@ int ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, unsigned short reply_flags) } cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { - LOG_INFO_IN_IRQ( - instance, + if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { + LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx], hno:%u instance is not operational!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; @@ -1718,9 +1641,8 @@ int ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, unsigned short reply_flags) } LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx], hno:%u vd pending had [%d] vds\n", - cmd->trace_id, PS3_HOST(instance), - p_dev_ctx->vd_info_buf_async->count); + "trace_id[0x%llx], hno:%u vd pending had [%d] vds\n", + cmd->trace_id, PS3_HOST(instance), p_dev_ctx->vd_info_buf_async->count); ps3_dev_vd_pending_data_switch(cmd); @@ -1728,28 +1650,26 @@ int ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, unsigned short reply_flags) cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - if (ps3_atomic_read(&instance->dev_context.abort_vdpending_cmd) == 0) { + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + if(instance->dev_context.abort_vdpending_cmd == 0){ ret = ps3_dev_vd_pending_resend(cmd); - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); - if (ret == PS3_SUCCESS) + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + if (ret == PS3_SUCCESS) { goto l_out; - } else { + } + }else{ LOG_FILE_INFO("hno:%u vd pending cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); instance->dev_context.vd_pending_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); ret = ps3_dev_mgr_vd_info_subscribe(instance); if (ret != PS3_SUCCESS) { LOG_INFO_IN_IRQ(instance, "hno:%u subscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } - ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); + instance->dev_context.abort_vdpending_cmd = 0; + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); goto l_out; } l_failed: @@ -1757,64 +1677,61 @@ int ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, unsigned short reply_flags) cmd->cmd_state.state = PS3_CMD_STATE_DEAD; ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx], CFID[%d], hno:%u to dead\n", - cmd->trace_id, cmd->index, PS3_HOST(instance)); + "trace_id[0x%llx], CFID[%d], hno:%u to dead\n", + cmd->trace_id, cmd->index, PS3_HOST(instance)); l_out: - ps3_atomic_dec(&p_dev_ctx->subwork); - LOG_INFO_IN_IRQ( - instance, + p_dev_ctx->subwork -= 1; + LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx], CFID[%d], hno:%u end proc a vd pending response, subwork:%d,ret:%d\n", - cmd->trace_id, cmd->index, PS3_HOST(instance), - ps3_atomic_read(&p_dev_ctx->subwork), ret); + cmd->trace_id, cmd->index, PS3_HOST(instance), p_dev_ctx->subwork,ret); return ret; } #ifdef _WINDOWS -int ps3_device_check_and_ack(struct ps3_instance *instance, - unsigned char channel_type, unsigned char channel, - unsigned short target_id) +BOOL ps3_device_check_and_ack(struct ps3_instance *instance, + U8 channel_type, U8 channel, U16 target_id) { - int ret_tmp = PS3_SUCCESS; - int ret = FALSE; + S32 ret_tmp = PS3_SUCCESS; + BOOL ret = FALSE; struct ps3_pd_entry *p_pd_entry = NULL; struct PS3VDEntry *p_vd_entry = NULL; - struct PS3DiskDevPos *p_diskPos = NULL; - unsigned char dev_type = PS3_DISK_TYPE_UNKNOWN; + struct PS3DiskDevPos* p_diskPos = NULL; + U8 dev_type = PS3_DISK_TYPE_UNKNOWN; - if (!ps3_scsi_visible_check(instance, channel, target_id, - channel_type)) { + if (!ps3_scsi_visible_check(instance, channel, target_id, channel_type)) { goto l_out; } if (channel_type == PS3_DISK_TYPE_PD) { - p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, - target_id); + p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, target_id); if (p_pd_entry) { + p_diskPos = &p_pd_entry->disk_pos; dev_type = PS3_DISK_TYPE_PD; + } - } else if (channel_type == PS3_DISK_TYPE_VD) { - p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, - target_id); + } + else if (channel_type == PS3_DISK_TYPE_VD) { + p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, target_id); if (p_vd_entry) { p_diskPos = &p_vd_entry->diskPos; dev_type = PS3_DISK_TYPE_VD; } } - if (p_diskPos == NULL) + if (p_diskPos == NULL) { goto l_out; + } ret_tmp = ps3_scsi_add_device_ack(instance, p_diskPos, dev_type); if (ret_tmp != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u dev[%u:%u] magic[%#x] pre scan ack NOK, ret %d\n", + LOG_ERROR("hno:%u dev[%u:%u] magic[%#x] pre scan ack NOK, ret %d\n", PS3_HOST(instance), channel, target_id, p_diskPos->diskMagicNum, ret_tmp); } else { LOG_INFO("hno:%u dev_type[%d] id[%u:%u] send ack success\n", - PS3_HOST(instance), dev_type, channel, target_id); + PS3_HOST(instance), dev_type, channel, target_id); ret = TRUE; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_update.h b/drivers/scsi/linkdata/ps3stor/ps3_device_update.h index 0a2fa04bfe6a..e51e8db3b04d 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_update.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_update.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_DEVICE_UPDATE_H_ #define _PS3_DEVICE_UPDATE_H_ @@ -10,33 +9,28 @@ #include "ps3_htp_event.h" #include "ps3_instance_manager.h" -unsigned char ps3_pd_scsi_visible_check(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, - unsigned char dev_type, - unsigned char config_flag, - unsigned char pd_state); +Bool ps3_pd_scsi_visible_check(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, U8 dev_type, U8 config_flag, + U8 pd_state); -int ps3_dev_update_detail_proc(struct ps3_instance *instance, - struct PS3EventDetail *event_detail, - unsigned int event_cnt); +S32 ps3_dev_update_detail_proc(struct ps3_instance *instance, + struct PS3EventDetail *event_detail, U32 event_cnt); -int ps3_dev_update_full_proc(struct ps3_instance *instance, - enum MgrEvtType event_type); +S32 ps3_dev_update_full_proc(struct ps3_instance *instance, + MgrEvtType_e event_type); -int ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, unsigned short reply_flags); +S32 ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, U16 reply_flags); #ifdef _WINDOWS -int ps3_device_check_and_ack(struct ps3_instance *instance, - unsigned char channel_type, unsigned char channel, - unsigned short target_id); +BOOL ps3_device_check_and_ack(struct ps3_instance *instance, + U8 channel_type, U8 channel, U16 target_id); #endif -unsigned int ps3_scsi_dev_magic(struct ps3_instance *instance, - struct scsi_device *sdev); +U32 ps3_scsi_dev_magic(struct ps3_instance *instance, struct scsi_device *sdev); void ps3_scsi_scan_host(struct ps3_instance *instance); void ps3_check_vd_member_change(struct ps3_instance *instance, - struct ps3_pd_entry *local_entry); + struct ps3_pd_entry *local_entry); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_drv_ver.h b/drivers/scsi/linkdata/ps3stor/ps3_drv_ver.h index 50b65aa7ac44..50ea282589db 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_drv_ver.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_drv_ver.h @@ -1,17 +1,15 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ #ifndef _PS3_DRV_VER_H_ #define _PS3_DRV_VER_H_ #define PS3_PRIVATE_VERSION "00.000.00.01" -#define PS3_DRV_VERSION "2.5.0.32" -#define PS3_DRV_COMMIT_ID "64d914a bbe55a7" -#define PS3_DRV_BUILD_TIME "Jan 24 2025 00:03:30" +#define PS3_DRV_VERSION "2.5.0.30" +#define PS3_DRV_COMMIT_ID "e2b0a93 3b1194f" +#define PS3_DRV_BUILD_TIME "Dec 20 2024 17:18:28" #define PS3_DRV_TOOLCHAIN_ID "" #define PS3_DRV_PRODUCT_SUPPORT "RAID/HBA" -#define PS3_DRV_LICENSE "GPL" -#define PS3_DRV_AUTHOR "ps3stor" -#define PS3_DRV_DESCRIPTION "ps3stor driver" +#define PS3_DRV_LICENSE "GPL" +#define PS3_DRV_AUTHOR "ps3stor" +#define PS3_DRV_DESCRIPTION "ps3stor driver" #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_dump.h b/drivers/scsi/linkdata/ps3stor/ps3_dump.h index 58733c955ec7..b6099a8ef371 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_dump.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_dump.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_CRASH_DUMP_H_ #define _PS3_CRASH_DUMP_H_ @@ -22,43 +21,44 @@ #include "ps3_htp.h" #include "ps3_htp_def.h" -#define PS3_DUMP_DATA_MAX_NUM 512 +#define PS3_DUMP_DATA_MAX_NUM 512 -#define WAIT_DUMP_COLLECT (1000) -#define WAIT_DUMP_TIMES_DEFAULT (300) -#define WAIT_DUMP_TIMES_MIN (10) -#define WAIT_DUMP_TIMES_MAX (3600) +#define WAIT_DUMP_COLLECT (1000) +#define WAIT_DUMP_TIMES_DEFAULT (300) +#define WAIT_DUMP_TIMES_MIN (10) +#define WAIT_DUMP_TIMES_MAX (3600) -#define WAIT_DUMP_DMA_DONE (200) +#define WAIT_DUMP_DMA_DONE (200) #ifndef _WINDOWS #ifdef __KERNEL__ -#define PS3_DUMP_FILE_DIR "/var/log" +#define PS3_DUMP_FILE_DIR "/var/log" #else -#define PS3_DUMP_FILE_DIR "/tmp" +#define PS3_DUMP_FILE_DIR "/tmp" #endif #else -#define PS3_DUMP_FILE_DIR "c:" +#define PS3_DUMP_FILE_DIR "c:" #endif -#define PS3_DUMP_FILE_CORE_PREFIX "core-" -#define PS3_DUMP_FILE_FWLOG_PREFIX "fwlog-" -#define PS3_DUMP_FILE_BAR_PREFIX "bar-" - -#define PS3_DUMP_STATUS_REG_DMA_FINISH_MASK (0x1 << 0) -#define PS3_DUMP_STATUS_REG_CRASH_DUMP_MASK (0x1 << 1) -#define PS3_DUMP_STATUS_REG_FW_DUMP_MASK (0x1 << 2) -#define PS3_DUMP_STATUS_REG_BAR_DUMP_MASK (0x1 << 3) -#define PS3_DUMP_STATUS_REG_CRASH_DUMP_TRIGGER_MASK (0x1 << 4) -#define PS3_DUMP_STATUS_REG_FW_DUMP_TRIGGER_MASK (0x2 << 4) -#define PS3_DUMP_STATUS_REG_BAR_DUMP_TRIGGER_MASK (0x3 << 4) -#define PS3_DUMP_STATUS_REG_ABORT_MASK (0x1 << 6) -#define PS3_DUMP_STATUS_REG_MASK (0x0F) -#define PS3_DUMP_STATUS_REG_INVALID_BITS_MASK (0x7F) - -#define PS3_REG_TEST(val, mask) (((val) & (mask)) ? PS3_TRUE : PS3_FALSE) -#define PS3_REG_SET(val, mask) (((val) |= (mask))) -#define PS3_REG_CLR(val, mask) ((val) &= (~(mask))) - -#define PS3_IOC_DUMP_SUPPORT(ins) (ins->dump_context.is_dump_support) +#define PS3_DUMP_FILE_CORE_PREFIX "core-" +#define PS3_DUMP_FILE_FWLOG_PREFIX "fwlog-" +#define PS3_DUMP_FILE_BAR_PREFIX "bar-" + +#define PS3_DUMP_STATUS_REG_DMA_FINISH_MASK (0x1 << 0) +#define PS3_DUMP_STATUS_REG_CRASH_DUMP_MASK (0x1 << 1) +#define PS3_DUMP_STATUS_REG_FW_DUMP_MASK (0x1 << 2) +#define PS3_DUMP_STATUS_REG_BAR_DUMP_MASK (0x1 << 3) +#define PS3_DUMP_STATUS_REG_CRASH_DUMP_TRIGGER_MASK (0x1 << 4) +#define PS3_DUMP_STATUS_REG_FW_DUMP_TRIGGER_MASK (0x2 << 4) +#define PS3_DUMP_STATUS_REG_BAR_DUMP_TRIGGER_MASK (0x3 << 4) +#define PS3_DUMP_STATUS_REG_ABORT_MASK (0x1 << 6) +#define PS3_DUMP_STATUS_REG_MASK (0x0F) +#define PS3_DUMP_STATUS_REG_INVALID_BITS_MASK (0x7F) + +#define PS3_REG_TEST(val, mask) (((val) & (mask)) ? PS3_TRUE:PS3_FALSE) +#define PS3_REG_SET(val, mask) (((val) |= (mask))) +#define PS3_REG_CLR(val, mask) ((val) &= (~(mask))) + +#define PS3_IOC_DUMP_SUPPORT(ins) \ + (ins->dump_context.is_dump_support) enum ps3_dump_work_status { PS3_DUMP_WORK_UNKNOWN, @@ -94,34 +94,34 @@ enum ps3_dump_file_status { #define PS3_DUMP_FILE_NAME_LEN (256) struct ps3_dump_file_info { - unsigned char filename[PS3_DUMP_FILE_NAME_LEN]; + U8 filename[PS3_DUMP_FILE_NAME_LEN]; #ifdef _WINDOWS - HANDLE fp; + HANDLE fp; #else struct file *fp; #endif - unsigned long long file_size; - unsigned int file_w_cnt; - unsigned int file_status; - unsigned int type; - unsigned char reserved[4]; + U64 file_size; + U32 file_w_cnt; + U32 file_status; + U32 type; + U8 reserved[4]; }; struct ps3_dump_context { - unsigned char dump_dir[PS3_DUMP_FILE_DIR_LEN]; - unsigned long long dump_data_size; - char dump_type; - int dump_state; - unsigned int dump_env; - unsigned int dump_work_status; - unsigned int dump_irq_handler_work_status; - unsigned long long copyed_data_size; - unsigned char *dump_dma_buf; + U8 dump_dir[PS3_DUMP_FILE_DIR_LEN]; + U64 dump_data_size; + S8 dump_type; + S32 dump_state; + U32 dump_env; + U32 dump_work_status; + U32 dump_irq_handler_work_status; + U64 copyed_data_size; + U8 *dump_dma_buf; dma_addr_t dump_dma_addr; - unsigned int dump_dma_wait_times; + U32 dump_dma_wait_times; #ifdef _WINDOWS struct ps3_delay_worker dump_work; - struct mutex dump_mutex; + ps3_mutex dump_mutex; #else struct workqueue_struct *dump_work_queue; struct delayed_work dump_work; @@ -129,36 +129,37 @@ struct ps3_dump_context { struct workqueue_struct *dump_irq_handler_work_queue; struct work_struct dump_irq_handler_work; spinlock_t dump_irq_handler_lock; - unsigned int dump_enabled; + U32 dump_enabled; #endif - struct mutex dump_lock; + ps3_mutex dump_lock; struct ps3_instance *instance; struct ps3_dump_file_info dump_out_file; struct ps3_cmd *dump_pending_cmd; - unsigned int dump_pending_send_times; - unsigned int dump_type_times; - unsigned int dump_state_times; - unsigned char is_dump_support; - unsigned char is_hard_recovered; + U32 dump_pending_send_times; + U32 dump_type_times; + U32 dump_state_times; + Bool is_dump_support; + Bool is_hard_recovered; - unsigned char reserved[2]; + U8 reserved[2]; }; -static inline const char *ps3_dump_type_to_name(int dump_type) +static inline const S8 *ps3_dump_type_to_name(S32 dump_type) { - static const char * const name[] = { [PS3_DUMP_TYPE_UNKNOWN] = "NULL", - [PS3_DUMP_TYPE_CRASH] = "dump_crash", - [PS3_DUMP_TYPE_FW_LOG] = "fw_log", - [PS3_DUMP_TYPE_BAR_DATA] = "bar_data" }; + static const S8 *name[] = { + [PS3_DUMP_TYPE_UNKNOWN] = "NULL", + [PS3_DUMP_TYPE_CRASH] = "dump_crash", + [PS3_DUMP_TYPE_FW_LOG] = "fw_log", + [PS3_DUMP_TYPE_BAR_DATA] = "bar_data" + }; return name[dump_type]; } -extern int ps3_dump_init(struct ps3_instance *instance); +extern S32 ps3_dump_init(struct ps3_instance *instance); extern void ps3_dump_exit(struct ps3_instance *instance); -extern int ps3_dump_type_set(struct ps3_dump_context *ctxt, int type, - unsigned int env); -extern int ps3_dump_state_set(struct ps3_dump_context *ctxt, int state); +extern S32 ps3_dump_type_set(struct ps3_dump_context *ctxt, S32 type, U32 env); +extern S32 ps3_dump_state_set(struct ps3_dump_context *ctxt, S32 state); #ifndef _WINDOWS extern struct ps3_dump_context *dev_to_dump_context(struct device *cdev); @@ -167,18 +168,18 @@ void ps3_dump_work_stop(struct ps3_instance *instance); #endif -int ps3_dump_dma_buf_alloc(struct ps3_instance *instance); +S32 ps3_dump_dma_buf_alloc(struct ps3_instance *instance); void ps3_dump_dma_buf_free(struct ps3_instance *instance); void ps3_dump_detect(struct ps3_instance *instance); #ifndef _WINDOWS -irqreturn_t ps3_dump_irq_handler(int virq, void *dev_id); +irqreturn_t ps3_dump_irq_handler(S32 virq, void *dev_id); #endif void ps3_dump_ctrl_set_int_ready(struct ps3_instance *instance); -unsigned char ps3_dump_is_trigger_log(struct ps3_instance *instance); +Bool ps3_dump_is_trigger_log(struct ps3_instance *instance); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_err_def.h b/drivers/scsi/linkdata/ps3stor/ps3_err_def.h index 97d778984ee4..2d1207dbdf5c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_err_def.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_err_def.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_ERR_DEF_H_ #define _PS3_ERR_DEF_H_ @@ -8,41 +7,41 @@ enum { - PS3_SUCCESS = 0x00, - PS3_FAILED = 0x01, - PS3_TIMEOUT = 0x02, - PS3_IN_IRQ_POLLING = 0x03, - PS3_DEV_UNKNOWN = 0x04, - PS3_RETRY = 0x05, - PS3_EBUSY = 0x06, - PS3_EINVAL = 0x07, - PS3_ENOMEM = 0x08, - PS3_ENODEV = 0x09, - PS3_ERESTARTSYS = 0x0a, - PS3_ENOTTY = 0x0b, - PS3_RESP_ERR = 0x0c, - PS3_RESP_INT = 0x0d, - PS3_ACTIVE_ERR = 0x0e, - PS3_CMD_NO_RESP = 0x0f, - PS3_IO_BLOCK = 0x10, - PS3_IO_REQUEUE = 0x11, - PS3_IO_CONFLICT_IN_Q = 0x12, - PS3_IO_CONFLICT = 0x13, - PS3_MGR_REC_FORCE = 0x14, - PS3_RECOVERED = 0x15, - PS3_IN_UNLOAD = 0x16, - PS3_NO_RECOVERED = 0x17, - PS3_IN_QOS_Q = 0x18, - PS3_IN_PCIE_ERR = 0x19, + PS3_SUCCESS = 0x00, + PS3_FAILED = 0x01, + PS3_TIMEOUT = 0x02, + PS3_IN_IRQ_POLLING = 0x03, + PS3_DEV_TYPE_UNKOWN = 0x04, + PS3_RETRY = 0x05, + PS3_EBUSY = 0x06, + PS3_EINVAL = 0x07, + PS3_ENOMEM = 0x08, + PS3_ENODEV = 0x09, + PS3_ERESTARTSYS = 0x0a, + PS3_ENOTTY = 0x0b, + PS3_RESP_ERR = 0x0c, + PS3_RESP_INT = 0x0d, + PS3_ACTIVE_ERR = 0x0e, + PS3_CMD_NO_RESP = 0x0f, + PS3_IO_BLOCK = 0x10, + PS3_IO_REQUEUE = 0x11, + PS3_IO_CONFLICT_IN_Q = 0x12, + PS3_IO_CONFLICT = 0x13, + PS3_MGR_REC_FORCE = 0x14, + PS3_RECOVERED = 0x15, + PS3_IN_UNLOAD = 0x16, + PS3_NO_RECOVERED = 0x17, + PS3_IN_QOS_Q = 0x18, + PS3_IN_PCIE_ERR = 0x19, }; -#define PS3_DRV_TRUE (1) -#define PS3_DRV_FALSE (0) +#define PS3_DRV_TRUE (1) +#define PS3_DRV_FALSE (0) struct ps3_fault_context { - unsigned char ioc_busy; - unsigned char reserved[2]; - unsigned long last_time; + U8 ioc_busy; + U8 reserved[2]; + ULong last_time; }; #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_event.c b/drivers/scsi/linkdata/ps3stor/ps3_event.c index 9feec32a51b6..739eabb60359 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_event.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_event.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include "ps3_event.h" #ifndef _WINDOWS #include @@ -21,7 +19,8 @@ #include "ps3_device_update.h" #include "ps3_util.h" #include "ps3_cmd_statistics.h" -unsigned short ps3_event_code_pd_count[] = { +#include "ps3_err_inject.h" +U16 ps3_event_code_pd_count[] = { PS3_EVT_CODE(MGR_EVT_DEVM_DISK_IN), PS3_EVT_CODE(MGR_EVT_DEVM_DISK_OUT), PS3_EVT_CODE(MGR_EVT_MULITPILE_PD_IN), @@ -37,7 +36,7 @@ unsigned short ps3_event_code_pd_count[] = { PS3_EVT_CODE(MGR_EVT_PD_PRE_READY) }; -unsigned short ps3_event_code_pd_attr[] = { +U16 ps3_event_code_pd_attr[] = { PS3_EVT_CODE(MGR_EVT_PD_INFO_CHANGE), PS3_EVT_CODE(MGR_EVT_PD_MARKED_READY), PS3_EVT_CODE(MGR_EVT_PD_MARKED_ONLINE), @@ -52,7 +51,7 @@ unsigned short ps3_event_code_pd_attr[] = { PS3_EVT_CODE(MGR_EVT_PD_MARKED_OFFLINE) }; -unsigned short ps3_event_code_vd_attr[] = { +U16 ps3_event_code_vd_attr[] = { PS3_EVT_CODE(MGR_EVT_VD_SETTINGS_CHANGE), PS3_EVT_CODE(MGR_EVT_VD_PD_CHANGE), PS3_EVT_CODE(MGR_EVT_VD_STATE_CHANGE), @@ -61,110 +60,105 @@ unsigned short ps3_event_code_vd_attr[] = { }; struct ps3_event_type_desc_map { - enum MgrEvtType event_type; + MgrEvtType_e event_type; const char *event_type_desc; }; static struct ps3_event_type_desc_map g_event_type_desc_table[] = { - { PS3_EVT_PD_COUNT, "PS3_EVT_PD_COUNT" }, - { PS3_EVT_VD_COUNT, "PS3_EVT_VD_COUNT" }, - { PS3_EVT_CTRL_INFO, "PS3_EVT_CTRL_INFO" }, - { PS3_EVT_PD_ATTR, "PS3_EVT_PD_ATTR" }, - { PS3_EVT_VD_ATTR, "PS3_EVT_VD_ATTRs" }, - { PS3_EVT_SAS_INFO, "PS3_EVT_SAS_INFO" }, - { PS3_EVT_DG_INFO, "MGR_EVT_DG_DELETED" }, + {PS3_EVT_PD_COUNT, "PS3_EVT_PD_COUNT"}, + {PS3_EVT_VD_COUNT, "PS3_EVT_VD_COUNT"}, + {PS3_EVT_CTRL_INFO, "PS3_EVT_CTRL_INFO"}, + {PS3_EVT_PD_ATTR, "PS3_EVT_PD_ATTR"}, + {PS3_EVT_VD_ATTR, "PS3_EVT_VD_ATTRs"}, + {PS3_EVT_SAS_INFO, "PS3_EVT_SAS_INFO"}, + {PS3_EVT_DG_INFO, "MGR_EVT_DG_DELETED"}, }; static struct fasync_struct *g_async_queue; -static void ps3_event_print_cmd(struct ps3_cmd *cmd, unsigned char is_send) +static void ps3_event_print_cmd(struct ps3_cmd *cmd, Bool is_send) { - LOG_INFO( - "trace_id[0x%llx], hno:%u event[%s] print cmd word type[%d]\n" - "\tdirect[%d], qmask[0x%x], CFID[%d], isr_sn[%d], vid[%d], pid[%d]\n", - cmd->trace_id, PS3_HOST(cmd->instance), - (is_send) ? "send" : "recv", cmd->cmd_word.type, - cmd->cmd_word.direct, cmd->cmd_word.qMask, - cmd->cmd_word.cmdFrameID, cmd->cmd_word.isrSN, - cmd->cmd_word.virtDiskID, cmd->cmd_word.phyDiskID); + LOG_INFO("trace_id[0x%llx], hno:%u event[%s] print cmd word type[%d]," + "direct[%d], qmask[0x%x], CFID[%d], isr_sn[%d], vid[%d], pid[%d]\n", + cmd->trace_id, PS3_HOST(cmd->instance), (is_send) ? "send" : "recv", + cmd->cmd_word.type, cmd->cmd_word.direct, + cmd->cmd_word.qMask, cmd->cmd_word.cmdFrameID, + cmd->cmd_word.isrSN, cmd->cmd_word.virtDiskID, + cmd->cmd_word.phyDiskID); } -void ps3_vd_pending_filter_table_build(unsigned char *data) +void ps3_vd_pending_filter_table_build(U8 *data) { - struct PS3EventFilter *event_filter = (struct PS3EventFilter *)data; - - memset(event_filter, 0, sizeof(struct PS3EventFilter)); + PS3EventFilter_s *event_filter = (PS3EventFilter_s*)data; + memset(event_filter, 0, sizeof(PS3EventFilter_s)); event_filter->eventType = PS3_EVT_VD_ATTR_LOCAL; event_filter->eventCodeCnt = ARRAY_SIZE(ps3_event_code_vd_attr); - data += sizeof(struct PS3EventFilter); + data += sizeof(PS3EventFilter_s); memcpy(data, ps3_event_code_vd_attr, sizeof(ps3_event_code_vd_attr)); } -void ps3_event_filter_table_get_raid(unsigned char *data) +void ps3_event_filter_table_get_raid(U8 *data) { - struct PS3EventFilter event_filter; - - memset(&event_filter, 0, sizeof(struct PS3EventFilter)); + PS3EventFilter_s event_filter; + memset(&event_filter, 0, sizeof(PS3EventFilter_s)); event_filter.eventType = PS3_EVT_PD_COUNT_LOCAL; event_filter.eventCodeCnt = ARRAY_SIZE(ps3_event_code_pd_count); - memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); - data += sizeof(struct PS3EventFilter); + memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); + data += sizeof(PS3EventFilter_s); memcpy(data, ps3_event_code_pd_count, sizeof(ps3_event_code_pd_count)); data += sizeof(ps3_event_code_pd_count); event_filter.eventType = PS3_EVT_VD_COUNT_LOCAL; event_filter.eventCodeCnt = 0; - memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); - data += sizeof(struct PS3EventFilter); + memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); + data += sizeof(PS3EventFilter_s); event_filter.eventType = PS3_EVT_CTRL_INFO_LOCAL; event_filter.eventCodeCnt = 0; - memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); - data += sizeof(struct PS3EventFilter); + memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); + data += sizeof(PS3EventFilter_s); event_filter.eventType = PS3_EVT_PD_ATTR_LOCAL; event_filter.eventCodeCnt = ARRAY_SIZE(ps3_event_code_pd_attr); - memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); - data += sizeof(struct PS3EventFilter); + memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); + data += sizeof(PS3EventFilter_s); memcpy(data, ps3_event_code_pd_attr, sizeof(ps3_event_code_pd_attr)); data += sizeof(ps3_event_code_pd_attr); } -void ps3_event_filter_table_get_hba(unsigned char *data) +void ps3_event_filter_table_get_hba(U8 *data) { - struct PS3EventFilter event_filter; - - memset(&event_filter, 0, sizeof(struct PS3EventFilter)); + PS3EventFilter_s event_filter; + memset(&event_filter, 0, sizeof(PS3EventFilter_s)); event_filter.eventType = PS3_EVT_SAS_INFO_LOCAL; event_filter.eventCodeCnt = 0; - memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); - data += sizeof(struct PS3EventFilter); + memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); + data += sizeof(PS3EventFilter_s); ps3_event_filter_table_get_raid(data); } -void ps3_event_filter_table_get_switch(unsigned char *data) +void ps3_event_filter_table_get_switch(U8 *data) { - struct PS3EventFilter event_filter; - - memset(&event_filter, 0, sizeof(struct PS3EventFilter)); + PS3EventFilter_s event_filter; + memset(&event_filter, 0, sizeof(PS3EventFilter_s)); event_filter.eventType = PS3_EVT_PD_COUNT_LOCAL; event_filter.eventCodeCnt = ARRAY_SIZE(ps3_event_code_pd_count); - memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); - data += sizeof(struct PS3EventFilter); + memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); + data += sizeof(PS3EventFilter_s); memcpy(data, ps3_event_code_pd_count, sizeof(ps3_event_code_pd_count)); data += sizeof(ps3_event_code_pd_count); } -static int ps3_event_type_proc(struct ps3_instance *instance, - enum MgrEvtType event_type) +static S32 ps3_event_type_proc(struct ps3_instance *instance, + MgrEvtType_e event_type) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; switch (event_type) { case PS3_EVT_PD_COUNT: @@ -177,8 +171,8 @@ static int ps3_event_type_proc(struct ps3_instance *instance, ret = ps3_ctrl_info_get(instance); break; default: - LOG_INFO("hno:%u Not cared event type %s\n", PS3_HOST(instance), - ps3_event_print(event_type)); + LOG_INFO("hno:%u Not cared event type %s\n", + PS3_HOST(instance), ps3_event_print(event_type)); break; } @@ -186,7 +180,7 @@ static int ps3_event_type_proc(struct ps3_instance *instance, } #ifndef _WINDOWS -int ps3_event_delay_set(struct ps3_instance *instance, unsigned int delay) +S32 ps3_event_delay_set(struct ps3_instance *instance, U32 delay) { struct ps3_event_context *event_ctx = NULL; struct ps3_event_delay_work *delay_work = NULL; @@ -205,17 +199,15 @@ int ps3_event_delay_set(struct ps3_instance *instance, unsigned int delay) #endif static void ps3_event_resubscribe(struct ps3_instance *instance, - struct ps3_cmd *cmd, - unsigned int event_proc_result_bitmap) + struct ps3_cmd *cmd, U32 event_proc_result_bitmap) { - unsigned long flags = 0; - struct PS3MgrReqFrame *mgr_req_frame = NULL; + ULong flags = 0; + PS3MgrReqFrame_s *mgr_req_frame = NULL; struct PS3MgrEvent *event_req_info = NULL; - + INJECT_START(PS3_ERR_IJ_INS_STATE_UNNORMAL, &instance->state_machine.is_load) if (!instance->state_machine.is_load) { - LOG_WARN_IN_IRQ( - instance, + LOG_WARN_IN_IRQ(instance, "hno:%u instance is suspend or instance unload!\n", PS3_HOST(instance)); return; @@ -224,27 +216,24 @@ static void ps3_event_resubscribe(struct ps3_instance *instance, mgr_req_frame = (struct PS3MgrReqFrame *)cmd->req_frame; event_req_info = (struct PS3MgrEvent *)&mgr_req_frame->value.event; - LOG_INFO_IN_IRQ( - instance, - "trace_id[0x%llx], hno:%u old event proc result bitmap: [0x%x]\n" - "\tcurrent event proc result bitmap: [0x%x]\n", + LOG_INFO_IN_IRQ(instance, + "trace_id[0x%llx], hno:%u old event proc result bitmap: [0x%x], " + "current event proc result bitmap: [0x%x]\n", cmd->trace_id, PS3_HOST(instance), event_req_info->eventTypeMapProcResult, event_proc_result_bitmap); event_req_info->eventTypeMapProcResult = event_proc_result_bitmap; - LOG_INFO_IN_IRQ( - instance, + LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx], hno:%u subcribe event proc result bitmap: [0x%x]\n", cmd->trace_id, PS3_HOST(instance), event_req_info->eventTypeMapProcResult); if (instance->ioc_adpter->event_filter_table_get != NULL) { - instance->ioc_adpter->event_filter_table_get( - (unsigned char *)cmd->ext_buf); + instance->ioc_adpter->event_filter_table_get((U8*)cmd->ext_buf); } - wmb(); /* in order to force CPU ordering */ + wmb(); PS3_MGR_CMD_STAT_INC(instance, cmd); ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); @@ -252,32 +241,29 @@ static void ps3_event_resubscribe(struct ps3_instance *instance, ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); if (ps3_async_cmd_send(cmd->instance, cmd) != PS3_SUCCESS) { - LOG_INFO_IN_IRQ( - instance, - "trace_id[0x%llx],CFID[%d],hno:%u re send event cmd failed\n", - cmd->trace_id, cmd->index, PS3_HOST(cmd->instance)); + LOG_INFO_IN_IRQ(instance, + "trace_id[0x%llx],CFID[%d],hno:%u re send event cmd faild\n", + cmd->trace_id,cmd->index, PS3_HOST(cmd->instance)); ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); cmd->cmd_state.state = PS3_CMD_STATE_DEAD; ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } + return; } -static unsigned int -ps3_event_proc_without_details(struct ps3_instance *instance, - struct PS3EventInfo *event_info) +static U32 ps3_event_proc_without_details(struct ps3_instance *instance, + struct PS3EventInfo *event_info) { - int ret = -PS3_FAILED; - unsigned int event_proc_result_bitmap = 0; - unsigned int mask_bit = 0X00000001; - unsigned int event_type = event_info->eventTypeMap & mask_bit; - + S32 ret = -PS3_FAILED; + U32 event_proc_result_bitmap = 0; + U32 mask_bit = 0X00000001; + U32 event_type = event_info->eventTypeMap & mask_bit; #ifndef _WINDOWS if (event_info->eventTypeMap & PS3_EVT_SAS_INFO) { ret = ps3_sas_expander_event_refresh(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u Event type PS3_EVT_SAS_INFO proc NOK!\n", + LOG_ERROR("hno:%u Event type PS3_EVT_SAS_INFO proc NOK!\n", PS3_HOST(instance)); event_proc_result_bitmap |= PS3_EVT_SAS_INFO; } @@ -287,13 +273,11 @@ ps3_event_proc_without_details(struct ps3_instance *instance, #endif while (mask_bit != 0) { if (event_type != 0) { - LOG_INFO( - "hno:%u Event type %s report without details!\n", - PS3_HOST(instance), - ps3_event_print((enum MgrEvtType)event_type)); + LOG_INFO("hno:%u Event type %s report without details!\n", + PS3_HOST(instance), ps3_event_print((MgrEvtType_e)event_type)); ret = ps3_event_type_proc(instance, - (enum MgrEvtType)event_type); + (MgrEvtType_e)event_type); } else { ret = PS3_SUCCESS; @@ -301,8 +285,8 @@ ps3_event_proc_without_details(struct ps3_instance *instance, if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u Event type %s proc NOK!\n", - PS3_HOST(instance), - ps3_event_print((enum MgrEvtType)event_type)); + PS3_HOST(instance), + ps3_event_print((MgrEvtType_e)event_type)); event_proc_result_bitmap |= event_type; } @@ -314,48 +298,45 @@ ps3_event_proc_without_details(struct ps3_instance *instance, } static void ps3_event_details_pre_proc(struct ps3_instance *instance, - struct PS3EventInfo *event_info, - struct ps3_cmd *cmd) + struct PS3EventInfo *event_info, struct ps3_cmd *cmd) { - unsigned int idx = 0; - struct PS3MgrReqFrame *mgr_req_frame = NULL; + U32 idx = 0; + PS3MgrReqFrame_s *mgr_req_frame = NULL; struct PS3MgrEvent *event_req_info = NULL; struct PS3EventDetail *event_detail = NULL; - mgr_req_frame = (struct PS3MgrReqFrame *)cmd->req_frame; + mgr_req_frame = (PS3MgrReqFrame_s *)cmd->req_frame; event_req_info = (struct PS3MgrEvent *)&mgr_req_frame->value.event; - for (idx = 0; idx < event_info->eventCount; idx++) { + for(idx = 0;idx < event_info->eventCount;idx++) { event_detail = &event_info->eventDetail[idx]; if (event_detail->eventType & - event_req_info->eventTypeMapProcResult) { - LOG_INFO( - "trace_id[0x%llx], hno:%u Event type %s code %s with\n" - "\ttimestamp[%d] dev id[0x%x] magic %#x do not process in details!\n", - cmd->trace_id, PS3_HOST(instance), - ps3_event_print(event_detail->eventType), - mgrEvtCodeTrans(event_detail->eventCode), - event_detail->timestamp, - event_detail->devicePos.diskDev.diskID, - event_detail->devicePos.diskMagicNum); + event_req_info->eventTypeMapProcResult) { + LOG_INFO("trace_id[0x%llx], hno:%u Event type %s code %s with " + "timestamp[%d] dev id[0x%x] magic %#x do not process in details!\n", + cmd->trace_id, PS3_HOST(instance), + ps3_event_print(event_detail->eventType), + mgrEvtCodeTrans(event_detail->eventCode), + event_detail->timestamp, + event_detail->devicePos.diskDev.diskID, + event_detail->devicePos.diskMagicNum); event_detail->eventType = PS3_EVT_ILLEGAL_TYPE; continue; } - if (event_detail->eventType == PS3_EVT_CTRL_INFO) { + if (event_detail->eventType == + PS3_EVT_CTRL_INFO) { event_detail->eventType = PS3_EVT_ILLEGAL_TYPE; continue; } event_info->eventTypeMap &= (~event_detail->eventType); - LOG_INFO( - "trace_id[0x%llx], hno:%u Event type %s code %s reports\n" - "\tin details with timestamp %d dev id 0x%x magic %#x!\n", + LOG_INFO("trace_id[0x%llx], hno:%u Event type %s code %s reports " + "in details with timestamp %d dev id 0x%x magic %#x!\n", cmd->trace_id, PS3_HOST(instance), ps3_event_print(event_detail->eventType), - mgrEvtCodeTrans(event_detail->eventCode), - event_detail->timestamp, + mgrEvtCodeTrans(event_detail->eventCode), event_detail->timestamp, event_detail->devicePos.diskDev.diskID, event_detail->devicePos.diskMagicNum); } @@ -363,38 +344,36 @@ static void ps3_event_details_pre_proc(struct ps3_instance *instance, event_info->eventTypeMap |= event_req_info->eventTypeMapProcResult; } -static unsigned int ps3_event_proc_with_details(struct ps3_instance *instance, - struct PS3EventInfo *event_info, - struct ps3_cmd *cmd) +static U32 ps3_event_proc_with_details(struct ps3_instance *instance, + struct PS3EventInfo *event_info, struct ps3_cmd *cmd) { - unsigned int event_proc_result_bitmap = 0; + U32 event_proc_result_bitmap = 0; ps3_event_details_pre_proc(instance, event_info, cmd); #ifndef _WINDOWS - event_proc_result_bitmap |= ps3_sas_update_detail_proc( - instance, event_info->eventDetail, event_info->eventCount); + event_proc_result_bitmap |= ps3_sas_update_detail_proc(instance, + event_info->eventDetail, event_info->eventCount); #endif - event_proc_result_bitmap = ps3_dev_update_detail_proc( - instance, event_info->eventDetail, event_info->eventCount); + event_proc_result_bitmap = ps3_dev_update_detail_proc(instance, + event_info->eventDetail, event_info->eventCount); return event_proc_result_bitmap; } static void ps3_event_delay(struct ps3_instance *instance, - struct ps3_event_delay_work *delay_work) + struct ps3_event_delay_work *delay_work) { struct ps3_cmd *cmd = delay_work->cmd; - unsigned int event_delay = 0; + U32 event_delay = 0; event_delay = delay_work->event_delay; - LOG_WARN( - "trace_id[0x%llx], hno:%u Event handle will delay %d seconds\n", + LOG_WARN("trace_id[0x%llx], hno:%u Event handle will delay %d seconds\n", cmd->trace_id, PS3_HOST(instance), event_delay); while (event_delay > 0) { - if (kthread_should_stop() || delay_work->event_delay == 0) { - LOG_WARN( - "trace_id[0x%llx], hno:%u Event handle delay cancel\n", + if (kthread_should_stop() || + delay_work->event_delay == 0){ + LOG_WARN("trace_id[0x%llx], hno:%u Event handle delay cancel\n", cmd->trace_id, PS3_HOST(instance)); return; } @@ -403,8 +382,7 @@ static void ps3_event_delay(struct ps3_instance *instance, schedule_timeout(HZ); event_delay--; } - LOG_WARN( - "trace_id[0x%llx], hno:%u Event handle delay %d seconds timeout\n", + LOG_WARN("trace_id[0x%llx], hno:%u Event handle delay %d seconds timeout\n", cmd->trace_id, PS3_HOST(instance), delay_work->event_delay); } @@ -412,37 +390,40 @@ void ps3_event_handle(struct ps3_event_delay_work *ps3_delay_work) { struct ps3_cmd *cmd = ps3_delay_work->cmd; struct ps3_instance *instance = cmd->instance; - struct PS3EventInfo *event_info = instance->event_context.event_info; - unsigned int event_proc_result_bitmap = PS3_EVT_ILLEGAL_TYPE; - struct ps3_event_delay_work *ps3_new_delay_work = NULL; - unsigned long flags = 0; - int ret; + struct PS3EventInfo* event_info = instance->event_context.event_info; + U32 event_proc_result_bitmap = PS3_EVT_ILLEGAL_TYPE; + struct ps3_event_delay_work* ps3_new_delay_work = NULL; + ULong flags = 0; + S32 ret; + INJECT_START(PS3_ERR_IJ_EVENT_CMD_NULL, instance); if (instance->event_context.event_cmd == NULL) { LOG_WARN("trace_id[0x%llx], hno:%u Event is unsubscribed\n", - cmd->trace_id, PS3_HOST(instance)); + cmd->trace_id, PS3_HOST(instance)); return; } if (!instance->state_machine.is_load) { - LOG_WARN( - "trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", + LOG_WARN("trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", cmd->trace_id, PS3_HOST(instance)); return; } LOG_INFO("trace_id[0x%llx], hno:%u event count[%d], bitmap[%08x]\n", - cmd->trace_id, PS3_HOST(instance), event_info->eventCount, - event_info->eventTypeMap); + cmd->trace_id, PS3_HOST(instance), event_info->eventCount, + event_info->eventTypeMap); + INJECT_START(PS3_ERR_IJ_EVENT_PROC_WAIT_HARD_FLAG, instance) + INJECT_START(PS3_ERR_IJ_EVENT_PROC_WAIT_HARD_SUBCRIBE, instance) #ifndef _WINDOWS - if (ps3_delay_work->event_delay) + if (ps3_delay_work->event_delay) { ps3_event_delay(instance, ps3_delay_work); + } #endif + INJECT_START(PS3_ERR_IJ_WAIT_NORMAL, instance) if (event_info->eventCount <= PS3_EVENT_DETAIL_BUF_MAX) { - LOG_INFO( - "trace_id[0x%llx], hno:%u Event has valid details info!\n", + LOG_INFO("trace_id[0x%llx], hno:%u Event has valid details info!\n", cmd->trace_id, PS3_HOST(instance)); event_proc_result_bitmap |= ps3_event_proc_with_details(instance, event_info, cmd); @@ -452,89 +433,83 @@ void ps3_event_handle(struct ps3_event_delay_work *ps3_delay_work) event_proc_result_bitmap |= ps3_event_proc_without_details(instance, event_info); } + PS3_IJ_SLEEP(5000, PS3_ERR_IJ_EVENT_DELAY); memset(event_info, 0, sizeof(*event_info)); ps3_event_print_cmd(cmd, PS3_TRUE); - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags); - if (ps3_atomic_read(&instance->event_context.abort_eventcmd) == 0 && - ps3_atomic_read(&instance->hardreset_event) == 0) { + INJECT_START(PS3_ERR_IJ_EVENT_SUBC_WAIT_HARD_FLAG, instance) + INJECT_START(PS3_ERR_IJ_EVENT_SUBC_WAIT_HARD_SUBCRIBE, instance) + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); + if (instance->event_context.abort_eventcmd == 0 && + instance->hardreset_event == 0) { ps3_new_delay_work = - (ps3_delay_work == - &instance->event_context - .delay_work_pool[PS3_EVENT_WORKER_POOL_SIZE - - 1]) ? - (&instance->event_context.delay_work_pool[0]) : - (ps3_delay_work + 1); + (ps3_delay_work == &instance->event_context.delay_work_pool[PS3_EVENT_WORKER_POOL_SIZE - 1])? + (&instance->event_context.delay_work_pool[0]):(ps3_delay_work + 1); instance->event_context.delay_work = ps3_new_delay_work; ps3_event_resubscribe(instance, cmd, event_proc_result_bitmap); - if (ps3_atomic_read(&instance->event_context.subwork) != 0) - ps3_atomic_dec(&instance->event_context.subwork); - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags); + if (instance->event_context.subwork != 0) { + instance->event_context.subwork -= 1; + } + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); } else { - LOG_INFO_IN_IRQ( - instance, + LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx], hno:%u Event proc free cmd:%d, abort_eventcmd %d!\n", cmd->trace_id, PS3_HOST(instance), cmd->index, - ps3_atomic_read(&instance->event_context.abort_eventcmd)); + instance->event_context.abort_eventcmd); instance->event_context.event_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); ps3_new_delay_work = - (ps3_delay_work == - &instance->event_context - .delay_work_pool[PS3_EVENT_WORKER_POOL_SIZE - - 1]) ? - (&instance->event_context.delay_work_pool[0]) : - (ps3_delay_work + 1); + (ps3_delay_work == &instance->event_context.delay_work_pool[PS3_EVENT_WORKER_POOL_SIZE - 1])? + (&instance->event_context.delay_work_pool[0]):(ps3_delay_work + 1); instance->event_context.delay_work = ps3_new_delay_work; - instance->event_req_info.eventTypeMapProcResult = - instance->event_req_info.eventTypeMap; + instance->event_req_info.eventTypeMapProcResult = instance->event_req_info.eventTypeMap; ret = ps3_event_subscribe(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR_IN_IRQ(instance, - "hno:%u event subscribe failed!\n", - PS3_HOST(instance)); + LOG_ERROR_IN_IRQ(instance, "hno:%u event subscribe failed!\n", + PS3_HOST(instance)); } - if (ps3_atomic_read(&instance->hardreset_event) != 0) - ps3_atomic_set(&instance->hardreset_event, 0); + if(instance->hardreset_event != 0) { + instance->hardreset_event = 0; + } - if (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0) - ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); - wmb(); /* in order to force CPU ordering */ - if (ps3_atomic_read(&instance->event_context.subwork) != 0) - ps3_atomic_dec(&instance->event_context.subwork); - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags); + if(instance->event_context.abort_eventcmd != 0) { + instance->event_context.abort_eventcmd = 0; + } + wmb(); + if (instance->event_context.subwork != 0) { + instance->event_context.subwork -= 1; + } + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); } + + return; } #ifdef _WINDOWS static void ps3_event_polling(void *ins) { - struct ps3_instance *instance = (struct ps3_instance *)ins; - + struct ps3_instance *instance = (struct ps3_instance*)ins; ps3_event_handle(&instance->event_context.delay_work); } #else static void ps3_event_polling(struct work_struct *work) { - struct ps3_event_delay_work *delay_work = ps3_container_of( - work, struct ps3_event_delay_work, event_work.work); + struct ps3_event_delay_work *delay_work = ps3_container_of(work, + struct ps3_event_delay_work, event_work.work); ps3_event_handle(delay_work); } #endif -const char *ps3_event_print(enum MgrEvtType event_type) +const char *ps3_event_print(MgrEvtType_e event_type) { - unsigned int idx = 0; + U32 idx = 0; const char *ps3_event_type_name = NULL; - for (idx = 0; idx < ARRAY_SIZE(g_event_type_desc_table); idx++) { + for (idx = 0;idx < ARRAY_SIZE(g_event_type_desc_table);idx++) { if (g_event_type_desc_table[idx].event_type == event_type) { - ps3_event_type_name = - g_event_type_desc_table[idx].event_type_desc; + ps3_event_type_name + = g_event_type_desc_table[idx].event_type_desc; break; } } @@ -542,45 +517,44 @@ const char *ps3_event_print(enum MgrEvtType event_type) return ps3_event_type_name; } -int ps3_event_context_init(struct ps3_instance *instance) +S32 ps3_event_context_init(struct ps3_instance *instance) { - int ret = -PS3_FAILED; - unsigned int idx = 0; + S32 ret = -PS3_FAILED; + U32 idx = 0; struct ps3_event_context *event_ctx = &instance->event_context; struct ps3_event_delay_work *delay_work = NULL; struct ps3_event_delay_work *delay_work_pool = NULL; - memset(event_ctx, 0, sizeof(*event_ctx)); #ifndef _WINDOWS - delay_work_pool = (struct ps3_event_delay_work *)ps3_kzalloc( - instance, sizeof(struct ps3_event_delay_work) * - PS3_EVENT_WORKER_POOL_SIZE); + delay_work_pool = (struct ps3_event_delay_work *)ps3_kzalloc(instance, + sizeof(struct ps3_event_delay_work) * PS3_EVENT_WORKER_POOL_SIZE); + INJECT_START(PS3_ERR_IJ_PS3_DELAY_WORK_POOL_ALLOC, &delay_work_pool); if (delay_work_pool == NULL) { LOG_ERROR("hno:%u delay work kzalloc failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } event_ctx->delay_work_pool = delay_work_pool; - for (idx = 0; idx < PS3_EVENT_WORKER_POOL_SIZE; idx++) { + for(idx = 0; idx < PS3_EVENT_WORKER_POOL_SIZE; idx++){ delay_work = &delay_work_pool[idx]; INIT_DELAYED_WORK(&delay_work->event_work, ps3_event_polling); } event_ctx->delay_work = &delay_work_pool[0]; event_ctx->event_cmd = NULL; event_ctx->event_abort_cmd = NULL; - ps3_atomic_set(&event_ctx->abort_eventcmd, 0); + event_ctx->abort_eventcmd = 0; event_ctx->flag = PS3_FALSE; #else delay_work = &event_ctx->delay_work; - if (ps3_worker_init(instance, &delay_work->event_work, "ps3_event_wk", - ps3_event_polling) != PS3_SUCCESS) { - LOG_ERROR("hno:%u worker init failed\n", PS3_HOST(instance)); + if (ps3_worker_init(instance, &delay_work->event_work, "ps3_event_wk", ps3_event_polling) != PS3_SUCCESS) { + LOG_ERROR("hno:%u worker init failed\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } #endif - ps3_atomic_set(&event_ctx->subwork, 0); + event_ctx->subwork = 0; ret = PS3_SUCCESS; l_out: @@ -591,7 +565,7 @@ void ps3_event_context_exit(struct ps3_instance *instance) { struct ps3_event_context *event_ctx = &instance->event_context; #ifdef _WINDOWS - struct ps3_event_delay_work *delay_work = NULL; + struct ps3_event_delay_work* delay_work = NULL; delay_work = &event_ctx->delay_work; ps3_worker_exit(&delay_work->event_work); @@ -599,62 +573,58 @@ void ps3_event_context_exit(struct ps3_instance *instance) if (event_ctx->delay_work_pool != NULL) { ps3_kfree(instance, event_ctx->delay_work_pool); event_ctx->delay_work_pool = NULL; - event_ctx->delay_work = NULL; + event_ctx->delay_work = NULL; } #endif memset(event_ctx, 0, sizeof(*event_ctx)); } -int ps3_event_subscribe(struct ps3_instance *instance) +S32 ps3_event_subscribe(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_event_context *event_ctx = &instance->event_context; struct PS3MgrEvent *event_req_info = &instance->event_req_info; if (!instance->is_need_event) { LOG_WARN_IN_IRQ(instance, "hno:%u IOC no need event!!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } if (event_ctx->event_cmd != NULL) { LOG_ERROR_IN_IRQ(instance, "hno:%u Event already subscribe!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } if (!instance->state_machine.is_load) { - LOG_WARN_IN_IRQ( - instance, - "hno:%u instance is suspend or instance unload!\n", + LOG_WARN_IN_IRQ(instance, "hno:%u instance is suspend or instance unload!\n", PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } ret = ps3_event_register(instance, event_req_info); + INJECT_START(PS3_ERR_IJ_WAIT_RESUME_EVENT_FAILED, &ret) if (ret != PS3_SUCCESS) { - LOG_WARN_IN_IRQ( - instance, - "hno:%u Failed to register event cmd, ret: %d\n", + LOG_WARN_IN_IRQ(instance, "hno:%u Failed to register event cmd, ret: %d\n", PS3_HOST(instance), ret); goto l_out; } - LOG_INFO_IN_IRQ(instance, - "hno:%u Success to subscribe event, bitmap[%08x]!\n", - PS3_HOST(instance), event_req_info->eventTypeMap); + LOG_INFO_IN_IRQ(instance, "hno:%u Success to subscribe event, bitmap[%08x]!\n", + PS3_HOST(instance), event_req_info->eventTypeMap); l_out: return ret; } -int ps3_event_unsubscribe(struct ps3_instance *instance) +S32 ps3_event_unsubscribe(struct ps3_instance *instance) { - unsigned long flags = 0; - unsigned long flags1 = 0; - int ret = -PS3_FAILED; + ULong flags = 0; + ULong flags1 = 0; + S32 ret = -PS3_FAILED; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; struct ps3_event_context *event_ctx = &instance->event_context; @@ -664,190 +634,163 @@ int ps3_event_unsubscribe(struct ps3_instance *instance) goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - if (event_ctx->flag) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + if(event_ctx->flag){ + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); goto l_out; } event_ctx->flag = PS3_TRUE; cmd = event_ctx->event_cmd; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); if (cmd == NULL) { LOG_WARN("hno:%u Event is not register yet\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + INJECT_START(PS3_ERR_IJ_SUBC_EVENT_CMD_INIT, instance) if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("hno:%u had been free,CFID:%d\n", PS3_HOST(instance), - cmd->index); - ps3_spin_lock_irqsave( - &instance->recovery_context->recovery_lock, &flags1); + LOG_WARN("hno:%u had been free,CFID:%d\n", + PS3_HOST(instance), cmd->index); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); event_ctx->event_cmd = NULL; - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); ret = PS3_SUCCESS; goto l_out; } else { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, - PS3_CANCEL_EVENT_CMD); - if (ret == -PS3_ENOMEM) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); - LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_EVENT_CMD); + INJECT_START(PS3_ERR_IJ_CANCEL_EVENT_CMD_FAIL, &ret) + if(ret == -PS3_ENOMEM){ + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); ret = PS3_FAILED; goto l_out; - } else if (ret != PS3_SUCCESS) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); + }else if(ret != PS3_SUCCESS){ + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), - ps3_cmd_frame_id( - instance->event_context.event_abort_cmd), - cmd->index); + PS3_HOST(instance), ps3_cmd_frame_id(instance->event_context.event_abort_cmd), cmd->index); abort_cmd = instance->event_context.event_abort_cmd; instance->event_context.event_abort_cmd = NULL; - if (abort_cmd != NULL) + if (abort_cmd != NULL) { ps3_task_cmd_free(instance, abort_cmd); + } ret = PS3_FAILED; goto l_out; } - ps3_atomic_set(&instance->event_context.abort_eventcmd, 1); - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + instance->event_context.abort_eventcmd = 1; + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_EVENT_CMD); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u event cancel cmd NOK, ret:%d\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - if (ps3_atomic_read(&instance->event_context.subwork) == 0) { - if (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0) { - ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + if(instance->event_context.subwork == 0){ + if(instance->event_context.abort_eventcmd != 0){ + instance->event_context.abort_eventcmd = 0; LOG_FILE_INFO("hno:%u event cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); event_ctx->event_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); } } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); l_out: - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); event_ctx->flag = PS3_FALSE; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); return ret; } -int ps3_soft_reset_event_resubscribe(struct ps3_instance *instance) +S32 ps3_soft_reset_event_resubscribe(struct ps3_instance *instance) { - unsigned long flags = 0; - unsigned long flags1 = 0; - int ret = -PS3_FAILED; + ULong flags = 0; + ULong flags1 = 0; + S32 ret = -PS3_FAILED; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; struct ps3_event_context *event_ctx = &instance->event_context; - unsigned char is_need_resend = PS3_FALSE; + Bool is_need_resend = PS3_FALSE; if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { ret = -PS3_FAILED; goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - if (event_ctx->flag) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + if(event_ctx->flag){ + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); goto l_out; } event_ctx->flag = PS3_TRUE; cmd = event_ctx->event_cmd; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); if (cmd == NULL) { LOG_WARN("hno:%u Event is not register yet\n", - PS3_HOST(instance)); - ps3_spin_lock_irqsave( - &instance->recovery_context->recovery_lock, &flags1); + PS3_HOST(instance)); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); is_need_resend = PS3_TRUE; goto l_resend; } ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + INJECT_START(PS3_ERR_IJ_RESUBC_EVENT_CMD_INIT, instance) if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("hno:%u had been free,CFID:%d\n", PS3_HOST(instance), - cmd->index); - ps3_spin_lock_irqsave( - &instance->recovery_context->recovery_lock, &flags1); + LOG_WARN("hno:%u had been free,CFID:%d\n", + PS3_HOST(instance), cmd->index); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); event_ctx->event_cmd = NULL; - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); ret = PS3_SUCCESS; goto l_out; } else { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, - PS3_CANCEL_EVENT_CMD); - if (ret == -PS3_ENOMEM) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); - LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_EVENT_CMD); + if (ret == -PS3_ENOMEM){ + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); ret = PS3_FAILED; goto l_out; - } else if (ret != PS3_SUCCESS) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); + } else if (ret != PS3_SUCCESS){ + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), - ps3_cmd_frame_id( - instance->event_context.event_abort_cmd), - cmd->index); + PS3_HOST(instance), ps3_cmd_frame_id(instance->event_context.event_abort_cmd), cmd->index); abort_cmd = instance->event_context.event_abort_cmd; instance->event_context.event_abort_cmd = NULL; - if (abort_cmd != NULL) + if (abort_cmd != NULL) { ps3_task_cmd_free(instance, abort_cmd); + } ret = PS3_FAILED; goto l_out; } - ps3_atomic_set(&instance->event_context.abort_eventcmd, 1); - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + instance->event_context.abort_eventcmd = 1; + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_EVENT_CMD); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u event cancel cmd failed, ret:%d\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - if (ps3_atomic_read(&instance->event_context.subwork) == 0) { - if (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0) { - ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + if(instance->event_context.subwork == 0){ + if(instance->event_context.abort_eventcmd != 0){ + instance->event_context.abort_eventcmd = 0; LOG_FILE_INFO("hno:%u event cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); event_ctx->event_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); @@ -862,27 +805,24 @@ int ps3_soft_reset_event_resubscribe(struct ps3_instance *instance) ret = ps3_event_subscribe(instance); if ((ret != PS3_SUCCESS) && (ret != -PS3_IN_UNLOAD)) { LOG_FILE_ERROR("hno:%u event subscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_FAILED; } } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); l_out: - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); event_ctx->flag = PS3_FALSE; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); return ret; } -int ps3_event_service(struct ps3_cmd *cmd, unsigned short reply_flags) +S32 ps3_event_service(struct ps3_cmd *cmd, U16 reply_flags) { - unsigned long flags = 0; - unsigned long flags1 = 0; - int ret = PS3_SUCCESS; + ULong flags = 0; + ULong flags1 = 0; + S32 ret = PS3_SUCCESS; struct ps3_instance *instance = cmd->instance; struct ps3_event_context *event_ctx = &instance->event_context; #ifdef _WINDOWS @@ -890,37 +830,31 @@ int ps3_event_service(struct ps3_cmd *cmd, unsigned short reply_flags) #else struct ps3_event_delay_work *delay_work = event_ctx->delay_work; #endif - int cur_state = PS3_INSTANCE_STATE_INIT; + S32 cur_state = PS3_INSTANCE_STATE_INIT; PS3_MGR_CMD_BACK_INC(instance, cmd, reply_flags); ps3_event_print_cmd(cmd, PS3_FALSE); if (reply_flags != PS3_REPLY_WORD_FLAG_SUCCESS) { - LOG_ERROR_IN_IRQ( - instance, + LOG_ERROR_IN_IRQ(instance, "trace_id[0x%llx], hno:%u Event notify fetal error!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; goto l_failed; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); if (event_ctx->event_cmd == NULL) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); - LOG_INFO_IN_IRQ( - instance, - "trace_id[0x%llx], hno:%u Event is unsubscribed!\n", + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + LOG_INFO_IN_IRQ(instance, + "trace_id[0x%llx], hno:%u Event is unsubscribed!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); if (!instance->state_machine.is_load) { - LOG_INFO_IN_IRQ( - instance, + LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; @@ -928,9 +862,8 @@ int ps3_event_service(struct ps3_cmd *cmd, unsigned short reply_flags) } cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { - LOG_INFO_IN_IRQ( - instance, + if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { + LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx], hno:%u instance is not operational!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; @@ -940,16 +873,17 @@ int ps3_event_service(struct ps3_cmd *cmd, unsigned short reply_flags) delay_work->cmd = cmd; #ifdef _WINDOWS if (ps3_worker_start(&delay_work->event_work) != PS3_SUCCESS) { - LOG_ERROR_IN_IRQ( - instance, + LOG_ERROR_IN_IRQ(instance, "trace_id[0x%llx], hno:%u Event start worker failed!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; goto l_failed; } - ps3_atomic_inc(&instance->event_context.subwork); + instance->event_context.subwork += 1; #else - ps3_atomic_inc(&instance->event_context.subwork); + INJECT_START(PS3_ERR_IJ_EVENT_INT_WAIT_HARD_FLAG, instance) + INJECT_START(PS3_ERR_IJ_EVENT_INT_WAIT_HARD_SUBCRIBE, instance) + instance->event_context.subwork += 1; schedule_delayed_work(&delay_work->event_work, 0); #endif goto l_out; @@ -958,393 +892,366 @@ int ps3_event_service(struct ps3_cmd *cmd, unsigned short reply_flags) ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); cmd->cmd_state.state = PS3_CMD_STATE_DEAD; ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx],CFID[%d], hno:%u failed!\n", - cmd->trace_id, cmd->index, PS3_HOST(instance)); + LOG_INFO_IN_IRQ(instance, + "trace_id[0x%llx],CFID[%d], hno:%u failed!\n", + cmd->trace_id, cmd->index, PS3_HOST(instance)); l_out: - LOG_INFO_IN_IRQ(instance, "instance->event_context.subwork[%u]!\n", - ps3_atomic_read(&instance->event_context.subwork)); + LOG_INFO_IN_IRQ(instance, + "instance->event_context.subwork[%u]!\n", + instance->event_context.subwork); return ret; } -int ps3_fasync(int fd, struct file *filp, int mode) +S32 ps3_fasync(int fd, struct file *filp, int mode) { - return fasync_helper(fd, filp, mode, &g_async_queue); + return fasync_helper(fd, filp, mode, &g_async_queue); } -int ps3_webSubscribe_context_init(struct ps3_instance *instance) +S32 ps3_webSubscribe_context_init(struct ps3_instance *instance) { - int ret = -PS3_FAILED; - struct ps3_webSubscribe_context *web_context = - &instance->webSubscribe_context; - - memset(web_context, 0, sizeof(*web_context)); - web_context->webSubscribe_cmd = NULL; - web_context->web_abort_cmd = NULL; - ps3_atomic_set(&web_context->subscribe_count, PS3_WEB_FLAG_INIT_VALUE); - ps3_atomic_set(&web_context->is_subscribe, PS3_WEB_FLAG_INIT_VALUE); - ps3_atomic_set(&web_context->is_abort, PS3_WEB_FLAG_INIT_VALUE); - ps3_atomic_set(&web_context->abort_webcmd, PS3_WEB_FLAG_INIT_VALUE); - ret = PS3_SUCCESS; - return ret; + S32 ret = -PS3_FAILED; + struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; + memset(web_context, 0, sizeof(*web_context)); + web_context->webSubscribe_cmd = NULL; + web_context->web_abort_cmd = NULL; + ps3_atomic_set(&web_context->subscribe_count, PS3_WEB_FLAG_INIT_VALUE); + ps3_atomic_set(&web_context->is_subscribe, PS3_WEB_FLAG_INIT_VALUE); + ps3_atomic_set(&web_context->is_abort, PS3_WEB_FLAG_INIT_VALUE); + web_context->abort_webcmd = PS3_WEB_FLAG_INIT_VALUE; + ret = PS3_SUCCESS; + return ret; } void ps3_webSubscribe_context_exit(struct ps3_instance *instance) { - struct ps3_webSubscribe_context *web_context = - &instance->webSubscribe_context; - - memset(web_context, 0, sizeof(*web_context)); + struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; + memset(web_context, 0, sizeof(*web_context)); } -static void ps3_web_resubscribe(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static void ps3_web_resubscribe(struct ps3_instance *instance, struct ps3_cmd *cmd) { - unsigned long flags = 0; + ULong flags = 0; + PS3_MGR_CMD_STAT_INC(instance, cmd); - PS3_MGR_CMD_STAT_INC(instance, cmd); - - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); if (ps3_async_cmd_send(cmd->instance, cmd) != PS3_SUCCESS) { - LOG_ERROR_IN_IRQ( - instance, - "trace_id[0x%llx],CFID[%d],hno:%u resend web cmd NOK\n", - cmd->trace_id, cmd->index, PS3_HOST(cmd->instance)); - - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - cmd->cmd_state.state = PS3_CMD_STATE_DEAD; - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - } + LOG_ERROR_IN_IRQ(instance, "trace_id[0x%llx],CFID[%d],hno:%u resend web cmd NOK\n", + cmd->trace_id,cmd->index, PS3_HOST(cmd->instance)); + + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + } + return; } -int ps3_webSubscribe_service(struct ps3_cmd *cmd, unsigned short reply_flags) +S32 ps3_webSubscribe_service(struct ps3_cmd *cmd, U16 reply_flags) { - unsigned long flags = 0; - int ret = PS3_SUCCESS; - struct ps3_instance *instance = cmd->instance; - struct ps3_webSubscribe_context *web_context = - &instance->webSubscribe_context; - - int cur_state = PS3_INSTANCE_STATE_INIT; - - PS3_MGR_CMD_BACK_INC(instance, cmd, reply_flags); - ps3_event_print_cmd(cmd, PS3_FALSE); - - if (reply_flags == PS3_REPLY_WORD_FLAG_FAIL) { - LOG_ERROR_IN_IRQ( - instance, - "trace_id[0x%llx], hno:%u Web notify fetal error!\n", - cmd->trace_id, PS3_HOST(instance)); - ret = -PS3_FAILED; - goto l_failed; - } - - if (web_context->webSubscribe_cmd == NULL) { - LOG_INFO_IN_IRQ( - instance, - "trace_id[0x%llx], hno:%u Web is unsubscribed!\n", - cmd->trace_id, PS3_HOST(instance)); - ret = -PS3_FAILED; - goto l_out; - } - - if (!instance->state_machine.is_load) { - LOG_INFO_IN_IRQ( - instance, - "trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", - cmd->trace_id, PS3_HOST(instance)); - ret = -PS3_FAILED; - goto l_failed; - } - - cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { - LOG_INFO_IN_IRQ( - instance, - "trace_id[0x%llx], hno:%u instance is not operational!\n", - cmd->trace_id, PS3_HOST(instance)); - ret = -PS3_FAILED; - goto l_failed; - } - - kill_fasync(&g_async_queue, PS3_EVENT_NOTICE_SIG, POLL_IN); - - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags); - if (ps3_atomic_read(&instance->webSubscribe_context.abort_webcmd) == 0) { - ps3_web_resubscribe(instance, cmd); - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags); - } else { - LOG_INFO_IN_IRQ( - instance, - "trace_id[0x%llx], hno:%u Web proc free cmd:%d, abort_webcmd %d!\n", - cmd->trace_id, PS3_HOST(instance), cmd->index, - ps3_atomic_read(&instance->webSubscribe_context.abort_webcmd)); - - instance->webSubscribe_context.webSubscribe_cmd = NULL; - ps3_mgr_cmd_free(instance, cmd); - ret = ps3_web_subscribe(instance); - if (ret != PS3_SUCCESS) { - LOG_ERROR_IN_IRQ(instance, - "hno:%u web subscribe failed!\n", - PS3_HOST(instance)); - } - ps3_atomic_set(&instance->webSubscribe_context.abort_webcmd, 0); - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags); - } - goto l_out; + ULong flags = 0; + S32 ret = PS3_SUCCESS; + struct ps3_instance *instance = cmd->instance; + struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; + + S32 cur_state = PS3_INSTANCE_STATE_INIT; + + PS3_MGR_CMD_BACK_INC(instance, cmd, reply_flags); + ps3_event_print_cmd(cmd, PS3_FALSE); + + if (reply_flags == PS3_REPLY_WORD_FLAG_FAIL) { + LOG_ERROR_IN_IRQ(instance, + "trace_id[0x%llx], hno:%u Web notify fetal error!\n", + cmd->trace_id, PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_failed; + } + + if (web_context->webSubscribe_cmd == NULL) { + LOG_INFO_IN_IRQ(instance, + "trace_id[0x%llx], hno:%u Web is unsubscribed!\n", + cmd->trace_id, PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_out; + } + + if (!instance->state_machine.is_load) { + LOG_INFO_IN_IRQ(instance, + "trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", + cmd->trace_id, PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_failed; + } + + cur_state = ps3_atomic_read(&instance->state_machine.state); + if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { + LOG_INFO_IN_IRQ(instance, + "trace_id[0x%llx], hno:%u instance is not operational!\n", + cmd->trace_id, PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_failed; + } + + kill_fasync(&g_async_queue, PS3_EVENT_NOTICE_SIG, POLL_IN); + + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); + if (instance->webSubscribe_context.abort_webcmd == 0) { + ps3_web_resubscribe(instance, cmd); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + } else { + LOG_INFO_IN_IRQ(instance, + "trace_id[0x%llx], hno:%u Web proc free cmd:%d, abort_webcmd %d!\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, + instance->webSubscribe_context.abort_webcmd); + + instance->webSubscribe_context.webSubscribe_cmd = NULL; + ps3_mgr_cmd_free(instance, cmd); + ret = ps3_web_subscribe(instance); + if (ret != PS3_SUCCESS) { + LOG_ERROR_IN_IRQ(instance, + "hno:%u web subscribe failed!\n", + PS3_HOST(instance)); + } + instance->webSubscribe_context.abort_webcmd = 0; + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + } + goto l_out; l_failed: - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - cmd->cmd_state.state = PS3_CMD_STATE_DEAD; - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx],CFID[%d], hno:%u failed!\n", - cmd->trace_id, cmd->index, PS3_HOST(instance)); + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + LOG_INFO_IN_IRQ(instance, + "trace_id[0x%llx],CFID[%d], hno:%u failed!\n", + cmd->trace_id, cmd->index, PS3_HOST(instance)); l_out: - return ret; + return ret; } -int ps3_web_subscribe(struct ps3_instance *instance) +S32 ps3_web_subscribe(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - + S32 ret = PS3_SUCCESS; if (!instance->is_need_event) { LOG_WARN_IN_IRQ(instance, "hno:%u ioc no need web server!!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - ret = ps3_web_register(instance); - if (ret != PS3_SUCCESS) { - LOG_WARN_IN_IRQ(instance, - "hno:%u Failed to register web cmd, ret: %d\n", - PS3_HOST(instance), ret); - goto l_out; - } + ret = ps3_web_register(instance); + if (ret != PS3_SUCCESS) { + LOG_WARN_IN_IRQ(instance, "hno:%u Failed to register web cmd, ret: %d\n", + PS3_HOST(instance), ret); + goto l_out; + } LOG_INFO_IN_IRQ(instance, "hno:%u Success to subscribe web event\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: - return ret; + return ret; } -int ps3_web_unsubscribe(struct ps3_instance *instance) +S32 ps3_web_unsubscribe(struct ps3_instance *instance) { - unsigned long flags = 0; - int ret = -PS3_FAILED; - struct ps3_cmd *cmd = NULL; - struct ps3_cmd *abort_cmd = NULL; - struct ps3_webSubscribe_context *web_context = - &instance->webSubscribe_context; - - if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { - ret = -PS3_FAILED; - goto l_out; - } - cmd = web_context->webSubscribe_cmd; - if (cmd == NULL) { - LOG_WARN("hno:%u web event is not register yet\n", - PS3_HOST(instance)); - ret = PS3_SUCCESS; - goto l_out; - } - - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("hno:%u had been free,CFID:%d\n", PS3_HOST(instance), - cmd->index); - web_context->webSubscribe_cmd = NULL; - ret = PS3_SUCCESS; - goto l_out; - } else { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - } - - if (ps3_atomic_add_unless(&instance->webSubscribe_context.is_abort, 1, - 1) == 0) { - ret = PS3_SUCCESS; - goto l_out; - } - - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_WEB_CMD); - if (ret == -PS3_ENOMEM) { - LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); - ret = -PS3_FAILED; - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } else if (ret != PS3_SUCCESS) { - LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), - ps3_cmd_frame_id( - instance->webSubscribe_context.web_abort_cmd), - cmd->index); - abort_cmd = instance->webSubscribe_context.web_abort_cmd; - instance->webSubscribe_context.web_abort_cmd = NULL; - if (abort_cmd != NULL) - ps3_task_cmd_free(instance, abort_cmd); - ret = -PS3_FAILED; - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } - ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_WEB_CMD); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u event cancel cmd NOK, ret:%d\n", - PS3_HOST(instance), ret); - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } - LOG_INFO("hno:%u web cmd free, CFID:%d\n", PS3_HOST(instance), - cmd->index); - web_context->webSubscribe_cmd = NULL; - ps3_mgr_cmd_free(instance, cmd); - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + ULong flags = 0; + S32 ret = -PS3_FAILED; + struct ps3_cmd *cmd = NULL; + struct ps3_cmd *abort_cmd = NULL; + struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; + + if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { + ret = -PS3_FAILED; + goto l_out; + } + cmd = web_context->webSubscribe_cmd; + if (cmd == NULL) { + LOG_WARN("hno:%u web event is not register yet\n", + PS3_HOST(instance)); + ret = PS3_SUCCESS; + goto l_out; + } + + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + LOG_WARN("hno:%u had been free,CFID:%d\n", + PS3_HOST(instance), cmd->index); + web_context->webSubscribe_cmd = NULL; + ret = PS3_SUCCESS; + goto l_out; + } else { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + } + + if (ps3_atomic_add_unless(&instance->webSubscribe_context.is_abort, 1, 1) == 0) { + ret = PS3_SUCCESS; + goto l_out; + } + + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_WEB_CMD); + INJECT_START(PS3_ERR_IJ_CANCEL_WEB_CMD_ALLOC_NULL, &ret) + if(ret == -PS3_ENOMEM){ + LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); + ret = -PS3_FAILED; + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } else if(ret != PS3_SUCCESS) { + LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", + PS3_HOST(instance), ps3_cmd_frame_id(instance->webSubscribe_context.web_abort_cmd), cmd->index); + abort_cmd = instance->webSubscribe_context.web_abort_cmd; + instance->webSubscribe_context.web_abort_cmd = NULL; + if (abort_cmd != NULL) { + ps3_task_cmd_free(instance, abort_cmd); + } + ret = -PS3_FAILED; + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } + ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_WEB_CMD); + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_1, &ret) + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u event cancel cmd NOK, ret:%d\n", + PS3_HOST(instance), ret); + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } + LOG_INFO("hno:%u web cmd free, CFID:%d\n", + PS3_HOST(instance), cmd->index); + web_context->webSubscribe_cmd = NULL; + ps3_mgr_cmd_free(instance, cmd); + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); l_out: - return ret; + return ret; } -int ps3_soft_reset_web_resubscribe(struct ps3_instance *instance) +S32 ps3_soft_reset_web_resubscribe(struct ps3_instance *instance) { - unsigned long flags = 0; - unsigned long flags1 = 0; - int ret = -PS3_FAILED; - struct ps3_cmd *cmd = NULL; - struct ps3_cmd *abort_cmd = NULL; - struct ps3_webSubscribe_context *web_context = - &instance->webSubscribe_context; - unsigned char is_need_resend = PS3_FALSE; - - if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { - ret = -PS3_FAILED; - goto l_out; - } - - cmd = web_context->webSubscribe_cmd; - if (cmd == NULL) { - LOG_WARN("hno:%u Web is not register yet\n", - PS3_HOST(instance)); - is_need_resend = PS3_TRUE; - ps3_spin_lock_irqsave( - &instance->recovery_context->recovery_lock, &flags1); - goto l_resend; - } - - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("hno:%u had been free,CFID:%d\n", PS3_HOST(instance), - cmd->index); - web_context->webSubscribe_cmd = NULL; - ret = PS3_SUCCESS; - goto l_out; - } else { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - } - - if (ps3_atomic_add_unless(&instance->webSubscribe_context.is_abort, 1, - 1) == 0) { - ret = PS3_SUCCESS; - goto l_out; - } - - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_WEB_CMD); - if (ret == -PS3_ENOMEM) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); - LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); - ret = -PS3_FAILED; - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } else if (ret != PS3_SUCCESS) { - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, flags1); - LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), - ps3_cmd_frame_id( - instance->webSubscribe_context.web_abort_cmd), - cmd->index); - abort_cmd = instance->webSubscribe_context.web_abort_cmd; - instance->webSubscribe_context.web_abort_cmd = NULL; - if (abort_cmd != NULL) - ps3_task_cmd_free(instance, abort_cmd); - ret = -PS3_FAILED; - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } - ps3_atomic_set(&instance->webSubscribe_context.abort_webcmd, 1); - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); - - ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_WEB_CMD); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u web cancel cmd failed, ret:%d\n", - PS3_HOST(instance), ret); - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags1); - if (ps3_atomic_read(&instance->webSubscribe_context.abort_webcmd) != 0) { - ps3_atomic_set(&instance->webSubscribe_context.abort_webcmd, 0); - LOG_FILE_INFO("hno:%u web cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); - web_context->webSubscribe_cmd = NULL; - ps3_mgr_cmd_free(instance, cmd); - is_need_resend = PS3_TRUE; - } - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + ULong flags = 0; + ULong flags1 = 0; + S32 ret = -PS3_FAILED; + struct ps3_cmd *cmd = NULL; + struct ps3_cmd *abort_cmd = NULL; + struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; + Bool is_need_resend = PS3_FALSE; + + if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { + ret = -PS3_FAILED; + goto l_out; + } + + cmd = web_context->webSubscribe_cmd; + if (cmd == NULL) { + LOG_WARN("hno:%u Web is not register yet\n", + PS3_HOST(instance)); + is_need_resend = PS3_TRUE; + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + goto l_resend; + } + + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + LOG_WARN("hno:%u had been free,CFID:%d\n", + PS3_HOST(instance), cmd->index); + web_context->webSubscribe_cmd = NULL; + ret = PS3_SUCCESS; + goto l_out; + } else { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + } + + if (ps3_atomic_add_unless(&instance->webSubscribe_context.is_abort, 1, 1) == 0) { + ret = PS3_SUCCESS; + goto l_out; + } + + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_WEB_CMD); + if (ret == -PS3_ENOMEM){ + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); + ret = -PS3_FAILED; + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } else if (ret != PS3_SUCCESS) { + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", + PS3_HOST(instance), ps3_cmd_frame_id(instance->webSubscribe_context.web_abort_cmd), cmd->index); + abort_cmd = instance->webSubscribe_context.web_abort_cmd; + instance->webSubscribe_context.web_abort_cmd = NULL; + if (abort_cmd != NULL) { + ps3_task_cmd_free(instance, abort_cmd); + } + ret = -PS3_FAILED; + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } + instance->webSubscribe_context.abort_webcmd = 1; + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + + ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_WEB_CMD); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u web cancel cmd failed, ret:%d\n", + PS3_HOST(instance), ret); + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + if (instance->webSubscribe_context.abort_webcmd != 0){ + instance->webSubscribe_context.abort_webcmd = 0; + LOG_FILE_INFO("hno:%u web cmd free, CFID:%d\n", + PS3_HOST(instance), cmd->index); + web_context->webSubscribe_cmd = NULL; + ps3_mgr_cmd_free(instance, cmd); + is_need_resend = PS3_TRUE; + } + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); l_resend: - if (is_need_resend) { - ret = ps3_web_subscribe(instance); - if ((ret != PS3_SUCCESS) && (ret != -PS3_IN_UNLOAD)) { - LOG_FILE_ERROR("hno:%u web subscribe failed!\n", - PS3_HOST(instance)); - ret = -PS3_FAILED; - } - } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags1); + if (is_need_resend) { + ret = ps3_web_subscribe(instance); + if ((ret != PS3_SUCCESS) && (ret != -PS3_IN_UNLOAD)) { + LOG_FILE_ERROR("hno:%u web subscribe failed!\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; + } + } + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); l_out: - return ret; + return ret; } void ps3_web_cmd_clear(struct ps3_instance *instance) { - unsigned long flags = 0; - struct ps3_cmd *cmd = NULL; - - ps3_atomic_set(&instance->webSubscribe_context.abort_webcmd, 0); - cmd = instance->webSubscribe_context.webSubscribe_cmd; - - if (cmd == NULL) { - LOG_WARN("hno:%u web cmd has been cancel\n", - PS3_HOST(instance)); - goto l_out; - } - - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("hno:%u free this cmd,CFID:%d\n", PS3_HOST(instance), - cmd->index); - instance->webSubscribe_context.webSubscribe_cmd = NULL; - goto l_out; - } else { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - } - - LOG_INFO("hno:%u web cmd free, CFID:%d\n", PS3_HOST(instance), - cmd->index); - instance->webSubscribe_context.webSubscribe_cmd = NULL; - ps3_mgr_cmd_free(instance, cmd); + ULong flags = 0; + struct ps3_cmd *cmd = NULL; + instance->webSubscribe_context.abort_webcmd = 0; + + cmd = instance->webSubscribe_context.webSubscribe_cmd; + + if (cmd == NULL) { + LOG_WARN("hno:%u web cmd has been cancel\n", + PS3_HOST(instance)); + goto l_out; + } + + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + LOG_WARN("hno:%u free this cmd,CFID:%d\n", + PS3_HOST(instance), cmd->index); + instance->webSubscribe_context.webSubscribe_cmd = NULL; + goto l_out; + } else { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + } + + LOG_INFO("hno:%u web cmd free, CFID:%d\n", + PS3_HOST(instance), cmd->index); + instance->webSubscribe_context.webSubscribe_cmd = NULL; + ps3_mgr_cmd_free(instance, cmd); l_out: - return; + return; } + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_event.h b/drivers/scsi/linkdata/ps3stor/ps3_event.h index 97b4b7293344..c1a8d0d9212b 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_event.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_event.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_EVENT_H_ #define _PS3_EVENT_H_ @@ -7,32 +6,32 @@ #define PS3_EVENT_WORKER_POOL_SIZE (3) #define PS3_WEB_FLAG_INIT_VALUE (0) -int ps3_event_context_init(struct ps3_instance *instance); +S32 ps3_event_context_init(struct ps3_instance *instance); void ps3_event_context_exit(struct ps3_instance *instance); -const char *ps3_event_print(enum MgrEvtType event_type); -int ps3_event_subscribe(struct ps3_instance *instance); -int ps3_event_unsubscribe(struct ps3_instance *instance); -int ps3_soft_reset_event_resubscribe(struct ps3_instance *instance); +const char *ps3_event_print(MgrEvtType_e event_type); +S32 ps3_event_subscribe(struct ps3_instance *instance); +S32 ps3_event_unsubscribe(struct ps3_instance *instance); +S32 ps3_soft_reset_event_resubscribe(struct ps3_instance *instance); void ps3_event_handle(struct ps3_event_delay_work *ps3_delay_work); -int ps3_event_service(struct ps3_cmd *cmd, unsigned short reply_flags); -int ps3_event_delay_set(struct ps3_instance *instance, unsigned int delay); +S32 ps3_event_service(struct ps3_cmd *cmd, U16 reply_flags); +S32 ps3_event_delay_set(struct ps3_instance *instance, U32 delay); -void ps3_event_filter_table_get_raid(unsigned char *data); +void ps3_event_filter_table_get_raid(U8 *data); -void ps3_event_filter_table_get_hba(unsigned char *data); +void ps3_event_filter_table_get_hba(U8 *data); -void ps3_event_filter_table_get_switch(unsigned char *data); +void ps3_event_filter_table_get_switch(U8 *data); -void ps3_vd_pending_filter_table_build(unsigned char *data); +void ps3_vd_pending_filter_table_build(U8 *data); -int ps3_fasync(int fd, struct file *filp, int mode); -int ps3_webSubscribe_context_init(struct ps3_instance *instance); +S32 ps3_fasync(int fd, struct file *filp, int mode); +S32 ps3_webSubscribe_context_init(struct ps3_instance *instance); void ps3_webSubscribe_context_exit(struct ps3_instance *instance); -int ps3_webSubscribe_service(struct ps3_cmd *cmd, unsigned short reply_flags); -int ps3_web_subscribe(struct ps3_instance *instance); -int ps3_web_unsubscribe(struct ps3_instance *instance); -int ps3_soft_reset_web_resubscribe(struct ps3_instance *instance); +S32 ps3_webSubscribe_service(struct ps3_cmd *cmd, U16 reply_flags); +S32 ps3_web_subscribe(struct ps3_instance *instance); +S32 ps3_web_unsubscribe(struct ps3_instance *instance); +S32 ps3_soft_reset_web_resubscribe(struct ps3_instance *instance); void ps3_web_cmd_clear(struct ps3_instance *instance); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_inner_data.h b/drivers/scsi/linkdata/ps3stor/ps3_inner_data.h index d3e3792084a3..34ca612e68d3 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_inner_data.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_inner_data.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_INNER_DATA_H_ #define _PS3_INNER_DATA_H_ @@ -23,39 +22,51 @@ #include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h" #include "ps3_device_manager.h" -#include "ps3_htp_register_fifo.h" +#include "ps3_register_fifo.h" #include "ps3_err_def.h" -#include "ps3_kernel_version.h" -#define PS3_DEFAULT_PAGE_SIZE_SHIFT (12) -#define PS3_CMD_SGE_FRAME_BUFFER_SIZE (4096) -#define PS3_DUMP_DMA_BUF_SIZE (0x100000) -#define PS3_DEFAULT_TASK_MGR_TIMEOUT (50) -#define PS3_DEFAULT_MGR_CMD_TIMEOUT (180) -#define PS3_CANCEL_MGR_CMD_TIMEOUT (30) -#define PS3_UNLOAD_MGR_CMD_TIMEOUT (60) -#define PS3_RAID_UNLOAD_MGR_CMD_TIMEOUT (360) -#define PS3_SOFT_RESET_WAIT_TIMEOUT (30) -#define PS3_SLEEP_TOLERATE_TIMEOUT (10) -#define PS3_RESET_WAIT_IO_REPLY_MAX_TIME (5) -#define PS3_REGISTER_SET_SIZE (147456) -#define PS3_MAX_DEBUG_REG_CNT (8) + +#define PS3_DEFAULT_PAGE_SIZE_SHIFT (12) +#define PS3_CMD_SGE_FRAME_BUFFER_SIZE (4096) +#define PS3_DUMP_DMA_BUF_SIZE (0x100000) +#define PS3_DEFAULT_TASK_MGR_TIMEOUT (50) +#define PS3_DEFAULT_MGR_CMD_TIMEOUT (180) +#define PS3_CANCEL_MGR_CMD_TIMEOUT (30) +#define PS3_UNLOAD_MGR_CMD_TIMEOUT (60) +#define PS3_RAID_UNLOAD_MGR_CMD_TIMEOUT (360) +#define PS3_SOFT_RESET_WAIT_TIMEOUT (30) +#define PS3_SLEEP_TOLERATE_TIMEOUT (10) +#define PS3_RESET_WAIT_IO_REPLY_MAX_TIME (5) +#define PS3_REGISTER_SET_SIZE (147456) +#define PS3_MAX_DEBUG_REG_CNT (8) #define PS3_HARD_RESET_MAX_RETRY (2) -#define PS3_MAX_REPLY_QUE_COUNT (128) +#define PS3_MAX_REPLY_QUE_COUNT (128) #define PS3_RAIDHBA_NUM_ADJUST_VALUE (1) #define PS3_DEVICE_IO_BUSY_THRESHOLD (8) -#if defined(PS3_MAP_QUEUES) +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 4)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 1)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0))) +#include +#ifndef PS3_TAGSET_SUPPORT +#define PS3_TAGSET_SUPPORT +#endif +#endif + +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9 && RHEL_MINOR >= 2)) || \ + (defined(CONFIG_SUSE_KERNEL) && \ + ((CONFIG_SUSE_VERSION == 15) && (CONFIG_SUSE_PATCHLEVEL >= 5)))) #define MAP_QUEUES_RET_TYPE void -#define MAP_QUEUES_RET_VAL(x) +#define MAP_QUEUES_RET_VAL(x) return #else #define MAP_QUEUES_RET_TYPE int -#define MAP_QUEUES_RET_VAL(x) (x) +#define MAP_QUEUES_RET_VAL(x) return x #endif -#define PS3_BLOCK_NUM_OF_32K (1 << 6) +#define PS3_BLOCK_NUM_OF_32K (1 << 6) #define PS3_VD_IO_16_OUTSTANDING (16) #define PS3_VD_IO_1_OUTSTANDING (1) enum { @@ -69,22 +80,22 @@ enum { }; -enum PS3FuncID { - PS3_FUNC_ID_0 = 0, - PS3_FUNC_ID_1 = 1, - PS3_FUNC_UNLIMITED = 2, -}; +typedef enum PS3FuncID { + PS3_FUNC_ID_0 = 0, + PS3_FUNC_ID_1 = 1, + PS3_FUNC_UNLIMITED = 2, +}PS3FuncID_e; enum { - PS3_SHIFT_BYTE = 8, - PS3_SHIFT_WORD = 16, - PS3_SHIFT_3BYTE = 24, - PS3_SHIFT_DWORD = 32, + PS3_SHIFT_BYTE = 8, + PS3_SHIFT_WORD = 16, + PS3_SHIFT_3BYTE = 24, + PS3_SHIFT_DWORD = 32, }; enum { PS3_SGL_MODE_SGE_COUNT_NO_DATA = 0, - PS3_SGL_MODE_SGE_COUNT_DIRECT = 1, + PS3_SGL_MODE_SGE_COUNT_DIRECT = 1, }; struct ps3_event_delay_work { @@ -94,32 +105,32 @@ struct ps3_event_delay_work { struct delayed_work event_work; #endif struct ps3_cmd *cmd; - unsigned int event_delay; + U32 event_delay; }; struct ps3_event_context { struct PS3EventInfo *event_info; struct ps3_cmd *event_cmd; struct ps3_cmd *event_abort_cmd; - atomic_t abort_eventcmd; + volatile U32 abort_eventcmd; #ifdef _WINDOWS struct ps3_event_delay_work delay_work; #else - struct ps3_event_delay_work *delay_work; - struct ps3_event_delay_work *delay_work_pool; + struct ps3_event_delay_work* delay_work; + struct ps3_event_delay_work* delay_work_pool; #endif - unsigned long long event_phy_addr; - atomic_t subwork; - unsigned char flag; + U64 event_phy_addr; + volatile U32 subwork; + Bool flag; }; struct ps3_webSubscribe_context { - struct ps3_cmd *webSubscribe_cmd; - struct ps3_cmd *web_abort_cmd; - atomic_t is_subscribe; - atomic_t is_abort; - atomic_t subscribe_count; - atomic_t abort_webcmd; + struct ps3_cmd *webSubscribe_cmd; + struct ps3_cmd *web_abort_cmd; + ps3_atomic32 is_subscribe; + ps3_atomic32 is_abort; + ps3_atomic32 subscribe_count; + volatile U32 abort_webcmd; }; #ifndef _WINDOWS @@ -130,234 +141,173 @@ struct ps3_refire_delay_work { #endif struct ps3_cmd_attr_context { - int throttle_que_depth; - int cur_can_que; - unsigned int vd_io_threshold; - unsigned int nvme_page_size; - unsigned char is_support_direct_cmd; - unsigned char reserved[7]; + S32 throttle_que_depth; + S32 cur_can_que; + U32 vd_io_threshold; + U32 nvme_page_size; + Bool is_support_direct_cmd; + U8 reserved[7]; }; enum { - PS3_REG_OFFSET_REQUEST_QUE = - (HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DOORBELL = (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DOORBELL_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DOORBELL_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_IRQ_CONTROL = - (HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_KEY = - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_STATE = - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET = (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_LOW = - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_HIGH = - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_TIME_CNT = - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_TIME_OUT_CNT = - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_KEY = - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_STATE = - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET = (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_LOW = - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_HIGH = - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_TIME_CNT = - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_TIME_OUT_CNT = - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_KEY_GAP_CFG = - (HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOC_FW_STATE = - (HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MAX_FW_CMD = - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MAX_CHAIN_SIZE = - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MAX_VD_INFO_SIZE = - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MAX_NVME_PAGE_SIZE = - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_FEATURE_SUPPORT = - (HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_FIRMWARE_VERSION = - (HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_REPLY_QUE = - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDWARE_VERSION = - (HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MGR_QUEUE_DEPTH = - (HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_CMD_QUEUE_DEPTH = - (HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_TFIFO_DEPTH = - (HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MAX_SEC_R1X_CMDS = - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT0 = - (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT1 = - (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT2 = - (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT3 = - (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT_ALL = - (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_IRQ_STATUS_RPT = - (HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DUMP_CTRL = (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DUMP_CTRl_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DUMP_CTRl_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DUMP_STATUS = - (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DUMP_DATA_SIZE = - (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_CMD_TRIGGER = - (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_CMD_TRIGGER_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_CMD_TRIGGER_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_REG_CMD_STATE = - (HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_COUNTER = - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG0 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG0_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG0_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG1 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG1_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG1_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG2 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG2_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG2_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG3 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG3_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG3_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG4 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG4_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG4_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG5 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG6 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG7 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG8 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG9 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG10 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG11 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG12 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_SESSION_ADDR = - (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_SESSION_ADDR_IRQ_CLEAR = - (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_SESSION_ADDR_IRQ_MASK = - (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_ADDR - - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_REQUEST_QUE = + (HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DOORBELL = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DOORBELL_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DOORBELL_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_IRQ_CONTROL = \ + (HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_KEY = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_STATE = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_LOW = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_HIGH = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_TIME_CNT = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_TIME_OUT_CNT = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_KEY = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_STATE = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_LOW = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_HIGH = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_TIME_CNT = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_TIME_OUT_CNT = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_KEY_GAP_CFG = \ + (HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOC_FW_STATE = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MAX_FW_CMD = \ + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MAX_CHAIN_SIZE = \ + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MAX_VD_INFO_SIZE = \ + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MAX_NVME_PAGE_SIZE = \ + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_FEATURE_SUPPORT = \ + (HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_FIRMWARE_VERSION = \ + (HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_REPLY_QUE = \ + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDWARE_VERSION = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MGR_QUEUE_DEPTH = \ + (HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_CMD_QUEUE_DEPTH = \ + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_TFIFO_DEPTH = \ + (HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MAX_SEC_R1X_CMDS = \ + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT0 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT1 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT2 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT3 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT_ALL = \ + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_IRQ_STATUS_RPT = \ + (HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_CTRL = + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_CTRl_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_CTRl_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_STATUS = + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_DATA_SIZE = + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_CMD_TRIGGER = + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_CMD_TRIGGER_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_CMD_TRIGGER_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_REG_CMD_STATE = + (HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_COUNTER = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG0 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG0_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG0_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG1 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG1_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG1_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG2 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG2_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG2_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG3 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG3_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG3_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG4 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG4_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG4_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG5 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG6 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG7 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG8 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG9 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG10 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG11 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG12 = \ + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_SESSION_ADDR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_SESSION_ADDR_IRQ_CLEAR = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_SESSION_ADDR_IRQ_MASK = \ + (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), }; + #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.c b/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.c index d3cf869f36bb..f2df499bb1b7 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.c @@ -1,10 +1,9 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #include "ps3_instance_manager.h" #include "ps3_driver_log.h" #include "ps3_ioc_manager.h" -#ifndef _WINDOWS +#ifndef _WINDOWS #include "ps3_debug.h" #include #include @@ -12,19 +11,19 @@ #include "ps3_cli_debug.h" #ifdef PS3_HARDWARE_HAPS_V200 -#define PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS (180) -#define PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS (3600) -#define PS3_INSTANCE_STATE_CHECK_INTERVAL_MS (1000) -#define PS3_INSTANCE_STATE_CHECK_NORMAL_INTERVAL_MS (3000) +#define PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS (180) +#define PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS (3600) +#define PS3_INSTANCE_STATE_CHECK_INTERVAL_MS (1000) +#define PS3_INSTANCE_STATE_CHECK_NORMAL_INTERVAL_MS (3000) #else -#define PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS (180) -#define PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS (420) -#define PS3_INSTANCE_STATE_CHECK_INTERVAL_MS (1000) +#define PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS (180) +#define PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS (420) +#define PS3_INSTANCE_STATE_CHECK_INTERVAL_MS (1000) #endif struct ps3_host_info g_ps3_host_info; -#ifndef _WINDOWS +#ifndef _WINDOWS struct ps3_mgmt_info *ps3_mgmt_info_get(void) { static struct ps3_mgmt_info g_mgmt_info; @@ -32,28 +31,29 @@ struct ps3_mgmt_info *ps3_mgmt_info_get(void) return &g_mgmt_info; } -struct ps3_instance *ps3_instance_lookup(unsigned short host_no) +struct ps3_instance *ps3_instance_lookup(U16 host_no) { struct ps3_instance *instance = NULL; struct list_head *pitem = NULL; - list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { instance = list_entry(pitem, struct ps3_instance, list_item); - if (instance->host->host_no == host_no) + if (instance->host->host_no == host_no) { return instance; + } } return NULL; } -int ps3_instance_add(struct ps3_instance *instance) +S32 ps3_instance_add(struct ps3_instance *instance) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct list_head *pitem = NULL; struct ps3_instance *peer_instance = NULL; - if (instance == NULL) + if (instance == NULL) { return ret; + } ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { @@ -63,17 +63,14 @@ int ps3_instance_add(struct ps3_instance *instance) } } - list_for_each_entry(peer_instance, - &ps3_mgmt_info_get()->instance_list_head, - list_item) { + list_for_each_entry(peer_instance, &ps3_mgmt_info_get()->instance_list_head, list_item) { if (peer_instance != NULL && - ps3_get_pci_domain(peer_instance->pdev) == - ps3_get_pci_domain(instance->pdev) && - peer_instance->pdev->bus->number == - instance->pdev->bus->number && - PCI_SLOT(peer_instance->pdev->devfn) == - PCI_SLOT(instance->pdev->devfn)) { + ps3_get_pci_domain(peer_instance->pdev) == ps3_get_pci_domain(instance->pdev) && + peer_instance->pdev->bus->number == instance->pdev->bus->number && + PCI_SLOT(peer_instance->pdev->devfn) == PCI_SLOT(instance->pdev->devfn)) { + INJECT_START(PS3_ERR_IJ_ASYNC_HARDRESET_PROBE, peer_instance) peer_instance->recovery_context->instance_change = 1; + INJECT_START(PS3_ERR_IJ_ADD_INSTANCE_WAIT, peer_instance) mb(); /* in order to force CPU ordering */ ps3_recovery_cancel_work_sync(peer_instance); instance->peer_instance = peer_instance; @@ -83,8 +80,7 @@ int ps3_instance_add(struct ps3_instance *instance) } } - list_add(&instance->list_item, - &ps3_mgmt_info_get()->instance_list_head); + list_add(&instance->list_item, &ps3_mgmt_info_get()->instance_list_head); mutex_init(&instance->state_machine.lock); ps3_mutex_init(&instance->task_mgr_reset_lock); ps3_mutex_init(&instance->task_abort_lock); @@ -95,31 +91,31 @@ int ps3_instance_add(struct ps3_instance *instance) ret = PS3_SUCCESS; l_repeat_add: ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); - if (pitem == NULL) - LOG_WARN("hno:%u repeat add instance!\n", PS3_HOST(instance)); + if (pitem == NULL) { + LOG_WARN("hno:%u repeat add instance!\n", + PS3_HOST(instance)); + } return ret; } -int ps3_instance_remove(struct ps3_instance *instance) +S32 ps3_instance_remove(struct ps3_instance *instance) { struct ps3_instance *peer_instance = NULL; - if (instance == NULL) + if (instance == NULL) { return -PS3_FAILED; + } ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); list_del(&instance->list_item); instance->peer_instance = NULL; - list_for_each_entry(peer_instance, - &ps3_mgmt_info_get()->instance_list_head, - list_item) { + list_for_each_entry(peer_instance, &ps3_mgmt_info_get()->instance_list_head, list_item) { if (peer_instance != NULL && - ps3_get_pci_domain(peer_instance->pdev) == - ps3_get_pci_domain(instance->pdev) && - peer_instance->pdev->bus->number == - instance->pdev->bus->number && - PCI_SLOT(peer_instance->pdev->devfn) == - PCI_SLOT(instance->pdev->devfn)) { + ps3_get_pci_domain(peer_instance->pdev) == ps3_get_pci_domain(instance->pdev) && + peer_instance->pdev->bus->number == instance->pdev->bus->number && + PCI_SLOT(peer_instance->pdev->devfn) == PCI_SLOT(instance->pdev->devfn)) { + INJECT_START(PS3_ERR_IJ_ASYNC_HARDRESET_REMOVE, peer_instance) + INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE_WAIT, peer_instance) peer_instance->recovery_context->instance_change = 1; mb(); /* in order to force CPU ordering */ ps3_recovery_cancel_work_sync(peer_instance); @@ -142,6 +138,8 @@ void ps3_mgmt_info_init(void) INIT_LIST_HEAD(&ps3_mgmt_info_get()->instance_list_head); ps3_cli_debug_init(); + + return; } void ps3_mgmt_exit(void) @@ -160,21 +158,30 @@ void ps3_instance_init(struct ps3_instance *instance) instance->state_machine.is_pci_err_recovery = PS3_FALSE; } -int ps3_instance_state_transfer(struct ps3_instance *instance, - unsigned int exp_cur_state, - unsigned int dest_state) +S32 ps3_instance_state_transfer(struct ps3_instance *instance, + U32 exp_cur_state, U32 dest_state) { - unsigned int cur_state = 0; - + U32 cur_state = 0; ps3_mutex_lock(&instance->state_machine.lock); +#if 0 + 由于当前硬件不支持拦截dma等通路,只能通过硬复位 + 来防止片内踩主机内存,所以状态需要正常切换 + + if (!instance->state_machine.is_load) { + LOG_ERROR("hno:%u driver is unload or suspend!\n", + PS3_HOST(instance)); + goto l_fail; + } +#endif cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state != exp_cur_state) + if (cur_state != exp_cur_state) { goto l_fail; + } - switch (cur_state) { + switch(cur_state) { case PS3_INSTANCE_STATE_INIT: if ((dest_state == PS3_INSTANCE_STATE_READY) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -182,8 +189,8 @@ int ps3_instance_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_READY: if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_PCIE_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY) || + (dest_state == PS3_INSTANCE_STATE_PCIE_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -191,8 +198,8 @@ int ps3_instance_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_PRE_OPERATIONAL: if ((dest_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY) || + (dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -200,80 +207,95 @@ int ps3_instance_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_OPERATIONAL: if ((dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_SUSPEND) || - (dest_state == PS3_INSTANCE_STATE_QUIT)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY) || + (dest_state == PS3_INSTANCE_STATE_SUSPEND) || + (dest_state == PS3_INSTANCE_STATE_QUIT)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_SOFT_RECOVERY: - if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { + if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) + || (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_RECOVERY: - if ((dest_state == PS3_INSTANCE_STATE_READY) || - (dest_state == PS3_INSTANCE_STATE_DEAD)) { + if ((dest_state == PS3_INSTANCE_STATE_READY) + || (dest_state == PS3_INSTANCE_STATE_DEAD)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_SUSPEND: - if (dest_state == PS3_INSTANCE_STATE_READY) + if (dest_state == PS3_INSTANCE_STATE_READY) { goto l_success; - else + } else { goto l_fail; + } break; case PS3_INSTANCE_STATE_DEAD: - if (dest_state == PS3_INSTANCE_STATE_QUIT) + if (dest_state == PS3_INSTANCE_STATE_QUIT) { goto l_success; - else + } else { goto l_fail; + } break; case PS3_INSTANCE_STATE_QUIT: goto l_fail; case PS3_INSTANCE_STATE_PCIE_RECOVERY: - if (dest_state == PS3_INSTANCE_STATE_RECOVERY) + if (dest_state == PS3_INSTANCE_STATE_RECOVERY) { goto l_success; - else + } else { goto l_fail; + } default: goto l_fail; } l_fail: ps3_mutex_unlock(&instance->state_machine.lock); - LOG_ERROR("hno:%u state transfer NOK! [exp_cur_state:%s][cur_state:%s][dest_state:%s]\n", - PS3_HOST(instance), namePS3InstanceState(exp_cur_state), - namePS3InstanceState(cur_state), - namePS3InstanceState(dest_state)); + LOG_ERROR("hno:%u state transfer NOK!" + "[exp_cur_state:%s][cur_state:%s][dest_state:%s]\n", + PS3_HOST(instance), + namePS3InstanceState(exp_cur_state), + namePS3InstanceState(cur_state), + namePS3InstanceState(dest_state)); return -PS3_FAILED; l_success: ps3_atomic_set(&instance->state_machine.state, dest_state); ps3_mutex_unlock(&instance->state_machine.lock); - LOG_INFO("hno:%u state transfer from %s to %s!\n", PS3_HOST(instance), - namePS3InstanceState(cur_state), - namePS3InstanceState(dest_state)); + LOG_INFO("hno:%u state transfer from %s to %s!\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state), + namePS3InstanceState(dest_state)); return PS3_SUCCESS; } -int ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, - unsigned int dest_state) +S32 ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, + U32 dest_state) { - unsigned int cur_state = 0; - + U32 cur_state = 0; +#if 0 + 由于当前硬件不支持拦截dma等通路,只能通过硬复位 + 来防止片内踩主机内存,所以状态需要正常切换 + if (!instance->state_machine.is_load) { + LOG_ERROR("hno:%u driver is unload or suspend!\n", + PS3_HOST(instance)); + goto l_fail; + } +#endif cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state == dest_state) + if(cur_state == dest_state){ goto l_success; - switch (cur_state) { + } + switch(cur_state) { case PS3_INSTANCE_STATE_INIT: if ((dest_state == PS3_INSTANCE_STATE_READY) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -281,7 +303,7 @@ int ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_READY: if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -289,8 +311,8 @@ int ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_PRE_OPERATIONAL: if ((dest_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY) || + (dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -298,63 +320,69 @@ int ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_OPERATIONAL: if ((dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_SUSPEND) || - (dest_state == PS3_INSTANCE_STATE_QUIT)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY) || + (dest_state == PS3_INSTANCE_STATE_SUSPEND) || + (dest_state == PS3_INSTANCE_STATE_QUIT)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_SOFT_RECOVERY: - if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { + if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) + || (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_RECOVERY: - if ((dest_state == PS3_INSTANCE_STATE_READY) || - (dest_state == PS3_INSTANCE_STATE_DEAD)) { + if ((dest_state == PS3_INSTANCE_STATE_READY) + || (dest_state == PS3_INSTANCE_STATE_DEAD)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_SUSPEND: - if (dest_state == PS3_INSTANCE_STATE_READY) + if (dest_state == PS3_INSTANCE_STATE_READY) { goto l_success; - else + } else { goto l_fail; + } break; case PS3_INSTANCE_STATE_DEAD: - if (dest_state == PS3_INSTANCE_STATE_QUIT) + if (dest_state == PS3_INSTANCE_STATE_QUIT) { goto l_success; - else + } else { goto l_fail; + } break; case PS3_INSTANCE_STATE_QUIT: goto l_fail; case PS3_INSTANCE_STATE_PCIE_RECOVERY: - if (dest_state == PS3_INSTANCE_STATE_RECOVERY) + if (dest_state == PS3_INSTANCE_STATE_RECOVERY) { goto l_success; - else + } else { goto l_fail; + } default: goto l_fail; } l_fail: - LOG_ERROR("hno:%u state transfer NOK! [cur_state:%s][dest_state:%s]\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), - namePS3InstanceState(dest_state)); + LOG_ERROR("hno:%u state transfer NOK!" + "[cur_state:%s][dest_state:%s]\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state), + namePS3InstanceState(dest_state)); return -PS3_FAILED; l_success: ps3_atomic_set(&instance->state_machine.state, dest_state); - LOG_INFO("hno:%u state transfer from %s to %s!\n", PS3_HOST(instance), - namePS3InstanceState(cur_state), - namePS3InstanceState(dest_state)); + LOG_INFO("hno:%u state transfer from %s to %s!\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state), + namePS3InstanceState(dest_state)); return PS3_SUCCESS; } @@ -366,10 +394,9 @@ void ps3_instance_state_transfer_to_dead_nolock(struct ps3_instance *instance) void ps3_instance_state_transfer_to_dead(struct ps3_instance *instance) { ps3_mutex_lock(&instance->state_machine.lock); - if (ps3_atomic_read(&instance->state_machine.state) != - PS3_INSTANCE_STATE_DEAD) { + if(ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_DEAD); + PS3_INSTANCE_STATE_DEAD); } ps3_mutex_unlock(&instance->state_machine.lock); } @@ -377,56 +404,51 @@ void ps3_instance_state_transfer_to_dead(struct ps3_instance *instance) void ps3_instance_state_transfer_to_pcie_recovery(struct ps3_instance *instance) { ps3_mutex_lock(&instance->state_machine.lock); - if (ps3_atomic_read(&instance->state_machine.state) != - PS3_INSTANCE_STATE_PCIE_RECOVERY) { + if(ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_PCIE_RECOVERY){ ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_PCIE_RECOVERY); + PS3_INSTANCE_STATE_PCIE_RECOVERY); } ps3_mutex_unlock(&instance->state_machine.lock); } void ps3_instance_state_transfer_to_quit(struct ps3_instance *instance) { - ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_QUIT); + ps3_atomic_set(&instance->state_machine.state, + PS3_INSTANCE_STATE_QUIT); } void ps3_instance_state_transfer_to_suspend(struct ps3_instance *instance) { ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_SUSPEND); + PS3_INSTANCE_STATE_SUSPEND); } void ps3_instance_state_transition_to_recovery(struct ps3_instance *instance) { ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_RECOVERY); + PS3_INSTANCE_STATE_RECOVERY); } -int ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance) +S32 ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance) { - unsigned int wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 2; - int cur_state = PS3_INSTANCE_STATE_INIT; - unsigned int idx = 0; - int ret = PS3_SUCCESS; - - for (idx = 0; idx < wait_cnt; idx++) { + U32 wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 2; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + U32 idx = 0; + S32 ret = PS3_SUCCESS; + for (idx = 0;idx < wait_cnt;idx++) { cur_state = ps3_atomic_read(&instance->state_machine.state); if ((cur_state == PS3_INSTANCE_STATE_DEAD) || - (cur_state == PS3_INSTANCE_STATE_QUIT)) { + (cur_state == PS3_INSTANCE_STATE_QUIT)){ ret = -PS3_FAILED; goto l_out; } ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state == - PS3_HOST_RESET_HARD_RESET_DONE && - ps3_atomic_read(&instance->state_machine.state) == - PS3_INSTANCE_STATE_OPERATIONAL) { - if (atomic_read( - &instance->cmd_statistics.io_outstanding) != - 0) { + if (instance->recovery_context->host_reset_state == PS3_HOST_RESET_HARD_RESET_DONE && + ps3_atomic_read(&instance->state_machine.state) == PS3_INSTANCE_STATE_OPERATIONAL){ + if(atomic_read(&instance->cmd_statistics.io_outstanding) != 0) { ret = -PS3_RETRY; } - ps3_mutex_unlock(&instance->state_machine.lock); + ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); @@ -436,13 +458,12 @@ int ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance) if (idx >= wait_cnt) { LOG_WARN("hno:%u wait pre_operational timeout!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state != - PS3_HOST_RESET_HARD_RESET_DONE) { + if (instance->recovery_context->host_reset_state != PS3_HOST_RESET_HARD_RESET_DONE) { LOG_WARN("hno:%u wait host reset hard reset done NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_RETRY; } ps3_mutex_unlock(&instance->state_machine.lock); @@ -451,20 +472,19 @@ int ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance) return ret; } -int ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance) +S32 ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance) { - unsigned int wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 3; - int cur_state = PS3_INSTANCE_STATE_INIT; - unsigned int idx = 0; + U32 wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 3; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + U32 idx = 0; - LOG_INFO("hno:%u wait dead or pre_operational begin\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u wait dead or pre_operational begin\n", PS3_HOST(instance)); for (idx = 0; idx < wait_cnt; idx++) { cur_state = ps3_atomic_read(&instance->state_machine.state); if ((cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_DEAD) || - (cur_state == PS3_INSTANCE_STATE_QUIT)) { + (cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || + (cur_state == PS3_INSTANCE_STATE_DEAD) || + (cur_state == PS3_INSTANCE_STATE_QUIT)) { break; } @@ -473,34 +493,32 @@ int ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance) if (idx >= wait_cnt) { LOG_WARN("hno:%u wait dead or pre_operational timeout!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } if ((cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL) && - (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) && - (cur_state != PS3_INSTANCE_STATE_DEAD)) { + (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) && + (cur_state != PS3_INSTANCE_STATE_DEAD)) { LOG_WARN("hno:%u wait dead or pre_operational NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return -PS3_FAILED; + } - LOG_INFO("hno:%u wait dead or pre_operational success!\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u wait dead or pre_operational success!\n", PS3_HOST(instance)); return PS3_SUCCESS; } -int ps3_instance_wait_for_operational(struct ps3_instance *instance, - unsigned char is_hardreset) +S32 ps3_instance_wait_for_operational(struct ps3_instance *instance, Bool is_hardreset) { - unsigned int wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 3; - int cur_state = PS3_INSTANCE_STATE_INIT; - unsigned int idx = 0; - int recovery_state = PS3_RESET_LOG_INTERVAL; + U32 wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 3; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + U32 idx = 0; + S32 recovery_state = PS3_RESET_LOG_INTERVAL; for (idx = 0; idx < wait_cnt; idx++) { if (!instance->state_machine.is_load) { - LOG_INFO("hno:%u instance state not is_load\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u instance state not is_load\n", PS3_HOST(instance)); break; } @@ -508,16 +526,11 @@ int ps3_instance_wait_for_operational(struct ps3_instance *instance, cur_state = ps3_atomic_read(&instance->state_machine.state); recovery_state = instance->recovery_context->recovery_state; if (((cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_DEAD) || - (cur_state == PS3_INSTANCE_STATE_QUIT)) && - (is_hardreset ? - (recovery_state == PS3_HARD_RECOVERY_FINISH) : - PS3_TRUE)) { - LOG_INFO( - "hno:%u wait break, cur_state: %s, recovery_state: %d, is_hardreset: %d\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state), recovery_state, - is_hardreset); + (cur_state == PS3_INSTANCE_STATE_DEAD) || + (cur_state == PS3_INSTANCE_STATE_QUIT)) && + (is_hardreset ? (recovery_state == PS3_HARD_RECOVERY_FINISH) : PS3_TRUE)) { + LOG_INFO("hno:%u wait break, cur_state: %s, recovery_state: %d, is_hardreset: %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), recovery_state, is_hardreset); ps3_mutex_unlock(&instance->state_machine.lock); break; } @@ -528,54 +541,51 @@ int ps3_instance_wait_for_operational(struct ps3_instance *instance, if (idx >= wait_cnt) { LOG_WARN("hno:%u wait operational timeout!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { - LOG_WARN( - "hno:%u wait operational NOK, cur_state: %s, recovery_state: %d\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), - recovery_state); + LOG_WARN("hno:%u wait operational NOK, cur_state: %s, recovery_state: %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), recovery_state); return -PS3_FAILED; + } LOG_INFO("hno:%u wait operational success!\n", PS3_HOST(instance)); return PS3_SUCCESS; } -int ps3_instance_wait_for_normal(struct ps3_instance *instance) +S32 ps3_instance_wait_for_normal(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int wait_cnt = PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS; - int cur_state = PS3_INSTANCE_STATE_INIT; - unsigned int idx = 0; - unsigned char is_pci_err_recovery = PS3_FALSE; + S32 ret = PS3_SUCCESS; + U32 wait_cnt = PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + U32 idx = 0; + Bool is_pci_err_recovery = PS3_FALSE; for (idx = 0; idx < wait_cnt; idx++) { + INJECT_START(PS3_ERR_IJ_V2_WAKE_RECOVERY_WAIT, instance); + INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_NORMAL, instance); is_pci_err_recovery = ps3_pci_err_recovery_get(instance); cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_DEAD && - PS3_IOC_STATE_HALT_SUPPORT(instance) && - PS3_HALT_CLI_SUPPORT(instance)) { + PS3_IOC_STATE_HALT_SUPPORT(instance) && + PS3_HALT_CLI_SUPPORT(instance)) { goto l_out; } if (ps3_state_is_normal(cur_state) || - cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_DEAD || - is_pci_err_recovery) { - LOG_DEBUG( - "hno:%u cur state: %d, pci err recovery: %d\n", - PS3_HOST(instance), cur_state, - is_pci_err_recovery); + cur_state == PS3_INSTANCE_STATE_QUIT || + cur_state == PS3_INSTANCE_STATE_DEAD || + is_pci_err_recovery) { + LOG_DEBUG("hno:%u cur state: %d, pci err recovery: %d\n", + PS3_HOST(instance), cur_state, is_pci_err_recovery); break; } if (!(idx % PS3_RESET_LOG_INTERVAL)) { - LOG_DEBUG( - "hno:%u state[%s] waiting for reset to finish\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state)); + LOG_DEBUG("hno:%u state[%s] waiting for reset to finish\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); } #ifdef PS3_HARDWARE_HAPS_V200 ps3_msleep(PS3_INSTANCE_STATE_CHECK_NORMAL_INTERVAL_MS); @@ -590,10 +600,8 @@ int ps3_instance_wait_for_normal(struct ps3_instance *instance) } if (!ps3_state_is_normal(cur_state) || is_pci_err_recovery) { - LOG_WARN( - "hno:%u cannot handle cmd, driver state: %s, pci recovery: %d\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), - is_pci_err_recovery); + LOG_WARN("hno:%u cannot handle cmd, driver state: %s, pci recovery: %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), is_pci_err_recovery); ret = -PS3_FAILED; goto l_out; } @@ -602,25 +610,23 @@ int ps3_instance_wait_for_normal(struct ps3_instance *instance) return ret; } -int ps3_recovery_state_wait_for_normal(struct ps3_instance *instance) +S32 ps3_recovery_state_wait_for_normal(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int wait_cnt = PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS; - int recovery_state = PS3_RESET_LOG_INTERVAL; - unsigned int idx = 0; - unsigned char is_pci_err_recovery = PS3_FALSE; + S32 ret = PS3_SUCCESS; + U32 wait_cnt = PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS; + S32 recovery_state = PS3_RESET_LOG_INTERVAL; + U32 idx = 0; + Bool is_pci_err_recovery = PS3_FALSE; for (idx = 0; idx < wait_cnt; idx++) { recovery_state = instance->recovery_context->recovery_state; is_pci_err_recovery = ps3_pci_err_recovery_get(instance); - if (recovery_state == PS3_HARD_RECOVERY_FINISH || - recovery_state == PS3_SOFT_RECOVERY_PROBE_PROCESS || - is_pci_err_recovery) { - LOG_DEBUG( - "hno:%u recovery state: %d, pci err recovery: %d\n", - PS3_HOST(instance), recovery_state, - is_pci_err_recovery); + if ( recovery_state == PS3_HARD_RECOVERY_FINISH || + recovery_state == PS3_SOFT_RECOVERY_PROBE_PROCESS || + is_pci_err_recovery) { + LOG_DEBUG("hno:%u recovery state: %d, pci err recovery: %d\n", + PS3_HOST(instance), recovery_state, is_pci_err_recovery); goto l_out; } #ifdef PS3_HARDWARE_HAPS_V200 @@ -637,11 +643,11 @@ int ps3_recovery_state_wait_for_normal(struct ps3_instance *instance) ret = -PS3_FAILED; LOG_WARN("hno:%u wait recovery time out, recovery_state: %d\n", - PS3_HOST(instance), recovery_state); + PS3_HOST(instance), recovery_state); l_out: if (is_pci_err_recovery) { LOG_WARN("hno:%u cannot handle cmd, pci recovery: %d\n", - PS3_HOST(instance), is_pci_err_recovery); + PS3_HOST(instance), is_pci_err_recovery); ret = -PS3_FAILED; } return ret; @@ -661,22 +667,21 @@ void ps3_host_info_get(void) g_ps3_host_info.vendor = PS3_HOST_VENDOR_HYGON; else if (strstr(cpu->x86_vendor_id, "AMD")) g_ps3_host_info.vendor = PS3_HOST_VENDOR_AMD; + g_ps3_host_info.processor_cnt = num_online_cpus(); #else memset(&g_ps3_host_info, 0, sizeof(struct ps3_host_info)); #endif memset(g_ps3_host_info.release, 0, SYS_INFO_LEN + 1); - snprintf(g_ps3_host_info.release, SYS_INFO_LEN, "%s", - utsname()->release); + snprintf(g_ps3_host_info.release, SYS_INFO_LEN, "%s", utsname()->release); - LOG_DEBUG( - "host info: machine=%u,vendor=%u,processor_cnt=%u release=%s\n", + LOG_DEBUG("host info: machine=%u,vendor=%u,processor_cnt=%u release=%s\n", g_ps3_host_info.machine, g_ps3_host_info.vendor, g_ps3_host_info.processor_cnt, g_ps3_host_info.release); } -unsigned short ps3_host_vendor_get(void) +U16 ps3_host_vendor_get(void) { return g_ps3_host_info.vendor; } @@ -686,8 +691,8 @@ char *ps3_host_release_get(void) return g_ps3_host_info.release; } -unsigned char ps3_is_last_func(struct ps3_instance *instance) +U8 ps3_is_last_func(struct ps3_instance *instance) { return (!ps3_ioc_multi_func_support(instance) || - (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1)); + (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1)); } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.h b/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.h index 06f049927440..67e2a285ec12 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.h @@ -1,9 +1,8 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_INSTANCE_MANAGER_H_ #define _PS3_INSTANCE_MANAGER_H_ -#ifndef _WINDOWS +#ifndef _WINDOWS #include #include #include @@ -30,97 +29,94 @@ #include "ps3_dump.h" #include "ps3_cmd_stat_def.h" #include "ps3_watchdog.h" +#include "ps3_err_inject.h" #include "ps3_qos.h" enum PS3_INSTANCE_STATE_TYPE { - PS3_INSTANCE_STATE_INIT = 0, - PS3_INSTANCE_STATE_READY = 1, - PS3_INSTANCE_STATE_PRE_OPERATIONAL = 2, - PS3_INSTANCE_STATE_OPERATIONAL = 3, - PS3_INSTANCE_STATE_SOFT_RECOVERY = 4, - PS3_INSTANCE_STATE_RECOVERY = 5, - PS3_INSTANCE_STATE_SUSPEND = 6, - PS3_INSTANCE_STATE_DEAD = 7, - PS3_INSTANCE_STATE_QUIT = 8, + PS3_INSTANCE_STATE_INIT = 0, + PS3_INSTANCE_STATE_READY = 1, + PS3_INSTANCE_STATE_PRE_OPERATIONAL = 2, + PS3_INSTANCE_STATE_OPERATIONAL = 3, + PS3_INSTANCE_STATE_SOFT_RECOVERY = 4, + PS3_INSTANCE_STATE_RECOVERY = 5, + PS3_INSTANCE_STATE_SUSPEND = 6, + PS3_INSTANCE_STATE_DEAD = 7, + PS3_INSTANCE_STATE_QUIT = 8, PS3_INSTANCE_STATE_PCIE_RECOVERY = 9, - PS3_INSTANCE_STATE_COUNT = 10 + PS3_INSTANCE_STATE_COUNT = 10 }; enum PS3_DEVICE_ERR_HANDLE_STATE_TYPE { - PS3_DEVICE_ERR_STATE_NORMAL = 0, - PS3_DEVICE_ERR_STATE_CLEAN = 1, - PS3_DEVICE_ERR_STATE_INIT = 2, + PS3_DEVICE_ERR_STATE_NORMAL = 0, + PS3_DEVICE_ERR_STATE_CLEAN = 1, + PS3_DEVICE_ERR_STATE_INIT = 2, }; struct ps3_instance_state_machine { - struct mutex lock; - atomic_t state; - unsigned char is_load; - unsigned char is_suspend; - unsigned char is_poweroff; - unsigned char is_pci_err_recovery; - unsigned char can_hostreset; + ps3_mutex lock; + ps3_atomic32 state; + Bool is_load; + Bool is_suspend; + Bool is_poweroff; + Bool is_pci_err_recovery; + Bool can_hostreset; }; -static inline const char *namePS3InstanceState(int s) +static inline const S8 *namePS3InstanceState(S32 s) { - static const char * const myNames[] = { - [PS3_INSTANCE_STATE_INIT] = "PS3_INSTANCE_STATE_INIT", - [PS3_INSTANCE_STATE_READY] = "PS3_INSTANCE_STATE_READY", - [PS3_INSTANCE_STATE_PRE_OPERATIONAL] = - "PS3_INSTANCE_STATE_PRE_OPERATIONAL", - [PS3_INSTANCE_STATE_OPERATIONAL] = - "PS3_INSTANCE_STATE_OPERATIONAL", - [PS3_INSTANCE_STATE_SOFT_RECOVERY] = - "PS3_INSTANCE_STATE_SOFT_RECOVERY", - [PS3_INSTANCE_STATE_RECOVERY] = "PS3_INSTANCE_STATE_RECOVERY", - [PS3_INSTANCE_STATE_SUSPEND] = "PS3_INSTANCE_STATE_SUSPEND", - [PS3_INSTANCE_STATE_DEAD] = "PS3_INSTANCE_STATE_DEAD", - [PS3_INSTANCE_STATE_QUIT] = "PS3_INSTANCE_STATE_QUIT", - [PS3_INSTANCE_STATE_PCIE_RECOVERY] = - "PS3_INSTANCE_STATE_PCIE_RECOVERY" + static const S8 *myNames[] = { + [PS3_INSTANCE_STATE_INIT] = "PS3_INSTANCE_STATE_INIT", + [PS3_INSTANCE_STATE_READY] = "PS3_INSTANCE_STATE_READY", + [PS3_INSTANCE_STATE_PRE_OPERATIONAL] = "PS3_INSTANCE_STATE_PRE_OPERATIONAL", + [PS3_INSTANCE_STATE_OPERATIONAL] = "PS3_INSTANCE_STATE_OPERATIONAL", + [PS3_INSTANCE_STATE_SOFT_RECOVERY] = "PS3_INSTANCE_STATE_SOFT_RECOVERY", + [PS3_INSTANCE_STATE_RECOVERY] = "PS3_INSTANCE_STATE_RECOVERY", + [PS3_INSTANCE_STATE_SUSPEND] = "PS3_INSTANCE_STATE_SUSPEND", + [PS3_INSTANCE_STATE_DEAD] = "PS3_INSTANCE_STATE_DEAD", + [PS3_INSTANCE_STATE_QUIT] = "PS3_INSTANCE_STATE_QUIT", + [PS3_INSTANCE_STATE_PCIE_RECOVERY] = "PS3_INSTANCE_STATE_PCIE_RECOVERY" }; - if (s >= PS3_INSTANCE_STATE_COUNT) + if (s >= PS3_INSTANCE_STATE_COUNT) { return "PS3_INSTANCE_STATE_INVALID"; + } return myNames[s]; } struct ps3_recovery_function { - int (*recovery_handle_cb)(struct ps3_instance *instance, - unsigned char reason); - int (*hardreset_handle_pre_cb)(struct ps3_instance *instance); - int (*hardreset_handle_wait_ready_cb)(struct ps3_instance *instance); - int (*hardreset_handle_init_running_cb)(struct ps3_instance *instance); - int (*hardreset_handle_post_cb)(struct ps3_instance *instance); - int (*hardreset_handle_finish_cb)(struct ps3_instance *instance); - int (*hardreset_handle_offline_cb)(struct ps3_instance *instance); - int (*softreset_handle_pre_cb)(struct ps3_instance *instance); - int (*softreset_handle_post_cb)(struct ps3_instance *instance); - int (*halt_handle_cb)(struct ps3_instance *instance); + S32 (*recovery_handle_cb)(struct ps3_instance *instance, U8 reason); + S32 (*hardreset_handle_pre_cb)(struct ps3_instance *instance); + S32 (*hardreset_handle_wait_ready_cb)(struct ps3_instance *instance); + S32 (*hardreset_handle_init_running_cb)(struct ps3_instance *instance); + S32 (*hardreset_handle_post_cb)(struct ps3_instance *instance); + S32 (*hardreset_handle_finish_cb)(struct ps3_instance *instance); + S32 (*hardreset_handle_offline_cb)(struct ps3_instance *instance); + S32 (*softreset_handle_pre_cb)(struct ps3_instance *instance); + S32 (*softreset_handle_post_cb)(struct ps3_instance *instance); + S32 (*halt_handle_cb)(struct ps3_instance *instance); }; struct ps3_instance { - struct list_head list_item; + ps3_list_head list_item; struct ps3_instance *peer_instance; -#ifndef _WINDOWS +#ifndef _WINDOWS struct pci_dev *pdev; struct Scsi_Host *host; #else - unsigned long bus_number; + ULong bus_number; struct ps3_pci_context pci_dev_context; #endif - struct Ps3Fifo __iomem *reg_set; - atomic_t watchdog_reg_read_fail_count; + Ps3Fifo_s __iomem *reg_set; + ps3_atomic32 watchdog_reg_read_fail_count; struct ps3_cmd_context cmd_context; struct ps3_irq_context irq_context; struct ps3_dev_context dev_context; -#ifndef _WINDOWS +#ifndef _WINDOWS struct ps3_sas_dev_context sas_dev_context; #endif struct ps3_event_context event_context; - struct ps3_webSubscribe_context webSubscribe_context; + struct ps3_webSubscribe_context webSubscribe_context; struct ps3_fault_context fault_context; @@ -131,8 +127,8 @@ struct ps3_instance { struct PS3IocCtrlInfo ctrl_info; struct PS3IocCtrlInfo *ctrl_info_buf; -#ifdef _WINDOWS - atomic_t ioctl_count; +#ifdef _WINDOWS + ps3_atomic32 ioctl_count; #else struct semaphore ioctl_sem; #endif @@ -140,104 +136,104 @@ struct ps3_instance { struct ps3_cmd_attr_context cmd_attr; struct PS3MgrEvent event_req_info; - spinlock_t req_queue_lock; + ps3_spinlock req_queue_lock; dma_addr_t ctrl_info_buf_h; dma_addr_t drv_info_buf_phys; - unsigned char *drv_info_buf; + U8 *drv_info_buf; dma_addr_t host_mem_info_buf_phys; - unsigned char *host_mem_info_buf; - unsigned int max_mgr_cmd_total_count; - unsigned int max_mgr_cmd_count; - unsigned int max_task_cmd_count; - unsigned int min_intr_count; - unsigned char reserve[4]; - unsigned int reply_fifo_depth_addition; - - unsigned long reg_bar; - unsigned char is_support_sync_cache; - unsigned char is_use_frontend_prp; - unsigned char dma_mask; - unsigned char is_support_jbod; - unsigned char use_clusting; - unsigned char is_adjust_register_count; - unsigned char is_scan_host_finish; - unsigned char is_probe_finish; - unsigned char is_probe_failed; - unsigned char is_suspend; - unsigned char is_resume; - unsigned char is_hard_reset; - unsigned char is_pci_reset; - unsigned char is_ioc_halt_support; - unsigned char is_shallow_soft_recovery_support; - unsigned char is_deep_soft_recovery_support; - unsigned char is_hard_recovery_support; - unsigned char is_halt_support_cli; - unsigned char is_half_hard_reset; - unsigned char is_host_added; - unsigned char is_need_event; - unsigned char is_raid1_direct_skip_mapblock_check; - unsigned char is_single_disk_raid0_direct_skip_strip_check; - unsigned char is_support_dump_ctrl; - unsigned char is_support_io_limit; - unsigned char task_manager_host_busy; - unsigned char hilMode; - unsigned char is_irq_prk_support; - unsigned char is_support_irq; - unsigned char is_raid; - unsigned char smp_affinity_enable; - unsigned char msix_combined; - unsigned char reserved[2]; - unsigned short unload_timeout; - unsigned short wait_ready_timeout; - unsigned short dev_id; - unsigned char dma_addr_bit_pos; - unsigned char pci_err_handle_state; + U8 *host_mem_info_buf; + U32 max_mgr_cmd_total_count; + U32 max_mgr_cmd_count; + U32 max_task_cmd_count; + U32 min_intr_count; + U8 reserve[4]; + U32 reply_fifo_depth_addition; + + ULong reg_bar; + Bool is_support_sync_cache; + Bool is_use_frontend_prp; + U8 dma_mask; + Bool is_support_jbod; + Bool use_clusting; + Bool is_adjust_register_count; + Bool is_scan_host_finish; + Bool is_probe_finish; + Bool is_probe_failed; + Bool is_suspend; + Bool is_resume; + Bool is_hard_reset; + Bool is_pci_reset; + Bool is_ioc_halt_support; + Bool is_shallow_soft_recovery_support; + Bool is_deep_soft_recovery_support; + Bool is_hard_recovery_support; + Bool is_halt_support_cli; + Bool is_half_hard_reset; + Bool is_host_added; + Bool is_need_event; + Bool is_raid1_direct_skip_mapblock_check; + Bool is_single_disk_raid0_direct_skip_strip_check; + Bool is_support_dump_ctrl; + Bool is_support_io_limit; + Bool task_manager_host_busy; + U8 hilMode; + Bool is_irq_prk_support; + Bool is_support_irq; + Bool is_raid; + Bool smp_affinity_enable; + Bool msix_combined; + U8 reserved[2]; + U16 unload_timeout; + U16 wait_ready_timeout; + U16 dev_id; + U8 dma_addr_bit_pos; + U8 pci_err_handle_state; const char *product_model; - long long __percpu *scsi_cmd_deliver; + S64 __percpu *scsi_cmd_deliver; - unsigned long long ioc_fw_version; - struct mutex task_mgr_reset_lock; + U64 ioc_fw_version; + ps3_mutex task_mgr_reset_lock; #ifdef _WINDOWS STOR_DPC device_reset_dpc; #endif - unsigned char page_mode_change; - unsigned long long page_mode_addr_mask; - atomic_t is_err_scsi_processing; - atomic_t reg_op_count; - atomic_t host_reset_processing; - atomic_t watchdog_ref; + Bool page_mode_change; + U64 page_mode_addr_mask; + ps3_atomic32 is_err_scsi_processing; + ps3_atomic32 reg_op_count; + ps3_atomic32 host_reset_processing; + ps3_atomic32 watchdog_ref; struct ps3_instance_state_machine state_machine; struct ps3_recovery_context *recovery_context; struct ps3_recovery_function recovery_function; #ifndef _WINDOWS struct work_struct recovery_irq_work; struct workqueue_struct *recovery_irq_queue; - unsigned char recovery_irq_enable; - unsigned char is_print_special_log; - unsigned char reserved2[2]; - unsigned int hard_dog_mask; + U8 recovery_irq_enable; + Bool is_print_special_log; + U8 reserved2[2]; + U32 hard_dog_mask; #endif - atomic_t hardreset_event; + volatile U32 hardreset_event; struct ps3_qos_context qos_context; - struct mutex task_abort_lock; - unsigned char r1x_mode; - unsigned long long start_pfn; - unsigned long long end_pfn; - unsigned long long so_start_addr; - unsigned long long so_end_addr; - int device_busy_threshold; - unsigned char is_pcie_err_detected; - unsigned char reserved3; + ps3_mutex task_abort_lock; + U8 r1x_mode; + U64 start_pfn; + U64 end_pfn; + U64 so_start_addr; + U64 so_end_addr; + S32 device_busy_threshold; + U8 is_pcie_err_detected; + U8 reserved3; }; #ifndef _WINDOWS struct ps3_mgmt_info { - struct mutex ps3_mgmt_lock; - struct list_head instance_list_head; + ps3_mutex ps3_mgmt_lock; + ps3_list_head instance_list_head; }; -enum { +enum { PS3_HOST_MACHINE_DEFAULT, PS3_HOST_MACHINE_X86 = 0, PS3_HOST_MACHINE_ARM, @@ -245,7 +241,7 @@ enum { PS3_HOST_MACHINE_COUNT, }; -enum { +enum { PS3_HOST_VENDOR_DEFAULT, PS3_HOST_VENDOR_INTEL = 0, PS3_HOST_VENDOR_HYGON, @@ -255,21 +251,21 @@ enum { #define SYS_INFO_LEN (64) struct ps3_host_info { - unsigned char machine; - unsigned char vendor; - unsigned short cpu_cnt; - unsigned short core_cnt; - unsigned short processor_cnt; + U8 machine; + U8 vendor; + U16 cpu_cnt; + U16 core_cnt; + U16 processor_cnt; char release[SYS_INFO_LEN + 1]; }; -struct ps3_mgmt_info *ps3_mgmt_info_get(void); +struct ps3_mgmt_info* ps3_mgmt_info_get(void); -struct ps3_instance *ps3_instance_lookup(unsigned short host_no); +struct ps3_instance *ps3_instance_lookup(U16 host_no); -int ps3_instance_add(struct ps3_instance *instance); +S32 ps3_instance_add(struct ps3_instance *instance); -int ps3_instance_remove(struct ps3_instance *instance); +S32 ps3_instance_remove(struct ps3_instance *instance); void ps3_mgmt_info_init(void); @@ -279,12 +275,10 @@ void ps3_mgmt_exit(void); void ps3_instance_init(struct ps3_instance *instance); -int ps3_instance_state_transfer(struct ps3_instance *instance, - unsigned int exp_cur_state, - unsigned int dest_state); - -int ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, - unsigned int dest_state); +S32 ps3_instance_state_transfer(struct ps3_instance *instance, + U32 exp_cur_state, U32 dest_state); +S32 ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, + U32 dest_state); void ps3_instance_state_transfer_to_dead_nolock(struct ps3_instance *instance); @@ -298,26 +292,20 @@ void ps3_instance_state_transfer_to_suspend(struct ps3_instance *instance); void ps3_instance_state_transition_to_recovery(struct ps3_instance *instance); -int ps3_instance_wait_for_operational(struct ps3_instance *instance, - unsigned char is_hardreset); - -int ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance); +S32 ps3_instance_wait_for_operational(struct ps3_instance *instance, Bool is_hardreset); +S32 ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance); -int ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance); +S32 ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance); -static inline unsigned char -ps3_is_instance_state_normal(struct ps3_instance *instance, - unsigned char need_prk_err) +static inline Bool ps3_is_instance_state_normal(struct ps3_instance *instance, Bool need_prk_err) { - int cur_state = ps3_atomic_read(&instance->state_machine.state); - + S32 cur_state = ps3_atomic_read(&instance->state_machine.state); + INJECT_START(PS3_ERR_IJ_SAS_REQ_PRE_CHECK, &cur_state) if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { - LOG_WARN_LIM_WITH_CHECK(instance, need_prk_err, - "hno:%u instance exception state %s\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state)); + cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && + cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { + LOG_WARN_LIM_WITH_CHECK(instance, need_prk_err, "hno:%u instance exception state %s\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); return PS3_FALSE; } @@ -325,62 +313,49 @@ ps3_is_instance_state_normal(struct ps3_instance *instance, return PS3_TRUE; } -static inline void ps3_pci_err_recovery_set(struct ps3_instance *instance, - unsigned char state) +static inline void ps3_pci_err_recovery_set(struct ps3_instance *instance, Bool state) { instance->state_machine.is_pci_err_recovery = state; } -static inline unsigned char -ps3_pci_err_recovery_get(struct ps3_instance *instance) +static inline Bool ps3_pci_err_recovery_get(struct ps3_instance *instance) { return instance->state_machine.is_pci_err_recovery; } - -static inline unsigned char -ps3_need_block_hard_reset_request(struct ps3_instance *instance) +static inline Bool ps3_need_block_hard_reset_request(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - + S32 ret = PS3_SUCCESS; if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN_LIM( - "hno[%u], host in pci recovery during reset request\n", + LOG_WARN_LIM("hno[%u], host in pci recovery during reset request\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto end; } ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state != - PS3_HOST_RESET_INIT) { + if(instance->recovery_context->host_reset_state != PS3_HOST_RESET_INIT) { ps3_mutex_unlock(&instance->state_machine.lock); - LOG_WARN_LIM( - "hno[%u], host in host reset during reset request\n", + LOG_WARN_LIM("hno[%u], host in host reset during reset request\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto end; } ps3_mutex_unlock(&instance->state_machine.lock); end: - return ((ret == PS3_SUCCESS) ? PS3_FALSE : PS3_TRUE); + return ((ret == PS3_SUCCESS) ? PS3_FALSE:PS3_TRUE); } - -static inline void -ps3_need_wait_hard_reset_request(struct ps3_instance *instance) +static inline void ps3_need_wait_hard_reset_request(struct ps3_instance *instance) { do { if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN_LIM( - "hno[%u], host in pci recovery during reset request\n", + LOG_WARN_LIM("hno[%u], host in pci recovery during reset request\n", PS3_HOST(instance)); ps3_msleep(100); continue; } ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state != - PS3_HOST_RESET_INIT) { + if(instance->recovery_context->host_reset_state != PS3_HOST_RESET_INIT) { ps3_mutex_unlock(&instance->state_machine.lock); - LOG_WARN_LIM( - "hno[%u], host in host reset during reset request\n", + LOG_WARN_LIM("hno[%u], host in host reset during reset request\n", PS3_HOST(instance)); ps3_msleep(100); continue; @@ -390,71 +365,66 @@ ps3_need_wait_hard_reset_request(struct ps3_instance *instance) } while (1); } -static inline unsigned char ps3_state_is_normal(int cur_state) +static inline Bool ps3_state_is_normal(S32 cur_state) { return (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL) ? - PS3_FALSE : - PS3_TRUE; + PS3_FALSE : PS3_TRUE; } -int ps3_instance_wait_for_normal(struct ps3_instance *instance); +S32 ps3_instance_wait_for_normal(struct ps3_instance *instance); -int ps3_recovery_state_wait_for_normal(struct ps3_instance *instance); +S32 ps3_recovery_state_wait_for_normal(struct ps3_instance *instance); struct ps3_ioc_adp_template { - int (*io_cmd_build)(struct ps3_cmd *cmd); - int (*mgr_cmd_build)(struct ps3_instance *instance, - struct ps3_cmd *cmd); + S32 (*io_cmd_build)(struct ps3_cmd *cmd); + S32 (*mgr_cmd_build)(struct ps3_instance *instance, + struct ps3_cmd *cmd); void (*init_cmd_send)(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); + struct PS3CmdWord *cmd_word); void (*cmd_send)(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); - unsigned int (*ioc_state_get)(struct ps3_instance *instance); - int (*ioc_init_state_to_ready)(struct ps3_instance *instance); - int (*ioc_init_proc)(struct ps3_instance *instance); + struct PS3CmdWord *cmd_word); + U32 (*ioc_state_get)(struct ps3_instance *instance); + S32 (*ioc_init_state_to_ready)(struct ps3_instance *instance); + S32 (*ioc_init_proc)(struct ps3_instance *instance); void (*ioc_resource_prepare)(struct ps3_instance *instance); - int (*ioc_hard_reset)(struct ps3_instance *instance); - int (*ioc_shallow_soft_reset)(struct ps3_instance *instance); - int (*ioc_deep_soft_reset)(struct ps3_instance *instance); - int (*ioc_force_to_fault)(struct ps3_instance *instance); - int (*ioc_force_to_halt)(struct ps3_instance *instance); - int (*irq_init)(struct ps3_instance *instance); + S32 (*ioc_hard_reset)(struct ps3_instance *instance); + S32 (*ioc_shallow_soft_reset)(struct ps3_instance *instance); + S32 (*ioc_deep_soft_reset)(struct ps3_instance *instance); + S32 (*ioc_force_to_fault)(struct ps3_instance *instance); + S32 (*ioc_force_to_halt)(struct ps3_instance *instance); + S32 (*irq_init)(struct ps3_instance *instance); void (*irq_enable)(struct ps3_instance *instance); void (*irq_disable)(struct ps3_instance *instance); #ifndef _WINDOWS irqreturn_t (*isr)(int irq_no, void *data); struct scsi_transport_template *(*sas_transport_get)(void); #else - unsigned char (*isr)(void *instance, unsigned long irq_no); + U8(*isr)(void *instance, ULong irq_no); #endif - void (*event_filter_table_get)(unsigned char *data); - void (*reg_write)(struct ps3_instance *instance, unsigned long long val, - void __iomem *reg); - unsigned long long (*reg_read)(struct ps3_instance *instance, - void __iomem *reg); - unsigned char (*is_need_direct_to_normal)(const struct ps3_cmd *cmd); - unsigned char (*max_replyq_count_get)(struct ps3_instance *instance, - unsigned int *max_replyq_count); + void (*event_filter_table_get)(U8 *data); + void (*reg_write)(struct ps3_instance *instance, U64 val, void __iomem *reg); + U64 (*reg_read)(struct ps3_instance *instance, void __iomem *reg); + Bool (*is_need_direct_to_normal)(const struct ps3_cmd *cmd); + Bool (*max_replyq_count_get)(struct ps3_instance *instance, + U32 *max_replyq_count); void (*check_vd_member_change)(struct ps3_instance *instance, - struct ps3_pd_entry *local_entry); - unsigned char (*scsih_stream_is_detect)(struct ps3_cmd *cmd); - unsigned char (*scsih_stream_is_direct)(const struct ps3_cmd *cmd); - unsigned int (*ioc_heartbeat_detect)(struct ps3_instance *instance); - void __iomem *(*reg_set)(struct pci_dev *pdev, unsigned long reg_bar); - unsigned char (*ioc_security_check)(struct ps3_instance *instance); + struct ps3_pd_entry *local_entry); + Bool (*scsih_stream_is_detect)(struct ps3_cmd *cmd); + Bool (*scsih_stream_is_direct)(const struct ps3_cmd *cmd); + U32 (*ioc_heartbeat_detect)(struct ps3_instance *instance); + void __iomem * (*reg_set)(struct pci_dev *pdev, ULong reg_bar); + Bool (*ioc_security_check)(struct ps3_instance *instance); void (*io_cmd_rebuild)(struct ps3_cmd *cmd); - unsigned char (*rw_cmd_is_need_split)(struct ps3_cmd *cmd); - unsigned char (*write_direct_enable)(struct ps3_cmd *cmd); - unsigned char (*ssd_vd_qmask_calculate)(struct ps3_cmd *cmd); + Bool (*rw_cmd_is_need_split)(struct ps3_cmd *cmd); + Bool (*write_direct_enable)(struct ps3_cmd *cmd); + Bool (*ssd_vd_qmask_calculate)(struct ps3_cmd *cmd); }; -#define PS3_DEVICE_IS_SWITCH(id) \ - ((id == PCI_DEVICE_ID_PS3_SWITCH || \ - id == PCI_DEVICE_ID_PS3_SWITCH_FPGA)) +#define PS3_DEVICE_IS_SWITCH(id) ((id == PCI_DEVICE_ID_PS3_SWITCH || \ + id == PCI_DEVICE_ID_PS3_SWITCH_FPGA)) #ifndef _WINDOWS -void ps3_ioc_adp_init(struct ps3_instance *instance, - const struct pci_device_id *id); +void ps3_ioc_adp_init(struct ps3_instance *instance, const struct pci_device_id *id); void ps3_remove(struct pci_dev *pdev); @@ -462,22 +432,22 @@ void ps3_remove(struct pci_dev *pdev); void ps3_ioc_adp_init(struct ps3_instance *instance); #endif -static inline int ps3_get_pci_function(struct pci_dev *pci) +static inline S32 ps3_get_pci_function(struct pci_dev *pci) { - return PCI_FUNC(pci->devfn); + return (PCI_FUNC(pci->devfn)); } -static inline int ps3_get_pci_slot(struct pci_dev *pci) +static inline S32 ps3_get_pci_slot(struct pci_dev * pci) { - return PCI_SLOT(pci->devfn); + return (PCI_SLOT(pci->devfn)); } -static inline int ps3_get_pci_bus(struct pci_dev *pci) +static inline S32 ps3_get_pci_bus(struct pci_dev * pci) { - return pci->bus->number; + return (pci->bus->number); } -static inline int ps3_get_pci_domain(struct pci_dev *pci) +static inline S32 ps3_get_pci_domain(struct pci_dev *pci) { return pci_domain_nr(pci->bus); } @@ -487,19 +457,13 @@ static inline bool ps3_is_latest_func(struct ps3_instance *instance) bool ret = PS3_TRUE; struct ps3_instance *peer_instance = NULL; - list_for_each_entry(peer_instance, - &ps3_mgmt_info_get()->instance_list_head, - list_item) { + list_for_each_entry(peer_instance, &ps3_mgmt_info_get()->instance_list_head, list_item) { if ((peer_instance != NULL) && - (ps3_get_pci_domain(peer_instance->pdev) == - ps3_get_pci_domain(instance->pdev)) && - (PCI_BUS_NUM(peer_instance->pdev->devfn) == - PCI_BUS_NUM(instance->pdev->devfn)) && - (PCI_SLOT(peer_instance->pdev->devfn) == - PCI_SLOT(instance->pdev->devfn)) && - (PCI_FUNC(peer_instance->pdev->devfn) != - PCI_FUNC(instance->pdev->devfn))) { - ret = PS3_FALSE; + (ps3_get_pci_domain(peer_instance->pdev) == ps3_get_pci_domain(instance->pdev)) && + (PCI_BUS_NUM(peer_instance->pdev->devfn) == PCI_BUS_NUM(instance->pdev->devfn)) && + (PCI_SLOT(peer_instance->pdev->devfn) == PCI_SLOT(instance->pdev->devfn)) && + (PCI_FUNC(peer_instance->pdev->devfn) != PCI_FUNC(instance->pdev->devfn))) { + ret = PS3_FALSE; } } @@ -507,31 +471,26 @@ static inline bool ps3_is_latest_func(struct ps3_instance *instance) } static inline void ps3_get_so_addr_ranger(struct ps3_instance *instance, - unsigned long long addr, - unsigned int offset) + U64 addr, U32 offset) { - unsigned long long so_end_addr = (addr + offset) - 1; + U64 so_end_addr = (addr + offset) - 1; if (instance->so_start_addr == 0 && instance->so_end_addr == 0) { instance->so_start_addr = addr; instance->so_end_addr = so_end_addr; goto l_out; } - instance->so_start_addr = - ((addr < instance->so_start_addr) ? addr : - instance->so_start_addr); - instance->so_end_addr = - ((so_end_addr > instance->so_end_addr) ? so_end_addr : - instance->so_end_addr); + instance->so_start_addr = ((addr < instance->so_start_addr) ? addr : instance->so_start_addr); + instance->so_end_addr = ((so_end_addr > instance->so_end_addr) ? so_end_addr : instance->so_end_addr); l_out: return; } void ps3_host_info_get(void); -unsigned short ps3_host_vendor_get(void); +U16 ps3_host_vendor_get(void); char *ps3_host_release_get(void); -unsigned char ps3_is_last_func(struct ps3_instance *instance); +U8 ps3_is_last_func(struct ps3_instance *instance); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_io_trace.c b/drivers/scsi/linkdata/ps3stor/ps3_io_trace.c index 4246f6a408ca..8f1801b6a944 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_io_trace.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_io_trace.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #ifndef _WINDOWS #include #include @@ -8,63 +6,65 @@ #include "ps3_instance_manager.h" #include "ps3_scsih_cmd_parse.h" #include "ps3_io_trace.h" -#include "ps3_kernel_version.h" -static inline const char *ps3_io_trace_direct_name(enum ps3_io_trace_dtype type) +static inline const char *ps3_io_trace_direct_name(ps3_io_trace_dtype type) { - static const char *const direct_name[] = { "cmd send", "cmd recv", - "unknown" }; - if (type >= PS3_IO_TRACE_DIRECT_COUNT) + static const char *direct_name[] = { + "cmd send", + "cmd recv", + "unknown" + }; + if(type >= PS3_IO_TRACE_DIRECT_COUNT) { return direct_name[PS3_IO_TRACE_DIRECT_COUNT]; + } return direct_name[type]; } #ifndef _WINDOWS -static inline unsigned char ps3_is_scsi_read_cmd(struct scsi_cmnd *s_cmnd) +static inline Bool ps3_is_scsi_read_cmd(struct scsi_cmnd *s_cmnd) { - return (s_cmnd != NULL && - s_cmnd->sc_data_direction == DMA_FROM_DEVICE && + return (s_cmnd != NULL && s_cmnd->sc_data_direction == DMA_FROM_DEVICE && (s_cmnd->cmnd[0] == READ_6 || s_cmnd->cmnd[0] == READ_10 || - s_cmnd->cmnd[0] == READ_12 || s_cmnd->cmnd[0] == READ_16)); + s_cmnd->cmnd[0] == READ_12 || s_cmnd->cmnd[0] == READ_16)); } -static inline unsigned char ps3_is_scsi_write_cmd(struct scsi_cmnd *s_cmnd) +static inline Bool ps3_is_scsi_write_cmd(struct scsi_cmnd *s_cmnd) { return (s_cmnd != NULL && s_cmnd->sc_data_direction == DMA_TO_DEVICE && (s_cmnd->cmnd[0] == WRITE_6 || s_cmnd->cmnd[0] == WRITE_10 || - s_cmnd->cmnd[0] == WRITE_12 || s_cmnd->cmnd[0] == WRITE_16)); + s_cmnd->cmnd[0] == WRITE_12 || s_cmnd->cmnd[0] == WRITE_16)); } static void ps3_scsi_sgl_crc(const struct ps3_cmd *cmd) { - unsigned int sge_count = 0; - unsigned int i = 0; - unsigned int crc = 0; - unsigned int seed = 0x1234; - char *pdata = NULL; - unsigned int buf_len = 0; - char buf[PS3_IO_TRACE_BUF_LEN] = { 0 }; + U32 sge_count = 0; + U32 i = 0; + U32 crc = 0; + U32 seed = 0x1234; + S8 *pdata = NULL; + U32 buf_len = 0; + S8 buf[PS3_IO_TRACE_BUF_LEN] = { 0 }; struct scatterlist *os_sgl = NULL; struct ps3_instance *instance = cmd->instance; struct scsi_cmnd *s_cmnd = cmd->scmd; - if (instance->debug_context.io_trace_switch == PS3_FALSE) + if (instance->debug_context.io_trace_switch == PS3_FALSE) { goto l_out; + } sge_count = cmd->os_sge_map_count; scsi_for_each_sg(s_cmnd, os_sgl, sge_count, i) { - pdata = (char *)sg_virt(os_sgl); + pdata = (S8 *)sg_virt(os_sgl); crc = crc32(seed, pdata, sg_dma_len(os_sgl)); memset(buf, '\0', sizeof(buf)); - buf_len = snprintf( - buf, PS3_IO_TRACE_BUF_LEN, - "hno:%u channel[%u], target[%u], trace_id[0x%llx], [%u of %u]sge\n" - "\tsge data addr[0x%llx] length[%u], D[%llx:%llx] CRC[0x%x]\n", - PS3_HOST(instance), s_cmnd->device->channel, - s_cmnd->device->id, cmd->trace_id, i + 1, sge_count, - (unsigned long long)sg_dma_address(os_sgl), - sg_dma_len(os_sgl), *(unsigned long long *)pdata, - *((unsigned long long *)(pdata + 8)), crc); + buf_len = snprintf(buf, PS3_IO_TRACE_BUF_LEN, + "hno:%u channel[%u], target[%u]," + "trace_id[0x%llx], [%u of %u]sge, sge data addr[0x%llx] length[%u], " + "D[%llx:%llx] CRC[0x%x] \n", + PS3_HOST(instance), s_cmnd->device->channel, s_cmnd->device->id, + cmd->trace_id, + i + 1, sge_count, sg_dma_address(os_sgl), + sg_dma_len(os_sgl), *(U64 *)pdata, *((U64 *)(pdata + 8)), crc); if (buf_len >= PS3_IO_TRACE_BUF_LEN) { LOG_ERROR("buf_len > PS3_IO_TRACE_BUF_LEN\n"); goto l_out; @@ -76,20 +76,21 @@ static void ps3_scsi_sgl_crc(const struct ps3_cmd *cmd) return; } #endif -void ps3_scsih_io_trace(const struct ps3_cmd *cmd, enum ps3_io_trace_dtype type) +void ps3_scsih_io_trace(const struct ps3_cmd *cmd, ps3_io_trace_dtype type) { - int buf_len = 0; + S32 buf_len = 0; char buf[PS3_IO_TRACE_BUF_LEN] = { 0 }; - unsigned long long lba = 0; + U64 lba = 0; if (cmd == NULL || cmd->scmd == NULL) { LOG_WARN("cmd or scmd is null\n"); goto l_out; } - if (scsi_sg_count(cmd->scmd) == 0) + if (scsi_sg_count(cmd->scmd) == 0) { goto l_out; + } -#if defined(PS3_CMD_CDB_CHECK) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) if (cmd->scmd->cmnd == NULL || cmd->instance->host == NULL) { LOG_WARN("cdb null\n"); goto l_out; @@ -101,28 +102,25 @@ void ps3_scsih_io_trace(const struct ps3_cmd *cmd, enum ps3_io_trace_dtype type) } #endif - if ((type == PS3_IO_TRACE_DIRECT_SEND && - ps3_is_scsi_write_cmd(cmd->scmd)) || - (type == PS3_IO_TRACE_DIRECT_RECV && - ps3_is_scsi_read_cmd(cmd->scmd))) { + if ((type == PS3_IO_TRACE_DIRECT_SEND && ps3_is_scsi_write_cmd(cmd->scmd)) || + (type == PS3_IO_TRACE_DIRECT_RECV && ps3_is_scsi_read_cmd(cmd->scmd))){ ps3_scsi_sgl_crc(cmd); } ps3_scsih_lba_parse(cmd->scmd->cmnd, &lba); memset(buf, '\0', sizeof(buf)); buf_len = snprintf(buf, PS3_IO_TRACE_BUF_LEN, - "%s, trace_id[0x%llx], hno:%u lba[0x%llx]\n", - ps3_io_trace_direct_name(type), cmd->trace_id, - PS3_HOST(cmd->instance), lba); + "%s, trace_id[0x%llx], hno:%u lba[0x%llx]\n", + ps3_io_trace_direct_name(type), cmd->trace_id, PS3_HOST(cmd->instance), lba); if (buf_len >= PS3_IO_TRACE_BUF_LEN) { LOG_ERROR("buf_len > PS3_IO_TRACE_BUF_LEN\n"); goto l_out; } DATA_DUMP(sg_virt(cmd->scmd->sdb.table.sgl), - min_t(unsigned int, cmd->scmd->sdb.table.sgl[0].length, - PS3_IO_TRACE_PRINT_COUNT), - buf); + min_t(U32, cmd->scmd->sdb.table.sgl[0].length, + PS3_IO_TRACE_PRINT_COUNT), buf); l_out: return; } + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_io_trace.h b/drivers/scsi/linkdata/ps3stor/ps3_io_trace.h index e52887949272..3675dad01f6e 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_io_trace.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_io_trace.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_IO_TRACE_H_ #define _PS3_IO_TRACE_H_ @@ -8,21 +7,18 @@ #define PS3_IO_TRACE_PRINT_COUNT (32) #define PS3_IO_TRACE_BUF_LEN (256) -enum ps3_io_trace_dtype { +typedef enum { PS3_IO_TRACE_DIRECT_SEND, PS3_IO_TRACE_DIRECT_RECV, PS3_IO_TRACE_DIRECT_COUNT, -}; +}ps3_io_trace_dtype; -void ps3_scsih_io_trace(const struct ps3_cmd *cmd, - enum ps3_io_trace_dtype type); -#define PS3_IO_TRACE(cmd, type) \ - do { \ - if ((cmd)->instance->debug_context.io_trace_switch == \ - PS3_FALSE) { \ - break; \ - } \ - ps3_scsih_io_trace((cmd), (type)); \ - } while (0) +void ps3_scsih_io_trace(const struct ps3_cmd *cmd, ps3_io_trace_dtype type); +#define PS3_IO_TRACE(cmd, type) do { \ + if ((cmd)->instance->debug_context.io_trace_switch == PS3_FALSE) { \ + break; \ + } \ + ps3_scsih_io_trace((cmd),(type)); \ +} while(0); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioc_adp.c b/drivers/scsi/linkdata/ps3stor/ps3_ioc_adp.c index 6fab2c805654..999d47d10d6b 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioc_adp.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioc_adp.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #ifdef _WINDOWS #include "ps3_def.h" #endif @@ -17,20 +15,20 @@ #include "ps3_module_para.h" #include "ps3_scsih.h" -#define MAX_MGR_CMD_COUNT (8) -#define MAX_TASK_CMD_COUNT (8) -#define MIN_MSIX_INT_COUNT (1) -#define PS3_HARD_DOG_MASK (0xF000000UL) +#define MAX_MGR_CMD_COUNT (8) +#define MAX_TASK_CMD_COUNT (8) +#define MIN_MSIX_INT_COUNT (1) +#define PS3_HARD_DOG_MASK (0xF000000UL) -#define SWITCH_MAX_MGR_CMD_COUNT (12) -#define SWITCH_MAX_TASK_CMD_COUNT (2) -#define SWITCH_MAX_MGR_CMD_TOTAL_COUNT (14) -#define SWITCH_MIN_MSI_INT_COUNT (1) -#define SWITCH_REPLY_FIFO_DEP_ADDITION (1) -#define PS3_HARD_DOG_MASK_SWITCH (0x1000000UL) +#define SWITCH_MAX_MGR_CMD_COUNT (12) +#define SWITCH_MAX_TASK_CMD_COUNT (2) +#define SWITCH_MAX_MGR_CMD_TOTAL_COUNT (14) +#define SWITCH_MIN_MSI_INT_COUNT (1) +#define SWITCH_REPLY_FIFO_DEP_ADDITION (1) +#define PS3_HARD_DOG_MASK_SWITCH (0x1000000UL) struct ps3_ioc_adp_temp_entry { - unsigned short device_id; + U16 device_id; struct ps3_ioc_adp_template *adp_template; }; @@ -62,9 +60,8 @@ void ps3_ioc_resource_prepare_switch(struct ps3_instance *instance) instance->ioc_fw_version = 0; instance->hilMode = HIL_MODEL_SW; instance->unload_timeout = PS3_DEFAULT_MGR_CMD_TIMEOUT; - instance->wait_ready_timeout = - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_SWITCH; - instance->is_half_hard_reset = PS3_FALSE; + instance->wait_ready_timeout = PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_SWITCH; + instance ->is_half_hard_reset = PS3_FALSE; instance->is_need_event = PS3_FALSE; instance->is_raid1_direct_skip_mapblock_check = PS3_FALSE; instance->is_single_disk_raid0_direct_skip_strip_check = PS3_FALSE; @@ -79,8 +76,7 @@ void ps3_ioc_resource_prepare_switch(struct ps3_instance *instance) instance->r1x_mode = PS3_R1X_MODE_NORMAL; instance->smp_affinity_enable = ps3_smp_affinity_query(); instance->page_mode_change = - ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : - PS3_TRUE; + ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : PS3_TRUE; instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_3_ADDR_MASK; ps3_mutex_init(&instance->task_mgr_reset_lock); ps3_mutex_init(&instance->task_abort_lock); @@ -92,8 +88,11 @@ void ps3_ioc_resource_prepare_raid(struct ps3_instance *instance) memset(event_req_info, 0, sizeof(struct PS3MgrEvent)); - event_req_info->eventTypeMap = PS3_EVT_PD_COUNT | PS3_EVT_VD_COUNT | - PS3_EVT_CTRL_INFO | PS3_EVT_PD_ATTR; + event_req_info->eventTypeMap = + PS3_EVT_PD_COUNT | + PS3_EVT_VD_COUNT | + PS3_EVT_CTRL_INFO | + PS3_EVT_PD_ATTR; event_req_info->eventLevel = PS3_EVENT_LEVEL_INFO; event_req_info->eventTypeMapProcResult = PS3_EVT_ILLEGAL_TYPE; @@ -116,13 +115,11 @@ void ps3_ioc_resource_prepare_raid(struct ps3_instance *instance) instance->hilMode = HIL_MODEL_HW_ENHANCED; instance->unload_timeout = PS3_RAID_UNLOAD_MGR_CMD_TIMEOUT; #ifdef PS3_HARDWARE_HAPS_V200 - instance->wait_ready_timeout = - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID_HAPS; + instance->wait_ready_timeout = PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID_HAPS; #else - instance->wait_ready_timeout = - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID; + instance->wait_ready_timeout = PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID; #endif - instance->is_half_hard_reset = PS3_FALSE; + instance ->is_half_hard_reset = PS3_FALSE; instance->is_need_event = PS3_TRUE; instance->is_raid1_direct_skip_mapblock_check = PS3_FALSE; instance->is_single_disk_raid0_direct_skip_strip_check = PS3_FALSE; @@ -137,8 +134,7 @@ void ps3_ioc_resource_prepare_raid(struct ps3_instance *instance) instance->task_manager_host_busy = PS3_FALSE; instance->smp_affinity_enable = ps3_smp_affinity_query(); instance->page_mode_change = - ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : - PS3_TRUE; + ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : PS3_TRUE; instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_3_ADDR_MASK; ps3_mutex_init(&instance->task_mgr_reset_lock); ps3_mutex_init(&instance->task_abort_lock); @@ -151,9 +147,12 @@ void ps3_ioc_resource_prepare_hba(struct ps3_instance *instance) memset(event_req_info, 0, sizeof(struct PS3MgrEvent)); - event_req_info->eventTypeMap = PS3_EVT_PD_COUNT | PS3_EVT_VD_COUNT | - PS3_EVT_CTRL_INFO | PS3_EVT_SAS_INFO | - PS3_EVT_PD_ATTR; + event_req_info->eventTypeMap = + PS3_EVT_PD_COUNT | + PS3_EVT_VD_COUNT | + PS3_EVT_CTRL_INFO | + PS3_EVT_SAS_INFO | + PS3_EVT_PD_ATTR; event_req_info->eventLevel = PS3_EVENT_LEVEL_INFO; event_req_info->eventTypeMapProcResult = PS3_EVT_ILLEGAL_TYPE; @@ -179,7 +178,7 @@ void ps3_ioc_resource_prepare_hba(struct ps3_instance *instance) instance->hilMode = HIL_MODEL_HW_ENHANCED; instance->unload_timeout = PS3_UNLOAD_MGR_CMD_TIMEOUT; instance->wait_ready_timeout = PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_HBA; - instance->is_half_hard_reset = PS3_FALSE; + instance ->is_half_hard_reset = PS3_FALSE; instance->is_need_event = PS3_TRUE; instance->is_raid1_direct_skip_mapblock_check = PS3_TRUE; instance->is_single_disk_raid0_direct_skip_strip_check = PS3_TRUE; @@ -195,37 +194,33 @@ void ps3_ioc_resource_prepare_hba(struct ps3_instance *instance) instance->task_manager_host_busy = PS3_FALSE; instance->r1x_mode = PS3_R1X_MODE_NORMAL; instance->page_mode_change = - ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : - PS3_TRUE; + ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : PS3_TRUE; instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_3_ADDR_MASK; ps3_mutex_init(&instance->task_mgr_reset_lock); ps3_mutex_init(&instance->task_abort_lock); ps3_hba_qos_prepare(instance); } -static unsigned char -ps3_replyq_count_raidhba_get(struct ps3_instance *instance, - unsigned int *max_replyq_count) +static Bool ps3_replyq_count_raidhba_get(struct ps3_instance *instance, + U32 *max_replyq_count) { - unsigned char ret = PS3_TRUE; - + Bool ret = PS3_TRUE; if (!ps3_max_replyq_count_get(instance, max_replyq_count)) { LOG_ERROR("hno:%u ps3_max_replyq_count_get NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_FALSE; goto l_out; } *max_replyq_count += PS3_RAIDHBA_NUM_ADJUST_VALUE; *max_replyq_count = *max_replyq_count > PS3_MAX_REPLY_QUE_COUNT ? - PS3_MAX_REPLY_QUE_COUNT : - *max_replyq_count; + PS3_MAX_REPLY_QUE_COUNT : *max_replyq_count; l_out: return ret; } -static unsigned char ps3_is_need_direct_to_normal_hba(const struct ps3_cmd *cmd) +static Bool ps3_is_need_direct_to_normal_hba(const struct ps3_cmd *cmd) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; if (ps3_direct_to_normal_query()) { ret = PS3_TRUE; @@ -256,176 +251,171 @@ static unsigned char ps3_is_need_direct_to_normal_hba(const struct ps3_cmd *cmd) return ret; } -static unsigned char -ps3_is_need_direct_to_normal_raid(const struct ps3_cmd *cmd) +static Bool ps3_is_need_direct_to_normal_raid(const struct ps3_cmd *cmd) { (void)cmd; return PS3_TRUE; } -static unsigned char -ps3_is_need_direct_to_normal_switch(const struct ps3_cmd *cmd) +static Bool ps3_is_need_direct_to_normal_switch(const struct ps3_cmd *cmd) { (void)cmd; return PS3_FALSE; } struct ps3_ioc_adp_template g_ps3_template_switch = { - .io_cmd_build = ps3_scsih_cmd_build, - .mgr_cmd_build = NULL, - .init_cmd_send = ps3_switch_init_cmd_send, - .cmd_send = ps3_switch_normal_cmd_send, - .ioc_state_get = ps3_ioc_state_get, - .ioc_init_state_to_ready = ps3_ioc_init_to_ready, - .ioc_init_proc = ps3_ioc_init_proc, - .ioc_resource_prepare = ps3_ioc_resource_prepare_switch, - .ioc_hard_reset = ps3_ioc_state_hard_reset, - .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, - .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, - .ioc_force_to_fault = ps3_ioc_state_force_to_fault, - .ioc_force_to_halt = ps3_ioc_state_force_to_halt, - .irq_init = ps3_irqs_init_switch, - .irq_enable = ps3_irqs_enable, - .irq_disable = ps3_irqs_disable, - .isr = ps3_irqs_service, + .io_cmd_build = ps3_scsih_cmd_build, + .mgr_cmd_build = NULL, + .init_cmd_send = ps3_switch_init_cmd_send, + .cmd_send = ps3_switch_normal_cmd_send, + .ioc_state_get = ps3_ioc_state_get, + .ioc_init_state_to_ready = ps3_ioc_init_to_ready, + .ioc_init_proc = ps3_ioc_init_proc, + .ioc_resource_prepare = ps3_ioc_resource_prepare_switch, + .ioc_hard_reset = ps3_ioc_state_hard_reset, + .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, + .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, + .ioc_force_to_fault = ps3_ioc_state_force_to_fault, + .ioc_force_to_halt = ps3_ioc_state_force_to_halt, + .irq_init = ps3_irqs_init_switch, + .irq_enable = ps3_irqs_enable, + .irq_disable = ps3_irqs_disable, + .isr = ps3_irqs_service, #ifndef _WINDOWS - .sas_transport_get = NULL, + .sas_transport_get = NULL, #endif - .event_filter_table_get = ps3_event_filter_table_get_switch, - .reg_write = ps3_reg_write_u64, + .event_filter_table_get = ps3_event_filter_table_get_switch, + .reg_write = ps3_reg_write_u64, #ifdef _WINDOWS - .reg_read = ps3_reg_read_u64, + .reg_read = ps3_reg_read_u64, #else - .reg_read = ps3_switch_ioc_reg_read, + .reg_read = ps3_switch_ioc_reg_read, #endif - .is_need_direct_to_normal = ps3_is_need_direct_to_normal_switch, - .max_replyq_count_get = ps3_max_replyq_count_get, - .check_vd_member_change = NULL, - .scsih_stream_is_detect = NULL, - .scsih_stream_is_direct = NULL, + .is_need_direct_to_normal = ps3_is_need_direct_to_normal_switch, + .max_replyq_count_get = ps3_max_replyq_count_get, + .check_vd_member_change = NULL, + .scsih_stream_is_detect = NULL, + .scsih_stream_is_direct = NULL, #ifdef PS3_HARDWARE_ASIC - .ioc_heartbeat_detect = ps3_ioc_heartbeat_detect, + .ioc_heartbeat_detect = ps3_ioc_heartbeat_detect, #else - .ioc_heartbeat_detect = NULL, + .ioc_heartbeat_detect = NULL, #endif - .reg_set = NULL, - .ioc_security_check = NULL, - .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, - .rw_cmd_is_need_split = NULL, - .write_direct_enable = NULL, - .ssd_vd_qmask_calculate = NULL, + .reg_set = NULL, + .ioc_security_check = NULL, + .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, + .rw_cmd_is_need_split = NULL, + .write_direct_enable = NULL, + .ssd_vd_qmask_calculate = NULL, }; struct ps3_ioc_adp_template g_ps3_template_hba = { - .io_cmd_build = ps3_scsih_cmd_build, - .mgr_cmd_build = NULL, - - - .init_cmd_send = ps3_switch_init_cmd_send, - .cmd_send = ps3_ioc_cmd_send, - .ioc_state_get = ps3_ioc_state_get, - .ioc_init_state_to_ready = ps3_ioc_init_to_ready, - .ioc_init_proc = ps3_ioc_init_proc, - .ioc_resource_prepare = ps3_ioc_resource_prepare_hba, - .ioc_hard_reset = ps3_ioc_state_hard_reset, - .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, - .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, - .ioc_force_to_fault = ps3_ioc_state_force_to_fault, - .ioc_force_to_halt = ps3_ioc_state_force_to_halt, - .irq_init = ps3_irqs_init, - .irq_enable = ps3_irqs_enable, - .irq_disable = ps3_irqs_disable, - .isr = ps3_irqs_service, + .io_cmd_build = ps3_scsih_cmd_build, + .mgr_cmd_build = NULL, + + + .init_cmd_send = ps3_switch_init_cmd_send, + .cmd_send = ps3_ioc_cmd_send, + .ioc_state_get = ps3_ioc_state_get, + .ioc_init_state_to_ready = ps3_ioc_init_to_ready, + .ioc_init_proc = ps3_ioc_init_proc, + .ioc_resource_prepare = ps3_ioc_resource_prepare_hba, + .ioc_hard_reset = ps3_ioc_state_hard_reset, + .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, + .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, + .ioc_force_to_fault = ps3_ioc_state_force_to_fault, + .ioc_force_to_halt = ps3_ioc_state_force_to_halt, + .irq_init = ps3_irqs_init, + .irq_enable = ps3_irqs_enable, + .irq_disable = ps3_irqs_disable, + .isr = ps3_irqs_service, #ifndef _WINDOWS - .sas_transport_get = ps3_sas_transport_get, + .sas_transport_get = ps3_sas_transport_get, #endif - .event_filter_table_get = ps3_event_filter_table_get_hba, - .reg_write = ps3_reg_write_u64, - .reg_read = ps3_reg_read_u64, - .is_need_direct_to_normal = ps3_is_need_direct_to_normal_hba, - .max_replyq_count_get = ps3_replyq_count_raidhba_get, - .check_vd_member_change = ps3_check_vd_member_change, - .scsih_stream_is_detect = ps3_scsih_stream_is_detect, - .scsih_stream_is_direct = ps3_hba_scsih_stream_is_direct, + .event_filter_table_get = ps3_event_filter_table_get_hba, + .reg_write = ps3_reg_write_u64, + .reg_read = ps3_reg_read_u64, + .is_need_direct_to_normal = ps3_is_need_direct_to_normal_hba, + .max_replyq_count_get = ps3_replyq_count_raidhba_get, + .check_vd_member_change = ps3_check_vd_member_change, + .scsih_stream_is_detect = ps3_scsih_stream_is_detect, + .scsih_stream_is_direct = ps3_hba_scsih_stream_is_direct, #ifdef PS3_HARDWARE_ASIC .ioc_heartbeat_detect = ps3_ioc_heartbeat_detect, #else .ioc_heartbeat_detect = NULL, #endif - .reg_set = ps3_reg_set_ioremap, - .ioc_security_check = NULL, - .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, - .rw_cmd_is_need_split = ps3_scsih_rw_cmd_is_need_split_hba, - .write_direct_enable = NULL, - .ssd_vd_qmask_calculate = ps3_ssd_vd_qmask_calculate_hba, + .reg_set = ps3_reg_set_ioremap, + .ioc_security_check = NULL, + .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, + .rw_cmd_is_need_split = ps3_scsih_rw_cmd_is_need_split_hba, + .write_direct_enable = NULL, + .ssd_vd_qmask_calculate = ps3_ssd_vd_qmask_calculate_hba, }; struct ps3_ioc_adp_template g_ps3_template_raid = { - .io_cmd_build = ps3_scsih_cmd_build, - .mgr_cmd_build = NULL, - - .init_cmd_send = ps3_switch_init_cmd_send, - .cmd_send = ps3_ioc_cmd_send, - .ioc_state_get = ps3_ioc_state_get, - .ioc_init_state_to_ready = ps3_ioc_init_to_ready, - .ioc_init_proc = ps3_ioc_init_proc, - .ioc_resource_prepare = ps3_ioc_resource_prepare_raid, - .ioc_hard_reset = ps3_ioc_state_hard_reset, - .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, - .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, - .ioc_force_to_fault = ps3_ioc_state_force_to_fault, - .ioc_force_to_halt = ps3_ioc_state_force_to_halt, - .irq_init = ps3_irqs_init, - .irq_enable = ps3_irqs_enable, - .irq_disable = ps3_irqs_disable, - .isr = ps3_irqs_service, + .io_cmd_build = ps3_scsih_cmd_build, + .mgr_cmd_build = NULL, + + .init_cmd_send = ps3_switch_init_cmd_send, + .cmd_send = ps3_ioc_cmd_send, + .ioc_state_get = ps3_ioc_state_get, + .ioc_init_state_to_ready = ps3_ioc_init_to_ready, + .ioc_init_proc = ps3_ioc_init_proc, + .ioc_resource_prepare = ps3_ioc_resource_prepare_raid, + .ioc_hard_reset = ps3_ioc_state_hard_reset, + .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, + .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, + .ioc_force_to_fault = ps3_ioc_state_force_to_fault, + .ioc_force_to_halt = ps3_ioc_state_force_to_halt, + .irq_init = ps3_irqs_init, + .irq_enable = ps3_irqs_enable, + .irq_disable = ps3_irqs_disable, + .isr = ps3_irqs_service, #ifndef _WINDOWS - .sas_transport_get = NULL, + .sas_transport_get = NULL, #endif - .event_filter_table_get = ps3_event_filter_table_get_raid, - .reg_write = ps3_reg_write_u64, - .reg_read = ps3_reg_read_u64, - .is_need_direct_to_normal = ps3_is_need_direct_to_normal_raid, - .max_replyq_count_get = ps3_replyq_count_raidhba_get, - .check_vd_member_change = NULL, - .scsih_stream_is_detect = ps3_scsih_stream_is_detect, - .scsih_stream_is_direct = ps3_raid_scsih_stream_is_direct, + .event_filter_table_get = ps3_event_filter_table_get_raid, + .reg_write = ps3_reg_write_u64, + .reg_read = ps3_reg_read_u64, + .is_need_direct_to_normal = ps3_is_need_direct_to_normal_raid, + .max_replyq_count_get = ps3_replyq_count_raidhba_get, + .check_vd_member_change = NULL, + .scsih_stream_is_detect = ps3_scsih_stream_is_detect, + .scsih_stream_is_direct = ps3_raid_scsih_stream_is_direct, #ifdef PS3_HARDWARE_ASIC .ioc_heartbeat_detect = ps3_ioc_heartbeat_detect, #else .ioc_heartbeat_detect = NULL, #endif - .reg_set = ps3_reg_set_ioremap, - .ioc_security_check = ps3_ioc_security_state_check, - .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, - .rw_cmd_is_need_split = ps3_scsih_rw_cmd_is_need_split_raid, - .write_direct_enable = ps3_write_direct_enable, - .ssd_vd_qmask_calculate = NULL, + .reg_set = ps3_reg_set_ioremap, + .ioc_security_check = ps3_ioc_security_state_check, + .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, + .rw_cmd_is_need_split = ps3_scsih_rw_cmd_is_need_split_raid, + .write_direct_enable = ps3_write_direct_enable, + .ssd_vd_qmask_calculate = NULL, }; static struct ps3_ioc_adp_temp_entry ps3_ioc_adp_template_map[] = { - { PCI_DEVICE_ID_PS3_RAID, &g_ps3_template_raid }, - { PCI_DEVICE_ID_PS3_HBA, &g_ps3_template_hba }, - { PCI_DEVICE_ID_PS3_SWITCH, &g_ps3_template_switch }, - { PCI_DEVICE_ID_PS3_SWITCH_FPGA, &g_ps3_template_switch }, - { PCI_DEVICE_ID_STARS_IOC_2020_18i, &g_ps3_template_hba }, - { PCI_DEVICE_ID_STARS_ROC_2020_10i, &g_ps3_template_raid }, - { PCI_DEVICE_ID_PS3_RAID_FPGA, &g_ps3_template_raid }, - { PCI_DEVICE_ID_STARS_IOC_2213_16i, &g_ps3_template_hba }, + {PCI_DEVICE_ID_PS3_RAID, &g_ps3_template_raid}, + {PCI_DEVICE_ID_PS3_HBA, &g_ps3_template_hba}, + {PCI_DEVICE_ID_PS3_SWITCH, &g_ps3_template_switch}, + {PCI_DEVICE_ID_PS3_SWITCH_FPGA, &g_ps3_template_switch}, + {PCI_DEVICE_ID_STARS_IOC_2020_18i, &g_ps3_template_hba}, + {PCI_DEVICE_ID_STARS_ROC_2020_10i, &g_ps3_template_raid}, + {PCI_DEVICE_ID_PS3_RAID_FPGA, &g_ps3_template_raid}, + {PCI_DEVICE_ID_STARS_IOC_2213_16i, &g_ps3_template_hba}, }; #ifndef _WINDOWS -void ps3_ioc_adp_init(struct ps3_instance *instance, - const struct pci_device_id *id) +void ps3_ioc_adp_init(struct ps3_instance *instance, const struct pci_device_id *id) { - unsigned short i = 0; - unsigned short adp_num = sizeof(ps3_ioc_adp_template_map) / - sizeof(struct ps3_ioc_adp_temp_entry); + U16 i = 0; + U16 adp_num = sizeof(ps3_ioc_adp_template_map) / sizeof(struct ps3_ioc_adp_temp_entry); for (i = 0; i < adp_num; i++) { if (id->device == ps3_ioc_adp_template_map[i].device_id) { - instance->ioc_adpter = - ps3_ioc_adp_template_map[i].adp_template; + instance->ioc_adpter = ps3_ioc_adp_template_map[i].adp_template; } } @@ -434,24 +424,19 @@ void ps3_ioc_adp_init(struct ps3_instance *instance, #else void ps3_ioc_adp_init(struct ps3_instance *instance) { - unsigned short i = 0; - unsigned short adp_num = sizeof(ps3_ioc_adp_template_map) / - sizeof(struct ps3_ioc_adp_temp_entry); + U16 i = 0; + U16 adp_num = sizeof(ps3_ioc_adp_template_map) / sizeof(struct ps3_ioc_adp_temp_entry); for (i = 0; i < adp_num; i++) { - if (instance->pci_dev_context.device_id == - ps3_ioc_adp_template_map[i].device_id) { - instance->ioc_adpter = - ps3_ioc_adp_template_map[i].adp_template; - LOG_WARN( - "hno:%u pci dev type is [%s]\n", + if (instance->pci_dev_context.device_id == ps3_ioc_adp_template_map[i].device_id) { + instance->ioc_adpter = ps3_ioc_adp_template_map[i].adp_template; + LOG_WARN("hno:%u pci dev type is [%s]\n", PS3_HOST(instance), - namePciDevType( - ps3_ioc_adp_template_map[i].device_id)); + namePciDevType(ps3_ioc_adp_template_map[i].device_id)); #ifdef _WINDOWS - instance->ioc_adpter->event_filter_table_get = - ps3_event_filter_table_get_raid; + instance->ioc_adpter->event_filter_table_get = ps3_event_filter_table_get_raid; #endif + } } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.c b/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.c index fe2246b2d4f4..79ac48381bf3 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #ifndef _WINDOWS #include @@ -18,130 +16,133 @@ #include "ps3_pci.h" #include "ps3_htp_def.h" #include "ps3_mgr_cmd.h" +#include "ps3_err_inject.h" +#include "ps3_inject.h" #include "ps3_drv_ver.h" -#define PS3_INIT_CMD_WAIT_MAX_TIMEOUT (180) -#define PS3_INIT_CMD_WAIT_INTERVAL (20) +#define PS3_INIT_CMD_WAIT_MAX_TIMEOUT (180) +#define PS3_INIT_CMD_WAIT_INTERVAL (20) #define PS3_INIT_CMD_CHECK_FAULT_INTERVAL (1000) #if (defined PS3_HARDWARE_FPGA && defined PS3_MODEL_V200) -#define PS3_REG_READ_MAX_TRY_COUNT (60) +#define PS3_REG_READ_MAX_TRY_COUNT (60) #else -#define PS3_REG_READ_MAX_TRY_COUNT (10) +#define PS3_REG_READ_MAX_TRY_COUNT (10) #endif #define PS3_REG_SWITCH_QEQUEST_QUEUE_OFFSET (0x10000) #define PS3_IOC_INIT_PROC_FAIL_RETRY_COUNT (2) -static int ps3_ioc_init_cmd_result_poll(struct ps3_instance *instance, - struct PS3InitReqFrame *init_frame_msg) +static S32 ps3_ioc_init_cmd_result_poll(struct ps3_instance *instance, + struct PS3InitReqFrame *init_frame_msg) { - unsigned int state = PS3_FW_STATE_UNDEFINED; - unsigned int wait_count = PS3_INIT_CMD_WAIT_MAX_TIMEOUT * 1000 / - PS3_INIT_CMD_WAIT_INTERVAL; - unsigned int count = 0; - int ret = -PS3_FAILED; + U32 state = PS3_FW_STATE_UNDEFINED; + U32 wait_count = PS3_INIT_CMD_WAIT_MAX_TIMEOUT * 1000 / + PS3_INIT_CMD_WAIT_INTERVAL; + U32 count = 0; + S32 ret = -PS3_FAILED; state = instance->ioc_adpter->ioc_state_get(instance); - while ((count < wait_count) && (state != PS3_FW_STATE_FAULT) && - (state != PS3_FW_STATE_CRITICAL)) { - rmb(); /* in order to force CPU ordering */ + while((count < wait_count) && (state != PS3_FW_STATE_FAULT) + && (state != PS3_FW_STATE_CRITICAL)) { + rmb(); ps3_msleep(PS3_INIT_CMD_WAIT_INTERVAL); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_8, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } - if (init_frame_msg->respStatus != U32_MAX) + if (init_frame_msg->respStatus != U32_MAX) { break; + } if (!(count % PS3_INIT_CMD_CHECK_FAULT_INTERVAL)) { - state = instance->ioc_adpter->ioc_state_get(instance) & - PS3_FW_STATE_MASK; + state = instance->ioc_adpter->ioc_state_get(instance) + & PS3_FW_STATE_MASK; } count++; } - if (state == PS3_FW_STATE_FAULT || state == PS3_FW_STATE_CRITICAL) { + if (state == PS3_FW_STATE_FAULT || + state == PS3_FW_STATE_CRITICAL) { LOG_ERROR("hno:%u init cmd NOK since IOC state fault\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } if (count == wait_count) { - LOG_ERROR( - "hno:%u init cmd timeout, state=%#x, respStatus=%#x\n", + LOG_ERROR("hno:%u init cmd timeout, state=%#x, respStatus=%#x\n", PS3_HOST(instance), state, init_frame_msg->respStatus); goto l_out; } if (init_frame_msg->respStatus != 0) { - LOG_ERROR("hno:%u init cmd NOK[%d]\n", PS3_HOST(instance), - init_frame_msg->respStatus); + LOG_ERROR("hno:%u init cmd NOK[%d]\n", + PS3_HOST(instance), init_frame_msg->respStatus); goto l_out; } - ret = PS3_SUCCESS; + ret = PS3_SUCCESS; LOG_WARN("hno:%u init cmd response successfully\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: init_frame_msg->respStatus = U32_MAX; return ret; } -static int ps3_ioc_init_cmd_issue(struct ps3_instance *instance, - struct PS3InitReqFrame *init_frame_msg) +static S32 ps3_ioc_init_cmd_issue(struct ps3_instance *instance, + struct PS3InitReqFrame *init_frame_msg) { struct ps3_cmd_context *cmd_context = &instance->cmd_context; struct PS3InitCmdWord cmd_word; memset(&cmd_word, 0, sizeof(struct PS3InitCmdWord)); - cmd_word.lowAddr = + cmd_word.lowAddr = cpu_to_le32(lower_32_bits(cmd_context->init_frame_buf_phys)); cmd_word.highAddr = cpu_to_le32(upper_32_bits(cmd_context->init_frame_buf_phys)); - cmd_word.type = PS3_CMDWORD_TYPE_INIT; + cmd_word.type = PS3_CMDWORD_TYPE_INIT; cmd_word.direct = PS3_CMDWORD_DIRECT_NORMAL; - instance->ioc_adpter->init_cmd_send(instance, - (struct PS3CmdWord *)&cmd_word); + instance->ioc_adpter->init_cmd_send(instance, (struct PS3CmdWord *)&cmd_word); - LOG_INFO("hno:%u init command: cmd.lowAddr[0x%x], cmd.highAddr[0x%x], cmd.type[%u]\n", - PS3_HOST(instance), cmd_word.lowAddr, cmd_word.highAddr, - cmd_word.type); + LOG_INFO("hno:%u init command: cmd.lowAddr[0x%x], cmd.highAddr[0x%x], " + "cmd.type[%u]\n", PS3_HOST(instance), cmd_word.lowAddr, + cmd_word.highAddr, cmd_word.type); + INJECT_START(PS3_ERR_IJ_FORCE_INIT_FAIL, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_A_INIT, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_INIT_FAIL, instance) return ps3_ioc_init_cmd_result_poll(instance, init_frame_msg); } -static int ps3_ioc_init_cmd_alloc(struct ps3_instance *instance) +static S32 ps3_ioc_init_cmd_alloc(struct ps3_instance *instance) { struct ps3_cmd_context *cmd_context = &instance->cmd_context; - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - cmd_context->init_frame_buf = (unsigned char *)ps3_dma_alloc_coherent( - instance, sizeof(struct PS3InitReqFrame), - (unsigned long long *)&cmd_context->init_frame_buf_phys); + cmd_context->init_frame_buf = + (U8*)ps3_dma_alloc_coherent(instance, + sizeof(struct PS3InitReqFrame), + &cmd_context->init_frame_buf_phys); if (!cmd_context->init_frame_buf) { LOG_ERROR("hno:%u Failed to alloc init cmd dma buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } - cmd_context->init_filter_table_buff = - (unsigned char *)ps3_dma_alloc_coherent( - instance, PS3_CMD_EXT_BUF_SIZE_MGR, - (unsigned long long *)&cmd_context - ->init_filter_table_phy_addr); + cmd_context->init_filter_table_buff = (U8*)ps3_dma_alloc_coherent(instance, + PS3_CMD_EXT_BUF_SIZE_MGR, + &cmd_context->init_filter_table_phy_addr); if (!cmd_context->init_filter_table_buff) { - LOG_ERROR( - "hno:%u Failed to alloc init filter table dma buffer\n", + LOG_ERROR("hno:%u Failed to alloc init filter table dma buffer\n", PS3_HOST(instance)); ret = -PS3_FAILED; } @@ -150,22 +151,22 @@ static int ps3_ioc_init_cmd_alloc(struct ps3_instance *instance) } #ifndef _WINDOWS -static int ps3_ioc_sys_info_get(struct ps3_instance *instance) +static S32 ps3_ioc_sys_info_get(struct ps3_instance *instance) { - struct ps3_cmd_context *cmd_context = &instance->cmd_context; - struct PS3DrvSysInfo *drv_sys_info = NULL; + struct ps3_cmd_context *cmd_context = &instance->cmd_context; + struct PS3DrvSysInfo *drv_sys_info = NULL; const char *sys_info = NULL; - unsigned int sys_info_len = 0; - int ret = -PS3_FAILED; + U32 sys_info_len = 0; + S32 ret = -PS3_FAILED; cmd_context->init_frame_sys_info_buf = - (unsigned char *)ps3_dma_alloc_coherent( - instance, sizeof(struct PS3DrvSysInfo), - (unsigned long long *)&cmd_context - ->init_frame_sys_info_phys); + (U8*)ps3_dma_alloc_coherent(instance, + sizeof(struct PS3DrvSysInfo), + &cmd_context->init_frame_sys_info_phys); + INJECT_START(PS3_ERR_IJ_PS3_INIT_FRAME_SYS_INFO_BUF_ALLOC, &cmd_context->init_frame_sys_info_buf); if (!cmd_context->init_frame_sys_info_buf) { LOG_ERROR("hno:%u Failed to alloc sysinfo dma buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -176,7 +177,8 @@ static int ps3_ioc_sys_info_get(struct ps3_instance *instance) sys_info = dmi_get_system_info(DMI_PRODUCT_UUID); if (!sys_info) { - LOG_INFO("hno:%u Failed to get sysinfo\n", PS3_HOST(instance)); + LOG_INFO("hno:%u Failed to get sysinfo\n", + PS3_HOST(instance)); drv_sys_info->systemIDLen = 0; drv_sys_info->version = 0; ret = PS3_SUCCESS; @@ -184,8 +186,7 @@ static int ps3_ioc_sys_info_get(struct ps3_instance *instance) } sys_info_len = strlen(sys_info) > PS3_DRV_SYSTEM_ID_MAX_LEN ? - PS3_DRV_SYSTEM_ID_MAX_LEN : - strlen(sys_info); + PS3_DRV_SYSTEM_ID_MAX_LEN : strlen(sys_info); memcpy(drv_sys_info->systemID, sys_info, sys_info_len); drv_sys_info->systemIDLen = sys_info_len; @@ -198,13 +199,15 @@ static int ps3_ioc_sys_info_get(struct ps3_instance *instance) #endif -int ps3_ioc_init_cmd_context_init(struct ps3_instance *instance) +S32 ps3_ioc_init_cmd_context_init(struct ps3_instance *instance) { - if (ps3_ioc_init_cmd_alloc(instance) != PS3_SUCCESS) + if (ps3_ioc_init_cmd_alloc(instance) != PS3_SUCCESS) { goto l_failed; + } #ifndef _WINDOWS - if (ps3_ioc_sys_info_get(instance) != PS3_SUCCESS) + if (ps3_ioc_sys_info_get(instance) != PS3_SUCCESS) { goto l_failed; + } #endif return PS3_SUCCESS; l_failed: @@ -214,51 +217,53 @@ int ps3_ioc_init_cmd_context_init(struct ps3_instance *instance) void ps3_ioc_init_cmd_context_exit(struct ps3_instance *instance) { - struct ps3_cmd_context *cmd_context = &instance->cmd_context; + struct ps3_cmd_context *cmd_context = &instance->cmd_context; LOG_INFO("entry\n"); #ifndef _WINDOWS if (cmd_context->init_frame_sys_info_buf != NULL) { - LOG_INFO("free init_frame_sys_info_buf = %p\n", - cmd_context->init_frame_sys_info_buf); - ps3_dma_free_coherent(instance, sizeof(struct PS3DrvSysInfo), - cmd_context->init_frame_sys_info_buf, - cmd_context->init_frame_sys_info_phys); + LOG_INFO("free init_frame_sys_info_buf = %p\n", cmd_context->init_frame_sys_info_buf); + ps3_dma_free_coherent(instance, + sizeof(struct PS3DrvSysInfo), + cmd_context->init_frame_sys_info_buf, + cmd_context->init_frame_sys_info_phys); cmd_context->init_frame_sys_info_buf = NULL; } #endif if (cmd_context->init_filter_table_buff != NULL) { - LOG_INFO("free init_filter_table_buff = %p\n", - cmd_context->init_filter_table_buff); - ps3_dma_free_coherent(instance, PS3_CMD_EXT_BUF_SIZE_MGR, - cmd_context->init_filter_table_buff, - cmd_context->init_filter_table_phy_addr); + LOG_INFO("free init_filter_table_buff = %p\n", cmd_context->init_filter_table_buff); + ps3_dma_free_coherent(instance, + PS3_CMD_EXT_BUF_SIZE_MGR, + cmd_context->init_filter_table_buff, + cmd_context->init_filter_table_phy_addr); cmd_context->init_filter_table_buff = NULL; cmd_context->init_filter_table_phy_addr = 0; } if (cmd_context->init_frame_buf != NULL) { - LOG_INFO("free init_frame_buf = %p\n", - cmd_context->init_frame_buf); - ps3_dma_free_coherent(instance, sizeof(struct PS3InitReqFrame), - cmd_context->init_frame_buf, - cmd_context->init_frame_buf_phys); + LOG_INFO("free init_frame_buf = %p\n", cmd_context->init_frame_buf); + ps3_dma_free_coherent(instance, + sizeof(struct PS3InitReqFrame), + cmd_context->init_frame_buf, + cmd_context->init_frame_buf_phys); cmd_context->init_frame_buf = NULL; } } -int ps3_drv_info_buf_alloc(struct ps3_instance *instance) +S32 ps3_drv_info_buf_alloc(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - instance->drv_info_buf = (unsigned char *)ps3_dma_alloc_coherent( - instance, sizeof(struct PS3DrvInfo), - (unsigned long long *)&instance->drv_info_buf_phys); + instance->drv_info_buf = + (U8*)ps3_dma_alloc_coherent(instance, + sizeof(struct PS3DrvInfo), + &instance->drv_info_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_DRV_INFO_BUF_ALLOC, &instance->drv_info_buf); if (instance->drv_info_buf == NULL) { LOG_ERROR("hno:%u Failed to alloc drv info dma buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } return ret; @@ -269,23 +274,24 @@ void ps3_drv_info_buf_free(struct ps3_instance *instance) if (instance->drv_info_buf != NULL) { LOG_INFO("drv_info_buf = %p\n", instance->drv_info_buf); ps3_dma_free_coherent(instance, sizeof(struct PS3DrvInfo), - instance->drv_info_buf, - instance->drv_info_buf_phys); + instance->drv_info_buf, + instance->drv_info_buf_phys); instance->drv_info_buf = NULL; } } -int ps3_host_mem_info_buf_alloc(struct ps3_instance *instance) +S32 ps3_host_mem_info_buf_alloc(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - instance->host_mem_info_buf = (unsigned char *)ps3_dma_alloc_coherent( - instance, + instance->host_mem_info_buf = + (U8*)ps3_dma_alloc_coherent(instance, (sizeof(struct PS3HostMemInfo) * PS3_HOST_MEM_INFO_NUM), - (unsigned long long *)&instance->host_mem_info_buf_phys); + &instance->host_mem_info_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_HOST_MEM_BUF_ALLOC, &instance->host_mem_info_buf); if (instance->host_mem_info_buf == NULL) { LOG_ERROR("hno:%u Failed to alloc host mem info dma buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } return ret; @@ -294,37 +300,27 @@ int ps3_host_mem_info_buf_alloc(struct ps3_instance *instance) void ps3_host_mem_info_buf_free(struct ps3_instance *instance) { if (instance->host_mem_info_buf != NULL) { - LOG_INFO("free host_mem_info_buf = %p\n", - instance->host_mem_info_buf); - ps3_dma_free_coherent( - instance, - (sizeof(struct PS3HostMemInfo) * PS3_HOST_MEM_INFO_NUM), + LOG_INFO("free host_mem_info_buf = %p\n", instance->host_mem_info_buf); + ps3_dma_free_coherent(instance, (sizeof(struct PS3HostMemInfo) * PS3_HOST_MEM_INFO_NUM), instance->host_mem_info_buf, instance->host_mem_info_buf_phys); instance->host_mem_info_buf = NULL; } } -int ps3_hard_reset_to_ready(struct ps3_instance *instance) +S32 ps3_hard_reset_to_ready(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - + S32 ret = PS3_SUCCESS; if (instance->peer_instance != NULL) { - if (instance->recovery_context->parall_hardreset_state == - PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_CONTINUE; - while (instance->recovery_context - ->parall_hardreset_state != - PS3_PARALLEL_HARDRESET_STATE_INIT) { - ps3_msleep( - PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_CONTINUE; + while (instance->recovery_context->parall_hardreset_state != PS3_PARALLEL_HARDRESET_STATE_INIT) { + ps3_msleep(PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); } } else { ret = ps3_hard_recovery_request(instance); - if (ret != PS3_SUCCESS) { - LOG_WARN( - "hno:%u hard recovery request failed\n", + if (ret != PS3_SUCCESS){ + LOG_WARN("hno:%u hard recovery request failed\n", PS3_HOST(instance)); goto l_out; } @@ -337,84 +333,92 @@ int ps3_hard_reset_to_ready(struct ps3_instance *instance) } ret = instance->ioc_adpter->ioc_hard_reset(instance); - if (ret == -PS3_FAILED) + if (ret == -PS3_FAILED) { goto l_out; - ret = ps3_ioc_state_ready_wait(instance); - if (ret != PS3_SUCCESS) + } + INJECT_START(PS3_ERR_IJ_HARD_WAIT_READY_FAILED_F0, instance); + if ((ret = ps3_ioc_state_ready_wait(instance)) != PS3_SUCCESS) { goto l_out; + } } l_out: if (ret == PS3_SUCCESS) { LOG_WARN("hno:%u ps3 fw state reset to ready successfully\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } else { - LOG_ERROR("hno:%u PS3 fw state reset to ready NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u PS3 fw state reset to ready NOK \n", + PS3_HOST(instance)); } return ret; } -int ps3_ioc_hard_reset_to_ready(struct ps3_instance *instance) +S32 ps3_ioc_hard_reset_to_ready(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; if (!instance->ioc_adpter->ioc_hard_reset) { ret = -PS3_FAILED; goto l_out; } - if (instance->recovery_context->heartbeat_recovery != - PS3_HEARTBEAT_HARDRESET_RECOVERY) { + if (instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_RECOVERY) { ret = instance->ioc_adpter->ioc_hard_reset(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } } - ret = ps3_ioc_state_transfer_to_ready(instance); - if (ret != PS3_SUCCESS) + INJECT_START(PS3_ERR_IJ_HARD_WAIT_READY_FAILED_F0, instance); + if ((ret = ps3_ioc_state_transfer_to_ready(instance)) != PS3_SUCCESS) { goto l_out; + } l_out: if (ret == PS3_SUCCESS) { LOG_WARN("hno:%u ps3 fw state reset to ready successfully\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } else { - LOG_ERROR("hno:%u PS3 fw state reset to ready NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u PS3 fw state reset to ready NOK \n", + PS3_HOST(instance)); } return ret; } -int ps3_ioc_init_to_ready(struct ps3_instance *instance) +S32 ps3_ioc_init_to_ready(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned char is_unload_valid = PS3_FALSE; + S32 ret = PS3_SUCCESS; + Bool is_unload_valid = PS3_FALSE; + INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING, instance); + INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING_RESUME_RECOVERY, instance); ret = ps3_ioc_state_transfer_to_ready(instance); - if (ret == PS3_SUCCESS) + INJECT_START(PS3_ERR_IJ_FW_STATE_RUNNING, &ret) + if (ret == PS3_SUCCESS) { goto l_out; + } ps3_check_debug0_valid_with_check(instance, &is_unload_valid, - PS3_CMD_TRIGGER_UNLOAD); - LOG_INFO( - "hno:%u PS3 fw state cannot directly init to ready successfully\n", + PS3_CMD_TRIGGER_UNLOAD); + LOG_INFO("hno:%u PS3 fw state cannot directly init to ready successfully\n", PS3_HOST(instance)); if (ret != -PS3_NO_RECOVERED) { - if (ps3_is_need_hard_reset(instance)) + if(ps3_is_need_hard_reset(instance)) { ret = ps3_hard_reset_to_ready(instance); + } } l_out: if (ret == PS3_SUCCESS) { LOG_INFO("hno:%u PS3 fw state init to ready successfully\n", - PS3_HOST(instance)); - if (is_unload_valid) + PS3_HOST(instance)); + if (is_unload_valid) { ret = ps3_ioc_notify_unload(instance); - } else { + } + }else { LOG_ERROR("hno:%u PS3 fw state init to ready NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } return ret; @@ -423,25 +427,22 @@ int ps3_ioc_init_to_ready(struct ps3_instance *instance) static void ps3_drv_info_prepare(struct ps3_instance *instance) { struct PS3DrvInfo *drv_info = NULL; - drv_info = (struct PS3DrvInfo *)instance->drv_info_buf; memset(drv_info, 0, sizeof(struct PS3DrvInfo)); snprintf(drv_info->drvName, PS3_DRV_NAME_MAX_LEN, PS3_DRV_AUTHOR); - snprintf(drv_info->drvVersion, PS3_DRV_VERSION_MAX_LEN, - PS3_DRV_VERSION); + snprintf(drv_info->drvVersion, PS3_DRV_VERSION_MAX_LEN, PS3_DRV_VERSION); drv_info->domain_support = PS3_TRUE; - drv_info->domain = (unsigned int)ps3_get_pci_domain(instance->pdev); + drv_info->domain = (U32)ps3_get_pci_domain(instance->pdev); drv_info->bus = ps3_get_pci_bus(instance->pdev); drv_info->dev = PCI_SLOT(instance->pdev->devfn); drv_info->func = PCI_FUNC(instance->pdev->devfn); drv_info->compatVer = PS3_COMPAT_VER_1; LOG_DEBUG("hno:%u driver information dump:\n" - "\t drvName = %s, drvVersion = %s\n" - "\t domain = %x bus = %llx, dev = %x, func = %x\n", - PS3_HOST(instance), drv_info->drvName, drv_info->drvVersion, - drv_info->domain, drv_info->bus, drv_info->dev, - drv_info->func); + "\t drvName = %s, drvVersion = %s\n" + "\t domain = %x bus = %llx, dev = %x, func = %x\n", + PS3_HOST(instance), drv_info->drvName, drv_info->drvVersion, + drv_info->domain, drv_info->bus, drv_info->dev, drv_info->func); } static inline bool ps3_pgdat_is_empty(pg_data_t *pgdat) @@ -449,12 +450,12 @@ static inline bool ps3_pgdat_is_empty(pg_data_t *pgdat) return !pgdat->node_start_pfn && !pgdat->node_spanned_pages; } -struct pglist_data *ps3_first_online_pgdat(void) +struct pglist_data *first_online_pgdat(void) { return NODE_DATA(first_online_node); } -struct pglist_data *ps3_next_online_pgdat(struct pglist_data *pgdat) +struct pglist_data *next_online_pgdat(struct pglist_data *pgdat) { int nid = next_online_node(pgdat->node_id); @@ -463,10 +464,10 @@ struct pglist_data *ps3_next_online_pgdat(struct pglist_data *pgdat) return NODE_DATA(nid); } -static unsigned char ps3_get_numa_mem_addr(struct ps3_instance *instance) +static Bool ps3_get_numa_mem_addr(struct ps3_instance *instance) { - unsigned char ret = PS3_FALSE; - int node = -1; + Bool ret = PS3_FALSE; + S32 node = -1; struct pglist_data *pgdata = NULL; node = dev_to_node(&instance->pdev->dev); @@ -479,11 +480,9 @@ static unsigned char ps3_get_numa_mem_addr(struct ps3_instance *instance) instance->start_pfn = pgdata->node_start_pfn << PAGE_SHIFT; instance->end_pfn = ((pgdat_end_pfn(pgdata) << PAGE_SHIFT) - 1); - LOG_INFO( - "host_no:%u numa:%d, addr range:[0x%llx - 0x%llx], so addr range:[0x%llx - 0x%llx]\n", - PS3_HOST(instance), node, instance->start_pfn, - instance->end_pfn, instance->so_start_addr, - instance->so_end_addr); + LOG_INFO("host_no:%u numa:%d, addr range:[0x%llx - 0x%llx], so addr range:[0x%llx - 0x%llx]\n", + PS3_HOST(instance), node, instance->start_pfn, instance->end_pfn, + instance->so_start_addr, instance->so_end_addr); ret = PS3_TRUE; l_out: return ret; @@ -492,25 +491,23 @@ static unsigned char ps3_get_numa_mem_addr(struct ps3_instance *instance) static void ps3_get_all_numa_mem_addr(struct ps3_instance *instance) { struct pglist_data *pgdata = NULL; - int node = -1; - unsigned char is_in_range = PS3_FALSE; - unsigned long long start_pfn = 0; - unsigned long long end_pfn = 0; + S32 node = -1; + Bool is_in_range = PS3_FALSE; + U64 start_pfn = 0; + U64 end_pfn = 0; if (ps3_get_numa_mem_addr(instance)) goto l_out; - for_each_ps3_online_pgdat(pgdata) - { + for_each_online_pgdat(pgdata) { if (ps3_pgdat_is_empty(pgdata)) continue; start_pfn = pgdata->node_start_pfn << PAGE_SHIFT; end_pfn = ((pgdat_end_pfn(pgdata) << PAGE_SHIFT) - 1); - if (PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - instance->dma_addr_bit_pos, - instance->so_start_addr) >= start_pfn && - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - instance->dma_addr_bit_pos, - instance->so_end_addr) <= end_pfn) { + INJECT_START(PS3_ERR_IJ_MOD_SO_ADDR, instance); + if (PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(instance->dma_addr_bit_pos, + instance->so_start_addr) >= start_pfn && + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(instance->dma_addr_bit_pos, instance->so_end_addr) <= + end_pfn) { node = pgdata->node_id; is_in_range = PS3_TRUE; break; @@ -523,11 +520,9 @@ static void ps3_get_all_numa_mem_addr(struct ps3_instance *instance) instance->start_pfn = 0; instance->end_pfn = 0; } - LOG_INFO( - "host_no:%u numa:%d, addr range:[0x%llx - 0x%llx], so addr range:[0x%llx - 0x%llx]\n", - PS3_HOST(instance), node, instance->start_pfn, - instance->end_pfn, instance->so_start_addr, - instance->so_end_addr); + LOG_INFO("host_no:%u numa:%d, addr range:[0x%llx - 0x%llx], so addr range:[0x%llx - 0x%llx]\n", + PS3_HOST(instance), node, instance->start_pfn, instance->end_pfn, + instance->so_start_addr, instance->so_end_addr); l_out: return; } @@ -535,7 +530,6 @@ static void ps3_get_all_numa_mem_addr(struct ps3_instance *instance) static void ps3_host_mem_info_prepare(struct ps3_instance *instance) { struct PS3HostMemInfo *host_mem_info = NULL; - host_mem_info = (struct PS3HostMemInfo *)instance->host_mem_info_buf; memset(host_mem_info, 0, sizeof(struct PS3HostMemInfo)); @@ -543,35 +537,35 @@ static void ps3_host_mem_info_prepare(struct ps3_instance *instance) host_mem_info->endAddr = instance->end_pfn; host_mem_info->type = PS3_MEM_TYPE_SO; LOG_DEBUG("hno:%u host mem info dump:\n" - "\t startAddr = 0x%llx, endAddr = 0x%llx, type = %u\n", - PS3_HOST(instance), host_mem_info->startAddr, - host_mem_info->endAddr, host_mem_info->type); + "\t startAddr = 0x%llx, endAddr = 0x%llx, type = %u\n", + PS3_HOST(instance), host_mem_info->startAddr, host_mem_info->endAddr, + host_mem_info->type); } static void ps3_ioc_init_cmd_prepare(struct ps3_instance *instance) { - struct ps3_cmd_context *cmd_context = &instance->cmd_context; - struct ps3_irq_context *irq_context = &instance->irq_context; - struct ps3_cmd_attr_context *cmd_attr = &instance->cmd_attr; - struct ps3_dump_context *dump_context = &instance->dump_context; - struct PS3InitReqFrame *init_frame_msg = NULL; + + struct ps3_cmd_context *cmd_context = &instance->cmd_context; + struct ps3_irq_context *irq_context = &instance->irq_context; + struct ps3_cmd_attr_context *cmd_attr = &instance->cmd_attr; + struct ps3_dump_context *dump_context = &instance->dump_context; + struct PS3InitReqFrame* init_frame_msg = NULL; init_frame_msg = (struct PS3InitReqFrame *)cmd_context->init_frame_buf; - memset(&init_frame_msg->reqHead, 0, sizeof(struct PS3ReqFrameHead)); + memset(&init_frame_msg->reqHead, 0, sizeof(PS3ReqFrameHead_s)); init_frame_msg->reqHead.cmdType = PS3_CMD_INIT_IOC; init_frame_msg->reqHead.timeout = PS3_INIT_CMD_WAIT_MAX_TIMEOUT; - init_frame_msg->ver = 0; - init_frame_msg->length = sizeof(struct PS3InitReqFrame); - init_frame_msg->operater = PS3_CMD_OPERATOR_TYPE_HOST; - init_frame_msg->pageSize = (unsigned char)cmd_attr->nvme_page_size; - init_frame_msg->msixVector = - (unsigned short)irq_context->valid_msix_vector_count; - init_frame_msg->pciIrqType = (unsigned short)irq_context->pci_irq_type; - init_frame_msg->osType = PS3_LINUX_FRAME; + init_frame_msg->ver = 0; + init_frame_msg->length = sizeof(struct PS3InitReqFrame); + init_frame_msg->operater = PS3_CMD_OPERATOR_TYPE_HOST; + init_frame_msg->pageSize = (U8)cmd_attr->nvme_page_size; + init_frame_msg->msixVector = (U16)irq_context->valid_msix_vector_count; + init_frame_msg->pciIrqType = (U16)irq_context->pci_irq_type; + init_frame_msg->osType = PS3_LINUX_FRAME; - init_frame_msg->timeStamp = cpu_to_le64(ps3_1970_now_ms_get()); + init_frame_msg->timeStamp = cpu_to_le64(ps3_1970_now_ms_get()); init_frame_msg->reqFrameBufBaseAddr = cpu_to_le64(cmd_context->req_frame_buf_phys); @@ -581,65 +575,53 @@ static void ps3_ioc_init_cmd_prepare(struct ps3_instance *instance) init_frame_msg->respFrameBaseAddr = cpu_to_le64(cmd_context->response_frame_buf_phys); - init_frame_msg->reqFrameMaxNum = - (unsigned short)cmd_context->max_cmd_count; - init_frame_msg->respFrameMaxNum = - (unsigned short)cmd_context->max_cmd_count; + init_frame_msg->reqFrameMaxNum = (U16)cmd_context->max_cmd_count; + init_frame_msg->respFrameMaxNum = (U16)cmd_context->max_cmd_count; init_frame_msg->bufSizePerRespFrame = PS3_RESP_FRAME_BUFFER_SIZE; - if (ps3_hil_mode_query() > HIL_MODEL_SW_ASSIST) + if(ps3_hil_mode_query() > HIL_MODEL_SW_ASSIST) + { init_frame_msg->hilMode = instance->hilMode; - else - init_frame_msg->hilMode = (unsigned char)ps3_hil_mode_query(); + }else{ + init_frame_msg->hilMode = (U8)ps3_hil_mode_query(); + } #ifndef _WINDOWS init_frame_msg->systemInfoBufAddr = cmd_context->init_frame_sys_info_phys; #endif if (!reset_devices) { - init_frame_msg->dumpDmaBufAddr = - cpu_to_le64(dump_context->dump_dma_addr); - init_frame_msg->dumpDmaBufLen = - cpu_to_le32(PS3_DUMP_DMA_BUF_SIZE); - init_frame_msg->dumpIsrSN = - cpu_to_le32(irq_context->dump_isrSN); + init_frame_msg->dumpDmaBufAddr = cpu_to_le64(dump_context->dump_dma_addr); + init_frame_msg->dumpDmaBufLen = cpu_to_le64(PS3_DUMP_DMA_BUF_SIZE); + init_frame_msg->dumpIsrSN = cpu_to_le32(irq_context->dump_isrSN); } #ifndef _WINDOWS init_frame_msg->debugMemArrayNum = cpu_to_le32(instance->debug_context.debug_mem_array_num); init_frame_msg->debugMemArrayAddr = (instance->debug_context.debug_mem_array_num != 0) ? - cpu_to_le64(instance->debug_context.debug_mem_buf_phy) : - 0; + cpu_to_le64(instance->debug_context.debug_mem_buf_phy) : 0; #endif - memset(cmd_context->init_filter_table_buff, 0, - PS3_CMD_EXT_BUF_SIZE_MGR); + memset(cmd_context->init_filter_table_buff, 0, PS3_CMD_EXT_BUF_SIZE_MGR); if (instance->ioc_adpter->event_filter_table_get != NULL) { - init_frame_msg->filterTableAddr = - cpu_to_le64(cmd_context->init_filter_table_phy_addr); - init_frame_msg->filterTableLen = - cpu_to_le32(PS3_CMD_EXT_BUF_SIZE_MGR); - instance->ioc_adpter->event_filter_table_get( - cmd_context->init_filter_table_buff); + init_frame_msg->filterTableAddr = cpu_to_le64(cmd_context->init_filter_table_phy_addr); + init_frame_msg->filterTableLen = cpu_to_le32(PS3_CMD_EXT_BUF_SIZE_MGR); + instance->ioc_adpter->event_filter_table_get(cmd_context->init_filter_table_buff); } ps3_drv_info_prepare(instance); - init_frame_msg->drvInfoBufAddr = - cpu_to_le64(instance->drv_info_buf_phys); + init_frame_msg->drvInfoBufAddr = cpu_to_le64(instance->drv_info_buf_phys); init_frame_msg->drvInfoBufLen = cpu_to_le16(sizeof(struct PS3DrvInfo)); ps3_get_all_numa_mem_addr(instance); if (instance->end_pfn != 0) { ps3_host_mem_info_prepare(instance); - init_frame_msg->hostMemInfoBaseAddr = - cpu_to_le64(instance->host_mem_info_buf_phys); - init_frame_msg->hostMemInfoNum = - cpu_to_le32(PS3_HOST_MEM_INFO_NUM); + init_frame_msg->hostMemInfoBaseAddr = cpu_to_le64(instance->host_mem_info_buf_phys); + init_frame_msg->hostMemInfoNum = cpu_to_le32(PS3_HOST_MEM_INFO_NUM); } else { init_frame_msg->hostMemInfoBaseAddr = 0; init_frame_msg->hostMemInfoNum = 0; } - LOG_DEBUG( - "hno:%u init frame information dump:\n" + LOG_DEBUG("hno:%u init frame information dump:\n" "\t initFramePhysicAddr = 0x%llx, initFrameLen = %d, version = %d\n" "\t pciIrqType = %d, msixVectorCount = %d, reqHead.cmdType = %d\n" "\t reqFrameBufBase = 0x%llx, reqFrameMaxNum = %d\n" @@ -648,29 +630,23 @@ static void ps3_ioc_init_cmd_prepare(struct ps3_instance *instance) "\t filterTableAddr = 0x%llx, filterTableLen = %d\n" "\t drvInfoBufAddr = 0x%llx, drvInfoBufLen = %d\n" "\t hostMemInfoBaseAddr = 0x%llx, hostMemInfoNum = %d, function = %d\n", - PS3_HOST(instance), - cpu_to_le64(cmd_context->init_frame_buf_phys), + PS3_HOST(instance), cpu_to_le64(cmd_context->init_frame_buf_phys), init_frame_msg->length, init_frame_msg->ver, - init_frame_msg->pciIrqType, init_frame_msg->msixVector, - init_frame_msg->reqHead.cmdType, - init_frame_msg->reqFrameBufBaseAddr, - init_frame_msg->reqFrameMaxNum, - init_frame_msg->respFrameBaseAddr, - init_frame_msg->reqFrameMaxNum, - init_frame_msg->bufSizePerRespFrame, - init_frame_msg->replyFifoDescBaseAddr, - init_frame_msg->systemInfoBufAddr, + init_frame_msg->pciIrqType, init_frame_msg->msixVector, init_frame_msg->reqHead.cmdType, + init_frame_msg->reqFrameBufBaseAddr, init_frame_msg->reqFrameMaxNum, + init_frame_msg->respFrameBaseAddr, init_frame_msg->reqFrameMaxNum, init_frame_msg->bufSizePerRespFrame, + init_frame_msg->replyFifoDescBaseAddr, init_frame_msg->systemInfoBufAddr, init_frame_msg->filterTableAddr, init_frame_msg->filterTableLen, init_frame_msg->drvInfoBufAddr, init_frame_msg->drvInfoBufLen, - init_frame_msg->hostMemInfoBaseAddr, - init_frame_msg->hostMemInfoNum, - ps3_get_pci_function(instance->pdev)); + init_frame_msg->hostMemInfoBaseAddr, init_frame_msg->hostMemInfoNum, ps3_get_pci_function(instance->pdev)); + + return; } -static int ps3_ioc_init_cmd_proc(struct ps3_instance *instance) +static S32 ps3_ioc_init_cmd_proc(struct ps3_instance *instance) { struct PS3MgrEvent *event_req_info = &instance->event_req_info; - struct ps3_cmd_context *cmd_context = &instance->cmd_context; + struct ps3_cmd_context *cmd_context = &instance->cmd_context; struct PS3InitReqFrame *init_frame_msg = NULL; ps3_ioc_init_cmd_prepare(instance); @@ -681,62 +657,62 @@ static int ps3_ioc_init_cmd_proc(struct ps3_instance *instance) init_frame_msg->respStatus = U32_MAX; ps3_all_reply_fifo_init(instance); - LOG_WARN( - "hno:%u start to send init cmd![init:0x%llx, respstats:0x%llx]\n", - PS3_HOST(instance), - (unsigned long long)cmd_context->init_frame_buf_phys, - (unsigned long long)cmd_context->init_frame_buf_phys + - offsetof(struct PS3InitReqFrame, respStatus)); + LOG_WARN("hno:%u start to send init cmd![init:0x%llx, respstats:0x%llx]\n", PS3_HOST(instance), + cmd_context->init_frame_buf_phys, + (U64)cmd_context->init_frame_buf_phys + offsetof(struct PS3InitReqFrame, respStatus)); return ps3_ioc_init_cmd_issue(instance, init_frame_msg); } -int ps3_ioc_init_proc(struct ps3_instance *instance) +S32 ps3_ioc_init_proc(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - int state = PS3_FW_STATE_UNDEFINED; - int retry = 0; + S32 ret = PS3_SUCCESS; + S32 state = PS3_FW_STATE_UNDEFINED; + S32 retry = 0; ps3_ioc_can_hardreset_set(instance, PS3_IOC_CANNOT_HARDRESET); while (retry < PS3_IOC_INIT_PROC_FAIL_RETRY_COUNT) { ret = ps3_ioc_init_cmd_proc(instance); - if (ret != PS3_SUCCESS) + INJECT_START(PS3_ERR_IJ_INIT_CMD_PROC_FAIL, &ret) + if (ret != PS3_SUCCESS) { goto l_clean; + } + INJECT_START(PS3_ERR_IJ_FORCE_INIT_RUNNING_FAIL, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_RUNNING, instance) ret = ps3_ioc_state_transfer_wait_to_running(instance); + INJECT_START(PS3_ERR_IJ_IOC_STATE_WAIT_TO_RUNNING_FAIL, &ret) if (ret != PS3_SUCCESS) { - if (ret == -PS3_IN_PCIE_ERR) + if (ret == -PS3_IN_PCIE_ERR) { goto l_out; + } goto l_clean; } goto l_out; -l_clean: + l_clean: state = instance->ioc_adpter->ioc_state_get(instance); - if (state == PS3_FW_STATE_WAIT || - state == PS3_FW_STATE_RUNNING) { - if (ps3_soc_unload(instance, PS3_TRUE, - PS3_UNLOAD_SUB_TYPE_REMOVE, - PS3_SUSPEND_TYPE_NONE) == - PS3_SUCCESS) { - LOG_INFO( - "device[%d] unload success,exit init proc.\n", - instance->pdev->dev.id); + INJECT_START(PS3_ERR_IJ_IOC_STATE_WAIT_TO_RUNNING_FAIL, &ret) + INJECT_START(PS3_ERR_IJ_IOC_INIT_PROC_STATE_RUNNING, &state) + INJECT_START(PS3_ERR_IJ_INIT_PROC_FAIL_NOUNLOAD, &state) + if(state == PS3_FW_STATE_WAIT || + state == PS3_FW_STATE_RUNNING){ + if (ps3_soc_unload(instance, PS3_TRUE, PS3_UNLOAD_SUB_TYPE_REMOVE, PS3_SUSPEND_TYPE_NONE) == PS3_SUCCESS) { + LOG_INFO("device[%d] unload success,exit init proc.\n", instance->pdev->dev.id); retry++; continue; } } ret = ps3_init_fail_hard_reset_with_doorbell(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("device[%d] hard reset NOK,exit init proc.\n", - instance->pdev->dev.id); + LOG_ERROR("device[%d] hard reset NOK,exit init proc.\n", instance->pdev->dev.id); goto l_out; } retry++; } - if (retry == PS3_IOC_INIT_PROC_FAIL_RETRY_COUNT) + if (retry == PS3_IOC_INIT_PROC_FAIL_RETRY_COUNT) { ret = -PS3_FAILED; - LOG_INFO("device[%d] doorbell success,exit init proc [%d].\n", - instance->pdev->dev.id, ret); + } + LOG_INFO("device[%d] doorbell success,exit init proc [%d].\n", instance->pdev->dev.id, ret); l_out: return ret; @@ -745,32 +721,34 @@ int ps3_ioc_init_proc(struct ps3_instance *instance) void ps3_ioc_legacy_irqs_enable(struct ps3_instance *instance) { LOG_INFO("hno:%u Enable legacy!\n", PS3_HOST(instance)); -#ifndef _WINDOWS +#ifndef _WINDOWS pci_intx(instance->pdev, 1); #else ps3_pci_intx(instance, 1); #endif + return; } void ps3_ioc_legacy_irqs_disable(struct ps3_instance *instance) { LOG_INFO("hno:%u Disable legacy!\n", PS3_HOST(instance)); -#ifndef _WINDOWS +#ifndef _WINDOWS pci_intx(instance->pdev, 0); #else ps3_pci_intx(instance, 0); #endif + return; } void ps3_ioc_msi_enable(struct ps3_instance *instance) { - unsigned int pos = 0; - unsigned short control = 0; + U32 pos = 0; + U16 control = 0; pos = ps3_pci_find_capability(instance, PCI_CAP_ID_MSI); if (pos == 0) { LOG_INFO("hno:%u Find PCI_CAP_ID_MSI failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return; } @@ -778,19 +756,21 @@ void ps3_ioc_msi_enable(struct ps3_instance *instance) if (!(control & PCI_MSI_FLAGS_ENABLE)) { LOG_INFO("hno:%u Enable Msi!\n", PS3_HOST(instance)); ps3_pci_write_config_word(instance, pos + PCI_MSI_FLAGS, - control | PCI_MSI_FLAGS_ENABLE); + control | PCI_MSI_FLAGS_ENABLE); } + + return; } void ps3_ioc_msi_disable(struct ps3_instance *instance) { - unsigned int pos = 0; - unsigned short control = 0; + U32 pos = 0; + U16 control = 0; pos = ps3_pci_find_capability(instance, PCI_CAP_ID_MSI); if (pos == 0) { LOG_ERROR("hno:%u Find PCI_CAP_ID_MSI failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return; } @@ -798,19 +778,22 @@ void ps3_ioc_msi_disable(struct ps3_instance *instance) if (control & PCI_MSI_FLAGS_ENABLE) { LOG_INFO("hno:%u Disable Msi!\n", PS3_HOST(instance)); ps3_pci_write_config_word(instance, pos + PCI_MSI_FLAGS, - control & ~PCI_MSI_FLAGS_ENABLE); + control & ~PCI_MSI_FLAGS_ENABLE); } + + return; + } void ps3_ioc_msix_enable(struct ps3_instance *instance) { - unsigned int pos = 0; - unsigned short control = 0; + U32 pos = 0; + U16 control = 0; pos = ps3_pci_find_capability(instance, PCI_CAP_ID_MSIX); if (pos == 0) { LOG_ERROR("hno:%u Find PCI_CAP_ID_MSIX failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return; } @@ -818,19 +801,21 @@ void ps3_ioc_msix_enable(struct ps3_instance *instance) if (!(control & PCI_MSIX_FLAGS_ENABLE)) { LOG_INFO("hno:%u Enable Msix!\n", PS3_HOST(instance)); ps3_pci_write_config_word(instance, pos + PCI_MSIX_FLAGS, - control | PCI_MSIX_FLAGS_ENABLE); + control | PCI_MSIX_FLAGS_ENABLE); } + + return; } void ps3_ioc_msix_disable(struct ps3_instance *instance) { - unsigned int pos = 0; - unsigned short control = 0; + U32 pos = 0; + U16 control = 0; pos = ps3_pci_find_capability(instance, PCI_CAP_ID_MSIX); if (pos == 0) { LOG_ERROR("hno:%u Find PCI_CAP_ID_MSIX failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return; } @@ -838,26 +823,28 @@ void ps3_ioc_msix_disable(struct ps3_instance *instance) if (control & PCI_MSIX_FLAGS_ENABLE) { LOG_INFO("hno:%u disable Msix!\n", PS3_HOST(instance)); ps3_pci_write_config_word(instance, pos + PCI_MSIX_FLAGS, - control & ~PCI_MSIX_FLAGS_ENABLE); + control & ~PCI_MSIX_FLAGS_ENABLE); } + + return; } -unsigned char ps3_ioc_is_legacy_irq_existed(struct ps3_instance *instance) +Bool ps3_ioc_is_legacy_irq_existed(struct ps3_instance *instance) { - unsigned short status = 0; - unsigned char is_legacy_irq_existed = PS3_FALSE; + U16 status = 0; + Bool is_legacy_irq_existed = PS3_FALSE; ps3_pci_read_config_word(instance, PCI_COMMAND, &status); if (status & PCI_COMMAND_INTX_DISABLE) { LOG_INFO("hno:%u Legacy irq is disabled!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ps3_pci_read_config_word(instance, PCI_STATUS, &status); if (status & PCI_STATUS_INTERRUPT) { LOG_INFO("hno:%u Legacy irq is existed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); is_legacy_irq_existed = PS3_TRUE; } @@ -866,40 +853,46 @@ unsigned char ps3_ioc_is_legacy_irq_existed(struct ps3_instance *instance) } void ps3_ioc_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word) + struct PS3CmdWord *cmd_word) { union PS3DefaultCmdWord *cmd_word_default = NULL; PS3_CMD_WORD_STAT_INC(instance, cmd_word); - cmd_word_default = (union PS3DefaultCmdWord *)cmd_word; + cmd_word_default = (union PS3DefaultCmdWord *) cmd_word; +#ifdef PS3_SUPPORT_INJECT + if(ps3_add_cmd_filter(instance, cmd_word)) { + goto l_out; + } +#endif - PS3_IOC_REG_WRITE(instance, cmd_fifo.request_fifo, ps3RequestQueue, - cmd_word_default->words); + PS3_IOC_REG_WRITE(instance, cmd_fifo.request_fifo, ps3RequestQueue, cmd_word_default->words); +#ifdef PS3_SUPPORT_INJECT +l_out: + return; +#endif } void ps3_ioc_scsi_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word) + struct PS3CmdWord *cmd_word) { union PS3DefaultCmdWord *cmd_word_default = NULL; PS3_CMD_WORD_STAT_INC(instance, cmd_word); cmd_word_default = (union PS3DefaultCmdWord *)cmd_word; - if (instance->is_pci_reset == PS3_FALSE) { + if(instance->is_pci_reset == PS3_FALSE) { ps3_ioc_reg_write(instance, cmd_word_default->words, - &instance->reg_set->cmd_fifo.request_fifo - .ps3RequestQueue); + &instance->reg_set->cmd_fifo.request_fifo.ps3RequestQueue); } else { LOG_FILE_ERROR("hno:%u register %p,write blocked by pci err\n", - PS3_HOST(instance), - &instance->reg_set->cmd_fifo.request_fifo - .ps3RequestQueue); + PS3_HOST(instance), + &instance->reg_set->cmd_fifo.request_fifo.ps3RequestQueue); } } void ps3_switch_normal_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word) + struct PS3CmdWord *cmd_word) { union PS3CmdWordU32 cmd_word_u32; union PS3DefaultCmdWord cmd_word_default; @@ -912,79 +905,69 @@ void ps3_switch_normal_cmd_send(struct ps3_instance *instance, cmd_word_u32.cmdWord.cmdFrameID = cmd_word->cmdFrameID; cmd_word_u32.cmdWord.type = cmd_word->type; cmd_word_u32.cmdWord.isrSN = cmd_word->isrSN; - cmd_word_u32.cmdWord.noReplyWord = - cmd->req_frame->frontendReq.reqHead.noReplyWord; + cmd_word_u32.cmdWord.noReplyWord = cmd->req_frame->frontendReq.reqHead.noReplyWord; cmd_word_default.words = 0; cmd_word_default.u.low = cmd_word_u32.val; - PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, reserved0, - cmd_word_default.words); + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, reserved0, cmd_word_default.words); } void ps3_switch_init_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word) + struct PS3CmdWord *cmd_word) { union PS3DefaultCmdWord *cmd_word_default = NULL; - PS3_CMD_WORD_STAT_INC(instance, cmd_word); - cmd_word_default = (union PS3DefaultCmdWord *)cmd_word; + cmd_word_default = (union PS3DefaultCmdWord *) cmd_word; ps3_atomic_inc(&(instance)->reg_op_count); - mb(); /* in order to force CPU ordering */ - if ((instance)->is_hard_reset == PS3_FALSE && - (instance)->is_pci_reset == PS3_FALSE) { - PS3_REG_SESSION_ADDR_WRITE( - instance, cmd_word_default->words, + mb(); + if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { + PS3_REG_SESSION_ADDR_WRITE(instance, cmd_word_default->words, &instance->reg_set->reg_f.Excl_reg.ps3SessioncmdAddr); } else { - LOG_ERROR( - "hno:%u register %p,write blocked by hardreset(%d) or pci recovery(%d)\n", - PS3_HOST(instance), - &instance->reg_set->reg_f.Excl_reg.ps3SessioncmdAddr, + LOG_ERROR("hno:%u register %p,write blocked by hardreset(%d) or pci recovery(%d)\n", + PS3_HOST(instance), &instance->reg_set->reg_f.Excl_reg.ps3SessioncmdAddr, (instance)->is_hard_reset, instance->is_pci_reset); } ps3_atomic_dec(&(instance)->reg_op_count); - LOG_DEBUG("hno:%u init qommand: cmd.words = 0x%llx, session_reg_offset = %#lx\n", - PS3_HOST(instance), cmd_word_default->words, - (unsigned long)offsetof(struct HilReg0Ps3RegisterF, - ps3SessioncmdAddr)); + LOG_DEBUG("hno:%u init command: cmd.words = 0x%llx, " + "session_reg_offset = %#lx\n", PS3_HOST(instance), + cmd_word_default->words, + offsetof(struct HilReg0Ps3RegisterF, ps3SessioncmdAddr)); } #ifndef _WINDOWS -unsigned long long ps3_switch_ioc_reg_read(struct ps3_instance *instance, - void __iomem *reg) +U64 ps3_switch_ioc_reg_read(struct ps3_instance *instance, void __iomem *reg) { - unsigned long long value = 0; + U64 value = 0; + U64 addr = (U64)reg; + value = (((U64)readl((void*)(addr + 0x4UL)) << 32) | (U64)readl(reg)); - value = (((unsigned long long)readl(reg + 0x4UL) << 32) | - (unsigned long long)readl(reg)); - if (&instance->reg_set->cmd_fifo.request_fifo.ps3RequestQueue == reg) - reg = reg - PS3_REG_SWITCH_QEQUEST_QUEUE_OFFSET; + if (&instance->reg_set->cmd_fifo.request_fifo.ps3RequestQueue == reg) { + reg = (void __iomem *)((U64)reg - PS3_REG_SWITCH_QEQUEST_QUEUE_OFFSET); + } ps3_reg_dump(instance, reg, value, PS3_TRUE); return value; } #endif inline void ps3_ioc_reg_write(struct ps3_instance *instance, - unsigned long long val, void __iomem *reg) + U64 val, void __iomem *reg) { ps3_reg_dump(instance, reg, val, PS3_FALSE); if (instance->ioc_adpter->reg_write) { instance->ioc_adpter->reg_write(instance, val, reg); } else { - LOG_FILE_ERROR("hno:%u no register write\n", - PS3_HOST(instance)); + LOG_FILE_ERROR("hno:%u no register write\n", PS3_HOST(instance)); } } void ps3_ioc_hardreset_reg_write(struct ps3_instance *instance, - unsigned long long val, void __iomem *reg, - unsigned char is_warn_prk) + U64 val, void __iomem *reg, Bool is_warn_prk) { ps3_reg_dump(instance, reg, val, PS3_FALSE); if (instance->ioc_adpter->reg_write) { if (is_warn_prk) { - LOG_WARN( - "hno:%u register write reset,val:0x%llx,reg=%p\n", - PS3_HOST(instance), val, reg); + LOG_WARN("hno:%u register write reset,val:0x%llx,reg=%p\n", + PS3_HOST(instance),val,reg); } instance->ioc_adpter->reg_write(instance, val, reg); } else { @@ -992,40 +975,38 @@ void ps3_ioc_hardreset_reg_write(struct ps3_instance *instance, } } -inline unsigned long long ps3_ioc_reg_read(struct ps3_instance *instance, - void __iomem *reg) +inline U64 ps3_ioc_reg_read(struct ps3_instance *instance, void __iomem *reg) { - unsigned long long value = 0; - - if (instance->ioc_adpter->reg_read) + U64 value = 0; + if (instance->ioc_adpter->reg_read) { value = instance->ioc_adpter->reg_read(instance, reg); - else + } else { LOG_ERROR("hno:%u no register read\n", PS3_HOST(instance)); + } ps3_reg_dump(instance, reg, value, PS3_TRUE); return value; } -unsigned long long ps3_ioc_hardreset_reg_read(struct ps3_instance *instance, - void __iomem *reg) +U64 ps3_ioc_hardreset_reg_read(struct ps3_instance *instance, void __iomem *reg) { - unsigned long long value = 0; - - if (instance->ioc_adpter->reg_read) + U64 value = 0; + if (instance->ioc_adpter->reg_read) { value = instance->ioc_adpter->reg_read(instance, reg); - else + } else { LOG_ERROR("hno:%u no register read\n", PS3_HOST(instance)); + } return value; } -inline unsigned long long -ps3_ioc_reg_read_with_check(struct ps3_instance *instance, void __iomem *reg) +inline U64 ps3_ioc_reg_read_with_check(struct ps3_instance *instance, + void __iomem *reg) { - unsigned char try_count = 0; - unsigned long long reg_value = ps3_ioc_reg_read(instance, reg); + U8 try_count = 0; + U64 reg_value = ps3_ioc_reg_read(instance, reg); while (reg_value == U64_MAX && - try_count != PS3_REG_READ_MAX_TRY_COUNT) { + try_count != PS3_REG_READ_MAX_TRY_COUNT) { ps3_msleep(PS3_REG_READ_INTERVAL_MS); try_count++; reg_value = ps3_ioc_reg_read(instance, reg); @@ -1034,38 +1015,39 @@ ps3_ioc_reg_read_with_check(struct ps3_instance *instance, void __iomem *reg) return reg_value; } -static unsigned long long ps3_ioc_reg_safe_read(struct ps3_instance *instance, - void __iomem *reg) +static U64 ps3_ioc_reg_safe_read(struct ps3_instance *instance, + void __iomem *reg) { - unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; - unsigned int count = 0; - unsigned int retry_cnt = 0; - unsigned long long tmp_value = U64_MAX; - unsigned long long value = U64_MAX; - unsigned char is_first = PS3_TRUE; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + U32 count = 0; + U32 retry_cnt = 0; + U64 tmp_value = U64_MAX; + U64 value = U64_MAX; + Bool is_first = PS3_TRUE; for (; retry_cnt < PS3_REG_READ_SAFE_RETRY_NUM; retry_cnt++) { tmp_value = ps3_ioc_reg_read_with_check(instance, reg); + INJECT_START(PS3_ERR_IJ_REG_READ_ERR, &tmp_value); if (tmp_value == U64_MAX) { value = U64_MAX; goto l_out; } fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); + INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED1, &fw_cur_state); + INJECT_START(PS3_ERR_IJ_IOC_TO_CRITICAL, &fw_cur_state); if (!ps3_ioc_state_valid_check(fw_cur_state)) { for (; count < PS3_REG_READ_RETRY_NUM; count++) { - fw_cur_state = - instance->ioc_adpter->ioc_state_get( - instance); + fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); + INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED1, &fw_cur_state); + INJECT_START(PS3_ERR_IJ_IOC_TO_CRITICAL, &fw_cur_state); if (ps3_ioc_state_valid_check(fw_cur_state)) { - value = ps3_ioc_reg_read_with_check( - instance, reg); + value = ps3_ioc_reg_read_with_check(instance, reg); goto l_out; } ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); } value = U64_MAX; - LOG_WARN_LIM("hno:%u wait ioc to valid state NOK\n", - PS3_HOST(instance)); + LOG_WARN_LIM("hno:%u wait ioc to valid state NOK\n", PS3_HOST(instance)); goto l_out; } if (is_first) { @@ -1073,9 +1055,9 @@ static unsigned long long ps3_ioc_reg_safe_read(struct ps3_instance *instance, is_first = PS3_FALSE; continue; } + INJECT_START(PS3_ERR_IJ_REG_READ_ZERO, &tmp_value); if (value != tmp_value) { - LOG_WARN_LIM( - "hno:%u reg value not equal old-new[%llu, %llu]\n", + LOG_WARN_LIM("hno:%u reg value not equal old-new[%llu, %llu]\n", PS3_HOST(instance), value, tmp_value); value = U64_MAX; goto l_out; @@ -1086,11 +1068,10 @@ static unsigned long long ps3_ioc_reg_safe_read(struct ps3_instance *instance, return value; } -unsigned long long ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, - void __iomem *reg) +U64 ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, void __iomem *reg) { - unsigned int retry_cnt = PS3_REG_READ_SAFE_RETRY_NUM; - unsigned long long reg_value = 0; + U32 retry_cnt = PS3_REG_READ_SAFE_RETRY_NUM; + U64 reg_value = 0; while (retry_cnt--) { reg_value = ps3_ioc_reg_safe_read(instance, reg); @@ -1101,32 +1082,27 @@ unsigned long long ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, return reg_value; } -unsigned char ps3_feature_support_reg_get(struct ps3_instance *instance) +Bool ps3_feature_support_reg_get(struct ps3_instance *instance) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3FeatureSupport, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + INJECT_START(PS3_ERR_IJ_FEATURE_REG_READ_ERR, &value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - ps3_feature_support = - (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; - instance->is_ioc_halt_support = - (ps3_feature_support->reg.fwHaltSupport == 1); - instance->is_shallow_soft_recovery_support = - (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); - instance->is_deep_soft_recovery_support = - (ps3_feature_support->reg.deepSoftRecoverySupport == 1); - instance->is_hard_recovery_support = - (ps3_feature_support->reg.hardRecoverySupport == 1); - instance->cmd_context.sgl_mode_support = - (ps3_feature_support->reg.sglModeSupport == 1); + ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + instance->is_ioc_halt_support = (ps3_feature_support->reg.fwHaltSupport == 1); + instance->is_shallow_soft_recovery_support = (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); + instance->is_deep_soft_recovery_support = (ps3_feature_support->reg.deepSoftRecoverySupport == 1); + instance->is_hard_recovery_support = (ps3_feature_support->reg.hardRecoverySupport == 1); + instance->cmd_context.sgl_mode_support = (ps3_feature_support->reg.sglModeSupport == 1); ret = PS3_TRUE; l_out: return ret; } + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.h b/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.h index 635f4aec4197..abd2c597a582 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_IOC_MANAGER_H_ #define _PS3_IOC_MANAGER_H_ @@ -7,287 +6,213 @@ #include "ps3_inner_data.h" #include "ps3_module_para.h" #include "ps3_ioc_state.h" - -#define PS3_REG_SESSION_ADDR_WRITE(instance, val, reg) \ +#ifndef _WINDOWS +#define PS3_REG_SESSION_ADDR_WRITE(instance, val, reg) \ + do { \ + ps3_reg_dump(instance, reg, val, PS3_FALSE); \ + writeq(val, reg); \ + } while(0) +#else +#define PS3_REG_SESSION_ADDR_WRITE(instance, val, reg) \ do { \ - ps3_reg_dump(instance, reg, val, PS3_FALSE); \ - ps3_ioc_reg_write(instance, val, reg); \ - } while (0) + ps3_reg_dump(instance, reg, val, PS3_FALSE); \ + ps3_ioc_reg_write(instance, val, reg); \ + } while(0) +#endif -#define PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES (100) -#define PS3_REG_READ_INTERVAL_MS (10) +#define PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES (100) +#define PS3_REG_READ_INTERVAL_MS (10) #if (defined PS3_HARDWARE_FPGA && defined PS3_MODEL_V200) -#define PS3_REG_WRITE_RETRY_NUM (60) +#define PS3_REG_WRITE_RETRY_NUM (60) #else -#define PS3_REG_WRITE_RETRY_NUM (10) +#define PS3_REG_WRITE_RETRY_NUM (10) #endif -#define PS3_REG_WRITE_INTERVAL_MS (10) -#define PS3_REG_READ_RETRY_NUM (5000) +#define PS3_REG_WRITE_INTERVAL_MS (10) +#define PS3_REG_READ_RETRY_NUM (5000) #define PS3_ATU_SUPPORT_READ_RETRY_NUM (3) #define PS3_REG_READ_SAFE_RETRY_NUM (3) #define PS3_HOST_MEM_INFO_NUM (1) -#define PS3_IOC_STATE_HALT_SUPPORT(ins) (ins->is_ioc_halt_support) +#define PS3_IOC_STATE_HALT_SUPPORT(ins) \ + (ins->is_ioc_halt_support) -#define PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT(ins) \ +#define PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT(ins) \ (ins->is_shallow_soft_recovery_support) -#define PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT(ins) \ - ((ins->is_deep_soft_recovery_support) && \ - ps3_deep_soft_reset_enable_query()) - -#define PS3_IOC_HARD_RECOVERY_SUPPORT(ins) \ - (PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(ins) || \ - ins->is_hard_recovery_support) - -#define PS3_HALT_CLI_SUPPORT(ins) (ins->is_halt_support_cli) - -#define PS3_IOC_REG_READ_WITH_CHECK(instance, reg_type, reg_name, read_value) \ - do { \ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); /* in order to force CPU ordering */ \ - if ((instance)->is_hard_reset == PS3_FALSE && \ - (instance)->is_pci_reset == PS3_FALSE) { \ - read_value = ps3_ioc_reg_read_with_check( \ - instance, \ - &(instance)->reg_set->reg_type.reg_name); \ - } else { \ - LOG_FILE_ERROR( \ - "hno:%u register %p,read blocked by hardreset(%d)\n" \ - "\tor pci err(%d)\n", \ - PS3_HOST(instance), \ - &(instance)->reg_set->reg_type.reg_name, \ - (instance)->is_hard_reset, \ - (instance)->is_pci_reset); \ - read_value = U64_MAX; \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ - } while (0) - -#define PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_type, reg_name, \ - read_value) \ - do { \ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); /* in order to force CPU ordering */ \ - if ((instance)->is_hard_reset == PS3_FALSE && \ - (instance)->is_pci_reset == PS3_FALSE) { \ - read_value = ps3_ioc_reg_retry_safe_read( \ - instance, \ - &(instance)->reg_set->reg_type.reg_name); \ - } else { \ - LOG_FILE_ERROR( \ - "hno:%u register %p,read blocked by hardreset(%d)\n" \ - "\tor pci err(%d)\n", \ - PS3_HOST(instance), \ - &(instance)->reg_set->reg_type.reg_name, \ - (instance)->is_hard_reset, \ - (instance)->is_pci_reset); \ - read_value = U64_MAX; \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ - } while (0) - -#define PS3_IOC_REG_READ_OFFSET(instance, offset, read_value) \ - do { \ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); /* in order to force CPU ordering */ \ - if ((instance)->is_hard_reset == PS3_FALSE && \ - (instance)->is_pci_reset == PS3_FALSE) { \ - read_value = ps3_ioc_reg_read( \ - instance, \ - (unsigned char *)(instance)->reg_set + \ - (offset)); \ - } else { \ - LOG_FILE_ERROR( \ - "hno:%u register %p, read blocked by hardreset(%d)\n" \ - "\tor pci err(%d)\n", \ - PS3_HOST(instance), \ - (unsigned char *)(instance)->reg_set + \ - (offset), \ - (instance)->is_hard_reset, \ - instance->is_pci_reset); \ - read_value = U64_MAX; \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ - } while (0) - -#define PS3_IOC_REG_READ_OFFSET_WITCH_CHECK(instance, offset, read_value) \ - do { \ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); /* in order to force CPU ordering */ \ - if ((instance)->is_hard_reset == PS3_FALSE && \ - (instance)->is_pci_reset == PS3_FALSE) { \ - read_value = ps3_ioc_reg_read_with_check( \ - instance, \ - (unsigned char *)(instance)->reg_set + \ - (offset)); \ - } else { \ - LOG_WARN( \ - "hno:%u register %p, read blocked by hardreset(%d)\n" \ - "\tor pci recovery(%d)\n", \ - PS3_HOST(instance), \ - (unsigned char *)(instance)->reg_set + \ - (offset), \ - (instance)->is_hard_reset, \ - instance->is_pci_reset); \ - read_value = U64_MAX; \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ - } while (0) - -#define PS3_IOC_REG_WRITE(instance, reg_type, reg_name, value) \ - do { \ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); /* in order to force CPU ordering */ \ - if ((instance)->is_hard_reset == PS3_FALSE && \ - (instance)->is_pci_reset == PS3_FALSE) { \ - ps3_ioc_reg_write( \ - instance, value, \ - &(instance)->reg_set->reg_type.reg_name); \ - } else { \ - LOG_FILE_ERROR( \ - "hno:%u register %p,write blocked by hardreset(%d)\n" \ - "\tor pci err(%d)\n", \ - PS3_HOST(instance), \ - &(instance)->reg_set->reg_type.reg_name, \ - (instance)->is_hard_reset, \ - instance->is_pci_reset); \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ - } while (0) - -#define PS3_IOC_REG_WRITE_OFFSET(instance, offset, value) \ - do { \ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); /* in order to force CPU ordering */ \ - if ((instance)->is_hard_reset == PS3_FALSE && \ - (instance)->is_pci_reset == PS3_FALSE) { \ - ps3_ioc_reg_write( \ - instance, value, \ - (unsigned char *)(instance)->reg_set + \ - (offset)); \ - } else { \ - LOG_FILE_ERROR( \ - "hno:%u register %p,write blocked by hardreset(%d)\n" \ - "\tor pci err(%d)\n", \ - PS3_HOST(instance), \ - (unsigned char *)(instance)->reg_set + \ - (offset), \ - (instance)->is_hard_reset, \ - instance->is_pci_reset); \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ - } while (0) - -#define PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_type, reg_name, value) \ - do { \ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); /* in order to force CPU ordering */ \ - if ((instance)->is_hard_reset == PS3_FALSE && \ - (instance)->is_pci_reset == PS3_FALSE) { \ - ps3_ioc_reg_write_with_check( \ - instance, value, \ - &(instance)->reg_set->reg_type.reg_name); \ - } else { \ - LOG_WARN( \ - "hno:%u register %p,write blocked by hardreset(%d)\n" \ - "\tor pci recovery(%d)\n", \ - PS3_HOST(instance), \ - &(instance)->reg_set->reg_type.reg_name, \ - (instance)->is_hard_reset, \ - instance->is_pci_reset); \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ - } while (0) - -#define PS3_IOC_REG_WRITE_OFFSET_WITH_CHECK(instance, offset, value) \ - do { \ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); /* in order to force CPU ordering */ \ - if ((instance)->is_hard_reset == PS3_FALSE && \ - (instance)->is_pci_reset == PS3_FALSE) { \ - ps3_ioc_reg_write_with_check( \ - instance, value, \ - (unsigned char *)(instance)->reg_set + \ - (offset)); \ - } else { \ - LOG_WARN( \ - "hno:%u register %p,write blocked by hardreset(%d)\n" \ - "\tor pci recovery(%d)\n", \ - PS3_HOST(instance), \ - (unsigned char *)(instance)->reg_set + \ - (offset), \ - (instance)->is_hard_reset, \ - instance->is_pci_reset); \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ - } while (0) - -int ps3_ioc_init_cmd_context_init(struct ps3_instance *instance); +#define PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT(ins) \ + ((ins->is_deep_soft_recovery_support) && ps3_deep_soft_reset_enable_query()) + +#define PS3_IOC_HARD_RECOVERY_SUPPORT(ins) \ + (PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(ins) || \ + ins->is_hard_recovery_support) + +#define PS3_HALT_CLI_SUPPORT(ins) \ + (ins->is_halt_support_cli) + +#define PS3_IOC_REG_READ_WITH_CHECK(instance, reg_type, reg_name, read_value) do {\ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); \ + if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ + read_value = ps3_ioc_reg_read_with_check(instance, &(instance)->reg_set->reg_type.reg_name); \ + } else { \ + LOG_FILE_ERROR("hno:%u register %p,read blocked by hardreset(%d) or pci err(%d)\n", \ + PS3_HOST(instance), &(instance)->reg_set->reg_type.reg_name, \ + (instance)->is_hard_reset, (instance)->is_pci_reset); \ + read_value = U64_MAX; \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ +} while(0); + +#define PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_type, reg_name, read_value) do {\ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); /* in order to force CPU ordering */ \ + if ((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ + read_value = ps3_ioc_reg_retry_safe_read(instance, &(instance)->reg_set->reg_type.reg_name); \ + } else { \ + LOG_FILE_ERROR("hno:%u register %p,read blocked by hardreset(%d) or pci err(%d)\n", \ + PS3_HOST(instance), &(instance)->reg_set->reg_type.reg_name, \ + (instance)->is_hard_reset, (instance)->is_pci_reset); \ + read_value = U64_MAX; \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ +} while (0) + +#define PS3_IOC_REG_READ_OFFSET(instance, offset, read_value) do {\ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); \ + if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ + read_value = ps3_ioc_reg_read(instance, (U8 *)(instance)->reg_set + (offset)); \ + } else { \ + LOG_FILE_ERROR("hno:%u register %p, read blocked by hardreset(%d) or pci err(%d)\n", \ + PS3_HOST(instance), (U8 *)(instance)->reg_set + (offset), \ + (instance)->is_hard_reset, instance->is_pci_reset); \ + read_value = U64_MAX; \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ +} while(0); + +#define PS3_IOC_REG_READ_OFFSET_WITCH_CHECK(instance, offset, read_value) do {\ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); \ + if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ + read_value = ps3_ioc_reg_read_with_check(instance, (U8 *)(instance)->reg_set + (offset)); \ + } else { \ + LOG_WARN("hno:%u register %p, read blocked by hardreset(%d) or pci recovery(%d)\n", \ + PS3_HOST(instance), (U8 *)(instance)->reg_set + (offset), \ + (instance)->is_hard_reset, instance->is_pci_reset); \ + read_value = U64_MAX; \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ +} while(0); + +#define PS3_IOC_REG_WRITE(instance, reg_type, reg_name, value) do {\ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); \ + if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ + ps3_ioc_reg_write(instance, value, &(instance)->reg_set->reg_type.reg_name); \ + } else { \ + LOG_FILE_ERROR("hno:%u register %p,write blocked by hardreset(%d) or pci err(%d)\n", \ + PS3_HOST(instance), &(instance)->reg_set->reg_type.reg_name, \ + (instance)->is_hard_reset, instance->is_pci_reset); \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ +} while(0) + +#define PS3_IOC_REG_WRITE_OFFSET(instance, offset, value) do {\ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); \ + if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ + ps3_ioc_reg_write(instance, value, (U8 *)(instance)->reg_set + (offset)); \ + } else { \ + LOG_FILE_ERROR("hno:%u register %p,write blocked by hardreset(%d) or pci err(%d)\n", \ + PS3_HOST(instance), (U8 *)(instance)->reg_set + (offset), \ + (instance)->is_hard_reset, instance->is_pci_reset); \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ +} while(0) + +#define PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_type, reg_name, value) do {\ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); \ + if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ + ps3_ioc_reg_write_with_check(instance, value, &(instance)->reg_set->reg_type.reg_name); \ + } else { \ + LOG_WARN("hno:%u register %p,write blocked by hardreset(%d) or pci recovery(%d)\n", \ + PS3_HOST(instance), &(instance)->reg_set->reg_type.reg_name, \ + (instance)->is_hard_reset, instance->is_pci_reset); \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ +} while(0) + +#define PS3_IOC_REG_WRITE_OFFSET_WITH_CHECK(instance, offset, value) do {\ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); \ + if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ + ps3_ioc_reg_write_with_check(instance, value, (U8 *)(instance)->reg_set + (offset)); \ + } else { \ + LOG_WARN("hno:%u register %p,write blocked by hardreset(%d) or pci recovery(%d)\n", \ + PS3_HOST(instance), (U8 *)(instance)->reg_set + (offset), \ + (instance)->is_hard_reset, instance->is_pci_reset); \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ +} while(0) + +S32 ps3_ioc_init_cmd_context_init(struct ps3_instance *instance); void ps3_ioc_init_cmd_context_exit(struct ps3_instance *instance); void ps3_ioc_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); + struct PS3CmdWord *cmd_word); void ps3_switch_init_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); + struct PS3CmdWord *cmd_word); void ps3_switch_normal_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); + struct PS3CmdWord *cmd_word); void ps3_ioc_legacy_irqs_enable(struct ps3_instance *instance); void ps3_ioc_legacy_irqs_disable(struct ps3_instance *instance); void ps3_ioc_msi_enable(struct ps3_instance *instance); void ps3_ioc_msi_disable(struct ps3_instance *instance); void ps3_ioc_msix_enable(struct ps3_instance *instance); void ps3_ioc_msix_disable(struct ps3_instance *instance); -unsigned char ps3_ioc_is_legacy_irq_existed(struct ps3_instance *instance); -int ps3_drv_info_buf_alloc(struct ps3_instance *instance); +Bool ps3_ioc_is_legacy_irq_existed(struct ps3_instance *instance); +S32 ps3_drv_info_buf_alloc(struct ps3_instance *instance); void ps3_drv_info_buf_free(struct ps3_instance *instance); -int ps3_host_mem_info_buf_alloc(struct ps3_instance *instance); +S32 ps3_host_mem_info_buf_alloc(struct ps3_instance *instance); void ps3_host_mem_info_buf_free(struct ps3_instance *instance); -int ps3_ioc_init_to_ready(struct ps3_instance *instance); - -int ps3_ioc_hard_reset_to_ready(struct ps3_instance *instance); +S32 ps3_ioc_init_to_ready(struct ps3_instance *instance); -int ps3_ioc_init_proc(struct ps3_instance *instance); +S32 ps3_ioc_hard_reset_to_ready(struct ps3_instance *instance); -void ps3_ioc_reg_write(struct ps3_instance *instance, unsigned long long val, - void __iomem *reg); +S32 ps3_ioc_init_proc(struct ps3_instance *instance); +void ps3_ioc_reg_write(struct ps3_instance *instance, U64 val, + void __iomem *reg); void ps3_ioc_hardreset_reg_write(struct ps3_instance *instance, - unsigned long long val, void __iomem *reg, - unsigned char is_warn_prk); - -unsigned long long ps3_ioc_hardreset_reg_read(struct ps3_instance *instance, - void __iomem *reg); + U64 val, void __iomem *reg, Bool is_warn_prk); +U64 ps3_ioc_hardreset_reg_read(struct ps3_instance *instance, + void __iomem *reg); +U64 ps3_ioc_reg_read(struct ps3_instance *instance, void __iomem *reg); -unsigned long long ps3_ioc_reg_read(struct ps3_instance *instance, - void __iomem *reg); +U64 ps3_ioc_reg_read_with_check(struct ps3_instance *instance, + void __iomem *reg); -unsigned long long ps3_ioc_reg_read_with_check(struct ps3_instance *instance, - void __iomem *reg); - -static inline unsigned char ps3_ioc_state_valid_check(unsigned int fw_cur_state) +static inline Bool ps3_ioc_state_valid_check(U32 fw_cur_state) { - return ((fw_cur_state > PS3_FW_STATE_START) && - (fw_cur_state != PS3_FW_STATE_MASK)); + return ((fw_cur_state > PS3_FW_STATE_START) && (fw_cur_state != PS3_FW_STATE_MASK)); } -unsigned long long ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, - void __iomem *reg); +U64 ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, void __iomem *reg); static inline void ps3_ioc_reg_write_with_check(struct ps3_instance *instance, - unsigned long long val, - void __iomem *reg) + U64 val, void __iomem *reg) { - unsigned char try_count = 0; + U8 try_count = 0; ps3_reg_dump(instance, reg, val, PS3_FALSE); if (instance->ioc_adpter->reg_write) { while (try_count != PS3_REG_WRITE_RETRY_NUM) { instance->ioc_adpter->reg_write(instance, val, reg); - if (instance->ioc_adpter->reg_read(instance, reg) == - val) { + if (instance->ioc_adpter->reg_read(instance, reg) == val) { break; } try_count++; @@ -297,171 +222,156 @@ static inline void ps3_ioc_reg_write_with_check(struct ps3_instance *instance, LOG_ERROR("hno:%u no register write\n", PS3_HOST(instance)); } - if (try_count == PS3_REG_WRITE_RETRY_NUM) + if (try_count == PS3_REG_WRITE_RETRY_NUM) { ps3_instance_state_transfer_to_dead(instance); + } } -unsigned long long ps3_switch_ioc_reg_read(struct ps3_instance *instance, - void __iomem *reg); +U64 ps3_switch_ioc_reg_read(struct ps3_instance *instance, void __iomem *reg); static inline void ps3_ioc_mgr_req_queue_lock_init(struct ps3_instance *instance) { - ps3_spin_lock_init(&instance->req_queue_lock); + ps3_spin_lock_init(&instance->req_queue_lock); } -static inline unsigned char -ps3_ioc_mgr_max_fw_cmd_get(struct ps3_instance *instance, - unsigned int *max_cmd_count) +static inline Bool ps3_ioc_mgr_max_fw_cmd_get(struct ps3_instance *instance, + U32 *max_cmd_count) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; union HilReg0Ps3RegisterFPs3MaxFwCmd *reg_max_fw_cmd = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxFwCmd, - value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxFwCmd, value); + INJECT_START(PS3_ERR_IJ_GET_REPLYQ_COUNT_INVALID, &value) if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3MaxFwCmd NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *max_cmd_count = 0; ret = PS3_FALSE; goto l_out; } reg_max_fw_cmd = (union HilReg0Ps3RegisterFPs3MaxFwCmd *)&value; - *max_cmd_count = (unsigned int)reg_max_fw_cmd->reg.ps3MaxFwCmd; + *max_cmd_count = (U32)reg_max_fw_cmd->reg.ps3MaxFwCmd; - if (instance->is_adjust_register_count) + if(instance->is_adjust_register_count) { *max_cmd_count += 1; - if (reset_devices && - *max_cmd_count > PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES) { - *max_cmd_count = PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES; } + if (reset_devices && *max_cmd_count > PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES) + *max_cmd_count = PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES; + l_out: return ret; } -static inline unsigned int +static inline U32 ps3_ioc_mgr_max_msix_vectors_get(struct ps3_instance *instance) { - unsigned long long reg_max_msix_vectors = PS3_MAX_REPLY_QUE_COUNT; + U64 reg_max_msix_vectors = PS3_MAX_REPLY_QUE_COUNT; (void)instance; - return (unsigned int)(reg_max_msix_vectors & - PS3_FW_MAX_MSIX_VECTORS_MASK); + return (U32)(reg_max_msix_vectors & PS3_FW_MAX_MSIX_VECTORS_MASK); } -static inline unsigned char -ps3_ioc_mgr_max_chain_size_get(struct ps3_instance *instance, - unsigned int *max_chain_size) +static inline Bool ps3_ioc_mgr_max_chain_size_get( + struct ps3_instance *instance, U32 *max_chain_size) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; union HilReg0Ps3RegisterFPs3MaxChainSize *max_chain_size_u = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3MaxChainSize, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxChainSize, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3MaxChainSize NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *max_chain_size = 0; ret = PS3_FALSE; goto l_out; } max_chain_size_u = (union HilReg0Ps3RegisterFPs3MaxChainSize *)&value; - *max_chain_size = (unsigned int)max_chain_size_u->reg.ps3MaxChainSize; + *max_chain_size = (U32)max_chain_size_u->reg.ps3MaxChainSize; l_out: return ret; } -static inline unsigned char -ps3_ioc_mgr_max_vd_info_size_get(struct ps3_instance *instance, - unsigned int *vd_info_size) +static inline Bool ps3_ioc_mgr_max_vd_info_size_get( + struct ps3_instance *instance, U32 *vd_info_size) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; union HilReg0Ps3RegisterFPs3MaxVdInfoSize *vd_info_size_u = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MaxVdInfoSize, - value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MaxVdInfoSize, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3MaxVdInfoSize NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *vd_info_size = 0; ret = PS3_FALSE; goto l_out; } vd_info_size_u = (union HilReg0Ps3RegisterFPs3MaxVdInfoSize *)&value; - *vd_info_size = (unsigned int)vd_info_size_u->reg.ps3MaxVdInfoSize; + *vd_info_size = (U32)vd_info_size_u->reg.ps3MaxVdInfoSize; l_out: return ret; } -static inline unsigned char -ps3_ioc_mgr_max_nvme_page_size_get(struct ps3_instance *instance, - unsigned int *max_nvme_page_size) +static inline Bool ps3_ioc_mgr_max_nvme_page_size_get( + struct ps3_instance *instance, U32 *max_nvme_page_size) { - unsigned char ret = PS3_TRUE; - union HilReg0Ps3RegisterFPs3MaxNvmePageSize *max_nvme_page_size_u = - NULL; - unsigned long long value = 0; + Bool ret = PS3_TRUE; + union HilReg0Ps3RegisterFPs3MaxNvmePageSize *max_nvme_page_size_u = NULL; + U64 value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3MaxNvmePageSize, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxNvmePageSize, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3MaxNvmePageSize NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *max_nvme_page_size = 0; ret = PS3_FALSE; goto l_out; } - max_nvme_page_size_u = - (union HilReg0Ps3RegisterFPs3MaxNvmePageSize *)&value; - *max_nvme_page_size = - (unsigned int)max_nvme_page_size_u->reg.ps3MaxNvmePageSize; + max_nvme_page_size_u = (union HilReg0Ps3RegisterFPs3MaxNvmePageSize *)&value; + *max_nvme_page_size = (U32)max_nvme_page_size_u->reg.ps3MaxNvmePageSize; l_out: return ret; } -static inline unsigned char -ps3_ioc_mgr_is_dma64_support(struct ps3_instance *instance, - unsigned char *is_dma64_support) +static inline Bool ps3_ioc_mgr_is_dma64_support(struct ps3_instance *instance, + Bool *is_dma64_support) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3FeatureSupport, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *is_dma64_support = PS3_FALSE; ret = PS3_FALSE; goto l_out; } - ps3_feature_support = - (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; *is_dma64_support = (ps3_feature_support->reg.dmaBit64Support != 0); l_out: return ret; } -static inline unsigned char -ps3_max_replyq_count_get(struct ps3_instance *instance, - unsigned int *max_replyq_count) +static inline Bool ps3_max_replyq_count_get(struct ps3_instance *instance, + U32 *max_replyq_count) { - unsigned char ret = PS3_TRUE; - unsigned long long value = 0; + Bool ret = PS3_TRUE; + U64 value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3MaxReplyque, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxReplyque, value); + INJECT_START(PS3_ERR_IJ_GET_REPLYQ_COUNT_INVALID, &value) if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3MaxReplyque NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *max_replyq_count = 0; ret = PS3_FALSE; goto l_out; @@ -472,160 +382,160 @@ ps3_max_replyq_count_get(struct ps3_instance *instance, return ret; } -static inline unsigned char -ps3_ioc_fw_version_get(struct ps3_instance *instance) +static inline Bool ps3_ioc_fw_version_get(struct ps3_instance *instance) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; union HilReg0Ps3RegisterFPs3FirmwareVersion *pver = NULL; - unsigned long long fw_version_last = instance->ioc_fw_version; - unsigned long long ver = 0; + U64 fw_version_last = instance->ioc_fw_version; + U64 ver = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3FirmwareVersion, ver); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FirmwareVersion, ver); if (ver == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FirmwareVersion NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); instance->ioc_fw_version = fw_version_last; ret = PS3_FALSE; goto l_out; } pver = (union HilReg0Ps3RegisterFPs3FirmwareVersion *)&ver; - instance->ioc_fw_version = (unsigned long long)pver->reg.ps3FmVer; + instance->ioc_fw_version = (U64)pver->reg.ps3FmVer; l_out: return ret; } -static inline unsigned char -ps3_ioc_sgl_mode_support(struct ps3_instance *instance, - unsigned char *is_sgl_mode_support) +static inline Bool ps3_ioc_sgl_mode_support(struct ps3_instance *instance, + Bool *is_sgl_mode_support) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3FeatureSupport, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *is_sgl_mode_support = PS3_FALSE; ret = PS3_FALSE; goto l_out; } - ps3_feature_support = - (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; *is_sgl_mode_support = (ps3_feature_support->reg.sglModeSupport == 1); l_out: return ret; } -static inline unsigned char -ps3_ioc_dump_support_get(struct ps3_instance *instance) +static inline Bool ps3_ioc_dump_support_get(struct ps3_instance *instance) { - unsigned char ret = PS3_TRUE; - unsigned char last_dump_support = - instance->dump_context.is_dump_support; + Bool ret = PS3_TRUE; + Bool last_dump_support = instance->dump_context.is_dump_support; union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, - value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + INJECT_START(PS3_ERR_IJ_FEATURE_SUPPORT_ERR, &value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); instance->dump_context.is_dump_support = last_dump_support; ret = PS3_FALSE; goto l_out; } - ps3_feature_support = - (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; instance->dump_context.is_dump_support = (ps3_feature_support->reg.dumpCrashSupport == 1); l_out: return ret; } -static inline unsigned char -ps3_ioc_state_halt_support_get(struct ps3_instance *instance) +static inline Bool ps3_ioc_state_halt_support_get(struct ps3_instance *instance) { - unsigned char ret = PS3_TRUE; - unsigned char last_halt_support = instance->is_ioc_halt_support; + Bool ret = PS3_TRUE; + Bool last_halt_support = instance->is_ioc_halt_support; union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, - value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); instance->is_ioc_halt_support = last_halt_support; ret = PS3_FALSE; goto l_out; } - ps3_feature_support = - (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; - instance->is_ioc_halt_support = - (ps3_feature_support->reg.fwHaltSupport == 1); + ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + instance->is_ioc_halt_support = (ps3_feature_support->reg.fwHaltSupport == 1); l_out: return ret; } -static inline unsigned char -ps3_ioc_recovery_count_get(struct ps3_instance *instance, - unsigned int *recovery_count) +static inline Bool ps3_ioc_recovery_count_get(struct ps3_instance *instance, + U32 *recovery_count) { - (void)instance; +#if 0 + Bool ret = PS3_TRUE; + U64 value = 0; + + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SoftresetCounter, value); + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3Debug4 failed!\n", + PS3_HOST(instance)); + *recovery_count = 0; + ret = PS3_FALSE; + goto l_out; + } + + *recovery_count = (U32)(value & PS3_IOC_RECOVERY_COUNT_MASK); +l_out: + return ret; +#else + (void) instance; *recovery_count = 0; return PS3_TRUE; +#endif } -static inline unsigned int ps3_ioc_state_get(struct ps3_instance *instance) +static inline U32 ps3_ioc_state_get(struct ps3_instance *instance) { - unsigned long long ioc_state = 0; + U64 ioc_state = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SocFwState, - ioc_state); - return (unsigned int)(ioc_state & PS3_FW_STATE_MASK); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SocFwState, ioc_state); + return (U32)(ioc_state & PS3_FW_STATE_MASK); } -static inline unsigned char -ps3_ioc_state_get_with_check(struct ps3_instance *instance, - unsigned int *ioc_state) +static inline Bool ps3_ioc_state_get_with_check(struct ps3_instance *instance, + U32 *ioc_state) { - unsigned char ret = PS3_TRUE; - unsigned long long value = 0; + Bool ret = PS3_TRUE; + U64 value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SocFwState, - value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SocFwState, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3SocFwState NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *ioc_state = 0; ret = PS3_FALSE; goto l_out; } - *ioc_state = (unsigned int)value & PS3_FW_STATE_MASK; + *ioc_state = (U32)value & PS3_FW_STATE_MASK; l_out: return ret; } -static inline unsigned char -ps3_get_doorbell_done_with_check(struct ps3_instance *instance, - unsigned char *is_doorbell_done) +static inline Bool ps3_get_doorbell_done_with_check(struct ps3_instance *instance, + Bool *is_doorbell_done) { - unsigned char ret = PS3_TRUE; - unsigned long long value = 0; + Bool ret = PS3_TRUE; + U64 value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3RegCmdState, - value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3RegCmdState, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3RegCmdState NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *is_doorbell_done = PS3_FALSE; ret = PS3_FALSE; goto l_out; @@ -636,59 +546,51 @@ ps3_get_doorbell_done_with_check(struct ps3_instance *instance, if (*is_doorbell_done) { value &= ~PS3_DOORBELL_DONE; if (instance->peer_instance != NULL && - instance->peer_instance->reg_set != NULL) { - PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, - ps3RegCmdState, value); + instance->peer_instance->reg_set != NULL) { + PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, ps3RegCmdState, value); PS3_IOC_REG_WRITE_WITH_CHECK(instance->peer_instance, - reg_f.Excl_reg, - ps3RegCmdState, value); + reg_f.Excl_reg, ps3RegCmdState, value); } else { - PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, - ps3RegCmdState, value); + PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, ps3RegCmdState, value); } + } l_out: return ret; } -static inline unsigned char -ps3_get_max_r1x_cmds_with_check(struct ps3_instance *instance, - unsigned short *max_r1x_cmds) +static inline Bool ps3_get_max_r1x_cmds_with_check(struct ps3_instance *instance, + U16 *max_r1x_cmds) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; union HilReg0Ps3RegisterFPs3MaxSecR1xCmds *ps3_max_sec_r1x_cmds = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3MaxSecR1xCmds, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxSecR1xCmds, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3Debug6 NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *max_r1x_cmds = 0; ret = PS3_FALSE; goto l_out; } - ps3_max_sec_r1x_cmds = - (union HilReg0Ps3RegisterFPs3MaxSecR1xCmds *)&value; + ps3_max_sec_r1x_cmds = (union HilReg0Ps3RegisterFPs3MaxSecR1xCmds *)&value; *max_r1x_cmds = ps3_max_sec_r1x_cmds->reg.ps3MaxSecR1xCmds; l_out: return ret; } -static inline unsigned char -ps3_check_debug0_valid_with_check(struct ps3_instance *instance, - unsigned char *is_doorbell_valid, - unsigned int check_mask) +static inline Bool ps3_check_debug0_valid_with_check( + struct ps3_instance *instance, Bool *is_doorbell_valid, U32 check_mask) { - unsigned char ret = PS3_TRUE; - unsigned long long value = 0; + Bool ret = PS3_TRUE; + U64 value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3CmdTrigger, - value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3CmdTrigger, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3CmdTrigger NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *is_doorbell_valid = PS3_FALSE; ret = PS3_FALSE; goto l_out; @@ -699,19 +601,19 @@ ps3_check_debug0_valid_with_check(struct ps3_instance *instance, return ret; } -static inline unsigned char -ps3_ioc_heartbeat_get(struct ps3_instance *instance, - unsigned long long *heartbeat_value) +static inline Bool ps3_ioc_heartbeat_get(struct ps3_instance *instance, + U64 *heartbeat_value) { - unsigned char ret = PS3_TRUE; - static unsigned char last_fault_state = PS3_TRUE; + Bool ret = PS3_TRUE; + static Bool last_fault_state = PS3_TRUE; - *heartbeat_value = ps3_ioc_reg_read_with_check( - instance, &instance->reg_set->reg_f.Excl_reg.ps3SocFwState); + *heartbeat_value = ps3_ioc_reg_read_with_check(instance, + &instance->reg_set->reg_f.Excl_reg.ps3SocFwState); + INJECT_START(PS3_ERR_IJ_READ_FW_STATE_REG_FF, heartbeat_value) if (*heartbeat_value == U64_MAX) { if (last_fault_state) { LOG_ERROR("hno:%u read reg ps3SocFwState NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); last_fault_state = PS3_FALSE; } *heartbeat_value = 0; @@ -719,8 +621,7 @@ ps3_ioc_heartbeat_get(struct ps3_instance *instance, goto l_out; } else { last_fault_state = PS3_TRUE; - LOG_DEBUG( - "hno:%u read reg ps3SocFwState success value[%llu]!\n", + LOG_DEBUG("hno:%u read reg ps3SocFwState success value[%llu]!\n", PS3_HOST(instance), *heartbeat_value); } @@ -728,35 +629,33 @@ ps3_ioc_heartbeat_get(struct ps3_instance *instance, return ret; } -static inline unsigned char -ps3_ioc_recovery_support_get(struct ps3_instance *instance) +static inline Bool ps3_ioc_recovery_support_get(struct ps3_instance *instance) { - unsigned char ret = PS3_TRUE; - unsigned char last_shallow_soft_recovery_support = + Bool ret = PS3_TRUE; + Bool last_shallow_soft_recovery_support = instance->is_shallow_soft_recovery_support; - unsigned char last_deep_soft_recovery_support = + Bool last_deep_soft_recovery_support = instance->is_deep_soft_recovery_support; - unsigned char last_hard_recovery_support = + Bool last_hard_recovery_support = instance->is_hard_recovery_support; union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, - value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); instance->is_shallow_soft_recovery_support = last_shallow_soft_recovery_support; instance->is_deep_soft_recovery_support = last_deep_soft_recovery_support; - instance->is_hard_recovery_support = last_hard_recovery_support; + instance->is_hard_recovery_support = + last_hard_recovery_support; ret = PS3_FALSE; goto l_out; } - ps3_feature_support = - (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; instance->is_shallow_soft_recovery_support = (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); instance->is_deep_soft_recovery_support = @@ -767,62 +666,56 @@ ps3_ioc_recovery_support_get(struct ps3_instance *instance) return ret; } -static inline unsigned char -ps3_ioc_multi_func_support(struct ps3_instance *instance) +static inline Bool ps3_ioc_multi_func_support(struct ps3_instance *instance) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; - unsigned long long value = 0; + U64 value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3FeatureSupport, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_FALSE; goto l_out; } - ps3_feature_support = - (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; ret = (ps3_feature_support->reg.multiDevfnSupport == 1); l_out: return ret; } -static inline unsigned char -ps3_ioc_security_state_check(struct ps3_instance *instance) +static inline Bool ps3_ioc_security_state_check(struct ps3_instance *instance) { - unsigned long long value = 0; - unsigned char ret = PS3_FALSE; - - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3Debug7, - value); - if (value == U64_MAX || (value & 0x1)) { - ret = PS3_TRUE; - LOG_ERROR( - "hno:%u read register NOK or ioc is security [%llu]\n", - PS3_HOST(instance), value); - } + U64 value = 0; + Bool ret = PS3_FALSE; + + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3Debug7, value); + if (value == U64_MAX || (value & 0x1)) { + ret = PS3_TRUE; + LOG_ERROR("hno:%u read register NOK or ioc is security [%llu]\n", + PS3_HOST(instance), value); + } #ifdef PS3_HARDWARE_SIM - ret = PS3_FALSE; + ret = PS3_FALSE; #endif - return ret; + return ret; } -static inline unsigned char -ps3_ioc_atu_support_get(struct ps3_instance *instance, unsigned char *bit_pos) +static inline Bool ps3_ioc_atu_support_get(struct ps3_instance *instance, U8 *bit_pos) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; union HilRegPs3RegisterFPs3AtuSupport *ps3_atu_support = NULL; - unsigned long long value = PS3_BIT_POS_DEFAULT; + U64 value = PS3_BIT_POS_DEFAULT; PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3Debug8, value); + INJECT_START(PS3_ERR_IJ_READ_ATU_REG_FAILED, &value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3AtuSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *bit_pos = PS3_BIT_POS_DEFAULT; ret = PS3_FALSE; goto l_out; @@ -833,31 +726,27 @@ ps3_ioc_atu_support_get(struct ps3_instance *instance, unsigned char *bit_pos) return ret; } -static inline unsigned char -ps3_ioc_atu_support_safe_get(struct ps3_instance *instance, - unsigned char *bit_pos) +static inline Bool ps3_ioc_atu_support_safe_get(struct ps3_instance *instance, U8 *bit_pos) { - unsigned char ret = PS3_FALSE; - unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; - unsigned int count = 0; - unsigned int retry_cnt = 0; - unsigned char tmp_bit_pos = 0; - unsigned char is_first = PS3_TRUE; + Bool ret = PS3_FALSE; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + U32 count = 0; + U32 retry_cnt = 0; + U8 tmp_bit_pos = 0; + Bool is_first = PS3_TRUE; for (; retry_cnt < PS3_ATU_SUPPORT_READ_RETRY_NUM; retry_cnt++) { if (!ps3_ioc_atu_support_get(instance, &tmp_bit_pos)) goto l_out; fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); + INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED, &fw_cur_state); if (!ps3_ioc_state_valid_check(fw_cur_state)) { for (; count < PS3_REG_READ_RETRY_NUM; count++) { - fw_cur_state = - instance->ioc_adpter->ioc_state_get( - instance); + fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); + INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED, &fw_cur_state); if (ps3_ioc_state_valid_check(fw_cur_state)) { - if (!ps3_ioc_atu_support_get( - instance, &tmp_bit_pos)) { + if (!ps3_ioc_atu_support_get(instance, &tmp_bit_pos)) goto l_out; - } *bit_pos = tmp_bit_pos; ret = PS3_TRUE; goto l_out; @@ -871,6 +760,7 @@ ps3_ioc_atu_support_safe_get(struct ps3_instance *instance, is_first = PS3_FALSE; continue; } + INJECT_START(PS3_ERR_IJ_BIT_POS_ERR, &tmp_bit_pos); if (*bit_pos != tmp_bit_pos) goto l_out; ps3_msleep(PS3_LOOP_TIME_INTERVAL_50MS); @@ -880,12 +770,10 @@ ps3_ioc_atu_support_safe_get(struct ps3_instance *instance, return ret; } -static inline unsigned char -ps3_ioc_atu_support_retry_read(struct ps3_instance *instance, - unsigned char *bit_pos) +static inline Bool ps3_ioc_atu_support_retry_read(struct ps3_instance *instance, U8 *bit_pos) { - unsigned int retry_cnt = PS3_ATU_SUPPORT_READ_RETRY_NUM; - unsigned char ret = PS3_FALSE; + U32 retry_cnt = PS3_ATU_SUPPORT_READ_RETRY_NUM; + Bool ret = PS3_FALSE; while (retry_cnt--) { if (ps3_ioc_atu_support_safe_get(instance, bit_pos)) { @@ -897,30 +785,23 @@ ps3_ioc_atu_support_retry_read(struct ps3_instance *instance, return ret; } -static inline void ps3_ioc_can_hardreset_set(struct ps3_instance *instance, - unsigned char enable) +static inline void ps3_ioc_can_hardreset_set(struct ps3_instance *instance, U8 enable) { - unsigned long long can_hardreset = 0; + U64 can_hardreset = 0; union HilRegPs3RegisterFPs3CanHardReset *ps3_can_hardreset = NULL; - ps3_can_hardreset = - (union HilRegPs3RegisterFPs3CanHardReset *)&can_hardreset; + ps3_can_hardreset = (union HilRegPs3RegisterFPs3CanHardReset *)&can_hardreset; ps3_can_hardreset->reg.canHardReset = enable; - PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3Debug9, - ps3_can_hardreset->val); + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3Debug9, ps3_can_hardreset->val); } -unsigned char ps3_feature_support_reg_get(struct ps3_instance *instance); +Bool ps3_feature_support_reg_get(struct ps3_instance *instance); void ps3_ioc_scsi_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); - -struct pglist_data *ps3_first_online_pgdat(void); + struct PS3CmdWord *cmd_word); -struct pglist_data *ps3_next_online_pgdat(struct pglist_data *pgdat); +struct pglist_data *first_online_pgdat(void); -#define for_each_ps3_online_pgdat(pgdat) \ - for (pgdat = ps3_first_online_pgdat(); pgdat; \ - pgdat = ps3_next_online_pgdat(pgdat)) +struct pglist_data *next_online_pgdat(struct pglist_data *pgdat); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.c b/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.c index 59af89542f7e..e3db8412846c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #ifndef _WINDOWS #include #include @@ -20,160 +19,160 @@ enum ps3_reset_type { PS3_FW_DEEP_SOFT_RESET = 2, }; -static inline const char *namePS3ResetType(int s) +static inline const S8 *namePS3ResetType(S32 s) { - static const char * const myNames[] = { - [PS3_FW_HARD_RESET] = "PS3_FW_HARD_RESET", - [PS3_FW_SHALLOW_SOFT_RESET] = "PS3_FW_SHALLOW_SOFT_RESET", - [PS3_FW_DEEP_SOFT_RESET] = "PS3_FW_DEEP_SOFT_RESET" + static const S8 *myNames[] = { + [PS3_FW_HARD_RESET] = "PS3_FW_HARD_RESET", + [PS3_FW_SHALLOW_SOFT_RESET] = "PS3_FW_SHALLOW_SOFT_RESET", + [PS3_FW_DEEP_SOFT_RESET] = "PS3_FW_DEEP_SOFT_RESET" }; - if (s > PS3_FW_DEEP_SOFT_RESET) + if (s > PS3_FW_DEEP_SOFT_RESET) { return "PS3_RESET_TYPE_INVALID"; + } return myNames[s]; } struct ps3_reset_key_map { - unsigned int reset_key_offset; - unsigned int reset_state_offset; - unsigned int reset_offset; - unsigned int reset_type; - unsigned int reset_status_offset; - unsigned int reset_status_mask; + U32 reset_key_offset; + U32 reset_state_offset; + U32 reset_offset; + U32 reset_type; + U32 reset_status_offset; + U32 reset_status_mask; }; struct ps3_state_desc_map { - unsigned int state; + U32 state; const char *state_desc; }; static struct ps3_reset_key_map g_reset_key_table[] = { - [PS3_FW_HARD_RESET] = { offsetof(struct HilReg0Ps3RegisterF, - ps3HardresetKey), - offsetof(struct HilReg0Ps3RegisterF, - ps3HardresetState), - offsetof(struct HilReg0Ps3RegisterF, - ps3Hardreset), - PS3_FW_HARD_RESET_ACT, - offsetof(struct HilReg0Ps3RegisterF, - ps3Hardreset), - PS3_HARDRESET_MASK }, - [PS3_FW_SHALLOW_SOFT_RESET] = { offsetof(struct HilReg0Ps3RegisterF, - ps3SoftresetKey), - offsetof(struct HilReg0Ps3RegisterF, - ps3SoftresetState), - offsetof(struct HilReg0Ps3RegisterF, - ps3Softreset), - PS3_FW_STATE_ACT_SHALLOW_SOFT_RESET, - offsetof(struct HilReg0Ps3RegisterF, - ps3Softreset), - PS3_SOFTRESET_MASK }, - [PS3_FW_DEEP_SOFT_RESET] = { offsetof(struct HilReg0Ps3RegisterF, - ps3SoftresetKey), - offsetof(struct HilReg0Ps3RegisterF, - ps3SoftresetState), - offsetof(struct HilReg0Ps3RegisterF, - ps3Softreset), - PS3_FW_STATE_ACT_DEEP_SOFT_RESET, - offsetof(struct HilReg0Ps3RegisterF, - ps3Softreset), - PS3_SOFTRESET_MASK }, + [PS3_FW_HARD_RESET] = { + offsetof(struct HilReg0Ps3RegisterF, ps3HardresetKey), + offsetof(struct HilReg0Ps3RegisterF, ps3HardresetState), + offsetof(struct HilReg0Ps3RegisterF, ps3Hardreset), + PS3_FW_HARD_RESET_ACT, + offsetof(struct HilReg0Ps3RegisterF, ps3Hardreset), + PS3_HARDRESET_MASK + }, + [PS3_FW_SHALLOW_SOFT_RESET] = { + offsetof(struct HilReg0Ps3RegisterF, ps3SoftresetKey), + offsetof(struct HilReg0Ps3RegisterF, ps3SoftresetState), + offsetof(struct HilReg0Ps3RegisterF, ps3Softreset), + PS3_FW_STATE_ACT_SHALLOW_SOFT_RESET, + offsetof(struct HilReg0Ps3RegisterF, ps3Softreset), + PS3_SOFTRESET_MASK + }, + [PS3_FW_DEEP_SOFT_RESET] = { + offsetof(struct HilReg0Ps3RegisterF, ps3SoftresetKey), + offsetof(struct HilReg0Ps3RegisterF, ps3SoftresetState), + offsetof(struct HilReg0Ps3RegisterF, ps3Softreset), + PS3_FW_STATE_ACT_DEEP_SOFT_RESET, + offsetof(struct HilReg0Ps3RegisterF, ps3Softreset), + PS3_SOFTRESET_MASK + }, }; static struct ps3_state_desc_map g_state_desc[] = { - { PS3_FW_STATE_UNDEFINED, "PS3_FW_STATE_UNDEFINED" }, - { PS3_FW_STATE_START, "PS3_FW_STATE_START" }, - { PS3_FW_STATE_READY, "PS3_FW_STATE_READY" }, - { PS3_FW_STATE_WAIT, "PS3_FW_STATE_WAIT" }, - { PS3_FW_STATE_RUNNING, "PS3_FW_STATE_RUNNING" }, - { PS3_FW_STATE_FLUSHING, "PS3_FW_STATE_FLUSHING" }, - { PS3_FW_STATE_RESET, "PS3_FW_STATE_RESET" }, - { PS3_FW_STATE_FAULT, "PS3_FW_STATE_FAULT" }, - { PS3_FW_STATE_CRITICAL, "PS3_FW_STATE_CRITICAL" }, - { PS3_FW_STATE_HALT, "PS3_FW_STATE_HALT" } + {PS3_FW_STATE_UNDEFINED, "PS3_FW_STATE_UNDEFINED"}, + {PS3_FW_STATE_START, "PS3_FW_STATE_START"}, + {PS3_FW_STATE_READY, "PS3_FW_STATE_READY"}, + {PS3_FW_STATE_WAIT, "PS3_FW_STATE_WAIT"}, + {PS3_FW_STATE_RUNNING, "PS3_FW_STATE_RUNNING"}, + {PS3_FW_STATE_FLUSHING, "PS3_FW_STATE_FLUSHING"}, + {PS3_FW_STATE_RESET, "PS3_FW_STATE_RESET"}, + {PS3_FW_STATE_FAULT, "PS3_FW_STATE_FAULT"}, + {PS3_FW_STATE_CRITICAL, "PS3_FW_STATE_CRITICAL"}, + {PS3_FW_STATE_HALT, "PS3_FW_STATE_HALT"} }; static void ps3_reset_key_write(struct ps3_instance *instance, - unsigned int offset) + U32 offset) { - static unsigned int reset_key_array[] = { - PS3_FW_DIAG_1ST_KEY, PS3_FW_DIAG_2ND_KEY, PS3_FW_DIAG_3RD_KEY, - PS3_FW_DIAG_4TH_KEY, PS3_FW_DIAG_5TH_KEY, PS3_FW_DIAG_6TH_KEY, - PS3_FW_DIAG_7TH_KEY, PS3_FW_DIAG_8TH_KEY, PS3_FW_DIAG_9TH_KEY + static U32 reset_key_array[] = { + PS3_FW_DIAG_1ST_KEY, + PS3_FW_DIAG_2ND_KEY, + PS3_FW_DIAG_3RD_KEY, + PS3_FW_DIAG_4TH_KEY, + PS3_FW_DIAG_5TH_KEY, + PS3_FW_DIAG_6TH_KEY, + PS3_FW_DIAG_7TH_KEY, + PS3_FW_DIAG_8TH_KEY, + PS3_FW_DIAG_9TH_KEY }; - unsigned int idx = 0; + U32 idx = 0; - for (idx = 0; idx < ARRAY_SIZE(reset_key_array); idx++) { - PS3_IOC_REG_WRITE_OFFSET( - instance, offset, - (unsigned long long)reset_key_array[idx]); + for(idx = 0;idx < ARRAY_SIZE(reset_key_array);idx++) { + PS3_IOC_REG_WRITE_OFFSET(instance, offset, (U64)reset_key_array[idx]); } } static void ps3_hardreset_key_write(struct ps3_instance *instance, - unsigned char *reset_key_vir_addr, - unsigned long long *timeval) + U8 *reset_key_vir_addr, U64 *timeval) { - static unsigned int reset_key_array[] = { - PS3_FW_DIAG_1ST_KEY, PS3_FW_DIAG_2ND_KEY, PS3_FW_DIAG_3RD_KEY, - PS3_FW_DIAG_4TH_KEY, PS3_FW_DIAG_5TH_KEY, PS3_FW_DIAG_6TH_KEY, - PS3_FW_DIAG_7TH_KEY, PS3_FW_DIAG_8TH_KEY, PS3_FW_DIAG_9TH_KEY + static U32 reset_key_array[] = { + PS3_FW_DIAG_1ST_KEY, + PS3_FW_DIAG_2ND_KEY, + PS3_FW_DIAG_3RD_KEY, + PS3_FW_DIAG_4TH_KEY, + PS3_FW_DIAG_5TH_KEY, + PS3_FW_DIAG_6TH_KEY, + PS3_FW_DIAG_7TH_KEY, + PS3_FW_DIAG_8TH_KEY, + PS3_FW_DIAG_9TH_KEY }; - unsigned int idx = 0; - + U32 idx = 0; timeval[PS3_START_WRITE_KEY_REG] = ps3_1970_now_ms_get(); - for (idx = 0; idx < ARRAY_SIZE(reset_key_array); idx++) { - ps3_ioc_hardreset_reg_write( - instance, (unsigned long long)reset_key_array[idx], - reset_key_vir_addr, 0); + for(idx = 0;idx < ARRAY_SIZE(reset_key_array);idx++) { + ps3_ioc_hardreset_reg_write(instance, + (U64)reset_key_array[idx], reset_key_vir_addr, 0); } timeval[PS3_END_WRITE_KEY_REG] = ps3_1970_now_ms_get(); } -static int ps3_reset_key_state_check(struct ps3_instance *instance, - unsigned int offset) +static S32 ps3_reset_key_state_check(struct ps3_instance *instance, + U32 offset) { - unsigned int reset_key_state = 0; - unsigned int read_count = 0; - const unsigned int retry_max = 50; - int ret = PS3_SUCCESS; - unsigned long long value = 0; + U32 reset_key_state = 0; + U32 read_count = 0; + const U32 retry_max = 50; + S32 ret = PS3_SUCCESS; + U64 value = 0; do { if (read_count >= retry_max) { - LOG_ERROR("hno:%u PS3 reset key state is still disabled after 5 sec\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u PS3 reset key state is still " + "disabled after 5 sec \n", PS3_HOST(instance)); ret = -PS3_FAILED; break; } - if (read_count != 0) + if (read_count != 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); + } PS3_IOC_REG_READ_OFFSET(instance, offset, value); - reset_key_state = (unsigned int)value; + reset_key_state = (U32)value; read_count++; } while (!(reset_key_state & PS3_FW_DIAG_ENABLE) || - (reset_key_state == U32_MAX)); + (reset_key_state == U32_MAX)); if (ret == PS3_SUCCESS) { - LOG_INFO( - "hno:%u PS3 reset key state is enabled after %d msecs\n", + LOG_INFO("hno:%u PS3 reset key state is enabled after %d msecs\n", PS3_HOST(instance), (read_count - 1) * PS3_LOOP_TIME_INTERVAL_100MS); } return ret; } -static int -ps3_hardreset_key_state_check(struct ps3_instance *instance, - unsigned char *reset_key_state_vir_addr, - unsigned long long *timeval) +static S32 ps3_hardreset_key_state_check(struct ps3_instance *instance, + U8 *reset_key_state_vir_addr, U64 *timeval) { - unsigned int reset_key_state = 0; - unsigned int read_count = 0; - const unsigned int retry_max = 900; - int ret = PS3_SUCCESS; + U32 reset_key_state = 0; + U32 read_count = 0; + const U32 retry_max = 900; + S32 ret = PS3_SUCCESS; timeval[PS3_START_WAIT_KEY_READY_REG] = ps3_1970_now_ms_get(); do { @@ -182,40 +181,41 @@ ps3_hardreset_key_state_check(struct ps3_instance *instance, break; } - if (read_count != 0) + if (read_count != 0) { ps3_mdelay(PS3_LOOP_TIME_INTERVAL_1MS); + } - reset_key_state = (unsigned int)ps3_ioc_hardreset_reg_read( - instance, reset_key_state_vir_addr); + reset_key_state = (U32)ps3_ioc_hardreset_reg_read(instance, + reset_key_state_vir_addr); read_count++; } while (!(reset_key_state & PS3_FW_DIAG_ENABLE) || - ((U32_MAX & reset_key_state) == U32_MAX)); + ((U32_MAX & reset_key_state) == U32_MAX)); timeval[PS3_END_WAIT_KEY_READY_REG] = ps3_1970_now_ms_get(); return ret; } -static int ps3_after_reset_request_check(struct ps3_instance *instance, - enum ps3_reset_type reset_type) +static S32 ps3_after_reset_request_check( + struct ps3_instance *instance, enum ps3_reset_type reset_type) { - unsigned int fw_state = instance->ioc_adpter->ioc_state_get(instance); - unsigned int read_count = 0; + U32 fw_state = instance->ioc_adpter->ioc_state_get(instance); + U32 read_count = 0; #ifdef PS3_HARDWARE_HAPS_V200 - const unsigned int retry_max = 3600; + const U32 retry_max = 3600; #else - const unsigned int retry_max = 1800; + const U32 retry_max = 1800; #endif - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; - while (read_count < retry_max) { - if ((fw_state == PS3_FW_STATE_START) || - (fw_state == PS3_FW_STATE_READY)) { + while(read_count < retry_max) { + if ( (fw_state == PS3_FW_STATE_START) || + (fw_state == PS3_FW_STATE_READY)) { ret = PS3_SUCCESS; break; } if ((reset_type == PS3_FW_SHALLOW_SOFT_RESET) || - (reset_type == PS3_FW_DEEP_SOFT_RESET)) { + (reset_type == PS3_FW_DEEP_SOFT_RESET)) { if (fw_state == PS3_FW_STATE_RUNNING) { ret = PS3_SUCCESS; break; @@ -223,8 +223,7 @@ static int ps3_after_reset_request_check(struct ps3_instance *instance, } if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; break; } @@ -233,73 +232,70 @@ static int ps3_after_reset_request_check(struct ps3_instance *instance, #else ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); #endif - fw_state = instance->ioc_adpter->ioc_state_get(instance); + fw_state = instance->ioc_adpter->ioc_state_get(instance); read_count++; } - if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u PS3 IOC state is not valid 180 secs after IOC reset, fw state is %s\n", - PS3_HOST(instance), ps3_ioc_state_print(fw_state)); + if ( ret != PS3_SUCCESS ) { + LOG_ERROR("hno:%u PS3 IOC state is not valid 180 secs after IOC reset, fw state is %s\n", + PS3_HOST(instance),ps3_ioc_state_print(fw_state)); } LOG_INFO("hno:%u fw state is %s\n", PS3_HOST(instance), - ps3_ioc_state_print(fw_state)); + ps3_ioc_state_print(fw_state)); return ret; + } -static int ps3_reset_request_completion_check(struct ps3_instance *instance, - unsigned int offset, - unsigned int completion_mask) +static S32 ps3_reset_request_completion_check( + struct ps3_instance *instance, U32 offset, U32 completion_mask) { - unsigned int read_count = 0; - const unsigned int retry_max = 1000; - int ret = PS3_SUCCESS; - unsigned long long value = 0; - unsigned int completion = 0; + U32 read_count = 0; + const U32 retry_max = 1000; + S32 ret = PS3_SUCCESS; + U64 value = 0; + U32 completion = 0; PS3_IOC_REG_READ_OFFSET(instance, offset, value); - completion = (unsigned int)value; - while (completion & completion_mask || completion == U32_MAX) { + completion = (U32)value; + while (completion & completion_mask || + completion == U32_MAX) { if (read_count > retry_max) { - LOG_ERROR( - "hno:%u PS3 reset flag is not clear 100 secs after reset request\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u PS3 reset flag is not " + "clear 100 secs after reset request \n", + PS3_HOST(instance)); ret = -PS3_FAILED; break; } if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); ret = -PS3_FAILED; break; } ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); PS3_IOC_REG_READ_OFFSET(instance, offset, value); - completion = (unsigned int)value; + completion = (U32)value; read_count++; } if (ret == PS3_SUCCESS) { - LOG_INFO( - "hno:%u PS3 reset complete %d msecs after reset complete\n", - PS3_HOST(instance), - read_count * PS3_LOOP_TIME_INTERVAL_100MS); + LOG_INFO("hno:%u PS3 reset complete %d msecs after reset complete \n", + PS3_HOST(instance), read_count * PS3_LOOP_TIME_INTERVAL_100MS); } return ret; } -const char *ps3_ioc_state_print(unsigned int state) +const char *ps3_ioc_state_print(U32 state) { - unsigned int idx = 0; - unsigned int fw_state = state & PS3_FW_STATE_MASK; + U32 idx = 0; + U32 fw_state = state & PS3_FW_STATE_MASK; const char *ps3_state_name = "invalid state"; - for (idx = 0; idx < ARRAY_SIZE(g_state_desc); idx++) { + for (idx = 0;idx < ARRAY_SIZE(g_state_desc);idx++) { if (g_state_desc[idx].state == fw_state) { ps3_state_name = g_state_desc[idx].state_desc; break; @@ -309,34 +305,29 @@ const char *ps3_ioc_state_print(unsigned int state) return ps3_state_name; } -static inline void -ps3_ioc_state_trigger_transition(struct ps3_instance *instance, - unsigned int action) +static inline void ps3_ioc_state_trigger_transition(struct ps3_instance *instance, U32 action) { - PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3Doorbell, - (unsigned long long)action); + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3Doorbell, (U64)action); } -static inline void ps3_ioc_debug0_trigger(struct ps3_instance *instance, - unsigned int mask_value) +static inline void ps3_ioc_debug0_trigger(struct ps3_instance *instance, U32 mask_value) { - PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3CmdTrigger, - (unsigned long long)mask_value); + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3CmdTrigger, (U64)mask_value); } -int ps3_ioc_state_fault_wait(struct ps3_instance *instance) +S32 ps3_ioc_state_fault_wait(struct ps3_instance *instance) { - unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; - int ret = PS3_SUCCESS; - unsigned int count = 0; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + S32 ret = PS3_SUCCESS; + U32 count = 0; fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); while (count < PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT) { if (fw_cur_state == PS3_FW_STATE_FAULT || - fw_cur_state == PS3_FW_STATE_CRITICAL) { + fw_cur_state == PS3_FW_STATE_CRITICAL) { LOG_INFO("hno:%u within 180s fw transfer to %s\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state)); break; } @@ -347,79 +338,87 @@ int ps3_ioc_state_fault_wait(struct ps3_instance *instance) if (fw_cur_state != PS3_FW_STATE_FAULT) { LOG_ERROR("hno:%u fw state[%s] is not fault\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state)); ret = -PS3_FAILED; } else { LOG_INFO("hno:%u fw state transition to %s\n", - PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state)); } return ret; } -int ps3_ioc_state_ready_wait(struct ps3_instance *instance) +S32 ps3_ioc_state_ready_wait(struct ps3_instance *instance) { - unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; - int ret = PS3_SUCCESS; - unsigned int count = 0; - unsigned char is_unload_valid = PS3_FALSE; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + S32 ret = PS3_SUCCESS; + U32 count = 0; + Bool is_unload_valid = PS3_FALSE; ps3_check_debug0_valid_with_check(instance, &is_unload_valid, - PS3_CMD_TRIGGER_UNLOAD); + PS3_CMD_TRIGGER_UNLOAD); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); while (count < instance->wait_ready_timeout) { +#if 0 + if ( (fw_cur_state == PS3_FW_STATE_READY) + || (fw_cur_state == PS3_FW_STATE_FAULT) + || (fw_cur_state == PS3_FW_STATE_HALT) ){ + break; + } +#else + INJECT_START(PS3_ERR_IJ_FORCE_HARD_READY_PCIE_ERRL, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } if (fw_cur_state == PS3_FW_STATE_READY && !is_unload_valid) { LOG_INFO("hno:%u within 180s fw transfer to %s\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state)); break; } +#endif #ifdef PS3_HARDWARE_HAPS_V200 ps3_msleep(PS3_LOOP_TIME_INTERVAL_3000MS); #else ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); #endif ps3_check_debug0_valid_with_check(instance, &is_unload_valid, - PS3_CMD_TRIGGER_UNLOAD); + PS3_CMD_TRIGGER_UNLOAD); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); count++; } if (fw_cur_state != PS3_FW_STATE_READY || is_unload_valid) { - LOG_ERROR( - "hno:%u fw state[%s] is not ready, or unload[%d] not done\n", - PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state), - is_unload_valid); + LOG_ERROR("hno:%u fw state[%s] is not ready, or unload[%d] not done\n", + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state), is_unload_valid); ret = -PS3_FAILED; } else { LOG_INFO("hno:%u fw state transition to %s\n", - PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state)); } l_out: return ret; } -int ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance) +S32 ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance) { - unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; - int ret = PS3_SUCCESS; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + S32 ret = PS3_SUCCESS; if (!ps3_ioc_state_get_with_check(instance, &fw_cur_state)) { ret = -PS3_FAILED; goto l_out; } - LOG_INFO("hno:%u fw state is %s(0x%x)\n", PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state), fw_cur_state); + LOG_INFO("hno:%u fw state is %s(0x%x)\n", + PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state), fw_cur_state); switch (fw_cur_state) { case PS3_FW_STATE_UNDEFINED: @@ -430,8 +429,9 @@ int ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance) if (ret != PS3_SUCCESS) { if (ret != -PS3_IN_PCIE_ERR) ret = -PS3_NO_RECOVERED; + LOG_ERROR("hno:%u fw state to ready NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } break; case PS3_FW_STATE_READY: @@ -439,14 +439,14 @@ int ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance) case PS3_FW_STATE_WAIT: case PS3_FW_STATE_RUNNING: LOG_WARN("hno:%u fw state is wait/running\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; break; case PS3_FW_STATE_FAULT: case PS3_FW_STATE_CRITICAL: case PS3_FW_STATE_HALT: - LOG_ERROR("hno:%u fw state is fault/halt, to ready NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u fw state is fault/halt, to ready NOK \n", + PS3_HOST(instance)); ret = -PS3_FAILED; break; @@ -458,34 +458,36 @@ int ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance) return ret; } -int ps3_ioc_state_transfer_wait_to_running(struct ps3_instance *instance) +S32 ps3_ioc_state_transfer_wait_to_running(struct ps3_instance *instance) { - unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; - int ret = PS3_SUCCESS; - unsigned int count = 0; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + S32 ret = PS3_SUCCESS; + U32 count = 0; fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - LOG_INFO("hno:%u fw state is %s(0x%x)\n", PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state), fw_cur_state); + INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_FAIL, &fw_cur_state) + LOG_INFO("hno:%u fw state is %s(0x%x)\n", + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state), fw_cur_state); while (count < PS3_FW_STATE_TO_RUNNING_TMO_LOOP_COUNT) { - if ((fw_cur_state == PS3_FW_STATE_RUNNING) || - (fw_cur_state == PS3_FW_STATE_FAULT) || - (fw_cur_state == PS3_FW_STATE_HALT) || - (fw_cur_state == PS3_FW_STATE_CRITICAL)) { + if ( (fw_cur_state == PS3_FW_STATE_RUNNING) + || (fw_cur_state == PS3_FW_STATE_FAULT) + || (fw_cur_state == PS3_FW_STATE_HALT) + || (fw_cur_state == PS3_FW_STATE_CRITICAL)){ break; } + INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING_PCI_ERR, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } ps3_mutex_lock(&instance->state_machine.lock); - if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { + if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; ps3_mutex_unlock(&instance->state_machine.lock); break; @@ -496,132 +498,129 @@ int ps3_ioc_state_transfer_wait_to_running(struct ps3_instance *instance) fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); count++; } + INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_FAIL1, &fw_cur_state) if (fw_cur_state != PS3_FW_STATE_RUNNING) { LOG_ERROR("hno:%u fw state transition NOK, state is %s\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state)); if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; } else { ret = -PS3_FAILED; } } - LOG_INFO("hno:%u fw state transit to %s\n", PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state)); + LOG_INFO("hno:%u fw state transit to %s\n", + PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state)); l_out: return ret; } -static int ps3_ioc_state_reset_request(struct ps3_instance *instance, - enum ps3_reset_type reset_type) +static S32 ps3_ioc_state_reset_request(struct ps3_instance *instance, + enum ps3_reset_type reset_type) { - int ret = -PS3_FAILED; - unsigned int ioc_reset_type = 0; - unsigned int reset_status_mask = 0; - unsigned int cur_state = 0; + S32 ret = -PS3_FAILED; + U32 ioc_reset_type = 0; + U32 reset_status_mask = 0; + U32 cur_state = 0; ioc_reset_type = g_reset_key_table[reset_type].reset_type; reset_status_mask = g_reset_key_table[reset_type].reset_status_mask; cur_state = ps3_atomic_read(&instance->state_machine.state); - LOG_INFO( - "hno:%u %s, key_offset: 0x%x, state_offset: 0x%x\n" - "\treset_offset: 0x%x, status_offset: 0x%x, IOC reset_type: 0x%8x\n" - "\tstatus mask: 0x%8x cur_state[%d]\n", + LOG_INFO("hno:%u %s, key_offset: 0x%x, state_offset: 0x%x," + " reset_offset: 0x%x, status_offset: 0x%x, IOC reset_type: 0x%8x" + " status mask: 0x%8x cur_state[%d]\n", PS3_HOST(instance), namePS3ResetType(reset_type), g_reset_key_table[reset_type].reset_key_offset, g_reset_key_table[reset_type].reset_state_offset, g_reset_key_table[reset_type].reset_offset, g_reset_key_table[reset_type].reset_status_offset, g_reset_key_table[reset_type].reset_type, - g_reset_key_table[reset_type].reset_status_mask, cur_state); + g_reset_key_table[reset_type].reset_status_mask, + cur_state); preempt_disable(); - ps3_reset_key_write(instance, - g_reset_key_table[reset_type].reset_key_offset); + ps3_reset_key_write(instance, g_reset_key_table[reset_type].reset_key_offset); preempt_enable(); - ps3_reset_key_state_check( - instance, g_reset_key_table[reset_type].reset_state_offset); + ps3_reset_key_state_check(instance, g_reset_key_table[reset_type].reset_state_offset); - PS3_IOC_REG_WRITE_OFFSET(instance, - g_reset_key_table[reset_type].reset_offset, - (unsigned long long)ioc_reset_type); + PS3_IOC_REG_WRITE_OFFSET(instance, g_reset_key_table[reset_type].reset_offset, (U64)ioc_reset_type); - if (ps3_hard_reset_waiting_query()) + if (ps3_hard_reset_waiting_query()) { ps3_msleep(ps3_hard_reset_waiting_query()); + } - if (ps3_reset_request_completion_check( - instance, g_reset_key_table[reset_type].reset_status_offset, - reset_status_mask) != PS3_SUCCESS) { + if (ps3_reset_request_completion_check(instance, g_reset_key_table[reset_type].reset_status_offset, + reset_status_mask) != PS3_SUCCESS) { goto l_out; } if (ps3_after_reset_request_check(instance, reset_type) != - PS3_SUCCESS) { + PS3_SUCCESS) { goto l_out; } ret = PS3_SUCCESS; l_out: - LOG_INFO("hno:%u PS3 %s complete, ret:%d\n", PS3_HOST(instance), - namePS3ResetType(reset_type), ret); + LOG_INFO("hno:%u PS3 %s complete, ret:%d\n", + PS3_HOST(instance), namePS3ResetType(reset_type), ret); return ret; } -static int ps3_ioc_state_hardreset_request(struct ps3_instance *instance, - enum ps3_reset_type reset_type) +static S32 ps3_ioc_state_hardreset_request(struct ps3_instance *instance, + enum ps3_reset_type reset_type) { - int ret = -PS3_FAILED; - unsigned char *reset_key_addr = NULL; - unsigned char *reset_state_addr = NULL; - unsigned char *reset_addr = NULL; - unsigned int ioc_reset_type = 0; - unsigned int cur_state = 0; - unsigned char *reg_start = (unsigned char *)instance->reg_set; - unsigned int read_count = 0; - const unsigned int retry_max = 180; - unsigned long flags = 0; - unsigned long long timeval[PS3_RESET_MAX_COUNT] = { 0 }; - - reset_key_addr = - reg_start + g_reset_key_table[reset_type].reset_key_offset; - reset_state_addr = - reg_start + g_reset_key_table[reset_type].reset_state_offset; - reset_addr = reg_start + g_reset_key_table[reset_type].reset_offset; + S32 ret = -PS3_FAILED; + U8 *reset_key_addr = NULL; + U8 *reset_state_addr = NULL; + U8 *reset_addr = NULL; + U32 ioc_reset_type = 0; + U32 cur_state = 0; + U8 *reg_start = (U8*)instance->reg_set; + U32 read_count = 0; + const U32 retry_max = 180; + ULong flags = 0; + U64 timeval[PS3_RESET_MAX_COUNT] = {0}; + + reset_key_addr = reg_start + + g_reset_key_table[reset_type].reset_key_offset; + reset_state_addr = reg_start + + g_reset_key_table[reset_type].reset_state_offset; + reset_addr = reg_start + + g_reset_key_table[reset_type].reset_offset; ioc_reset_type = g_reset_key_table[reset_type].reset_type; cur_state = ps3_atomic_read(&instance->state_machine.state); - LOG_INFO( - "hno:%u %s, key_offset: 0x%x, state_offset: 0x%x\n" - "\treset_offset: 0x%x, status_offset: 0x%x, IOC reset_type: 0x%8x\n" - "\tstatus mask: 0x%8x cur_state[%d]\n", + LOG_INFO("hno:%u %s, key_offset: 0x%x, state_offset: 0x%x," + " reset_offset: 0x%x, status_offset: 0x%x, IOC reset_type: 0x%8x" + " status mask: 0x%8x cur_state[%d]\n", PS3_HOST(instance), namePS3ResetType(reset_type), g_reset_key_table[reset_type].reset_key_offset, g_reset_key_table[reset_type].reset_state_offset, g_reset_key_table[reset_type].reset_offset, g_reset_key_table[reset_type].reset_status_offset, g_reset_key_table[reset_type].reset_type, - g_reset_key_table[reset_type].reset_status_mask, cur_state); + g_reset_key_table[reset_type].reset_status_mask, + cur_state); instance->is_hard_reset = PS3_TRUE; - mb(); /* in order to force CPU ordering */ - while (ps3_atomic_read(&instance->reg_op_count) != 0) { + mb(); + while(ps3_atomic_read(&instance->reg_op_count) != 0){ ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - if (read_count++ > retry_max) { + if(read_count++ > retry_max){ LOG_INFO("hno:%u %s, wait reg op over:%d ms,failed\n", - PS3_HOST(instance), - namePS3ResetType(reset_type), - read_count * PS3_LOOP_TIME_INTERVAL_100MS); + PS3_HOST(instance), namePS3ResetType(reset_type), + read_count*PS3_LOOP_TIME_INTERVAL_100MS); ret = -PS3_FAILED; goto l_out; } } + INJECT_START(PS3_ERR_IJ_V2_RECOVERY_WAIT_NOTIFY, instance); ps3_wait_scsi_cmd_done(instance, PS3_TRUE); ps3_wait_mgr_cmd_done(instance, PS3_TRUE); if (instance->peer_instance != NULL) { @@ -629,110 +628,104 @@ static int ps3_ioc_state_hardreset_request(struct ps3_instance *instance, ps3_wait_mgr_cmd_done(instance->peer_instance, PS3_TRUE); } + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_4, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_INFO("hno:%u pcie recovery proceess\n", PS3_HOST(instance)); + LOG_INFO("hno:%u pcie recovery proceess\n", + PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } - spin_lock_irqsave(&instance->recovery_context->ps3_hardreset_lock, - flags); + spin_lock_irqsave(&instance->recovery_context->ps3_hardreset_lock, flags); ps3_hardreset_key_write(instance, reset_key_addr, timeval); - ret = ps3_hardreset_key_state_check(instance, reset_state_addr, - timeval); - if (ret != PS3_SUCCESS) { - spin_unlock_irqrestore( - &instance->recovery_context->ps3_hardreset_lock, flags); + ret = ps3_hardreset_key_state_check(instance, reset_state_addr, timeval); + if(ret != PS3_SUCCESS){ + spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, flags); LOG_INFO("hno:%u %s, key check failed, ret:%d\n", - PS3_HOST(instance), namePS3ResetType(reset_type), ret); + PS3_HOST(instance), namePS3ResetType(reset_type),ret); goto l_out; } + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_5, instance) if (ps3_pci_err_recovery_get(instance)) { - spin_unlock_irqrestore( - &instance->recovery_context->ps3_hardreset_lock, flags); - LOG_WARN("hno:%u pcie recovery proceess\n", PS3_HOST(instance)); + spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, flags); + LOG_WARN("hno:%u pcie recovery proceess\n", + PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } timeval[PS3_START_WRITE_HARDRESET_REG] = ps3_1970_now_ms_get(); - ps3_ioc_hardreset_reg_write(instance, - (unsigned long long)ioc_reset_type, - reset_addr, PS3_TRUE); + ps3_ioc_hardreset_reg_write(instance, (U64)ioc_reset_type, reset_addr, PS3_TRUE); timeval[PS3_END_WRITE_HARDRESET_REG] = ps3_1970_now_ms_get(); - spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, - flags); - LOG_INFO("hno:%u %s, key_offset: key state success\n" - "\tthen write hardreset ioc_reset_type:%u, reset_addr:%p\n", - PS3_HOST(instance), namePS3ResetType(reset_type), - ioc_reset_type, reset_addr); + spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, flags); + LOG_INFO("hno:%u %s, key_offset: key state success, " + "then write hardreset ioc_reset_type:%u, reset_addr:%p\n", + PS3_HOST(instance), namePS3ResetType(reset_type), ioc_reset_type, reset_addr); LOG_INFO("hno:%u time:%lld-%lld-%lld-%lld-%lld-%lld\n", - PS3_HOST(instance), timeval[PS3_START_WRITE_KEY_REG], - timeval[PS3_END_WRITE_KEY_REG], - timeval[PS3_START_WAIT_KEY_READY_REG], - timeval[PS3_END_WAIT_KEY_READY_REG], - timeval[PS3_START_WRITE_HARDRESET_REG], - timeval[PS3_END_WRITE_HARDRESET_REG]); + PS3_HOST(instance), timeval[PS3_START_WRITE_KEY_REG], timeval[PS3_END_WRITE_KEY_REG], + timeval[PS3_START_WAIT_KEY_READY_REG], timeval[PS3_END_WAIT_KEY_READY_REG], + timeval[PS3_START_WRITE_HARDRESET_REG], timeval[PS3_END_WRITE_HARDRESET_REG]); instance->recovery_context->hardreset_count++; if (ps3_hard_reset_waiting_query()) ps3_msleep(ps3_hard_reset_waiting_query()); - LOG_INFO("hno:%u %s, after sleep:%d ms\n", PS3_HOST(instance), - namePS3ResetType(reset_type), ps3_hard_reset_waiting_query()); + + LOG_INFO("hno:%u %s, after sleep:%d ms\n", + PS3_HOST(instance), namePS3ResetType(reset_type),ps3_hard_reset_waiting_query()); instance->is_hard_reset = PS3_FALSE; - ret = ps3_after_reset_request_check(instance, reset_type); - if (ret != PS3_SUCCESS) + if ((ret = ps3_after_reset_request_check(instance, reset_type)) != + PS3_SUCCESS) { goto l_out; + } ret = PS3_SUCCESS; l_out: instance->is_hard_reset = PS3_FALSE; - LOG_INFO("hno:%u PS3 %s complete, ret:%d\n", PS3_HOST(instance), - namePS3ResetType(reset_type), ret); + LOG_INFO("hno:%u PS3 %s complete, ret:%d\n", + PS3_HOST(instance), namePS3ResetType(reset_type), ret); return ret; } -int ps3_ioc_state_hard_reset(struct ps3_instance *instance) +S32 ps3_ioc_state_hard_reset(struct ps3_instance *instance) { if (ps3_use_hard_reset_reg_query()) { - return ps3_ioc_state_hardreset_request(instance, - PS3_FW_HARD_RESET); + return ps3_ioc_state_hardreset_request(instance, PS3_FW_HARD_RESET); } else { - return ps3_ioc_state_reset_request(instance, - PS3_FW_SHALLOW_SOFT_RESET); + return ps3_ioc_state_reset_request(instance, PS3_FW_SHALLOW_SOFT_RESET); } } -int ps3_ioc_state_shallow_soft_reset(struct ps3_instance *instance) +S32 ps3_ioc_state_shallow_soft_reset(struct ps3_instance *instance) { return ps3_ioc_state_reset_request(instance, PS3_FW_SHALLOW_SOFT_RESET); } -int ps3_ioc_state_deep_soft_reset(struct ps3_instance *instance) +S32 ps3_ioc_state_deep_soft_reset(struct ps3_instance *instance) { return ps3_ioc_state_reset_request(instance, PS3_FW_DEEP_SOFT_RESET); } -static int ps3_trigger_ioc_state_change_by_doorbell( - struct ps3_instance *instance, unsigned int expect_fw_state, - unsigned int doorbell_trigger, u32 time_out) +static S32 ps3_trigger_ioc_state_change_by_doorbell(struct ps3_instance *instance, + U32 expect_fw_state, U32 doorbell_trigger, u32 time_out) { - unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; - unsigned char is_doorbell_done = PS3_TRUE; - int ret = PS3_SUCCESS; - unsigned int count = 0; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + Bool is_doorbell_done = PS3_TRUE; + S32 ret = PS3_SUCCESS; + U32 count = 0; LOG2_WARN("hno:%u expect fw state:%s, doorbell_trigger is %d\n", - PS3_HOST(instance), ps3_ioc_state_print(expect_fw_state), - doorbell_trigger); + PS3_HOST(instance), + ps3_ioc_state_print(expect_fw_state), doorbell_trigger); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - if (fw_cur_state == expect_fw_state) + if (fw_cur_state == expect_fw_state) { goto l_out; + } + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_2, instance) if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; @@ -741,27 +734,25 @@ static int ps3_trigger_ioc_state_change_by_doorbell( ps3_ioc_state_trigger_transition(instance, doorbell_trigger); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - if (doorbell_trigger == PS3_REG_DOORBELL_STATE_TO_FAULT) + if (doorbell_trigger == PS3_REG_DOORBELL_STATE_TO_FAULT) { ps3_get_doorbell_done_with_check(instance, &is_doorbell_done); + } while (count < time_out) { - if (fw_cur_state == expect_fw_state && is_doorbell_done) + if (fw_cur_state == expect_fw_state && is_doorbell_done) { break; + } ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); if (fw_cur_state == PS3_FW_STATE_MASK) { - LOG_ERROR( - "hno:%u break because get fw_cur_state NOK.\n", + LOG_ERROR("hno:%u break because get fw_cur_state NOK.\n", PS3_HOST(instance)); break; } - if (doorbell_trigger == PS3_REG_DOORBELL_STATE_TO_FAULT && - !is_doorbell_done) { - if (ps3_get_doorbell_done_with_check( - instance, &is_doorbell_done) == PS3_FALSE) { - LOG_ERROR( - "hno:%u break because get doorbell_done NOK.\n", + if (doorbell_trigger == PS3_REG_DOORBELL_STATE_TO_FAULT && !is_doorbell_done) { + if (ps3_get_doorbell_done_with_check(instance, &is_doorbell_done) == PS3_FALSE) { + LOG_ERROR("hno:%u break because get doorbell_done NOK.\n", PS3_HOST(instance)); break; } @@ -769,10 +760,11 @@ static int ps3_trigger_ioc_state_change_by_doorbell( count++; } + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_DOORBELL_FAILED, &fw_cur_state) if (fw_cur_state != expect_fw_state) { - LOG_ERROR( - "hno:%u fw state transition NOK, is_doorbell_done %d state is %s\n", - PS3_HOST(instance), is_doorbell_done, + LOG_ERROR("hno:%u fw state transition NOK, is_doorbell_done %d state is %s\n", + PS3_HOST(instance), + is_doorbell_done, ps3_ioc_state_print(fw_cur_state)); ret = -PS3_FAILED; } @@ -780,65 +772,69 @@ static int ps3_trigger_ioc_state_change_by_doorbell( return ret; } -int ps3_ioc_notify_unload(struct ps3_instance *instance) +S32 ps3_ioc_notify_unload(struct ps3_instance *instance) { - unsigned char is_unload_valid = PS3_FALSE; - int ret = PS3_SUCCESS; - unsigned int count = 0; - unsigned char unload_type = PS3_CMD_TRIGGER_UNLOAD; + Bool is_unload_valid = PS3_FALSE; + S32 ret = PS3_SUCCESS; + U32 count = 0; + U8 unload_type = PS3_CMD_TRIGGER_UNLOAD; - LOG_WARN("hno:%u trigger ioc unload reg!!\n", PS3_HOST(instance)); + LOG_WARN("hno:%u trigger ioc unload reg!!\n", + PS3_HOST(instance)); - if (instance->state_machine.is_suspend) + if (instance->state_machine.is_suspend) { unload_type = PS3_CMD_TRIGGER_UNLOAD_SUSPEND; + } ps3_ioc_debug0_trigger(instance, unload_type); ps3_check_debug0_valid_with_check(instance, &is_unload_valid, - unload_type); + unload_type); while (count < PS3_FW_STATE_TO_UNLOAD_TMO_LOOP_COUNT) { - if (!is_unload_valid) + if (!is_unload_valid) { break; + } ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); ps3_check_debug0_valid_with_check(instance, &is_unload_valid, - unload_type); + unload_type); count++; } if (is_unload_valid) { LOG_ERROR("hno:%u do not wait unload done\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } return ret; } -int ps3_ioc_state_force_to_fault(struct ps3_instance *instance) +S32 ps3_ioc_state_force_to_fault(struct ps3_instance *instance) { - return ps3_trigger_ioc_state_change_by_doorbell( - instance, PS3_FW_STATE_FAULT, PS3_REG_DOORBELL_STATE_TO_FAULT, + return ps3_trigger_ioc_state_change_by_doorbell(instance, + PS3_FW_STATE_FAULT, PS3_REG_DOORBELL_STATE_TO_FAULT, PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT); } -int ps3_ioc_state_force_to_halt(struct ps3_instance *instance) +S32 ps3_ioc_state_force_to_halt(struct ps3_instance *instance) { - return ps3_trigger_ioc_state_change_by_doorbell( - instance, PS3_FW_STATE_HALT, PS3_REG_DOORBELL_STATE_TO_HALT, + return ps3_trigger_ioc_state_change_by_doorbell(instance, + PS3_FW_STATE_HALT, PS3_REG_DOORBELL_STATE_TO_HALT, PS3_FW_STATE_TO_HALT_TMO_LOOP_COUNT); } #ifdef PS3_HARDWARE_ASIC -unsigned int ps3_ioc_heartbeat_detect(struct ps3_instance *instance) +U32 ps3_ioc_heartbeat_detect(struct ps3_instance *instance) { - unsigned int ret = PS3_FALSE; - unsigned long long heartbeat_value = 0; + U32 ret = PS3_FALSE; + U64 heartbeat_value = 0; - (void)instance; + (void) instance; - if (!ps3_enable_heartbeat_query()) + if (!ps3_enable_heartbeat_query()) { return ret; + } if (!ps3_ioc_heartbeat_get(instance, &heartbeat_value)) { LOG_DEBUG("hno:%u probably Linkdown\n", PS3_HOST(instance)); @@ -846,8 +842,7 @@ unsigned int ps3_ioc_heartbeat_detect(struct ps3_instance *instance) } if (heartbeat_value & instance->hard_dog_mask) { - LOG_DEBUG("hno:%u heartbeat detect success\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u heartbeat detect success\n", PS3_HOST(instance)); ret = PS3_TRUE; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.h b/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.h index 518a99605ad4..7c62cbf99d0e 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.h @@ -1,31 +1,30 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_IOC_STATE_H_ #define _PS3_IOC_STATE_H_ #include "ps3_instance_manager.h" enum { - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID = 18000, - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_HBA = 18000, - PS3_WAIT_FOR_OUTSTANDING_IO_COMPLETE = 9000, - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_SWITCH = 15000, - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID_HAPS = 3600, - PS3_FW_STATE_TO_RUNNING_TMO_LOOP_COUNT = 9000, - PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT = 1500, - PS3_FW_STATE_TO_HALT_TMO_LOOP_COUNT = 9000, - PS3_FW_STATE_TO_UNLOAD_TMO_LOOP_COUNT = 500, - PS3_WAIT_EVENT_CMD_LOOP_COUNT = 100, - PS3_LOOP_TIME_INTERVAL_1MS = 1, - PS3_LOOP_TIME_INTERVAL_20MS = 20, - PS3_LOOP_TIME_INTERVAL_50MS = 50, - PS3_LOOP_TIME_INTERVAL_100MS = 100, - PS3_LOOP_TIME_INTERVAL_3000MS = 3000, - PS3_WRITE_HARD_RESET_WAIT_TIME_500MS = 500, - PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT = 9000, - PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS = 20, - PS3_PS3_LOOP_TIME_INTERVAL_1000MS = 1000, - PS3_TRANS_DEAD_IOC_FAILED_MAX_COUNT = 10, + PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID = 18000, + PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_HBA = 18000, + PS3_WAIT_FOR_OUTSTANDING_IO_COMPLETE = 9000, + PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_SWITCH = 15000, + PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID_HAPS = 3600, + PS3_FW_STATE_TO_RUNNING_TMO_LOOP_COUNT = 9000, + PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT = 1500, + PS3_FW_STATE_TO_HALT_TMO_LOOP_COUNT = 9000, + PS3_FW_STATE_TO_UNLOAD_TMO_LOOP_COUNT = 500, + PS3_WAIT_EVENT_CMD_LOOP_COUNT = 100, + PS3_LOOP_TIME_INTERVAL_1MS = 1, + PS3_LOOP_TIME_INTERVAL_20MS = 20, + PS3_LOOP_TIME_INTERVAL_50MS = 50, + PS3_LOOP_TIME_INTERVAL_100MS = 100, + PS3_LOOP_TIME_INTERVAL_3000MS = 3000, + PS3_WRITE_HARD_RESET_WAIT_TIME_500MS = 500, + PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT =9000, + PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS =20, + PS3_PS3_LOOP_TIME_INTERVAL_1000MS = 1000, + PS3_TRANS_DEAD_IOC_FAILED_MAX_COUNT = 10, }; enum ps3_reset_time_type { PS3_START_WRITE_KEY_REG = 0, @@ -37,50 +36,46 @@ enum ps3_reset_time_type { PS3_RESET_MAX_COUNT = 6, }; -#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED \ - (PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT * \ - PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS / HZ + \ - PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT * PS3_LOOP_TIME_INTERVAL_20MS / \ - HZ + \ - PS3_LOOP_TIME_INTERVAL_100MS * PS3_LOOP_TIME_INTERVAL_100MS / HZ + \ - PS3_WRITE_HARD_RESET_WAIT_TIME_500MS / HZ + \ - PS3_SLEEP_TOLERATE_TIMEOUT) +#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED (PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT * \ + PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS / HZ + \ + PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT * PS3_LOOP_TIME_INTERVAL_20MS / HZ + \ + PS3_LOOP_TIME_INTERVAL_100MS * PS3_LOOP_TIME_INTERVAL_100MS / HZ + \ + PS3_WRITE_HARD_RESET_WAIT_TIME_500MS / HZ + \ + PS3_SLEEP_TOLERATE_TIMEOUT) #ifdef PS3_HARDWARE_HAPS_V200 -#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME(ins) \ - (PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED + \ - (ins)->wait_ready_timeout * PS3_LOOP_TIME_INTERVAL_3000MS / HZ) +#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME(ins) (PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED + \ + (ins)->wait_ready_timeout * PS3_LOOP_TIME_INTERVAL_3000MS / HZ) #else -#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME(ins) \ - (PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED + \ - (ins)->wait_ready_timeout * PS3_LOOP_TIME_INTERVAL_20MS / HZ) +#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME(ins) (PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED + \ + (ins)->wait_ready_timeout * PS3_LOOP_TIME_INTERVAL_20MS / HZ) #endif -int ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance); +S32 ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance); -int ps3_ioc_state_transfer_wait_to_running(struct ps3_instance *instance); +S32 ps3_ioc_state_transfer_wait_to_running(struct ps3_instance *instance); -int ps3_ioc_state_hard_reset(struct ps3_instance *instance); +S32 ps3_ioc_state_hard_reset(struct ps3_instance *instance); -int ps3_ioc_state_shallow_soft_reset(struct ps3_instance *instance); +S32 ps3_ioc_state_shallow_soft_reset(struct ps3_instance *instance); -int ps3_ioc_state_deep_soft_reset(struct ps3_instance *instance); +S32 ps3_ioc_state_deep_soft_reset(struct ps3_instance *instance); -int ps3_ioc_state_force_to_fault(struct ps3_instance *instance); +S32 ps3_ioc_state_force_to_fault(struct ps3_instance *instance); -int ps3_ioc_state_force_to_halt(struct ps3_instance *instance); +S32 ps3_ioc_state_force_to_halt(struct ps3_instance *instance); -int ps3_ioc_notify_unload(struct ps3_instance *instance); +S32 ps3_ioc_notify_unload(struct ps3_instance *instance); #ifdef PS3_HARDWARE_ASIC -unsigned int ps3_ioc_heartbeat_detect(struct ps3_instance *instance); +U32 ps3_ioc_heartbeat_detect(struct ps3_instance *instance); #endif -int ps3_ioc_state_ready_wait(struct ps3_instance *instance); +S32 ps3_ioc_state_ready_wait(struct ps3_instance *instance); -int ps3_ioc_state_fault_wait(struct ps3_instance *instance); +S32 ps3_ioc_state_fault_wait(struct ps3_instance *instance); -const char *ps3_ioc_state_print(unsigned int state); +const char *ps3_ioc_state_print(U32 state); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioctl.c b/drivers/scsi/linkdata/ps3stor/ps3_ioctl.c index 916a15a5609c..c7779f28e260 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioctl.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioctl.c @@ -1,14 +1,11 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #include "ps3_ioctl.h" #ifdef _WINDOWS #include -#define PS3_FUNC_FROM_CTL_CODE(ctrlCode) \ - (((unsigned long)(ctrlCode & 0x3FFC)) >> 2) -#define PS3_ACC_FROM_CTL_CODE(ctrlCode) \ - (((unsigned long)(ctrlCode & 0xC000)) >> 14) +#define PS3_FUNC_FROM_CTL_CODE(ctrlCode) (((ULong)(ctrlCode & 0x3FFC)) >> 2) +#define PS3_ACC_FROM_CTL_CODE(ctrlCode) (((ULong)(ctrlCode & 0xC000)) >> 14) #else #include @@ -33,9 +30,10 @@ #include "ps3_mgr_channel.h" #include "ps3_mgr_cmd_err.h" #include "ps3_util.h" +#include "ps3_err_inject.h" #include "ps3_event.h" -int ps3_ioctl_init(struct ps3_instance *instance, int cmd_num) +S32 ps3_ioctl_init(struct ps3_instance*instance, S32 cmd_num) { #ifdef _WINDOWS (void)cmd_num; @@ -43,21 +41,18 @@ int ps3_ioctl_init(struct ps3_instance *instance, int cmd_num) #else sema_init(&instance->ioctl_sem, cmd_num); #endif - ps3_atomic_set(&instance->cmd_statistics.cli_cnt, - PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&instance->cmd_statistics.cli_cnt, PS3_CMD_STAT_INIT_VALUE); return PS3_SUCCESS; } -static int ps3_ioctl_capbility_pre_check(struct ps3_instance *instance, - struct PS3IoctlSyncCmd *ioc) +static S32 ps3_ioctl_capbility_pre_check(struct ps3_instance *instance, + struct PS3IoctlSyncCmd* ioc) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; if (ioc->sgeCount > PS3_MAX_IOCTL_SGE_NUM || ioc->sgeCount == 0) { - LOG_WARN( - "hno:%u ioctl req, SGE count [%d] > max limit [%d], or SGE count = 0\n", - PS3_HOST(instance), ioc->sgeCount, - PS3_MAX_IOCTL_SGE_NUM); + LOG_WARN("hno:%u ioctl req, SGE count [%d] > max limit [%d], or SGE count = 0\n", + PS3_HOST(instance), ioc->sgeCount, PS3_MAX_IOCTL_SGE_NUM); ret = -PS3_EINVAL; goto l_out; } @@ -69,10 +64,10 @@ static int ps3_ioctl_capbility_pre_check(struct ps3_instance *instance, void ps3_ioctl_buff_bit_pos_update(struct ps3_cmd *cmd) { - unsigned char i = 0; + U8 i = 0; struct PS3Sge *pSge = (struct PS3Sge *)cmd->req_frame->mgrReq.sgl; struct ps3_instance *instance = cmd->instance; - unsigned char bit_pos = 0; + U8 bit_pos = 0; if (cmd->transient == NULL) goto l_out; @@ -84,17 +79,12 @@ void ps3_ioctl_buff_bit_pos_update(struct ps3_cmd *cmd) if (cmd->transient->transient_buff[i] != NULL) { if (pSge->ext == 1) pSge = (struct PS3Sge *)cmd->ext_buf; - bit_pos = ps3_dma_addr_bit_pos_check( - (dma_addr_t)le64_to_cpu(pSge->addr)); + bit_pos = ps3_dma_addr_bit_pos_check((dma_addr_t)le64_to_cpu(pSge->addr)); if (bit_pos != instance->dma_addr_bit_pos) { - pSge->addr = cpu_to_le64( - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - bit_pos, - le64_to_cpu(pSge->addr))); - pSge->addr = cpu_to_le64( - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, - le64_to_cpu(pSge->addr))); + pSge->addr = cpu_to_le64(PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, + le64_to_cpu(pSge->addr))); + pSge->addr = cpu_to_le64(PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + le64_to_cpu(pSge->addr))); } } pSge++; @@ -105,22 +95,25 @@ void ps3_ioctl_buff_bit_pos_update(struct ps3_cmd *cmd) void ps3_ioctl_buff_release(struct ps3_cmd *cmd) { - unsigned char i = 0; - struct PS3Sge *pSge = (struct PS3Sge *)cmd->req_frame->mgrReq.sgl; + U8 i = 0; + struct PS3Sge *pSge = (struct PS3Sge*)cmd->req_frame->mgrReq.sgl; struct ps3_instance *instance = cmd->instance; - if (cmd->transient == NULL) + if (cmd->transient == NULL) { return; + } - if (cmd->transient->sge_num == 0) + if (cmd->transient->sge_num == 0) { return; + } for (i = 0; i < cmd->transient->sge_num; i++) { if (cmd->transient->transient_buff[i] != NULL) { - if (pSge->ext == 1) - pSge = (struct PS3Sge *)cmd->ext_buf; - ps3_dma_free_coherent( - instance, cpu_to_le32(pSge->length), + if (pSge->ext == 1) { + pSge = (struct PS3Sge*)cmd->ext_buf; + } + ps3_dma_free_coherent(instance, + cpu_to_le32(pSge->length), cmd->transient->transient_buff[i], (dma_addr_t)cpu_to_le64(pSge->addr)); @@ -129,24 +122,21 @@ void ps3_ioctl_buff_release(struct ps3_cmd *cmd) } pSge++; } - memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); + memset((void*)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); cmd->transient->sge_num = 0; } -static int ps3_ioctl_sge_fill(struct ps3_instance *instance, - unsigned char *base_addr, struct PS3Sge *psrc_sge, - struct PS3Sge *pdst_sge, void **transient_buff) +static S32 ps3_ioctl_sge_fill(struct ps3_instance *instance, U8 *base_addr, + struct PS3Sge *psrc_sge, struct PS3Sge *pdst_sge, void **transient_buff) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; dma_addr_t transient_addr = 0; - *transient_buff = - ps3_dma_alloc_coherent(instance, psrc_sge->length, - (unsigned long long *)&transient_addr); + *transient_buff = ps3_dma_alloc_coherent(instance, + psrc_sge->length, &transient_addr); if (*transient_buff == NULL) { - LOG_ERROR( - "hno:%u Failed to alloc kernel SGL buffer for IOCTL\n", + LOG_ERROR("hno:%u Failed to alloc kernel SGL buffer for IOCTL\n", PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_out; @@ -155,19 +145,16 @@ static int ps3_ioctl_sge_fill(struct ps3_instance *instance, pdst_sge->length = cpu_to_le32(psrc_sge->length); pdst_sge->ext = 0; pdst_sge->lastSge = 0; - pdst_sge->addr = (unsigned long long)cpu_to_le64(transient_addr); + pdst_sge->addr = (U64)cpu_to_le64(transient_addr); #ifdef _WINDOWS - LOG_DEBUG( - "===base_addr[%p],psrc_sge->addr[%d], psrc_sge->length[%d]\n", + LOG_DEBUG("===base_addr[%p],psrc_sge->addr[%d], psrc_sge->length[%d] \n", base_addr, psrc_sge->addr, psrc_sge->length); - memcpy(*transient_buff, (void *)(base_addr + psrc_sge->addr), - psrc_sge->length); + memcpy(*transient_buff, (void*)(base_addr + psrc_sge->addr), psrc_sge->length); #else (void)base_addr; - if (copy_from_user(*transient_buff, - (void __user *)(uintptr_t)psrc_sge->addr, - psrc_sge->length)) { - LOG_ERROR("hno:%u, copy from user err\n", PS3_HOST(instance)); + if (copy_from_user(*transient_buff, (void __user*)psrc_sge->addr, psrc_sge->length)) { + LOG_ERROR("hno:%u, copy from user err\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -176,22 +163,20 @@ static int ps3_ioctl_sge_fill(struct ps3_instance *instance, return ret; } -static int ps3_ioctl_sgl_fill(struct ps3_instance *instance, - struct ps3_cmd *cmd, struct PS3IoctlSyncCmd *ioc) +static S32 ps3_ioctl_sgl_fill(struct ps3_instance *instance, + struct ps3_cmd *cmd, struct PS3IoctlSyncCmd* ioc) { - unsigned char i = 0; - int ret = PS3_SUCCESS; + U8 i = 0; + S32 ret = PS3_SUCCESS; struct PS3Sge *pdst_sge = NULL; - struct PS3Sge *psrc_sge = - (struct PS3Sge *)((unsigned int *)ioc + ioc->sglOffset); - unsigned char pre_sge_count = - (unsigned char)((ioc->sgeCount > PS3_FRAME_REQ_SGE_NUM_MGR) ? - (PS3_FRAME_REQ_SGE_NUM_MGR - 1) : - ioc->sgeCount); + struct PS3Sge *psrc_sge = (struct PS3Sge*)((U32*)ioc + + ioc->sglOffset); + U8 pre_sge_count = (U8)((ioc->sgeCount > PS3_FRAME_REQ_SGE_NUM_MGR) ? + (PS3_FRAME_REQ_SGE_NUM_MGR - 1) : ioc->sgeCount); if (cmd->transient->sge_num != 0) { LOG_ERROR("trace_id[0x%llx], hno:%u got cmd NOK: %d\n", - cmd->trace_id, PS3_HOST(instance), cmd->index); + cmd->trace_id, PS3_HOST(instance), cmd->index); PS3_BUG(); ret = -PS3_FAILED; goto l_out; @@ -199,27 +184,25 @@ static int ps3_ioctl_sgl_fill(struct ps3_instance *instance, cmd->transient->sge_num = ioc->sgeCount; cmd->req_frame->mgrReq.sgeOffset = - offsetof(struct PS3MgrReqFrame, sgl) >> - PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; + offsetof(PS3MgrReqFrame_s, sgl) >> PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; cmd->req_frame->mgrReq.sgeCount = ioc->sgeCount; pdst_sge = cmd->req_frame->mgrReq.sgl; for (i = 0; i < pre_sge_count; i++) { LOG_DEBUG("trace_id[0x%llx], hno:%u sge[%u] size : %d\n", - cmd->trace_id, PS3_HOST(instance), i, - psrc_sge->length); + cmd->trace_id, PS3_HOST(instance), i, + psrc_sge->length); pdst_sge->length = 0; if (psrc_sge->length > 0) { - ret = ps3_ioctl_sge_fill( - instance, (unsigned char *)ioc, psrc_sge, - pdst_sge, &cmd->transient->transient_buff[i]); + ret = ps3_ioctl_sge_fill(instance, (U8*)ioc, psrc_sge, pdst_sge, + &cmd->transient->transient_buff[i]); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "trace_id[0x%llx], hno:%u sge[%u] fill data error(%d)\n", - cmd->trace_id, PS3_HOST(instance), i, ret); + LOG_ERROR("trace_id[0x%llx], hno:%u sge[%u] " + "fill data error(%d)\n", cmd->trace_id, + PS3_HOST(instance), i, ret); goto l_out; } } @@ -229,37 +212,29 @@ static int ps3_ioctl_sgl_fill(struct ps3_instance *instance, } if (ioc->sgeCount > PS3_FRAME_REQ_SGE_NUM_MGR) { - LOG_FILE_INFO( - "hno:%u ioctl req num %d is bigger than req frame num %d\n", - PS3_HOST(instance), ioc->sgeCount, - PS3_FRAME_REQ_SGE_NUM_MGR); - pdst_sge->addr = - (unsigned long long)cpu_to_le64(cmd->ext_buf_phys); + LOG_FILE_INFO("hno:%u ioctl req num %d is bigger than req frame num %d\n", + PS3_HOST(instance), ioc->sgeCount, PS3_FRAME_REQ_SGE_NUM_MGR); + pdst_sge->addr = (U64)cpu_to_le64(cmd->ext_buf_phys); pdst_sge->length = 0; pdst_sge->ext = 1; - pdst_sge = (struct PS3Sge *)cmd->ext_buf; + pdst_sge = (struct PS3Sge*)cmd->ext_buf; cmd->req_frame->mgrReq.sgeCount++; - for (i = PS3_FRAME_REQ_SGE_NUM_MGR - 1; i < ioc->sgeCount; - i++) { - LOG_DEBUG( - "trace_id[0x%llx], hno:%u sge[%u] size : %d\n", + for (i = PS3_FRAME_REQ_SGE_NUM_MGR - 1; i < ioc->sgeCount; i++) { + LOG_DEBUG("trace_id[0x%llx], hno:%u sge[%u] size : %d\n", cmd->trace_id, PS3_HOST(instance), i, psrc_sge->length); pdst_sge->length = 0; if (psrc_sge->length > 0) { - ret = ps3_ioctl_sge_fill( - instance, (unsigned char *)ioc, - psrc_sge, pdst_sge, + ret = ps3_ioctl_sge_fill(instance, (U8*)ioc, psrc_sge, pdst_sge, &cmd->transient->transient_buff[i]); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "trace_id[0x%llx], hno:%u sge[%u] fill data error(%d)\n", - cmd->trace_id, - PS3_HOST(instance), i, ret); + LOG_ERROR("trace_id[0x%llx], hno:%u sge[%u] fill data error(%d)\n", + cmd->trace_id, PS3_HOST(instance), i, + ret); goto l_out; } } @@ -275,33 +250,29 @@ static int ps3_ioctl_sgl_fill(struct ps3_instance *instance, return ret; } -static int ps3_ioctl_complete(struct ps3_instance *instance, - struct ps3_cmd *cmd, struct PS3IoctlSyncCmd *ioc) +static S32 ps3_ioctl_complete(struct ps3_instance *instance, + struct ps3_cmd *cmd, + struct PS3IoctlSyncCmd* ioc) { - int ret = PS3_SUCCESS; - unsigned int i = 0; + S32 ret = PS3_SUCCESS; + U32 i = 0; - struct PS3Sge *psrc_sge = - (struct PS3Sge *)((unsigned int *)ioc + ioc->sglOffset); + struct PS3Sge *psrc_sge = (struct PS3Sge*)((U32*)ioc + + ioc->sglOffset); for (i = 0; i < ioc->sgeCount; i++) { - LOG_DEBUG( - "trace_id[0x%llx], hno:%u CFID [%d], transient_buff[%u] address: %p, data size: %d\n", - cmd->trace_id, PS3_HOST(instance), cmd->index, i, - cmd->transient->transient_buff[i], psrc_sge->length); + LOG_DEBUG("trace_id[0x%llx], hno:%u CFID [%d], transient_buff[%u] address: %p, data size: %d\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, + i, cmd->transient->transient_buff[i], psrc_sge->length); if (psrc_sge->length > 0) { #ifdef _WINDOWS - memcpy((void *)((unsigned char *)ioc + psrc_sge->addr), - cmd->transient->transient_buff[i], - psrc_sge->length); + memcpy((void*)((U8*)ioc + psrc_sge->addr), cmd->transient->transient_buff[i], psrc_sge->length); #else - if (copy_to_user( - (void __user *)(uintptr_t)psrc_sge->addr, - cmd->transient->transient_buff[i], - psrc_sge->length)) { + if (copy_to_user((void __user*)psrc_sge->addr, + cmd->transient->transient_buff[i], psrc_sge->length)) { LOG_ERROR("hno:%u copy to user err\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -310,38 +281,35 @@ static int ps3_ioctl_complete(struct ps3_instance *instance, psrc_sge++; } #ifndef _WINDOWS -l_out: + l_out: #endif - LOG_FILE_INFO( - "trace_id[0x%llx], ioctl complete hno:%u CFID [%u], ret[%d]\n", + LOG_FILE_INFO("trace_id[0x%llx], ioctl complete hno:%u CFID [%u], ret[%d]\n", cmd->trace_id, PS3_HOST(instance), cmd->index, ret); return ret; } -static int ps3_ioctl_mgr_handle(struct ps3_instance *instance, - struct PS3IoctlSyncCmd *ioc) +static S32 ps3_ioctl_mgr_handle(struct ps3_instance *instance, + struct PS3IoctlSyncCmd* ioc) + { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - int send_result = PS3_SUCCESS; - unsigned char retry_count = 0; + S32 send_result = PS3_SUCCESS; + U8 retry_count = 0; while (retry_count < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); ret = ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE); if (ret != PS3_SUCCESS) { - ps3_atomic_dec( - &instance->cmd_statistics.cmd_delivering); + ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (ret == -PS3_RECOVERED) { - if (++retry_count < - PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { - ret = ps3_instance_wait_for_normal( - instance); + if (++retry_count < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { + INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_STATE_NORMAL, instance); + ret = ps3_instance_wait_for_normal(instance); } } if (ret != PS3_SUCCESS) { - LOG_WARN_LIM( - "tid[0x%llx], hno:%u ioctl cmd pre check NOK ret:%d!\n", + LOG_WARN_LIM("tid[0x%llx], hno:%u ioctl cmd pre check NOK ret:%d!\n", ioc->traceId, PS3_HOST(instance), ret); goto l_no_free_cmd; } @@ -350,61 +318,60 @@ static int ps3_ioctl_mgr_handle(struct ps3_instance *instance, break; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_FORCE_IOCTL_ALLOC_CMD_FAILED, &cmd) if (cmd == NULL) { LOG_WARN("hno:%u ioctl req, not get a cmd packet\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); goto l_no_free_cmd; } LOG_DEBUG("trace_id[0x%llx], hno:%u CFID [%u], get mgr cmd succeed\n", - cmd->trace_id, PS3_HOST(instance), cmd->index); + cmd->trace_id, PS3_HOST(instance), cmd->index); cmd->time_out = 0; cmd->is_interrupt = PS3_DRV_TRUE; if (ioc->traceId != 0) { ps3_cmd_trace_id_replace(cmd, ioc->traceId); - LOG_DEBUG( - "trace_id[0x%llx], hno:%u CFID [%u], change trace id from cli\n", + LOG_DEBUG("trace_id[0x%llx], hno:%u CFID [%u], change trace id from cli\n", cmd->trace_id, PS3_HOST(instance), cmd->index); } memset(&cmd->req_frame->mgrReq, 0, sizeof(struct PS3MgrReqFrame)); - memset(cmd->transient->transient_buff, 0, - sizeof(void *) * PS3_MAX_IOCTL_SGE_NUM); + memset(cmd->transient->transient_buff, 0, sizeof(void*) * PS3_MAX_IOCTL_SGE_NUM); ret = ps3_ioctl_sgl_fill(instance, cmd, ioc); if (ret != PS3_SUCCESS) { ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); goto l_out; } + INJECT_START(PS3_ERR_IJ_FORCE_IOCTL_WAIT_RECOVERY, instance); ps3_ioctl_req_frame_build(cmd); ps3_mgr_cmd_word_build(cmd); + INJECT_START(PS3_ERR_IJ_IOCTL_WAIT_IRQ_DISABLE, cmd); send_result = ps3_cmd_send_sync(instance, cmd); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_NO_RESP, &send_result); ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret == -PS3_CMD_NO_RESP) { - LOG_ERROR( - "trace_id[0x%llx], hno:%u ioctl request no response!\n", + LOG_ERROR("trace_id[0x%llx], hno:%u ioctl request no response!\n", cmd->trace_id, PS3_HOST(instance)); goto l_no_free_cmd; } if (ret != PS3_SUCCESS) { - LOG_ERROR( - "trace_id[0x%llx], hno:%u ioctl send request NOK!%d\n", + LOG_ERROR("trace_id[0x%llx], hno:%u ioctl send request NOK!%d\n", cmd->trace_id, PS3_HOST(instance), ret); goto l_out; } ret = ps3_ioctl_complete(instance, cmd, ioc); - LOG_INFO( - "trace_id[0x%llx], hno:%u CFID [%u], ioctl cmd_type[%d], sub_type[%d] end\n", + LOG_INFO("trace_id[0x%llx], hno:%u CFID [%u], ioctl cmd_type[%d], sub_type[%d] end\n", cmd->trace_id, PS3_HOST(instance), cmd->index, ioc->msg.header.cmdType, ioc->msg.header.cmdSubType); @@ -417,42 +384,35 @@ static int ps3_ioctl_mgr_handle(struct ps3_instance *instance, #ifdef _WINDOWS -static unsigned char ps3_ioctl_windows_pre_check(struct ps3_instance *instance, - struct _PS3_IO_CONTROL ioctl) +static U8 ps3_ioctl_windows_pre_check(struct ps3_instance *instance, + PPS3_IO_CONTROL ioctl) { - unsigned char ret = PS3_TRUE; - unsigned char i = 0; - unsigned char *base_addr = (unsigned char *)&ioctl->ps3Ioctl; - unsigned char *last_addr = base_addr + ioctl->SrbHeader.Length; + U8 ret = PS3_TRUE; + U8 i = 0; + U8 *base_addr = (U8*)&ioctl->ps3Ioctl; + U8 *last_addr = base_addr + ioctl->SrbHeader.Length; if (ioctl->ps3Ioctl.data == NULL || ioctl->SrbHeader.Length == 0) { - LOG_WARN( - "hno:%u ioctl req, data is [%p], or data len is [%llu]\n", - PS3_HOST(instance), ioctl->ps3Ioctl.data, - ioctl->SrbHeader.Length); + LOG_WARN("hno:%u ioctl req, data is [%p], or data len is [%llu]\n", + PS3_HOST(instance), ioctl->ps3Ioctl.data, ioctl->SrbHeader.Length); ret = PS3_FALSE; goto l_out; } - if (ps3_ioctl_capbility_pre_check(instance, &ioctl->ps3Ioctl) != - PS3_SUCCESS) { + if (ps3_ioctl_capbility_pre_check(instance, &ioctl->ps3Ioctl) != PS3_SUCCESS) { ret = PS3_FALSE; goto l_out; } LOG_INFO("hno:%u base_addr[%p], Length[%d], last_addr[%p]\n", - PS3_HOST(instance), base_addr, ioctl->SrbHeader.Length, - last_addr); + PS3_HOST(instance), base_addr, ioctl->SrbHeader.Length, last_addr); for (i = 0; i < ioctl->ps3Ioctl.sgeCount; i++) { if (base_addr + ioctl->ps3Ioctl.Sgl[i].addr + - ioctl->ps3Ioctl.Sgl[i].length > - last_addr) { - LOG_ERROR( - "hno:%u ioctl req, sge[%d] len[%d] > total len[%d], sge offset[%p], base addr[%p]\n", - PS3_HOST(instance), i, - ioctl->ps3Ioctl.Sgl[i].length, - ioctl->SrbHeader.Length, + ioctl->ps3Ioctl.Sgl[i].length > last_addr) { + + LOG_ERROR("hno:%u ioctl req, sge[%d] len[%d] > total len[%d], sge offset[%p], base addr[%p]\n", + PS3_HOST(instance), i, ioctl->ps3Ioctl.Sgl[i].length, ioctl->SrbHeader.Length, ioctl->ps3Ioctl.Sgl[i].addr, &ioctl->ps3Ioctl); ret = PS3_FALSE; goto l_out; @@ -465,34 +425,33 @@ static unsigned char ps3_ioctl_windows_pre_check(struct ps3_instance *instance, return ret; } -int ps3_ioctl_callback_proc(struct ps3_cmd *cmd, unsigned char reply_flags) +S32 ps3_ioctl_callback_proc(struct ps3_cmd *cmd, U8 reply_flags) { - unsigned long flags = 0; - int ret = PS3_SUCCESS; + ULong flags = 0; + S32 ret = PS3_SUCCESS; struct ps3_instance *instance = cmd->instance; - int send_result = -PS3_RESP_ERR; + S32 send_result = -PS3_RESP_ERR; SCSI_REQUEST_BLOCK *srb = cmd->srb; - struct _PS3_IO_CONTROL ps3_ioctl = NULL; + PPS3_IO_CONTROL ps3_ioctl = NULL; - LOG_DEBUG( - "hno:%u trace_id[0x%llx], got a ioctl response, reply_flags[0x%x]\n", + LOG_DEBUG("hno:%u trace_id[0x%llx], got a ioctl response, reply_flags[0x%x]\n", PS3_HOST(instance), cmd->trace_id, reply_flags); PS3_MGR_CMD_BACK_INC(instance, cmd, reply_flags); if (unlikely(reply_flags != PS3_REPLY_WORD_FLAG_SUCCESS) && - cmd->retry_cnt < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { + cmd->retry_cnt < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { LOG_ERROR("trace_id[0x%llx], hno:%u ioctl cmd return failed\n", - cmd->trace_id, PS3_HOST(instance)); + cmd->trace_id, PS3_HOST(instance)); ret = ps3_err_mgr_cmd_proc(instance, send_result, cmd); - if (ret == -PS3_CMD_NO_RESP) + if (ret == -PS3_CMD_NO_RESP) { ret = ps3_mgr_cmd_no_resp_proc(instance, cmd); + } if (ret != -PS3_RETRY) { LOG_WARN("hno:%u CFID:%d retry, retries:%d, ret:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt, - ret); + PS3_HOST(instance), cmd->index, cmd->retry_cnt, ret); goto l_out; } @@ -502,17 +461,16 @@ int ps3_ioctl_callback_proc(struct ps3_cmd *cmd, unsigned char reply_flags) cmd->retry_cnt++; if (cmd->retry_cnt >= PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { LOG_ERROR("hno:%u retry time full.\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - LOG_INFO("hno:%u mgr CFID[%d] retry:%u\n", PS3_HOST(instance), - cmd->index, cmd->retry_cnt); + LOG_INFO("hno:%u mgr CFID[%d] retry:%u\n", + PS3_HOST(instance), cmd->index, cmd->retry_cnt); ret = ps3_srb_send(instance, srb); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "trace_id[0x%llx], hno:%u ioctl send request failed!%d\n", + LOG_ERROR("trace_id[0x%llx], hno:%u ioctl send request failed!%d\n", cmd->trace_id, PS3_HOST(instance), ret); goto l_out; } @@ -522,13 +480,12 @@ int ps3_ioctl_callback_proc(struct ps3_cmd *cmd, unsigned char reply_flags) l_out: SrbSetSrbStatus(srb, SRB_STATUS_ERROR); - if ((cmd->resp_frame->normalRespFrame.respStatus == - PS3_DRV_MGR_RESTART_COMMAND_RSP) && - (reply_flags == PS3_REPLY_WORD_FLAG_FAIL)) { - reply_flags = PS3_REPLY_WORD_FLAG_SUCCESS; + if((cmd->resp_frame->normalRespFrame.respStatus == PS3_DRV_MGR_RESTART_COMMAND_RSP) && + (reply_flags == PS3_REPLY_WORD_FLAG_FAIL)){ + reply_flags = PS3_REPLY_WORD_FLAG_SUCCESS; } if (likely(reply_flags == PS3_REPLY_WORD_FLAG_SUCCESS)) { - ps3_ioctl = (struct _PS3_IO_CONTROL)SrbGetDataBuffer(srb); + ps3_ioctl = (PPS3_IO_CONTROL)SrbGetDataBuffer(srb); ps3_ioctl_complete(instance, cmd, &ps3_ioctl->ps3Ioctl); SrbSetSrbStatus(srb, SRB_STATUS_SUCCESS); } @@ -539,45 +496,38 @@ int ps3_ioctl_callback_proc(struct ps3_cmd *cmd, unsigned char reply_flags) ps3_atomic_dec(&instance->ioctl_count); l_retry: - LOG_DEBUG( - "hno:%u trace_id[0x%llx], end proc a ioctl response, ret[%d]\n", + LOG_DEBUG("hno:%u trace_id[0x%llx], end proc a ioctl response, ret[%d]\n", PS3_HOST(instance), cmd->trace_id, ret); return ret; } -unsigned char ps3_ioctl_build_io(_In_ struct ps3_instance *instance, - _In_ PSCSI_REQUEST_BLOCK Srb) +U8 ps3_ioctl_build_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLOCK Srb) { - unsigned char ret = PS3_FALSE; - struct _PS3_IO_CONTROL ps3_ioctl = - (struct _PS3_IO_CONTROL)SrbGetDataBuffer(Srb); - - LOG_INFO( - "ioctl parase: Type[0x%x], Method[0x%x], Function[0x%x], Access[0x%x]\n", - DEVICE_TYPE_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), - METHOD_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), - PS3_FUNC_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), - PS3_ACC_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode)); - - if (memcmp(ps3_ioctl->SrbHeader.Signature, PS3_IOCTL_SIG, - sizeof(PS3_IOCTL_SIG)) != 0) { - LOG_ERROR("hno:%u ioctl signature error\n", PS3_HOST(instance)); + U8 ret = PS3_FALSE; + PPS3_IO_CONTROL ps3_ioctl = (PPS3_IO_CONTROL)SrbGetDataBuffer(Srb); + + LOG_INFO("ioctl parase: Type[0x%x], Method[0x%x], Function[0x%x], Access[0x%x] \n", + DEVICE_TYPE_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), METHOD_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), + PS3_FUNC_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), PS3_ACC_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode)); + + if (memcmp(ps3_ioctl->SrbHeader.Signature, PS3_IOCTL_SIG, sizeof(PS3_IOCTL_SIG)) != 0) { + LOG_ERROR("hno:%u ioctl signature error\n", + PS3_HOST(instance)); SrbSetSrbStatus(Srb, SRB_STATUS_INVALID_REQUEST); goto l_out; } if (!instance->state_machine.is_load) { - LOG_WARN( - "trace_id[0x%llx], hno:%u instance state not is_load\n", + LOG_WARN("trace_id[0x%llx], hno:%u instance state not is_load\n", ps3_ioctl->ps3Ioctl.traceId, PS3_HOST(instance)); SrbSetSrbStatus(Srb, SRB_STATUS_NO_HBA); goto l_out; } - if (!ps3_atomic_add_unless(&instance->ioctl_count, 1, - PS3_MAX_IOCTL_CMDS)) { - LOG_WARN("hno:%u ioctl concurrency full\n", PS3_HOST(instance)); + if (!ps3_atomic_add_unless(&instance->ioctl_count, 1, PS3_MAX_IOCTL_CMDS)) { + LOG_WARN("hno:%u ioctl concurrency full\n", + PS3_HOST(instance)); SrbSetSrbStatus(Srb, SRB_STATUS_BUSY); goto l_out; @@ -591,15 +541,15 @@ unsigned char ps3_ioctl_build_io(_In_ struct ps3_instance *instance, ret = ps3_ioctl_windows_pre_check(instance, ps3_ioctl); if (!ret) { LOG_WARN("hno:%u ioctl capblity not support\n", - PS3_HOST(instance)); + PS3_HOST(instance)); SrbSetSrbStatus(Srb, SRB_STATUS_INVALID_REQUEST); ps3_atomic_dec(&instance->ioctl_count); goto l_out; } - if (ps3_ioctl_mgr_handle(instance, &ps3_ioctl->ps3Ioctl, Srb) != - PS3_SUCCESS) { - LOG_ERROR("hno:%u ioctl handle err\n", PS3_HOST(instance)); + if (ps3_ioctl_mgr_handle(instance, &ps3_ioctl->ps3Ioctl, Srb) != PS3_SUCCESS) { + LOG_ERROR("hno:%u ioctl handle err\n", + PS3_HOST(instance)); SrbSetSrbStatus(Srb, SRB_STATUS_ERROR); ps3_atomic_dec(&instance->ioctl_count); goto l_out; @@ -608,24 +558,22 @@ unsigned char ps3_ioctl_build_io(_In_ struct ps3_instance *instance, ret = PS3_TRUE; SrbSetSrbStatus(Srb, SRB_STATUS_SUCCESS); l_out: - if (!ret) + if (!ret) { StorPortNotification(RequestComplete, instance, Srb); + } return ret; } -unsigned char ps3_ioctl_start_io(_In_ struct ps3_instance *instance, - _In_ PSCSI_REQUEST_BLOCK Srb) +U8 ps3_ioctl_start_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLOCK Srb) { struct ps3_cmd *cmd = ps3_cmd_from_srb_extension_get(Srb); - unsigned char ret = PS3_FALSE; - int ret_tmp = PS3_SUCCESS; - + U8 ret = PS3_FALSE; + S32 ret_tmp = PS3_SUCCESS; SrbSetSrbStatus(Srb, SRB_STATUS_ERROR); ret_tmp = ps3_srb_send(instance, Srb); if (ret_tmp != PS3_SUCCESS) { - LOG_ERROR( - "trace_id[0x%llx], hno:%u ioctl send request failed!%d\n", + LOG_ERROR("trace_id[0x%llx], hno:%u ioctl send request failed!%d\n", cmd->trace_id, PS3_HOST(instance), ret_tmp); goto l_out; } @@ -644,25 +592,26 @@ unsigned char ps3_ioctl_start_io(_In_ struct ps3_instance *instance, #else -static int ps3_ioctl_mgr_sync(unsigned long arg) +static S32 ps3_ioctl_mgr_sync(ULong arg) { - int ret = PS3_SUCCESS; - struct PS3IoctlSyncCmd *ioc = NULL; + S32 ret = PS3_SUCCESS; + struct PS3IoctlSyncCmd* ioc = NULL; struct ps3_instance *instance = NULL; - struct PS3IoctlSyncCmd __user *user_ioc = - (struct PS3IoctlSyncCmd __user *)arg; + struct PS3IoctlSyncCmd __user* user_ioc = + (struct PS3IoctlSyncCmd __user*)arg; - ioc = (struct PS3IoctlSyncCmd *)memdup_user( - (const void __user *)user_ioc, sizeof(*ioc)); + ioc = (struct PS3IoctlSyncCmd*)memdup_user( + (const void __user*)user_ioc, sizeof(*ioc)); + INJECT_START(PS3_ERR_IJ_FORCE_MEMDUP_USER_RETURN_FAILED, &ioc) if (IS_ERR(ioc)) { LOG_ERROR("ioctl memdup_user err\n"); return PTR_ERR(ioc); } - LOG_INFO("ioctl ps3_ioctl_sync_cmd: trace_id[0x%llx], hno:%u\n" - "\tcmd_type[%d], sgl_offset[%d], sge_count[%d], result[%d]\n", - ioc->traceId, ioc->hostId, ioc->msg.header.cmdType, - ioc->sglOffset, ioc->sgeCount, ioc->resultCode); + LOG_INFO("ioctl ps3_ioctl_sync_cmd: trace_id[0x%llx], hno:%u " + "cmd_type[%d], sgl_offset[%d], sge_count[%d], result[%d]\n", + ioc->traceId, ioc->hostId, ioc->msg.header.cmdType, + ioc->sglOffset, ioc->sgeCount, ioc->resultCode); ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); instance = ps3_instance_lookup(ioc->hostId); @@ -676,16 +625,16 @@ static int ps3_ioctl_mgr_sync(unsigned long arg) if (!instance->state_machine.is_load) { ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); LOG_WARN("trace_id[0x%llx], hno:%u instance state [%d]\n", - ioc->traceId, PS3_HOST(instance), - instance->state_machine.is_load); + ioc->traceId, PS3_HOST(instance), + instance->state_machine.is_load); ret = -ENODEV; goto l_out_free_ioc; } + INJECT_START(PS3_ERR_IJ_SCSI_SCAN_HOST_NOT_FINISH, instance) if (!instance->is_scan_host_finish) { ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); - LOG_WARN( - "trace_id[0x%llx], hno:%u instance scan host not finish\n", + LOG_WARN("trace_id[0x%llx], hno:%u instance scan host not finish\n", ioc->traceId, PS3_HOST(instance)); ret = -EAGAIN; goto l_out_free_ioc; @@ -694,67 +643,61 @@ static int ps3_ioctl_mgr_sync(unsigned long arg) ps3_atomic_inc(&instance->cmd_statistics.cli_cnt); ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); - LOG_FILE_INFO("hno:%u ioctl ready get sem\n", PS3_HOST(instance)); + LOG_FILE_INFO("hno:%u ioctl ready get sem\n", + PS3_HOST(instance)); if (down_interruptible(&instance->ioctl_sem)) { - LOG_WARN("hno:%u ioctl concurrency full\n", PS3_HOST(instance)); + LOG_WARN("hno:%u ioctl concurrency full\n", + PS3_HOST(instance)); ret = -ERESTARTSYS; goto l_out_dec_cnt; } ret = ps3_instance_wait_for_normal(instance); + INJECT_START(PS3_ERR_IJ_FORCE_IOCTL_WAIT_NORMAL_FAILED, &ret); if (ret != PS3_SUCCESS) { - LOG_WARN( - "trace_id[0x%llx], hno:%u instance state not allowed ioctl req\n", + LOG_WARN("trace_id[0x%llx], hno:%u instance state not allowed ioctl req\n", ioc->traceId, PS3_HOST(instance)); ret = -ENODEV; goto l_out_up; } - LOG_INFO("hno:%u ioctl got sem\n", PS3_HOST(instance)); - - if (ioc->msg.header.cmdType == PS3_IOCTL_CMD_WEB_SUBSCRIBE) { - if (ps3_atomic_read( - &instance->webSubscribe_context.is_subscribe) != - 1) { - if (ps3_atomic_add_unless(&instance->webSubscribe_context - .subscribe_count, - 1, 1) != 0) { - ret = ps3_web_subscribe(instance); - if (ret != PS3_SUCCESS) { - ps3_atomic_set( - &instance->webSubscribe_context - .subscribe_count, - 0); - ret = -EBUSY; - goto l_out_up; - } - ps3_atomic_set(&instance->webSubscribe_context - .is_subscribe, - 1); - goto l_out_dec_cnt; - } else { - ret = -EAGAIN; - goto l_out_up; - } - } else { - ret = PS3_SUCCESS; - goto l_out_up; - } - } else { - ret = ps3_ioctl_capbility_pre_check(instance, ioc); - if (ret != PS3_SUCCESS) { - LOG_WARN("hno:%u ioctl capblity not support\n", - PS3_HOST(instance)); - ret = -EINVAL; - goto l_out_up; - } - ret = ps3_ioctl_mgr_handle(instance, ioc); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u ioctl handle NOK\n", - PS3_HOST(instance)); - ret = -EBUSY; - } - } + LOG_INFO("hno:%u ioctl got sem\n", + PS3_HOST(instance)); + + if (ioc->msg.header.cmdType == PS3_IOCTL_CMD_WEB_SUBSCRIBE) { + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) != 1) { + if (ps3_atomic_add_unless(&instance->webSubscribe_context.subscribe_count, 1, 1) != 0) { + ret = ps3_web_subscribe(instance); + if (ret != PS3_SUCCESS) { + ps3_atomic_set(&instance->webSubscribe_context.subscribe_count, 0); + ret = -EBUSY; + goto l_out_up; + } + ps3_atomic_set(&instance->webSubscribe_context.is_subscribe, 1); + goto l_out_dec_cnt; + } else { + ret = -EAGAIN; + goto l_out_up; + } + } else { + ret = PS3_SUCCESS; + goto l_out_up; + } + } else { + ret = ps3_ioctl_capbility_pre_check(instance, ioc); + if (ret != PS3_SUCCESS) { + LOG_WARN("hno:%u ioctl capblity not support\n", + PS3_HOST(instance)); + ret = -EINVAL; + goto l_out_up; + } + ret = ps3_ioctl_mgr_handle(instance, ioc); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u ioctl handle NOK\n", + PS3_HOST(instance)); + ret = -EBUSY; + } + } l_out_up: up(&instance->ioctl_sem); @@ -765,17 +708,31 @@ static int ps3_ioctl_mgr_sync(unsigned long arg) return ret; } -long ps3_ioctl_fops(struct file *file, unsigned int cmd, unsigned long arg) +#if 0 +static S32 ps3_ioctl_mgr_async(struct file *file, ULong arg) { - int ret = -ENOTTY; + (void)file; + (void)arg; + return PS3_SUCCESS; +} +#endif - if (file == NULL || arg == 0) +long ps3_ioctl_fops(struct file *file, U32 cmd, ULong arg) +{ + S32 ret = -ENOTTY; + if (file == NULL || arg == 0) { goto l_out; + } switch (cmd) { case PS3_CMD_IOCTL_SYNC_CMD: ret = ps3_ioctl_mgr_sync(arg); break; +#if 0 + case PS3_CMD_IOCTL_ASYNC_CMD: + return ps3_ioctl_mgr_async(file, arg); + break; +#endif default: break; } @@ -786,21 +743,20 @@ long ps3_ioctl_fops(struct file *file, unsigned int cmd, unsigned long arg) void ps3_clean_mgr_cmd(struct ps3_instance *instance) { struct ps3_cmd_context *context = &instance->cmd_context; - unsigned int mgr_cmd_idx = 0; - unsigned int mgr_start_idx = context->max_scsi_cmd_count; - unsigned int mgr_end_idx = - context->max_scsi_cmd_count + instance->max_mgr_cmd_count; + U32 mgr_cmd_idx = 0; + U32 mgr_start_idx = context->max_scsi_cmd_count; + U32 mgr_end_idx = context->max_scsi_cmd_count + + instance->max_mgr_cmd_count; struct ps3_cmd *cmd = NULL; for (mgr_cmd_idx = mgr_start_idx; mgr_cmd_idx < mgr_end_idx; - mgr_cmd_idx++) { + mgr_cmd_idx++) { cmd = context->cmd_buf[mgr_cmd_idx]; if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { LOG_WARN("hno:%u mgr cmd[%d] complete force!\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); - cmd->resp_frame->normalRespFrame.respStatus = - PS3_MGR_REC_FORCE; + cmd->resp_frame->normalRespFrame.respStatus = PS3_MGR_REC_FORCE; cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; complete(&cmd->sync_done); } @@ -810,12 +766,13 @@ void ps3_clean_mgr_cmd(struct ps3_instance *instance) void ps3_ioctl_clean(struct ps3_instance *instance) { if (ps3_atomic_read(&instance->state_machine.state) != - PS3_INSTANCE_STATE_QUIT) { + PS3_INSTANCE_STATE_QUIT){ goto l_out; } while (ps3_atomic_read(&instance->cmd_statistics.cli_cnt) != 0) { - LOG_INFO("hno:%u ioctls not finish\n", PS3_HOST(instance)); + LOG_INFO("hno:%u ioctls not finish\n", + PS3_HOST(instance)); ps3_clean_mgr_cmd(instance); ps3_msleep(1000); } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioctl.h b/drivers/scsi/linkdata/ps3stor/ps3_ioctl.h index 8ca03e20523f..f8e300535041 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioctl.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioctl.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_IOCTL_H_ #define _PS3_IOCTL_H_ @@ -10,24 +9,22 @@ #include "ps3_cmd_channel.h" #include "ps3_htp_ioctl.h" -#define PS3_MAX_IOCTL_CMDS 3 +#define PS3_MAX_IOCTL_CMDS 3 #ifdef _WINDOWS -unsigned char ps3_ioctl_start_io(_In_ struct ps3_instance *instance, - _In_ PSCSI_REQUEST_BLOCK Srb); -unsigned char ps3_ioctl_build_io(_In_ struct ps3_instance *instance, - _In_ PSCSI_REQUEST_BLOCK Srb); +U8 ps3_ioctl_start_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLOCK Srb); +U8 ps3_ioctl_build_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLOCK Srb); #else -long ps3_ioctl_fops(struct file *file, unsigned int cmd, unsigned long arg); +long ps3_ioctl_fops(struct file *file, U32 cmd, ULong arg); #endif -int ps3_ioctl_init(struct ps3_instance *instance, int cmd_num); +S32 ps3_ioctl_init(struct ps3_instance *instance, S32 cmd_num); void ps3_ioctl_buff_release(struct ps3_cmd *cmd); -static inline void ps3_ioctl_req_frame_build(struct ps3_cmd *cmd) +inline static void ps3_ioctl_req_frame_build(struct ps3_cmd *cmd) { - struct PS3MgrReqFrame *mgr_req = &cmd->req_frame->mgrReq; + PS3MgrReqFrame_s* mgr_req = &cmd->req_frame->mgrReq; mgr_req->reqHead.traceID = cmd->trace_id; mgr_req->reqHead.cmdType = PS3_CMD_IOCTL; @@ -38,12 +35,10 @@ static inline void ps3_ioctl_req_frame_build(struct ps3_cmd *cmd) mgr_req->syncFlag = 1; } -static inline void ps3_ioctl_cmd_word_build(struct ps3_instance *instance, - struct ps3_cmd *cmd, - unsigned short cmd_frame_id) +inline static void ps3_ioctl_cmd_word_build(struct ps3_instance *instance, + struct ps3_cmd *cmd, U16 cmd_frame_id) { - struct PS3CmdWord *cmd_word = &cmd->cmd_word; - + struct PS3CmdWord* cmd_word = &cmd->cmd_word; memset(cmd_word, 0, sizeof(*cmd_word)); (void)instance; @@ -56,10 +51,11 @@ static inline void ps3_ioctl_cmd_word_build(struct ps3_instance *instance, #endif } -int ps3_ioctl_callback_proc(struct ps3_cmd *cmd, unsigned char reply_flags); +S32 ps3_ioctl_callback_proc(struct ps3_cmd *cmd, U8 reply_flags); void ps3_ioctl_clean(struct ps3_instance *instance); void ps3_ioctl_buff_bit_pos_update(struct ps3_cmd *cmd); #endif + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_irq.c b/drivers/scsi/linkdata/ps3stor/ps3_irq.c index b983719eeb47..da19c948e88a 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_irq.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_irq.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include "ps3_irq.h" #ifndef _WINDOWS @@ -19,58 +17,53 @@ #ifndef _WINDOWS -static const unsigned int PS3_INTERRUPT_CMD_DISABLE_ALL_MASK = 0x02; -static const unsigned int PS3_INTERRUPT_CMD_ENABLE_MSIX = 0x01; -static const unsigned int PS3_INTERRUPT_MASK_DISABLE = 0x00000002; -static const unsigned int PS3_INTERRUPT_STATUS_EXIST_IRQ = 0x00000001; -static const unsigned int PS3_INTERRUPT_CLEAR_IRQ = 0x00000001; - -static const unsigned int PS3_SSD_IOPS_MSIX_VECTORS = 8; -static const unsigned int PS3_HDD_IOPS_MSIX_VECTORS = 8; -static const unsigned int PS3_IRQ_POLL_SCHED_THRESHOLD = 1024; -static const unsigned int PS3_HIGH_IOPS_VECTOR_BATCH_COUNT_SHIFT = 5; -static const unsigned int PS3_BALANCE_MODE_MIN_CPU_NUM = 16; -static const int PS3_SSD_MAX_BUSY_THRESHOLD = 40; -static const unsigned int PS3_IOPS_MSIX_VECTORS = 12; -static const int PS3_HYGON_BUSY_ADJUST_THRESHOLD = 32; -static const unsigned int PS3_MSIX_COMBINED_MODE_MSIX_VECTORS = 16; - -#define PS3_IRQCTX_HOST(irq_context) \ - (ps3_container_of((irq_context), struct ps3_instance, irq_context) \ - ->host->host_no) - -#define PS3_MGR_CMD_MSIX_INDEX(irq_context) \ - ((irq_context)->high_iops_msix_vectors) -#define IS_HIGN_OPS_IRQ(irq_context, irq) \ +const U32 PS3_INTERRUPT_STATUS_NO_IRQ = 0x00; +const U32 PS3_INTERRUPT_CMD_DISABLE_ALL_MASK = 0x02; +const U32 PS3_INTERRUPT_CMD_ENABLE_MSIX = 0x01; +const U32 PS3_INTERRUPT_MASK_DISABLE = 0x00000002; +const U32 PS3_INTERRUPT_STATUS_EXIST_IRQ = 0x00000001; +const U32 PS3_INTERRUPT_CLEAR_IRQ= 0x00000001; + +const U32 PS3_SSD_IOPS_MSIX_VECTORS = 8; +const U32 PS3_HDD_IOPS_MSIX_VECTORS = 8; +const U32 PS3_IRQ_POLL_SCHED_THRESHOLD = 1024; +const U32 PS3_HIGH_IOPS_VECTOR_BATCH_COUNT_SHIFT = 5; +const U32 PS3_BALANCE_MODE_MIN_CPU_NUM = 16; +const S32 PS3_SSD_MAX_BUSY_THRESHOLD = 40; +const U32 PS3_IOPS_MSIX_VECTORS = 12; +const S32 PS3_HYGON_BUSY_ADJUST_THRESHOLD = 32; +const U32 PS3_MSIX_COMBINED_MODE_MSIX_VECTORS = 16; + +#define PS3_IRQCTX_HOST(irq_context) \ + ps3_container_of((irq_context), struct ps3_instance, irq_context)->host->host_no + +#define PS3_MGR_CMD_MSIX_INDEX(irq_context) ((irq_context)->high_iops_msix_vectors) +#define IS_HIGN_OPS_IRQ(irq_context, irq) \ (((irq_context)->high_iops_msix_vectors > (irq)->isrSN)) #define PS3_MULTI_DATA_DISK_BUSY_THRESHOLD(var, base) ((var) > (base)) static void msix_irq_mode_check(struct ps3_irq_context *irq_context, - unsigned int max_vectors) + U32 max_vectors) { - unsigned int online_cpu_num = num_online_cpus(); - unsigned short speed = 0; - unsigned short lnksta = 0; - unsigned int iops_msix_cnt = 0; + U32 online_cpu_num = num_online_cpus(); + U16 speed = 0; + U16 lnksta = 0; + U32 iops_msix_cnt = 0; if (!ps3_ioc_multi_func_support(irq_context->instance) || - ps3_get_pci_function(irq_context->instance->pdev) == - PS3_FUNC_ID_1) { + ps3_get_pci_function(irq_context->instance->pdev) == PS3_FUNC_ID_1) { iops_msix_cnt = PS3_IOPS_MSIX_VECTORS; } else { iops_msix_cnt = 0; } - pcie_capability_read_word(irq_context->instance->pdev, PCI_EXP_LNKSTA, - &lnksta); + pcie_capability_read_word(irq_context->instance->pdev, PCI_EXP_LNKSTA, &lnksta); speed = lnksta & PCI_EXP_LNKSTA_CLS; - if ((iops_msix_cnt > 0) && - (online_cpu_num >= PS3_BALANCE_MODE_MIN_CPU_NUM) && - (iops_msix_cnt < max_vectors) && (speed >= 0x4)) { + if ((iops_msix_cnt > 0) && (online_cpu_num >= PS3_BALANCE_MODE_MIN_CPU_NUM) && + (iops_msix_cnt < max_vectors) && (speed >= 0x4)) { irq_context->high_iops_msix_vectors = iops_msix_cnt; - irq_context->valid_msix_vector_count = min( - irq_context->high_iops_msix_vectors + online_cpu_num, - max_vectors); + irq_context->valid_msix_vector_count = + min(irq_context->high_iops_msix_vectors + online_cpu_num, max_vectors); irq_context->is_support_balance = PS3_TRUE; irq_context->is_balance_current_perf_mode = PS3_TRUE; } else { @@ -80,11 +73,13 @@ static void msix_irq_mode_check(struct ps3_irq_context *irq_context, irq_context->valid_msix_vector_count = min(online_cpu_num, max_vectors); } + + return; } -static inline unsigned char ps3_is_linx80_os(void) +static inline Bool ps3_is_linx80_os(void) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; #if (!defined(PS3_OS_MANAGED_IRQ_SUPPORT)) ret = PS3_TRUE; #endif @@ -92,9 +87,9 @@ static inline unsigned char ps3_is_linx80_os(void) return ret; } -static inline unsigned char ps3_support_irq_affinity(void) +static inline Bool ps3_support_irq_affinity(void) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; #if defined(DRIVER_SUPPORT_KERNEL_IRQ_AFFINITY) ret = PS3_TRUE; @@ -108,33 +103,31 @@ static inline unsigned char ps3_support_irq_affinity(void) return ret; } -static unsigned int __ps3_irq_vectors_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static U32 __ps3_irq_vectors_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { int msix_vectors = 0; - unsigned int irq_flags = PCI_IRQ_MSIX | PCI_IRQ_MSI; + U32 irq_flags = PCI_IRQ_MSIX | PCI_IRQ_MSI; struct ps3_instance *instance = irq_context->instance; - unsigned int ps3_irq_mode = ps3_pci_irq_mode_query(); + U32 ps3_irq_mode = ps3_pci_irq_mode_query(); struct irq_affinity *descp = NULL; #if defined(PS3_OS_MANAGED_IRQ_SUPPORT) - struct irq_affinity desc = { - .pre_vectors = irq_context->high_iops_msix_vectors - }; + struct irq_affinity desc = { .pre_vectors = irq_context->high_iops_msix_vectors }; descp = &desc; #endif switch (ps3_irq_mode) { - case PS3_PCI_IRQ_MODE_LEGACY: - irq_flags = PCI_IRQ_LEGACY; - break; - case PS3_PCI_IRQ_MODE_MSI: - irq_flags = PCI_IRQ_MSI; - break; - case PS3_PCI_IRQ_MODE_MSIX: - irq_flags = PCI_IRQ_MSIX; - break; - default: - break; + case PS3_PCI_IRQ_MODE_LEGACY: + irq_flags = PCI_IRQ_LEGACY; + break; + case PS3_PCI_IRQ_MODE_MSI: + irq_flags = PCI_IRQ_MSI; + break; + case PS3_PCI_IRQ_MODE_MSIX: + irq_flags = PCI_IRQ_MSIX; + break; + default: + break; } if (ps3_support_irq_affinity() || ps3_is_linx80_os()) { @@ -144,92 +137,89 @@ static unsigned int __ps3_irq_vectors_alloc(struct pci_dev *pdev, descp = NULL; } else { if (irq_context->is_support_balance == PS3_TRUE && - irq_context->is_balance_current_perf_mode == PS3_TRUE) { + irq_context->is_balance_current_perf_mode == PS3_TRUE) { descp = NULL; } else { - if (irq_context->instance->smp_affinity_enable) + if (irq_context->instance->smp_affinity_enable) { irq_flags |= PCI_IRQ_AFFINITY; - else + } else { descp = NULL; + } } } - LOG_INFO( - "host_no:%u pci_irq_mode:%d specified, msix_vectors:%d max:%d\n", + LOG_INFO("host_no:%u pci_irq_mode:%d specified, msix_vectors:%d max:%d\n", PS3_IRQCTX_HOST(irq_context), ps3_irq_mode, irq_context->high_iops_msix_vectors, irq_context->valid_msix_vector_count); #if defined(PS3_OS_MANAGED_IRQ_SUPPORT) - msix_vectors = pci_alloc_irq_vectors_affinity( - pdev, - max(instance->min_intr_count, - irq_context->high_iops_msix_vectors), + msix_vectors = pci_alloc_irq_vectors_affinity(pdev, + max(instance->min_intr_count, irq_context->high_iops_msix_vectors), irq_context->valid_msix_vector_count, irq_flags, descp); #else - msix_vectors = - pci_alloc_irq_vectors(pdev, - max(instance->min_intr_count, - irq_context->high_iops_msix_vectors), - irq_context->valid_msix_vector_count, - irq_flags); + msix_vectors = pci_alloc_irq_vectors(pdev, + max(instance->min_intr_count, irq_context->high_iops_msix_vectors), + irq_context->valid_msix_vector_count, irq_flags); #endif if (msix_vectors <= 0) { LOG_WARN("host_no:%u alloc msi irq fail! msix_vectors:%d\n", - PS3_IRQCTX_HOST(irq_context), msix_vectors); + PS3_IRQCTX_HOST(irq_context), msix_vectors); msix_vectors = 0; } else { if (pdev->msix_enabled == 1) { irq_context->pci_irq_type = PS3_PCI_IRQ_MSIX; LOG_DEBUG("host_no:%u alloc msix count:%d\n", - PS3_IRQCTX_HOST(irq_context), msix_vectors); + PS3_IRQCTX_HOST(irq_context), msix_vectors); } else if (pdev->msi_enabled == 1) { irq_context->pci_irq_type = PS3_PCI_IRQ_MSI; LOG_DEBUG("host_no:%u alloc msi count:%d\n", - PS3_IRQCTX_HOST(irq_context), msix_vectors); + PS3_IRQCTX_HOST(irq_context), msix_vectors); } else { - LOG_ERROR( - "host_no:%u msi/msix all disable, msix_vectors:%d\n", + LOG_ERROR("host_no:%u msi/msix all disable, msix_vectors:%d\n", PS3_IRQCTX_HOST(irq_context), msix_vectors); } } - return (unsigned int)msix_vectors; + return (U32)msix_vectors; } -static void -ps3_iops_vectors_affinity_hint_set(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static void ps3_iops_vectors_affinity_hint_set(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { - unsigned int msix_vector = 0; - unsigned int os_vector = 0; - int node = -1; - const struct cpumask *mask = NULL; - int cpu_id = 0; + U32 msix_vector = 0; + U32 os_vector = 0; + S32 node = -1; + const struct cpumask* mask = NULL; + S32 cpu_id = 0; if (!ps3_support_irq_affinity()) goto l_out; - if (!irq_context->is_support_balance) + if (!irq_context->is_support_balance) { goto l_out; + } if (!irq_context->instance->smp_affinity_enable) goto l_out; node = dev_to_node(&pdev->dev); - if (node >= 0) + if (node >= 0) { mask = cpumask_of_node(node); + } - if (mask == NULL) + if (mask == NULL) { mask = cpu_online_mask; + } for_each_cpu_and(cpu_id, mask, cpu_online_mask) { - LOG_DEBUG("host_no:%u affinity_hint cpu_id:%d, node:%d\n", - PS3_IRQCTX_HOST(irq_context), cpu_id, node); + LOG_DEBUG("host_no:%u affinity_hint cpu_id:%d, node:%d \n", + PS3_IRQCTX_HOST(irq_context), cpu_id, node); } - for (msix_vector = 0; msix_vector < irq_context->high_iops_msix_vectors; - msix_vector++) { + for (msix_vector = 0; + msix_vector < irq_context->high_iops_msix_vectors; + msix_vector++) { os_vector = pci_irq_vector(pdev, msix_vector); irq_set_affinity_hint(os_vector, mask); } @@ -237,18 +227,17 @@ ps3_iops_vectors_affinity_hint_set(struct pci_dev *pdev, return; } -static unsigned int ps3_irq_vectors_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context, - unsigned int max_vectors) +static U32 ps3_irq_vectors_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context, + U32 max_vectors) { - unsigned int msix_vectors = 0; - int nr_entries = 0; - + U32 msix_vectors = 0; + S32 nr_entries = 0; msix_irq_mode_check(irq_context, max_vectors); msix_vectors = __ps3_irq_vectors_alloc(pdev, irq_context); if ((msix_vectors != irq_context->valid_msix_vector_count) && - (irq_context->is_support_balance)) { + (irq_context->is_support_balance)) { pci_free_irq_vectors(pdev); irq_context->is_support_balance = PS3_FALSE; irq_context->is_balance_current_perf_mode = PS3_FALSE; @@ -256,9 +245,10 @@ static unsigned int ps3_irq_vectors_alloc(struct pci_dev *pdev, irq_context->valid_msix_vector_count = min(num_online_cpus(), max_vectors); msix_vectors = __ps3_irq_vectors_alloc(pdev, irq_context); - LOG_DEBUG("host_no:%u alloc resource for normal perf mode!\n", - PS3_IRQCTX_HOST(irq_context)); + LOG_DEBUG("host_no:%u alloc resource for normal perf mode! \n", + PS3_IRQCTX_HOST(irq_context)); } + INJECT_START(PS3_ERR_IJ_IRQ_VECTORS_ALLOC_FAILED, &msix_vectors) if (msix_vectors > 0) { irq_context->valid_msix_vector_count = msix_vectors; ps3_iops_vectors_affinity_hint_set(pdev, irq_context); @@ -267,27 +257,25 @@ static unsigned int ps3_irq_vectors_alloc(struct pci_dev *pdev, irq_context->is_support_balance = PS3_FALSE; irq_context->is_balance_current_perf_mode = PS3_FALSE; nr_entries = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY); + INJECT_START(PS3_ERR_IJ_ALLOC_LEGACY_VECTOR_FAILED, &nr_entries) if (nr_entries != 1) { - LOG_ERROR("host_no:%u alloc irq fail!\n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u alloc irq fail! \n", + PS3_IRQCTX_HOST(irq_context)); irq_context->valid_msix_vector_count = 0; } else { irq_context->valid_msix_vector_count = 1; irq_context->pci_irq_type = PS3_PCI_IRQ_LEGACY; LOG_DEBUG("host_no:%u alloc legacy irq\n", - PS3_IRQCTX_HOST(irq_context)); + PS3_IRQCTX_HOST(irq_context)); } } return irq_context->valid_msix_vector_count; } -static inline unsigned char -ps3_irq_set_affinity_hint(struct pci_dev *pdev, unsigned int msix_vector, - const struct cpumask *mask, - unsigned char smp_affinity_enable) -{ - unsigned int os_vector = pci_irq_vector(pdev, msix_vector); - unsigned char ret = PS3_TRUE; +static inline Bool ps3_irq_set_affinity_hint(struct pci_dev *pdev, + U32 msix_vector, const struct cpumask *mask, Bool smp_affinity_enable) { + U32 os_vector = pci_irq_vector(pdev, msix_vector); + Bool ret = PS3_TRUE; if (smp_affinity_enable) { if (irq_set_affinity_hint(os_vector, mask)) @@ -297,28 +285,27 @@ ps3_irq_set_affinity_hint(struct pci_dev *pdev, unsigned int msix_vector, } static void __ps3_cpu_msix_table_init(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) + struct ps3_irq_context *irq_context) { const struct cpumask *mask = NULL; - int cpu_id = 0; - unsigned int normal_msix_index = irq_context->high_iops_msix_vectors; - unsigned char smp_affinify_enable = - irq_context->instance->smp_affinity_enable; + S32 cpu_id = 0; + U32 normal_msix_index = irq_context->high_iops_msix_vectors; + Bool smp_affinify_enable = irq_context->instance->smp_affinity_enable; for (; normal_msix_index < irq_context->valid_msix_vector_count; - normal_msix_index++) { + normal_msix_index++) { mask = pci_irq_get_affinity(pdev, normal_msix_index); - if (mask == NULL) + if (mask == NULL) { goto l_get_affinity_failed; + } for_each_cpu_and(cpu_id, mask, cpu_online_mask) { - if (cpu_id >= irq_context->cpu_msix_table_sz) + if (cpu_id >= irq_context->cpu_msix_table_sz) { break; + } irq_context->cpu_msix_table[cpu_id] = normal_msix_index; - LOG_DEBUG( - "host_no:%u affinity cpu_id:%d, msix_index:%d\n", - PS3_IRQCTX_HOST(irq_context), cpu_id, - normal_msix_index); + LOG_DEBUG("host_no:%u affinity cpu_id:%d, msix_index:%d \n", + PS3_IRQCTX_HOST(irq_context), cpu_id, normal_msix_index); } } @@ -328,73 +315,70 @@ static void __ps3_cpu_msix_table_init(struct pci_dev *pdev, cpu_id = cpumask_first(cpu_online_mask); normal_msix_index = irq_context->high_iops_msix_vectors; for (; normal_msix_index < irq_context->valid_msix_vector_count; - normal_msix_index++) { + normal_msix_index++) { mask = get_cpu_mask(cpu_id); - if (!ps3_irq_set_affinity_hint(pdev, normal_msix_index, mask, - smp_affinify_enable)) { + if (!ps3_irq_set_affinity_hint(pdev, normal_msix_index, + mask, smp_affinify_enable)) { LOG_ERROR("host_no:%u set affinity failed, %d.\n", - PS3_IRQCTX_HOST(irq_context), - normal_msix_index); + PS3_IRQCTX_HOST(irq_context), normal_msix_index); } else { irq_context->cpu_msix_table[cpu_id] = normal_msix_index; - LOG_DEBUG( - "host_no:%u affinity cpu_id:%d, msix_index:%d\n", - PS3_IRQCTX_HOST(irq_context), cpu_id, - normal_msix_index); + LOG_DEBUG("host_no:%u affinity cpu_id:%d, msix_index:%d \n", + PS3_IRQCTX_HOST(irq_context), cpu_id, normal_msix_index); } cpu_id = cpumask_next(cpu_id, cpu_online_mask); } + return; } -static int ps3_cpu_msix_table_init(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static S32 ps3_cpu_msix_table_init(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { - int last_cpu_id = 0; - int cpu_id = 0; - + S32 last_cpu_id = 0; + S32 cpu_id = 0; for_each_online_cpu(cpu_id) { last_cpu_id = cpu_id; } irq_context->cpu_msix_table_sz = last_cpu_id + 1; irq_context->cpu_msix_table = - kcalloc(irq_context->cpu_msix_table_sz, sizeof(int), GFP_KERNEL); + (U32*)kcalloc(irq_context->cpu_msix_table_sz, sizeof(S32), GFP_KERNEL); + INJECT_START(PS3_ERR_IJ_CPU_MSIX_TABLE_ALLOC_FAILED, &(irq_context->cpu_msix_table)) if (irq_context->cpu_msix_table == NULL) { - LOG_ERROR("host_no:%u kcalloc fail!\n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u kcalloc fail! \n", + PS3_IRQCTX_HOST(irq_context)); return -PS3_FAILED; } - __ps3_cpu_msix_table_init(pdev, irq_context); + __ps3_cpu_msix_table_init(pdev, irq_context) ; return PS3_SUCCESS; } -static int ps3_reply_fifo_desc_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static S32 ps3_reply_fifo_desc_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { size_t reply_fifo_desc_buf_size = sizeof(struct PS3ReplyFifoDesc) * - irq_context->valid_msix_vector_count; - - irq_context->reply_fifo_desc_buf_pool = - (struct dma_pool *)ps3_dma_pool_create( - "PS3 reply fifo desc pool", &pdev->dev, - reply_fifo_desc_buf_size, + irq_context->valid_msix_vector_count; + irq_context->reply_fifo_desc_buf_pool = (struct dma_pool *) + ps3_dma_pool_create("PS3 reply fifo desc pool", + &pdev->dev, reply_fifo_desc_buf_size, sizeof(struct PS3ReplyFifoDesc), 0); + INJECT_START(PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_POOL_ALLOC_FAILED, &(irq_context->reply_fifo_desc_buf_pool)) if (irq_context->reply_fifo_desc_buf_pool == NULL) { - LOG_ERROR("host_no:%u ps3_dma_pool_create fail!\n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u ps3_dma_pool_create fail! \n", + PS3_IRQCTX_HOST(irq_context)); goto l_desc_buf_pool_failed; } - irq_context->reply_fifo_desc_buf = - (struct PS3ReplyFifoDesc *)ps3_dma_pool_zalloc( - irq_context->instance, - irq_context->reply_fifo_desc_buf_pool, GFP_KERNEL, + irq_context->reply_fifo_desc_buf = (struct PS3ReplyFifoDesc*) + ps3_dma_pool_zalloc(irq_context->instance, irq_context->reply_fifo_desc_buf_pool, + GFP_KERNEL, &irq_context->reply_fifo_desc_buf_phys); + INJECT_START(PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_ALLOC_FAILED, &(irq_context->reply_fifo_desc_buf)) if (irq_context->reply_fifo_desc_buf == NULL) { - LOG_ERROR("host_no:%u ps3_dma_pool_create fail!\n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u ps3_dma_pool_create fail! \n", + PS3_IRQCTX_HOST(irq_context)); goto l_desc_buf_alloc_failed; } @@ -410,76 +394,80 @@ static int ps3_reply_fifo_desc_alloc(struct pci_dev *pdev, static void ps3_reply_fifo_desc_free(struct ps3_irq_context *irq_context) { if (irq_context->reply_fifo_desc_buf != NULL) { - ps3_dma_pool_free(irq_context->reply_fifo_desc_buf_pool, - irq_context->reply_fifo_desc_buf, - irq_context->reply_fifo_desc_buf_phys); - irq_context->reply_fifo_desc_buf = NULL; - irq_context->reply_fifo_desc_buf_phys = 0; + ps3_dma_pool_free( + irq_context->reply_fifo_desc_buf_pool, + irq_context->reply_fifo_desc_buf, + irq_context->reply_fifo_desc_buf_phys); + irq_context->reply_fifo_desc_buf = NULL; + irq_context->reply_fifo_desc_buf_phys = 0; } if (irq_context->reply_fifo_desc_buf_pool != NULL) { ps3_dma_pool_destroy(irq_context->reply_fifo_desc_buf_pool); irq_context->reply_fifo_desc_buf_pool = NULL; } + + return; } -static int __ps3_reply_fifo_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static S32 __ps3_reply_fifo_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { - struct PS3ReplyWord **virt_base = - irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - size_t reply_fifo_size = - sizeof(struct PS3ReplyWord) * irq_context->reply_fifo_depth; - unsigned int i = 0; - + size_t reply_fifo_size = sizeof(struct PS3ReplyWord) * + irq_context->reply_fifo_depth; + U32 i = 0; (void)pdev; + for (; i < irq_context->valid_msix_vector_count; i++) { - virt_base[i] = (struct PS3ReplyWord *)ps3_dma_pool_alloc( - irq_context->instance, irq_context->reply_fifo_pool, - GFP_KERNEL, &phys_base[i]); + virt_base[i] = (struct PS3ReplyWord *) + ps3_dma_pool_alloc(irq_context->instance, irq_context->reply_fifo_pool, + GFP_KERNEL, + &phys_base[i]); + INJECT_START(PS3_ERR_IJ_REPLY_VIRT_BASE_ALLOC_FAILED, &(virt_base[i])) if (virt_base[i] == NULL) { - LOG_ERROR("host_no:%u ps3_dma_pool_zalloc fail!\n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u ps3_dma_pool_zalloc fail! \n", + PS3_IRQCTX_HOST(irq_context)); goto l_alloc_failed; } memset(virt_base[i], 0xff, reply_fifo_size); - ps3_get_so_addr_ranger(irq_context->instance, phys_base[i], - reply_fifo_size); - LOG_DEBUG("host_no:%u reply_fifo index:%u phy addr:0x%llx!\n", - PS3_IRQCTX_HOST(irq_context), i, - (unsigned long long)phys_base[i]); + ps3_get_so_addr_ranger(irq_context->instance, phys_base[i], reply_fifo_size); + LOG_DEBUG("host_no:%u reply_fifo index:%u phy addr:0x%llx! \n", + PS3_IRQCTX_HOST(irq_context), i, phys_base[i]); } return PS3_SUCCESS; l_alloc_failed: for (; i > 0; i--) { - ps3_dma_pool_free(irq_context->reply_fifo_pool, - virt_base[i - 1], phys_base[i - 1]); - virt_base[i - 1] = NULL; - phys_base[i - 1] = 0; + ps3_dma_pool_free( + irq_context->reply_fifo_pool, + virt_base[i-1], phys_base[i-1]); + virt_base[i-1] = NULL; + phys_base[i-1] = 0; } return -PS3_FAILED; } -static int ps3_reply_fifo_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static S32 ps3_reply_fifo_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { - size_t reply_fifo_size = - sizeof(struct PS3ReplyWord) * irq_context->reply_fifo_depth; - + size_t reply_fifo_size = sizeof(struct PS3ReplyWord) * + irq_context->reply_fifo_depth; irq_context->reply_fifo_pool = - ps3_dma_pool_create("PS3 reply fifo pool", &pdev->dev, - reply_fifo_size, DMA_ALIGN_BYTES_4K, 0); + ps3_dma_pool_create("PS3 reply fifo pool", + &pdev->dev, reply_fifo_size, DMA_ALIGN_BYTES_4K, 0); + INJECT_START(PS3_ERR_IJ_REPLY_FIFO_POOL_ALLOC_FAILED, &(irq_context->reply_fifo_pool)) if (irq_context->reply_fifo_pool == NULL) { - LOG_ERROR("host_no:%u ps3_dma_pool_create fail!\n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u ps3_dma_pool_create fail! \n", + PS3_IRQCTX_HOST(irq_context)); goto l_reply_fifo_pool_failed; } - if (__ps3_reply_fifo_alloc(pdev, irq_context) != PS3_SUCCESS) + if (__ps3_reply_fifo_alloc(pdev, irq_context) != PS3_SUCCESS) { goto l_reply_fifo_alloc_failed; + } return PS3_SUCCESS; @@ -492,20 +480,23 @@ static int ps3_reply_fifo_alloc(struct pci_dev *pdev, static void ps3_reply_fifo_free(struct ps3_irq_context *irq_context) { - struct PS3ReplyWord **virt_base = - irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - unsigned int i = 0; + U32 i = 0; - if (irq_context->reply_fifo_pool == NULL) + if (irq_context->reply_fifo_pool == NULL) { goto l_out; + } for (; i < irq_context->valid_msix_vector_count; i++) { - if (virt_base[i] == NULL) + + if (virt_base[i] == NULL) { continue; + } - ps3_dma_pool_free(irq_context->reply_fifo_pool, virt_base[i], - phys_base[i]); + ps3_dma_pool_free( + irq_context->reply_fifo_pool, + virt_base[i], phys_base[i]); virt_base[i] = NULL; phys_base[i] = 0; } @@ -516,14 +507,16 @@ static void ps3_reply_fifo_free(struct ps3_irq_context *irq_context) return; } -static int ps3_irq_resource_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static S32 ps3_irq_resource_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { - if (ps3_reply_fifo_desc_alloc(pdev, irq_context) != PS3_SUCCESS) + if (ps3_reply_fifo_desc_alloc(pdev, irq_context) != PS3_SUCCESS) { goto l_desc_alloc_failed; + } - if (ps3_reply_fifo_alloc(pdev, irq_context) != PS3_SUCCESS) + if (ps3_reply_fifo_alloc(pdev, irq_context) != PS3_SUCCESS) { goto l_reply_fifo_alloc_failed; + } return PS3_SUCCESS; @@ -537,14 +530,16 @@ static void ps3_irq_resource_free(struct ps3_irq_context *irq_context) { ps3_reply_fifo_free(irq_context); ps3_reply_fifo_desc_free(irq_context); + + return; } static void ps3_reply_fifo_desc_set(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) + struct ps3_irq_context *irq_context) { struct PS3ReplyFifoDesc *desc_buf = irq_context->reply_fifo_desc_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - unsigned int i = 0; + U32 i = 0; for (; i < irq_context->valid_msix_vector_count; i++) { desc_buf[i].ReplyFifoBaseAddr = cpu_to_le64(phys_base[i]); @@ -552,16 +547,18 @@ static void ps3_reply_fifo_desc_set(struct pci_dev *pdev, desc_buf[i].depthReplyFifo = irq_context->reply_fifo_depth; if (irq_context->is_support_balance && - i < irq_context->high_iops_msix_vectors) { + i < irq_context->high_iops_msix_vectors) { desc_buf[i].isrAccMode = PS3_ISR_ACC_MODE_IOPS_VER0; - } else { + } + else { desc_buf[i].isrAccMode = PS3_ISR_ACC_MODE_LATENCY; } } + + return; } -static inline void __ps3_irqs_exit(struct ps3_irq *irq, - struct ps3_irq_context *irq_context) +static inline void __ps3_irqs_exit(struct ps3_irq *irq, struct ps3_irq_context *irq_context) { irq_set_affinity_hint(irq->irqNo, NULL); @@ -570,34 +567,33 @@ static inline void __ps3_irqs_exit(struct ps3_irq *irq, irq->is_irq_poll_disabled = PS3_TRUE; } else { LOG_INFO("host_no:%u irq poll(%u) already disabled!\n", - PS3_HOST(irq_context->instance), irq->isrSN); + PS3_HOST(irq_context->instance), irq->isrSN); } free_irq(irq->irqNo, irq); } -int ps3_irqs_init(struct ps3_instance *instance) +S32 ps3_irqs_init(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = - irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; struct pci_dev *pdev = instance->pdev; struct ps3_irq *irqs = NULL; - unsigned int i = 0; - unsigned int dump_irq_index; - int retval; - - irq_context->irqs = (struct ps3_irq *)ps3_kcalloc( - instance, irq_context->valid_msix_vector_count, + U32 i = 0; + U32 dump_irq_index; + S32 retval; + irq_context->irqs = (struct ps3_irq*) + ps3_kcalloc(instance, irq_context->valid_msix_vector_count, sizeof(struct ps3_irq)); + INJECT_START(PS3_ERR_IJ_IRQS_ALLOC_FAILED, &(irq_context->irqs)) if (irq_context->irqs == NULL) { - LOG_ERROR("host_no:%u kcalloc fail!\n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u kcalloc fail! \n", + PS3_IRQCTX_HOST(irq_context)); goto l_out; } irqs = irq_context->irqs; - for (i = 0; i < irq_context->valid_msix_vector_count; i++) { + for (i=0; i < irq_context->valid_msix_vector_count; i++) { irqs[i].irqNo = pci_irq_vector(pdev, i); irqs[i].isrSN = i; irqs[i].reply_fifo_virt_base_addr = virt_base[i]; @@ -609,37 +605,39 @@ int ps3_irqs_init(struct ps3_instance *instance) atomic_set(&irqs[i].is_busy, 0); irqs[i].last_reply_idx = 0; snprintf(irqs[i].name, PS3_IRQ_NAME_LENGTH, "ps3_irq_%d_%d", - instance->host->host_no, i); + instance->host->host_no, i); retval = request_irq(irqs[i].irqNo, instance->ioc_adpter->isr, - IRQF_SHARED, irqs[i].name, &(irqs[i])); + IRQF_SHARED, irqs[i].name, &(irqs[i])); + INJECT_START(PS3_ERR_IJ_REPLY_REQ_IRQS_FAILED, &retval) if (retval) { LOG_ERROR("host_no:%u request_irq failed! SN:%d\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); goto l_failed; } - ps3_irq_poll_init(&irqs[i].irqpoll, - PS3_IRQ_POLL_SCHED_THRESHOLD, - ps3_irqpoll_service); + ps3_irq_poll_init(&irqs[i].irqpoll, PS3_IRQ_POLL_SCHED_THRESHOLD, + ps3_irqpoll_service); } - dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); + dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); retval = request_irq(irqs[dump_irq_index].irqNo, ps3_dump_irq_handler, - IRQF_SHARED, "ps3_dump_irq", (void *)instance); + IRQF_SHARED, "ps3_dump_irq", (void *)instance); + INJECT_START(PS3_ERR_IJ_DUMP_REQ_IRQS_FAILED, &retval) if (retval) { LOG_ERROR("host_no:%u request dump irq failed! SN:%d\n", - PS3_HOST(instance), dump_irq_index); - goto l_failed; - } + PS3_HOST(instance), dump_irq_index); + goto l_failed; + } irq_context->dump_isrSN = dump_irq_index; instance->ioc_adpter->irq_disable(instance); return PS3_SUCCESS; l_failed: - for (; i > 0; i--) - __ps3_irqs_exit(&irqs[i - 1], irq_context); + for (; i > 0; i--) { + __ps3_irqs_exit(&irqs[i-1], irq_context); + } if (irq_context->irqs != NULL) { ps3_kfree(instance, irq_context->irqs); @@ -649,29 +647,28 @@ int ps3_irqs_init(struct ps3_instance *instance) return -PS3_FAILED; } -int ps3_irqs_init_switch(struct ps3_instance *instance) +S32 ps3_irqs_init_switch(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = - irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; struct pci_dev *pdev = instance->pdev; struct ps3_irq *irqs = NULL; struct ps3_irq_recovery *irqs_recovery = NULL; - unsigned int i = 0; - unsigned int dump_irq_index; - unsigned int watch_irq_index = PS3_SWITCH_IRQ_INDEX; + U32 i = 0; + U32 dump_irq_index; + U32 watch_irq_index = PS3_SWITCH_IRQ_INDEX; - irq_context->irqs = (struct ps3_irq *)ps3_kcalloc( - instance, irq_context->valid_msix_vector_count, + irq_context->irqs = (struct ps3_irq*) + ps3_kcalloc(instance, irq_context->valid_msix_vector_count, sizeof(struct ps3_irq)); if (irq_context->irqs == NULL) { - LOG_ERROR("host_no:%u kcalloc fail!\n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u kcalloc fail! \n", + PS3_IRQCTX_HOST(irq_context)); goto l_out; } irqs = irq_context->irqs; - for (i = 0; i < irq_context->valid_msix_vector_count; i++) { + for (i=0; i < irq_context->valid_msix_vector_count; i++) { irqs[i].irqNo = pci_irq_vector(pdev, i); irqs[i].isrSN = i; irqs[i].reply_fifo_virt_base_addr = virt_base[i]; @@ -683,34 +680,34 @@ int ps3_irqs_init_switch(struct ps3_instance *instance) atomic_set(&irqs[i].is_busy, 0); irqs[i].last_reply_idx = 0; snprintf(irqs[i].name, PS3_IRQ_NAME_LENGTH, "ps3_irq_%d_%d", - instance->host->host_no, i); + instance->host->host_no, i); if (request_irq(irqs[i].irqNo, instance->ioc_adpter->isr, - IRQF_SHARED, irqs[i].name, &(irqs[i]))) { + IRQF_SHARED, irqs[i].name, &(irqs[i]))) { LOG_ERROR("host_no:%u request_irq failed! SN:%d\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); goto l_failed; } - ps3_irq_poll_init(&irqs[i].irqpoll, - PS3_IRQ_POLL_SCHED_THRESHOLD, - ps3_irqpoll_service); + ps3_irq_poll_init(&irqs[i].irqpoll, PS3_IRQ_POLL_SCHED_THRESHOLD, + ps3_irqpoll_service); } - dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); - if (request_irq(irqs[dump_irq_index].irqNo, ps3_dump_irq_handler, - IRQF_SHARED, "ps3_dump_irq", (void *)instance)) { - LOG_ERROR("host_no:%u request dump irq failed! SN:%d\n", - PS3_HOST(instance), dump_irq_index); - goto l_failed; - } + dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); + if (request_irq(irqs[dump_irq_index].irqNo, ps3_dump_irq_handler, IRQF_SHARED, "ps3_dump_irq", (void *)instance)) { + LOG_ERROR("host_no:%u request dump irq failed! SN:%d\n", + PS3_HOST(instance), dump_irq_index); + goto l_failed; + } irq_context->dump_isrSN = dump_irq_index; - irq_context->irq_recovery = (struct ps3_irq_recovery *)ps3_kcalloc( - instance, 1, sizeof(struct ps3_irq_recovery)); + + irq_context->irq_recovery = (struct ps3_irq_recovery*) + ps3_kcalloc(instance, 1, + sizeof(struct ps3_irq_recovery)); if (irq_context->irq_recovery == NULL) { - LOG_ERROR("host_no:%u kcalloc irq_recovery fail!\n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u kcalloc irq_recovery fail! \n", + PS3_IRQCTX_HOST(irq_context)); goto l_free_dump; } irqs_recovery = irq_context->irq_recovery; @@ -718,11 +715,10 @@ int ps3_irqs_init_switch(struct ps3_instance *instance) irqs_recovery->isrSN = watch_irq_index; irqs_recovery->instance = instance; - if (request_irq(irqs_recovery[watch_irq_index].irqNo, - ps3_recovery_irq_handler, IRQF_SHARED, - "ps3_watchdog_irq", (void *)irqs_recovery)) { + if (request_irq(irqs_recovery[watch_irq_index].irqNo, ps3_recovery_irq_handler, + IRQF_SHARED, "ps3_watchdog_irq", (void *)irqs_recovery)) { LOG_ERROR("host_no:%u request watchdog irq failed! SN:%d\n", - PS3_HOST(instance), watch_irq_index); + PS3_HOST(instance), watch_irq_index); goto l_free_dump; } instance->ioc_adpter->irq_disable(instance); @@ -731,8 +727,9 @@ int ps3_irqs_init_switch(struct ps3_instance *instance) l_free_dump: free_irq(irqs[dump_irq_index].irqNo, instance); l_failed: - for (; i > 0; i--) - __ps3_irqs_exit(&irqs[i - 1], irq_context); + for (; i > 0; i--) { + __ps3_irqs_exit(&irqs[i-1], irq_context); + } if (irq_context->irqs != NULL) { ps3_kfree(instance, irq_context->irqs); @@ -752,51 +749,50 @@ void ps3_irqs_exit(struct ps3_instance *instance) struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = irq_context->irqs; struct pci_dev *pdev = instance->pdev; - unsigned int i = 0; - unsigned int dump_irq_index; - unsigned int watch_irq_index = PS3_SWITCH_IRQ_INDEX; - struct ps3_irq_recovery *irq_recovery; + U32 i = 0; + U32 dump_irq_index; + U32 watch_irq_index = PS3_SWITCH_IRQ_INDEX; + struct ps3_irq_recovery * irq_recovery; - if (irqs == NULL) + if (irqs == NULL) { goto l_out; + } dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); irq_set_affinity_hint(irqs[dump_irq_index].irqNo, NULL); free_irq(irqs[dump_irq_index].irqNo, instance); if (irq_context->irq_recovery != NULL) { - irq_set_affinity_hint( - irq_context->irq_recovery[watch_irq_index].irqNo, NULL); - free_irq(irq_context->irq_recovery[watch_irq_index].irqNo, - irq_context->irq_recovery); + irq_set_affinity_hint(irq_context->irq_recovery[watch_irq_index].irqNo, NULL); + free_irq(irq_context->irq_recovery[watch_irq_index].irqNo, irq_context->irq_recovery); irq_recovery = irq_context->irq_recovery; irq_context->irq_recovery = NULL; ps3_kfree(instance, irq_recovery); } - for (i = 0; i < irq_context->valid_msix_vector_count; i++) + for (i=0; i < irq_context->valid_msix_vector_count; i++) { __ps3_irqs_exit(&irqs[i], irq_context); + } irq_context->irqs = NULL; kfree(irqs); - if (pdev->msix_enabled || pdev->msi_enabled) + if (pdev->msix_enabled || pdev->msi_enabled) { pci_free_irq_vectors(pdev); + } l_out: return; } -static unsigned char ps3_irq_max_vectors_calc(struct ps3_instance *instance, - int *max_vectors) +static Bool ps3_irq_max_vectors_calc(struct ps3_instance *instance, + S32 *max_vectors) { - unsigned char ret = PS3_TRUE; - unsigned int max_replyq_count = 0; + Bool ret = PS3_TRUE; + U32 max_replyq_count = 0; - if (!instance->ioc_adpter->max_replyq_count_get(instance, - &max_replyq_count)) { - LOG_ERROR("host_no:%u get max replyq count NOK\n", - PS3_HOST(instance)); + if (!instance->ioc_adpter->max_replyq_count_get(instance, &max_replyq_count)) { + LOG_ERROR("host_no:%u get max replyq count NOK\n", PS3_HOST(instance)); ret = PS3_FALSE; goto l_out; } @@ -807,52 +803,54 @@ static unsigned char ps3_irq_max_vectors_calc(struct ps3_instance *instance, LOG_INFO("reqlyq max_replyq_count:%d\n", max_replyq_count); *max_vectors = pci_msix_vec_count(instance->pdev); + INJECT_START(PS3_ERR_IJ_GET_MSIX_VEC_COUNT_INVALID, max_vectors) if (*max_vectors <= 0) { *max_vectors = pci_msi_vec_count(instance->pdev); + INJECT_START(PS3_ERR_IJ_GET_MSIX_VEC_COUNT_INVALID, max_vectors) if (*max_vectors < 0) { *max_vectors = 0; goto l_out; } } - *max_vectors = min_t(int, *max_vectors, max_replyq_count); + *max_vectors = min_t(S32, *max_vectors, max_replyq_count); l_out: return ret; } -int ps3_irq_context_init(struct ps3_instance *instance) +S32 ps3_irq_context_init(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct pci_dev *pdev = instance->pdev; - int max_vectors = 0; - - if (!ps3_irq_max_vectors_calc(instance, &max_vectors)) + S32 max_vectors = 0; + if (!ps3_irq_max_vectors_calc(instance, &max_vectors)) { goto l_irq_vectors_alloc_failed; + } if (!ps3_ioc_mgr_max_fw_cmd_get(instance, - &irq_context->reply_fifo_depth)) { + &irq_context->reply_fifo_depth)) { goto l_irq_vectors_alloc_failed; } irq_context->reply_fifo_depth += instance->reply_fifo_depth_addition; irq_context->instance = instance; - LOG_INFO("max_vectors:%d replyQ_depth:%d\n", max_vectors, - irq_context->reply_fifo_depth); + LOG_INFO("max_vectors:%d replyQ_depth:%d\n", + max_vectors, irq_context->reply_fifo_depth); if (max_vectors <= 0) { - LOG_ERROR("host_no:%u IOC max_vectors invliad:%d\n", - PS3_IRQCTX_HOST(irq_context), max_vectors); + LOG_ERROR("host_no:%u IOC max_vectors invliad:%d \n", + PS3_IRQCTX_HOST(irq_context), max_vectors); goto l_irq_vectors_alloc_failed; } - if (!instance->msix_combined) + if (!instance->msix_combined) { instance->smp_affinity_enable = PS3_FALSE; + } if (ps3_irq_vectors_alloc(pdev, irq_context, max_vectors) < - instance->min_intr_count) { - LOG_ERROR( - "host_no:%u alloc irq NOK![cpunum:%d][irq_type:%d][min_intr:%d]\n", + instance->min_intr_count) { + LOG_ERROR("host_no:%u alloc irq NOK![cpunum:%d][irq_type:%d][min_intr:%d] \n", PS3_IRQCTX_HOST(irq_context), num_online_cpus(), irq_context->pci_irq_type, instance->min_intr_count); if (irq_context->valid_msix_vector_count > 0) { @@ -863,11 +861,13 @@ int ps3_irq_context_init(struct ps3_instance *instance) goto l_irq_vectors_alloc_failed; } - if (ps3_cpu_msix_table_init(pdev, irq_context) != PS3_SUCCESS) + if (ps3_cpu_msix_table_init(pdev, irq_context) != PS3_SUCCESS) { goto l_cpu_msix_table_init_failed; + } - if (ps3_irq_resource_alloc(pdev, irq_context) != PS3_SUCCESS) + if (ps3_irq_resource_alloc(pdev, irq_context) != PS3_SUCCESS) { goto l_irq_resource_alloc_failed; + } ps3_reply_fifo_desc_set(pdev, irq_context); instance->is_support_irq = PS3_TRUE; @@ -886,93 +886,93 @@ int ps3_irq_context_init(struct ps3_instance *instance) return -PS3_FAILED; } -int ps3_irq_context_exit(struct ps3_instance *instance) +S32 ps3_irq_context_exit(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct pci_dev *pdev = instance->pdev; - if (!instance->is_pcie_err_detected) + if (!instance->is_pcie_err_detected) { ps3_irq_resource_free(irq_context); + } if (irq_context->cpu_msix_table != NULL) { kfree(irq_context->cpu_msix_table); irq_context->cpu_msix_table = NULL; } - if (pdev->msix_enabled || pdev->msi_enabled) + if (pdev->msix_enabled || pdev->msi_enabled) { pci_free_irq_vectors(pdev); + } if (!instance->is_pcie_err_detected) memset(irq_context, 0, sizeof(struct ps3_irq_context)); + return PS3_SUCCESS; } -static inline unsigned char ps3_is_hdd_cmd(struct ps3_cmd *cmd) +static inline Bool ps3_is_hdd_cmd(struct ps3_cmd *cmd) { - unsigned char is_hdd_io = PS3_FALSE; + Bool is_hdd_io = PS3_FALSE; const struct PS3VDEntry *vd_entry = NULL; if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { vd_entry = cmd->io_attr.vd_entry; - if (!vd_entry->isNvme && !vd_entry->isSsd) + if (!vd_entry->isNvme && !vd_entry->isSsd) { is_hdd_io = PS3_TRUE; + } } else { - if (ps3_is_hdd_pd(cmd->io_attr.pd_entry->dev_type)) + if (ps3_is_hdd_pd(cmd->io_attr.pd_entry->dev_type)) { is_hdd_io = PS3_TRUE; + } } return is_hdd_io; } -static inline unsigned char ps3_sdev_is_high_load(struct ps3_cmd *cmd, - unsigned short scale) +static inline Bool ps3_sdev_is_high_load(struct ps3_cmd *cmd, U16 scale) { - int busy_base = cmd->instance->device_busy_threshold; - int busy_threshold = busy_base * scale; - int device_busy = 0; + S32 busy_base = cmd->instance->device_busy_threshold; + S32 busy_threshold = busy_base * scale; + S32 device_busy = 0; #if defined DRIVER_SUPPORT_PRIV_BUSY - struct ps3_scsi_priv_data *device_priv_data = - (struct ps3_scsi_priv_data *)cmd->scmd->device->hostdata; - - if (device_priv_data == NULL) + struct ps3_scsi_priv_data *device_priv_data = (struct ps3_scsi_priv_data*)cmd->scmd->device->hostdata; + if (device_priv_data == NULL) { return PS3_FALSE; + } device_busy = atomic_read(&device_priv_data->sdev_priv_busy); #else device_busy = atomic_read(&cmd->scmd->device->device_busy); #endif - if (PS3_MULTI_DATA_DISK_BUSY_THRESHOLD(busy_threshold, busy_base) && - !ps3_is_hdd_cmd(cmd)) { + if (PS3_MULTI_DATA_DISK_BUSY_THRESHOLD(busy_threshold, busy_base) && !ps3_is_hdd_cmd(cmd)) { if (ps3_host_vendor_get() == PS3_HOST_VENDOR_HYGON && - busy_threshold <= PS3_HYGON_BUSY_ADJUST_THRESHOLD) { + busy_threshold <= PS3_HYGON_BUSY_ADJUST_THRESHOLD) { busy_threshold = busy_base; } else if (busy_threshold > PS3_SSD_MAX_BUSY_THRESHOLD) { busy_threshold = PS3_SSD_MAX_BUSY_THRESHOLD; } } - if (device_busy > busy_threshold) + if (device_busy > busy_threshold) { return PS3_TRUE; + } return PS3_FALSE; } -static inline unsigned int -ps3_iops_msix_index_get(struct ps3_irq_context *irq_context) +static inline U32 ps3_iops_msix_index_get(struct ps3_irq_context *irq_context) { - unsigned int msix_index = 0; - unsigned int ioc_count = - atomic_add_return(1, &irq_context->high_iops_io_count); - unsigned int batch_num = - ioc_count >> PS3_HIGH_IOPS_VECTOR_BATCH_COUNT_SHIFT; + U32 msix_index = 0; + U32 ioc_count = atomic_add_return(1, &irq_context->high_iops_io_count); + U32 batch_num = ioc_count >> PS3_HIGH_IOPS_VECTOR_BATCH_COUNT_SHIFT; msix_index = batch_num % PS3_IOPS_MSIX_VECTORS; return msix_index; } -unsigned int ps3_msix_index_get(struct ps3_cmd *cmd, unsigned short scale) +U32 ps3_msix_index_get(struct ps3_cmd *cmd, U16 scale) { int processor_id = 0; - unsigned int msix_index = 0; + U32 msix_index = 0; struct ps3_irq_context *irq_context = &cmd->instance->irq_context; if (irq_context->valid_msix_vector_count == 1) { @@ -986,38 +986,41 @@ unsigned int ps3_msix_index_get(struct ps3_cmd *cmd, unsigned short scale) } if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type) && - (irq_context->is_balance_current_perf_mode) && - ps3_sdev_is_high_load(cmd, scale)) { + (irq_context->is_balance_current_perf_mode) && + ps3_sdev_is_high_load(cmd, scale)) { msix_index = ps3_iops_msix_index_get(irq_context); } else if (cmd->instance->host->nr_hw_queues > 1) { - msix_index = blk_mq_unique_tag_to_hwq(blk_mq_unique_tag( - SCMD_GET_REQUEST(cmd->scmd))) + - irq_context->high_iops_msix_vectors; + msix_index = blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(SCMD_GET_REQUEST(cmd->scmd))) + + irq_context->high_iops_msix_vectors; } else { processor_id = raw_smp_processor_id(); msix_index = irq_context->cpu_msix_table[processor_id]; - if (msix_index == PS3_MGR_CMD_MSIX_INDEX(irq_context)) + if (msix_index == PS3_MGR_CMD_MSIX_INDEX(irq_context)) { msix_index++; + } } l_out: return msix_index; } -void ps3_perf_update(struct ps3_instance *instance, unsigned char iocPerfMode) +void ps3_perf_update(struct ps3_instance *instance, U8 iocPerfMode) { struct ps3_irq_context *irq_context = &instance->irq_context; - unsigned char support_balance = irq_context->is_support_balance; - unsigned char *is_balance = &irq_context->is_balance_current_perf_mode; + Bool support_balance = irq_context->is_support_balance; + Bool *is_balance = &irq_context->is_balance_current_perf_mode; if (support_balance) { - if (iocPerfMode == PS3_PERF_MODE_BALANCE) + if (iocPerfMode == PS3_PERF_MODE_BALANCE) { *is_balance = PS3_TRUE; - else + } else { *is_balance = PS3_FALSE; + } } else { *is_balance = PS3_FALSE; } + + return; } void ps3_irqs_enable(struct ps3_instance *instance) { @@ -1025,7 +1028,8 @@ void ps3_irqs_enable(struct ps3_instance *instance) LOG_DEBUG("host_no:%u irq enable\n", PS3_HOST(instance)); - switch (irq_context->pci_irq_type) { + switch (irq_context->pci_irq_type) + { case PS3_PCI_IRQ_LEGACY: ps3_ioc_legacy_irqs_enable(instance); break; @@ -1036,12 +1040,13 @@ void ps3_irqs_enable(struct ps3_instance *instance) ps3_ioc_msix_enable(instance); break; default: - LOG_ERROR("host_no:%u irq type is NOK :%d\n", - PS3_HOST(instance), irq_context->pci_irq_type); + LOG_ERROR("host_no:%u irq type is NOK :%d \n", + PS3_HOST(instance), irq_context->pci_irq_type); break; } irq_context->is_enable_interrupts = PS3_DRV_TRUE; - mb(); /* in order to force CPU ordering */ + mb(); + return; } void ps3_irqs_disable(struct ps3_instance *instance) @@ -1050,12 +1055,14 @@ void ps3_irqs_disable(struct ps3_instance *instance) LOG_DEBUG("host_no:%u irq disable\n", PS3_HOST(instance)); - if (irq_context->is_enable_interrupts == PS3_DRV_FALSE) + if(irq_context->is_enable_interrupts == PS3_DRV_FALSE) { goto l_out; + } irq_context->is_enable_interrupts = PS3_DRV_FALSE; - mb(); /* in order to force CPU ordering */ - switch (irq_context->pci_irq_type) { + mb(); + switch (irq_context->pci_irq_type) + { case PS3_PCI_IRQ_LEGACY: ps3_ioc_legacy_irqs_disable(instance); break; @@ -1066,8 +1073,8 @@ void ps3_irqs_disable(struct ps3_instance *instance) ps3_ioc_msix_disable(instance); break; default: - LOG_ERROR("host_no:%u irq type is NOK :%d\n", - PS3_HOST(instance), irq_context->pci_irq_type); + LOG_ERROR("host_no:%u irq type is NOK :%d \n", + PS3_HOST(instance), irq_context->pci_irq_type); break; } @@ -1089,26 +1096,26 @@ irqreturn_t ps3_irqs_service(int irq_so, void *priv) } irq_context = &irq->instance->irq_context; - if ((unsigned int)irq_so != irq->irqNo) { + if ((U32)irq_so != irq->irqNo) { LOG_ERROR_IN_IRQ(irq->instance, - "irq_so:%d != irq->irqNo:%d !\n", irq_so, - irq->irqNo); + "irq_so:%d != irq->irqNo:%d !\n", + irq_so, irq->irqNo); ret = IRQ_NONE; goto l_out; } if (!irq_context->is_enable_interrupts) { LOG_INFO_IN_IRQ(irq->instance, - "host_no:%u interrupt has disabled !\n", - PS3_HOST(irq->instance)); + "host_no:%u interrupt has disabled !\n", + PS3_HOST(irq->instance)); ret = IRQ_NONE; goto l_out; } if (irq->is_sched_irq_poll) { LOG_WARN_IN_IRQ(irq->instance, - "host_no:%u had enter into irq poll !\n", - PS3_HOST(irq->instance)); + "host_no:%u had enter into irq poll !\n", + PS3_HOST(irq->instance)); ret = IRQ_HANDLED; goto l_out; } @@ -1116,7 +1123,7 @@ irqreturn_t ps3_irqs_service(int irq_so, void *priv) complete_num = ps3_cmd_complete(irq); if (complete_num <= 0) { LOG_DEBUG("host_no:%u there is no completed ps3_cmd !\n", - PS3_HOST(irq->instance)); + PS3_HOST(irq->instance)); ret = IRQ_NONE; } else { ret = IRQ_HANDLED; @@ -1126,11 +1133,10 @@ irqreturn_t ps3_irqs_service(int irq_so, void *priv) return ret; } -int ps3_irqpoll_service(struct irq_poll *irqpoll, int budget) +S32 ps3_irqpoll_service(struct irq_poll *irqpoll, int budget) { - int complete_num = 0; - struct ps3_irq *irq = - ps3_container_of(irqpoll, struct ps3_irq, irqpoll); + S32 complete_num = 0; + struct ps3_irq *irq = ps3_container_of(irqpoll, struct ps3_irq, irqpoll); if (irq->is_enable_irq) { disable_irq(irq->irqNo); @@ -1152,10 +1158,10 @@ void ps3_irqpolls_enable(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = irq_context->irqs; - unsigned int i = 0; - - if (irqs == NULL) + U32 i = 0; + if (irqs == NULL) { return; + } for (; i < irq_context->valid_msix_vector_count; i++) { if (irqs[i].is_irq_poll_disabled == PS3_TRUE) { @@ -1163,19 +1169,21 @@ void ps3_irqpolls_enable(struct ps3_instance *instance) irqs[i].is_irq_poll_disabled = PS3_FALSE; } else { LOG_INFO("host_no:%u irq poll(%d) not disabled!\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); } } + + return; } void ps3_irqs_sync(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = irq_context->irqs; - unsigned int i = 0; - - if (irqs == NULL) + U32 i = 0; + if (irqs == NULL) { goto l_out; + } for (; i < irq_context->valid_msix_vector_count; i++) { synchronize_irq(irqs[i].irqNo); @@ -1184,7 +1192,7 @@ void ps3_irqs_sync(struct ps3_instance *instance) irqs[i].is_irq_poll_disabled = PS3_TRUE; } else { LOG_INFO("host_no:%u irq poll(%d) already disabled!\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); } } l_out: @@ -1197,14 +1205,14 @@ static void ps3_reply_fifo_desc_free(struct ps3_instance *instance); static void ps3_reply_fifo_free(struct ps3_instance *instance); static void ps3_irq_resource_free(struct ps3_instance *instance); -static unsigned char ps3_irq_max_vectors_calc(struct ps3_instance *instance, - unsigned int *max_vectors) +static Bool ps3_irq_max_vectors_calc(struct ps3_instance *instance, + U32 *max_vectors) { - unsigned char ret = PS3_TRUE; - unsigned int max_replyq_count = 0; + Bool ret = PS3_TRUE; + U32 max_replyq_count = 0; if (!instance->ioc_adpter->max_replyq_count_get(instance, - &max_replyq_count)) { + &max_replyq_count)) { ret = PS3_FALSE; goto l_out; } @@ -1214,27 +1222,25 @@ static unsigned char ps3_irq_max_vectors_calc(struct ps3_instance *instance, *max_vectors = instance->pci_dev_context.irq_vec_count; *max_vectors = PS3_MIN(*max_vectors, max_replyq_count); - *max_vectors = - PS3_MIN(*max_vectors, (unsigned int)num_online_cpus() + 1); + *max_vectors = PS3_MIN(*max_vectors, (U32)num_online_cpus() + 1); l_out: return ret; } -static int ps3_reply_fifo_desc_alloc(struct ps3_instance *instance) +static S32 ps3_reply_fifo_desc_alloc(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - irq_context->reply_fifo_desc_buf_size = - sizeof(struct PS3ReplyFifoDesc) * + irq_context->reply_fifo_desc_buf_size = sizeof(struct PS3ReplyFifoDesc) * irq_context->valid_msix_vector_count; - irq_context->reply_fifo_desc_buf = - (struct PS3ReplyFifoDesc *)ps3_dma_alloc_coherent( - instance, irq_context->reply_fifo_desc_buf_size, - (unsigned long long *)&irq_context - ->reply_fifo_desc_buf_phys); + irq_context->reply_fifo_desc_buf = (struct PS3ReplyFifoDesc*) + ps3_dma_alloc_coherent(instance, + irq_context->reply_fifo_desc_buf_size, + &irq_context->reply_fifo_desc_buf_phys); if (irq_context->reply_fifo_desc_buf == NULL) { - LOG_ERROR("host_no:%u dma alloc fail!\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u dma alloc fail! \n", + PS3_HOST(instance)); goto l_failed; } @@ -1247,36 +1253,37 @@ static int ps3_reply_fifo_desc_alloc(struct ps3_instance *instance) static void ps3_reply_fifo_desc_free(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - if (irq_context->reply_fifo_desc_buf != NULL) { ps3_dma_free_coherent(instance, - irq_context->reply_fifo_desc_buf_size, - irq_context->reply_fifo_desc_buf, - irq_context->reply_fifo_desc_buf_phys); + irq_context->reply_fifo_desc_buf_size, + irq_context->reply_fifo_desc_buf, + irq_context->reply_fifo_desc_buf_phys); irq_context->reply_fifo_desc_buf = NULL; irq_context->reply_fifo_desc_buf_phys = 0; } + + return; } -static int ps3_reply_fifo_alloc(struct ps3_instance *instance) +static S32 ps3_reply_fifo_alloc(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = - irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - unsigned int i = 0; + U32 i = 0; - irq_context->reply_fifo_size = - sizeof(struct PS3ReplyWord) * irq_context->reply_fifo_depth; + irq_context->reply_fifo_size = sizeof(struct PS3ReplyWord) * + irq_context->reply_fifo_depth; for (; i < irq_context->valid_msix_vector_count; i++) { - virt_base[i] = (struct PS3ReplyWord *)ps3_dma_alloc_coherent( - instance, irq_context->reply_fifo_size, - (unsigned long long *)&phys_base[i]); + virt_base[i] = (struct PS3ReplyWord*) + ps3_dma_alloc_coherent(instance, + irq_context->reply_fifo_size, + &phys_base[i]); if (virt_base[i] == NULL) { - LOG_ERROR("host_no:%u ps3_dma_pool_zalloc fail!\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u ps3_dma_pool_zalloc fail! \n", + PS3_HOST(instance)); goto l_failed; } memset(virt_base[i], 0xff, irq_context->reply_fifo_size); @@ -1292,33 +1299,36 @@ static int ps3_reply_fifo_alloc(struct ps3_instance *instance) static void ps3_reply_fifo_free(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = - irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - unsigned int i = 0; + U32 i = 0; for (; i < irq_context->valid_msix_vector_count; i++) { - if (virt_base[i] == NULL) + + if (virt_base[i] == NULL) { continue; + } - ps3_dma_free_coherent(instance, irq_context->reply_fifo_size, - virt_base[i], phys_base[i]); + ps3_dma_free_coherent(instance, + irq_context->reply_fifo_size, + virt_base[i], + phys_base[i]); virt_base[i] = NULL; phys_base[i] = 0; } + + return; } -static inline int ps3_irq_group_affinity_alloc(struct ps3_instance *instance) +static inline S32 ps3_irq_group_affinity_alloc(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - unsigned int size = - sizeof(GROUP_AFFINITY) * irq_context->valid_msix_vector_count; + U32 size = sizeof(GROUP_AFFINITY) * irq_context->valid_msix_vector_count; irq_context->group_affinity = ps3_kzalloc(instance, size); if (irq_context->group_affinity == NULL) { - LOG_ERROR("host_no:%u, group_affinity alloc failed\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u, group_affinity alloc failed\n", PS3_HOST(instance)); return -PS3_FAILED; } return PS3_SUCCESS; @@ -1332,16 +1342,19 @@ static inline void ps3_irq_group_affinity_free(struct ps3_instance *instance) } } -static int ps3_irq_resource_alloc(struct ps3_instance *instance) +static S32 ps3_irq_resource_alloc(struct ps3_instance *instance) { - if (ps3_reply_fifo_desc_alloc(instance) != PS3_SUCCESS) + if (ps3_reply_fifo_desc_alloc(instance) != PS3_SUCCESS) { goto l_failed; + } - if (ps3_reply_fifo_alloc(instance) != PS3_SUCCESS) + if (ps3_reply_fifo_alloc(instance) != PS3_SUCCESS) { goto l_failed; + } - if (ps3_irq_group_affinity_alloc(instance) != PS3_SUCCESS) + if (ps3_irq_group_affinity_alloc(instance) != PS3_SUCCESS) { goto l_failed; + } return PS3_SUCCESS; @@ -1355,6 +1368,8 @@ static void ps3_irq_resource_free(struct ps3_instance *instance) ps3_irq_group_affinity_free(instance); ps3_reply_fifo_free(instance); ps3_reply_fifo_desc_free(instance); + + return; } static void ps3_reply_fifo_desc_set(struct ps3_instance *instance) @@ -1362,31 +1377,33 @@ static void ps3_reply_fifo_desc_set(struct ps3_instance *instance) struct ps3_irq_context *irq_context = &instance->irq_context; struct PS3ReplyFifoDesc *desc_buf = irq_context->reply_fifo_desc_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - unsigned int i = 0; + U32 i = 0; for (; i < irq_context->valid_msix_vector_count; i++) { desc_buf[i].ReplyFifoBaseAddr = cpu_to_le64(phys_base[i]); desc_buf[i].irqNo = i; - desc_buf[i].depthReplyFifo = - (unsigned short)irq_context->reply_fifo_depth; + desc_buf[i].depthReplyFifo = (U16)irq_context->reply_fifo_depth; - if (i < irq_context->high_iops_msix_vectors) + if (i < irq_context->high_iops_msix_vectors) { desc_buf[i].isHighIops = PS3_TRUE; - else + } else { desc_buf[i].isHighIops = PS3_FALSE; + } } + + return; } -int ps3_irq_context_init(struct ps3_instance *instance) +S32 ps3_irq_context_init(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - unsigned int max_vectors = 0; - - if (!ps3_irq_max_vectors_calc(instance, &max_vectors)) + U32 max_vectors = 0; + if (!ps3_irq_max_vectors_calc(instance, &max_vectors)) { goto l_failed; + } if (!ps3_ioc_mgr_max_fw_cmd_get(instance, - &irq_context->reply_fifo_depth)) { + &irq_context->reply_fifo_depth)) { goto l_failed; } @@ -1395,12 +1412,11 @@ int ps3_irq_context_init(struct ps3_instance *instance) irq_context->high_iops_msix_vectors = 0; - LOG_INFO("max_vectors:%d replyQ_depth:%d\n", max_vectors, - irq_context->reply_fifo_depth); + LOG_INFO("max_vectors:%d replyQ_depth:%d\n", + max_vectors, irq_context->reply_fifo_depth); if (max_vectors <= instance->min_intr_count) { - LOG_ERROR( - "host_no:%u alloc irq failed![cpunum:%d][irq_type:%d][min_intr:%d]\n", + LOG_ERROR("host_no:%u alloc irq failed![cpunum:%d][irq_type:%d][min_intr:%d] \n", PS3_HOST(instance), num_online_cpus(), irq_context->pci_irq_type, instance->min_intr_count); goto l_failed; @@ -1408,8 +1424,9 @@ int ps3_irq_context_init(struct ps3_instance *instance) irq_context->pci_irq_type = instance->pci_dev_context.pci_irq_type; irq_context->valid_msix_vector_count = max_vectors; - if (ps3_irq_resource_alloc(instance) != PS3_SUCCESS) + if (ps3_irq_resource_alloc(instance) != PS3_SUCCESS) { goto l_failed; + } ps3_reply_fifo_desc_set(instance); @@ -1420,40 +1437,46 @@ int ps3_irq_context_init(struct ps3_instance *instance) return -PS3_FAILED; } -int ps3_irq_context_exit(struct ps3_instance *instance) +S32 ps3_irq_context_exit(struct ps3_instance *instance) { ps3_irq_resource_free(instance); return PS3_SUCCESS; } -unsigned char ps3_irqs_service(void *priv, unsigned long irq_no) +U8 ps3_irqs_service(void *priv, ULong irq_no) { - struct ps3_instance *instance = (struct ps3_instance *)priv; - unsigned int isrSN = (unsigned int)irq_no; - - if (isrSN >= instance->irq_context.valid_msix_vector_count) + struct ps3_instance *instance = (struct ps3_instance*)priv; + U32 isrSN = (U32)irq_no; + if (isrSN >= instance->irq_context.valid_msix_vector_count) { goto l_out; + } - if (!instance->irq_context.is_enable_interrupts) + if (!instance->irq_context.is_enable_interrupts) { goto l_out; + } - StorPortIssueDpc(instance, &instance->irq_context.irqs[isrSN].dpc, - &instance->irq_context.irqs[isrSN].isrSN, NULL); + StorPortIssueDpc(instance, + &instance->irq_context.irqs[isrSN].dpc, + &instance->irq_context.irqs[isrSN].isrSN, + NULL); l_out: return PS3_TRUE; } -static void ps3_irq_dpc_routine(PSTOR_DPC dpc, void *context, void *isr_no, - void *arg) +static void ps3_irq_dpc_routine(PSTOR_DPC dpc, + void *context, + void *isr_no, + void *arg +) { - struct ps3_instance *instance = (struct ps3_instance *)context; - unsigned int isrSN = *((unsigned int *)isr_no); + struct ps3_instance *instance = (struct ps3_instance*)context; + U32 isrSN = *((U32*)isr_no); struct ps3_irq *irqs = &instance->irq_context.irqs[isrSN]; - (void)arg; (void)dpc; + LOG_DEBUG("%d\n", isrSN); irqs->is_dpc_running = PS3_TRUE; @@ -1462,22 +1485,22 @@ static void ps3_irq_dpc_routine(PSTOR_DPC dpc, void *context, void *isr_no, irqs->is_dpc_running = PS3_FALSE; } -int ps3_irqs_dpc_init(struct ps3_instance *instance) +S32 ps3_irqs_dpc_init(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = NULL; - unsigned int i = 0; + U32 i = 0; irqs = irq_context->irqs; if (irq_context->irqs == NULL) { - LOG_ERROR("host_no:%u irqs fail!\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u irqs fail! \n", + PS3_HOST(instance)); goto l_out; } for (i = 0; i < irq_context->valid_msix_vector_count; i++) { irqs[i].is_dpc_running = PS3_FALSE; - StorPortInitializeDpc(instance, &irqs[i].dpc, - ps3_irq_dpc_routine); + StorPortInitializeDpc(instance, &irqs[i].dpc, ps3_irq_dpc_routine); } instance->ioc_adpter->irq_disable(instance); return PS3_SUCCESS; @@ -1486,19 +1509,19 @@ int ps3_irqs_dpc_init(struct ps3_instance *instance) return -PS3_FAILED; } -int ps3_irqs_init(struct ps3_instance *instance) +S32 ps3_irqs_init(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = - irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; struct ps3_irq *irqs = NULL; - unsigned int i = 0; + U32 i = 0; - irq_context->irqs = (struct ps3_irq *)ps3_kcalloc( - instance, irq_context->valid_msix_vector_count, - sizeof(struct ps3_irq)); + irq_context->irqs = (struct ps3_irq*) + ps3_kcalloc(instance, irq_context->valid_msix_vector_count, + sizeof(struct ps3_irq)); if (irq_context->irqs == NULL) { - LOG_ERROR("host_no:%u kcalloc fail!\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u kcalloc fail! \n", + PS3_HOST(instance)); goto l_out; } irqs = irq_context->irqs; @@ -1518,19 +1541,19 @@ int ps3_irqs_init(struct ps3_instance *instance) return -PS3_FAILED; } -int ps3_irqs_init_switch(struct ps3_instance *instance) +S32 ps3_irqs_init_switch(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = - irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; struct ps3_irq *irqs = NULL; - unsigned int i = 0; + U32 i = 0; - irq_context->irqs = (struct ps3_irq *)ps3_kcalloc( - instance, irq_context->valid_msix_vector_count, - sizeof(struct ps3_irq)); + irq_context->irqs = (struct ps3_irq*) + ps3_kcalloc(instance, irq_context->valid_msix_vector_count, + sizeof(struct ps3_irq)); if (irq_context->irqs == NULL) { - LOG_ERROR("host_no:%u kcalloc fail!\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u kcalloc fail! \n", + PS3_HOST(instance)); goto l_out; } irqs = irq_context->irqs; @@ -1550,28 +1573,29 @@ int ps3_irqs_init_switch(struct ps3_instance *instance) return -PS3_FAILED; } -static void ps3_irq_dpc_sync(struct ps3_instance *instance, - struct ps3_irq *irqs) +static void ps3_irq_dpc_sync(struct ps3_instance *instance, struct ps3_irq *irqs) { - unsigned long status = STOR_STATUS_SUCCESS; - unsigned char cancel_ret = PS3_TRUE; + ULong status = STOR_STATUS_SUCCESS; + U8 cancel_ret = PS3_TRUE; if (irqs == NULL) { - LOG_ERROR("host_no:%u irqs fail!\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u irqs fail! \n", + PS3_HOST(instance)); goto l_out; } status = StorPortCancelDpc(instance, &irqs->dpc, &cancel_ret); if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("host_no:%u, cancel dpc failed,status:0x%x\n", - PS3_HOST(instance), status); + LOG_ERROR("host_no:%u, cancel dpc failed,status:0x%x\n", PS3_HOST(instance), status); } - if (cancel_ret) + if (cancel_ret) { goto l_out; + } - while (irqs->is_dpc_running) + while (irqs->is_dpc_running) { ps3_msleep(10); + } l_out: return; } @@ -1581,8 +1605,9 @@ void ps3_irqs_exit(struct ps3_instance *instance) struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = irq_context->irqs; - if (irqs == NULL) + if (irqs == NULL) { goto l_out; + } instance->ioc_adpter->irq_disable(instance); ps3_kfree(instance, irqs); @@ -1598,7 +1623,8 @@ void ps3_irqs_enable(struct ps3_instance *instance) LOG_DEBUG("host_no:%u irq enable\n", PS3_HOST(instance)); - switch (irq_context->pci_irq_type) { + switch (irq_context->pci_irq_type) + { case PS3_PCI_IRQ_LEGACY: ps3_ioc_legacy_irqs_enable(instance); break; @@ -1609,25 +1635,27 @@ void ps3_irqs_enable(struct ps3_instance *instance) ps3_ioc_msix_enable(instance); break; default: - LOG_ERROR("host_no:%u irq type is failed :%d\n", - PS3_HOST(instance), irq_context->pci_irq_type); + LOG_ERROR("host_no:%u irq type is failed :%d \n", + PS3_HOST(instance), irq_context->pci_irq_type); break; } irq_context->is_enable_interrupts = PS3_DRV_TRUE; - mb(); /* in order to force CPU ordering */ + mb(); + return; } void ps3_irqs_disable(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = irq_context->irqs; - unsigned int i = 0; - + U32 i = 0; LOG_DEBUG("host_no:%u irq disable\n", PS3_HOST(instance)); - if (irq_context->is_enable_interrupts == PS3_DRV_FALSE) + if(irq_context->is_enable_interrupts == PS3_DRV_FALSE) { goto l_out; - switch (irq_context->pci_irq_type) { + } + switch (irq_context->pci_irq_type) + { case PS3_PCI_IRQ_LEGACY: ps3_ioc_legacy_irqs_disable(instance); break; @@ -1638,19 +1666,21 @@ void ps3_irqs_disable(struct ps3_instance *instance) ps3_ioc_msix_disable(instance); break; default: - LOG_ERROR("host_no:%u irq type is failed :%d\n", - PS3_HOST(instance), irq_context->pci_irq_type); + LOG_ERROR("host_no:%u irq type is failed :%d \n", + PS3_HOST(instance), irq_context->pci_irq_type); break; } if (irqs == NULL) { - LOG_ERROR("host_no:%u irqs fail!\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u irqs fail! \n", + PS3_HOST(instance)); goto l_out; } - for (i = 0; i < irq_context->valid_msix_vector_count; i++) + for (i = 0; i < irq_context->valid_msix_vector_count; i++) { ps3_irq_dpc_sync(instance, &irqs[i]); + } irq_context->is_enable_interrupts = PS3_DRV_FALSE; - mb(); /* in order to force CPU ordering */ + mb(); l_out: return; @@ -1660,14 +1690,14 @@ void ps3_irqs_disable(struct ps3_instance *instance) void ps3_all_reply_fifo_init(struct ps3_instance *instance) { - unsigned int reply_fifo_size = sizeof(struct PS3ReplyWord) * - instance->irq_context.reply_fifo_depth; + U32 reply_fifo_size = sizeof(struct PS3ReplyWord) * + instance->irq_context.reply_fifo_depth; struct ps3_irq *irq = NULL; - unsigned int i = 0; - + U32 i = 0; LOG_DEBUG("host_no:%u start to reply fifo init!\n", PS3_HOST(instance)); - if (instance->irq_context.irqs == NULL) + if (instance->irq_context.irqs == NULL) { return; + } for (; i < instance->irq_context.valid_msix_vector_count; ++i) { irq = instance->irq_context.irqs + i; @@ -1675,4 +1705,7 @@ void ps3_all_reply_fifo_init(struct ps3_instance *instance) irq->last_reply_idx = 0; } LOG_DEBUG("host_no:%u end to reply fifo init!\n", PS3_HOST(instance)); + + return; } + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_irq.h b/drivers/scsi/linkdata/ps3stor/ps3_irq.h index d41c37b4af4b..1a5f65f0f04c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_irq.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_irq.h @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ #ifndef _PS3_IRQ_H_ #define _PS3_IRQ_H_ @@ -15,13 +13,21 @@ #include "ps3_err_def.h" #include "ps3_cmd_channel.h" #include "ps3_inner_data.h" -#include "ps3_kernel_version.h" -#define PS3_IRQ_NAME_LENGTH (32) -#define PS3_SWITCH_IRQ_INDEX (0) +#define PS3_IRQ_NAME_LENGTH (32) +#define PS3_SWITCH_IRQ_INDEX (0) struct ps3_instance; +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 2)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0))) +#define DRIVER_SUPPORT_KERNEL_IRQ_AFFINITY +#endif + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4,9,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) +#define PS3_OS_MANAGED_IRQ_SUPPORT +#endif + enum { PS3_PCI_IRQ_MODE_NONE_SPE = 0, PS3_PCI_IRQ_MODE_LEGACY = 1, @@ -34,83 +40,83 @@ struct ps3_irq { struct PS3ReplyWord *reply_fifo_virt_base_addr; struct ps3_instance *instance; - unsigned int irqNo; - unsigned int isrSN; - unsigned short last_reply_idx; - unsigned char reserved0[6]; + U32 irqNo; + U32 isrSN; + U16 last_reply_idx; + U8 reserved0[6]; #ifdef _WINDOWS STOR_DPC dpc; + volatile U8 is_dpc_running; #else struct irq_poll irqpoll; - unsigned char is_irq_poll_disabled; - unsigned int irq_poll_sched_threshold; - unsigned char is_sched_irq_poll; - unsigned char is_enable_irq; - unsigned char reserved1[2]; + Bool is_irq_poll_disabled; + U32 irq_poll_sched_threshold; + Bool is_sched_irq_poll; + Bool is_enable_irq; + U8 reserved1[2]; #endif - atomic_t is_busy; + ps3_atomic32 is_busy; }; struct ps3_irq_recovery { - unsigned int irqNo; - unsigned int isrSN; - unsigned char reserved0[8]; + U32 irqNo; + U32 isrSN; + U8 reserved0[8]; struct ps3_instance *instance; }; struct ps3_irq_context { struct ps3_instance *instance; - unsigned int reply_fifo_depth; - unsigned int valid_msix_vector_count; - unsigned int high_iops_msix_vectors; - unsigned int dump_isrSN; - unsigned int reply_fifo_desc_buf_size; + U32 reply_fifo_depth; + U32 valid_msix_vector_count; + U32 high_iops_msix_vectors; + U32 dump_isrSN; + U32 reply_fifo_desc_buf_size; #ifndef _WINDOWS struct dma_pool *reply_fifo_desc_buf_pool; #endif - unsigned int reply_fifo_size; + U32 reply_fifo_size; dma_addr_t reply_fifo_desc_buf_phys; struct PS3ReplyFifoDesc *reply_fifo_desc_buf; #ifndef _WINDOWS struct dma_pool *reply_fifo_pool; #endif - struct PS3ReplyWord - *reply_fifo_virt_base_addr_buf[PS3_MAX_REPLY_QUE_COUNT]; + struct PS3ReplyWord *reply_fifo_virt_base_addr_buf[PS3_MAX_REPLY_QUE_COUNT]; dma_addr_t reply_fifo_phys_base_addr_buf[PS3_MAX_REPLY_QUE_COUNT]; struct ps3_irq *irqs; #ifndef _WINDOWS - unsigned int *cpu_msix_table; + U32 *cpu_msix_table; atomic_t high_iops_io_count; - int cpu_msix_table_sz; + S32 cpu_msix_table_sz; #endif - unsigned char is_enable_interrupts; - unsigned char is_support_balance; - unsigned char is_balance_current_perf_mode; - unsigned char pci_irq_type; + Bool is_enable_interrupts; + Bool is_support_balance; + Bool is_balance_current_perf_mode; + U8 pci_irq_type; #ifdef _WINDOWS - PGROUP_AFFINITY group_affinity; + PGROUP_AFFINITY group_affinity; #endif - struct ps3_irq_recovery *irq_recovery; + struct ps3_irq_recovery * irq_recovery; }; -int ps3_irq_context_init(struct ps3_instance *instance); +S32 ps3_irq_context_init(struct ps3_instance *instance); -int ps3_irq_context_exit(struct ps3_instance *instance); +S32 ps3_irq_context_exit(struct ps3_instance *instance); -int ps3_irqs_dpc_init(struct ps3_instance *instance); +S32 ps3_irqs_dpc_init(struct ps3_instance *instance); -int ps3_irqs_init(struct ps3_instance *instance); +S32 ps3_irqs_init(struct ps3_instance *instance); -int ps3_irqs_init_switch(struct ps3_instance *instance); +S32 ps3_irqs_init_switch(struct ps3_instance *instance); void ps3_irqs_exit(struct ps3_instance *instance); #ifndef _WINDOWS -unsigned int ps3_msix_index_get(struct ps3_cmd *cmd, unsigned short pd_count); +U32 ps3_msix_index_get(struct ps3_cmd *cmd, U16 pd_count); -void ps3_perf_update(struct ps3_instance *instance, unsigned char iocPerfMode); +void ps3_perf_update(struct ps3_instance *instance, U8 iocPerfMode); #endif void ps3_irqs_enable(struct ps3_instance *instance); @@ -123,13 +129,13 @@ void ps3_irqs_sync(struct ps3_instance *instance); #ifndef _WINDOWS irqreturn_t ps3_irqs_service(int irq_so, void *priv); #else -unsigned char ps3_irqs_service(void *priv, unsigned long irq_no); +U8 ps3_irqs_service(void *priv, ULong irq_no); #endif #ifndef _WINDOWS int ps3_irqpoll_service(struct irq_poll *irqpoll, int budget); #endif -static inline unsigned char ps3_irq_busy_add(struct ps3_irq *irq) +static inline Bool ps3_irq_busy_add(struct ps3_irq *irq) { return ps3_atomic_add_unless(&irq->is_busy, 1, 1); } @@ -139,8 +145,7 @@ static inline void ps3_irq_busy_dec(struct ps3_irq *irq) ps3_atomic_dec(&irq->is_busy); } -static inline unsigned char -ps3_irq_is_enable(const struct ps3_irq_context *irq_ctx) +static inline Bool ps3_irq_is_enable(const struct ps3_irq_context *irq_ctx) { return (irq_ctx->is_enable_interrupts == PS3_DRV_TRUE); } @@ -148,7 +153,7 @@ ps3_irq_is_enable(const struct ps3_irq_context *irq_ctx) void ps3_all_reply_fifo_init(struct ps3_instance *instance); #ifndef _WINDOWS -static inline void ps3_irq_poll_sched(struct irq_poll *iop) +static inline void ps3_irq_poll_sched(struct irq_poll * iop) { #ifdef CONFIG_IRQ_POLL irq_poll_sched(iop); @@ -157,8 +162,7 @@ static inline void ps3_irq_poll_sched(struct irq_poll *iop) #endif } -static inline void ps3_irq_poll_init(struct irq_poll *iop, int weight, - irq_poll_fn *func) +static inline void ps3_irq_poll_init(struct irq_poll *iop, int weight, irq_poll_fn *func) { #ifdef CONFIG_IRQ_POLL irq_poll_init(iop, weight, func); @@ -169,7 +173,7 @@ static inline void ps3_irq_poll_init(struct irq_poll *iop, int weight, #endif } -static inline void ps3_irq_poll_complete(struct irq_poll *iop) +static inline void ps3_irq_poll_complete(struct irq_poll * iop) { #ifdef CONFIG_IRQ_POLL irq_poll_complete(iop); @@ -178,7 +182,7 @@ static inline void ps3_irq_poll_complete(struct irq_poll *iop) #endif } -static inline void ps3_irq_poll_enable(struct irq_poll *iop) +static inline void ps3_irq_poll_enable(struct irq_poll * iop) { #ifdef CONFIG_IRQ_POLL irq_poll_enable(iop); @@ -187,7 +191,7 @@ static inline void ps3_irq_poll_enable(struct irq_poll *iop) #endif } -static inline void ps3_irq_poll_disable(struct irq_poll *iop) +static inline void ps3_irq_poll_disable(struct irq_poll * iop) { #ifdef CONFIG_IRQ_POLL irq_poll_disable(iop); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_kernel_version.h b/drivers/scsi/linkdata/ps3stor/ps3_kernel_version.h deleted file mode 100644 index 7b5b6ed3b17a..000000000000 --- a/drivers/scsi/linkdata/ps3stor/ps3_kernel_version.h +++ /dev/null @@ -1,31 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ -#ifndef _PS3_KERNEL_VERSION_H_ -#define _PS3_KERNEL_VERSION_H_ - -#define DRIVER_SUPPORT_PRIV_BUSY -#define PS3_TRACK_QUEUE_DEPTH -#define PS3_SUPPORT_PCIE_REPORT -#define PS3_SUPPORT_CMD_SCP -#define PS3_SUPPORT_DRIVER_SENSE -#define PS3_SUPPORT_FS -#define PS3_DID_NEXUS_FAILURE -#define PS3_FALLTHROUGH -#define PS3_SYPPORT_BIO_ITER -#define PS3_AER_CLEAR_STATUS -#define PS3_LINUX_SIGNAL -#define DRIVER_SUPPORT_KERNEL_IRQ_AFFINITY -#define PS3_OS_MANAGED_IRQ_SUPPORT -#define PS3_CMD_CDB_CHECK -#include -#ifndef PS3_TAGSET_SUPPORT -#define PS3_TAGSET_SUPPORT -#endif -#define PS3_FSNOTIFY_FILE -#define PS3_KERNEL_WRITE_FILE -#define PS3_BLK_QUEUE_FLAG_CLEAR -#define PS3_STATIC_MINOR -#define PS3_SUPPORT_FLUSH_SCHEDULED -#define PS3_MAP_QUEUES_RET - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_load.c b/drivers/scsi/linkdata/ps3stor/ps3_load.c index 03aa9fa8c866..ed7c6308e05e 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_load.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_load.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #include "ps3_load.h" #include "ps3_instance_manager.h" #include "ps3_ioc_manager.h" @@ -12,249 +11,273 @@ #ifdef _WINDOWS -static int ps3_init_ioc_prepare(struct ps3_instance *instance); +static S32 ps3_init_ioc_prepare(struct ps3_instance *instance); static void ps3_init_ioc_prepare_exit(struct ps3_instance *instance); -static int ps3_init_ioc_complete(struct ps3_instance *instance); +static S32 ps3_init_ioc_complete(struct ps3_instance *instance); static void ps3_init_ioc_complete_exit(struct ps3_instance *instance); -static int ps3_pci_init_complete(struct ps3_instance *instance); +static S32 ps3_pci_init_complete(struct ps3_instance *instance); static void ps3_pci_init_complete_exit(struct ps3_instance *instance); -int ps3_firmware_init(struct ps3_instance *instance) +S32 ps3_firmware_init(struct ps3_instance *instance) { - ps3_ioc_adp_init(instance); + ps3_ioc_adp_init(instance); - if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != - PS3_SUCCESS) { - goto l_failed; - } - ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_READY); + if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != PS3_SUCCESS) { + goto l_failed; + } + ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_READY); - if (ps3_pci_init_complete(instance) != PS3_SUCCESS) - goto l_failed; + if (ps3_pci_init_complete(instance) != PS3_SUCCESS) { + goto l_failed; + } - if (ps3_init_ioc_prepare(instance) != PS3_SUCCESS) - goto l_failed; + if (ps3_init_ioc_prepare(instance) != PS3_SUCCESS) { + goto l_failed; + } - if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) - goto l_failed; - ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_PRE_OPERATIONAL); + if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) { + goto l_failed; + } + ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_PRE_OPERATIONAL); - if (ps3_ctrl_info_get(instance) != PS3_SUCCESS) - goto l_failed; + if (ps3_ctrl_info_get(instance) != PS3_SUCCESS) { + goto l_failed; + } - if (ps3_init_ioc_complete(instance) != PS3_SUCCESS) - goto l_failed; + if (ps3_init_ioc_complete(instance) != PS3_SUCCESS) { + goto l_failed; + } - ps3_ioctl_init(instance, PS3_MAX_IOCTL_CMDS); + ps3_ioctl_init(instance, PS3_MAX_IOCTL_CMDS); - return PS3_SUCCESS; + return PS3_SUCCESS; l_failed: - DbgPrint("fireware init failed\n"); - ps3_firmware_exit(instance); - return -PS3_FAILED; + DbgPrint("fireware init failed\n"); + ps3_firmware_exit(instance); + return -PS3_FAILED; } void ps3_firmware_exit(struct ps3_instance *instance) { - ps3_pci_init_complete_exit(instance); - ps3_init_ioc_complete_exit(instance); - ps3_init_ioc_prepare_exit(instance); + ps3_pci_init_complete_exit(instance); + ps3_init_ioc_complete_exit(instance); + ps3_init_ioc_prepare_exit(instance); + + return; } void ps3_remove(struct ps3_instance *instance) { - unsigned long flags = 0; + ULong flags = 0; + LOG_INFO("hno:%u ps3_remove\n", PS3_HOST(instance)); - LOG_INFO("hno:%u %s\n", PS3_HOST(instance), __func__); - instance->state_machine.is_load = PS3_FALSE; - instance->ioc_adpter->irq_disable(instance); + instance->state_machine.is_load = PS3_FALSE; + instance->ioc_adpter->irq_disable(instance); - ps3_watchdog_stop(instance); - ps3_recovery_context_exit(instance); + ps3_watchdog_stop(instance); - ps3_event_unsubscribe(instance); - ps3_spin_lock_irqsave(&instance->recov ery_context->recovery_lock, - &flags); - ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); - ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags); - ps3_dev_mgr_vd_info_unsubscribe(instance); + ps3_recovery_context_exit(instance); + + ps3_event_unsubscribe(instance); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); + instance->event_context.abort_eventcmd = 0; + instance->dev_context.abort_vdpending_cmd = 0; + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + ps3_dev_mgr_vd_info_unsubscribe(instance); #ifndef _WINDOWS - ps3_sas_device_data_exit(instance); + ps3_sas_device_data_exit(instance); #endif - ps3_device_mgr_data_exit(instance); + ps3_device_mgr_data_exit(instance); #ifndef _WINDOWS - if (ps3_sas_is_support_smp(instance)) - sas_remove_host(instance->host); - else - scsi_remove_host(instance->host); + if (ps3_sas_is_support_smp(instance)) { + sas_remove_host(instance->host); + } + else { + scsi_remove_host(instance->host); + } #else - ps3_device_unload_done(instance); + ps3_device_unload_done(instance); #endif - if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_REMOVE, - PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { - LOG_ERROR("hno:%u unload failed.\n", PS3_HOST(instance)); - if (ps3_ioc_hard_reset_to_ready(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u hard reset failed.\n", - PS3_HOST(instance)); - } - } + if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_REMOVE, PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { + LOG_ERROR("hno:%u unload failed.\n", PS3_HOST(instance)); + if (ps3_ioc_hard_reset_to_ready(instance) != PS3_SUCCESS) { + LOG_ERROR("hno:%u hard reset failed.\n", PS3_HOST(instance)); + } + } #ifndef _WINDOWS - ps3_irqs_sync(instance); - ps3_irqpolls_enable(instance); + ps3_irqs_sync(instance); + ps3_irqpolls_enable(instance); #endif - ps3_instance_state_transfer_to_quit(instance); + ps3_instance_state_transfer_to_quit(instance); - ps3_firmware_exit(instance); - ps3_pci_exit(instance); + ps3_firmware_exit(instance); + ps3_pci_exit(instance); #ifndef _WINDOWS - pci_set_drvdata(instance->pdev, NULL); - ps3_instance_put(instance); - scsi_host_put(instance->host); + pci_set_drvdata(instance->pdev, NULL); + ps3_instance_put(instance); + scsi_host_put(instance->host); - ps3_dma_dump_mapping(pdev); + ps3_dma_dump_mapping(pdev); #endif + return; } static void ps3_cmd_attr_context_init(struct ps3_instance *instance) { - unsigned int cmd_qdepth = 0; - - instance->cmd_attr.cur_can_que = - instance->cmd_context.max_scsi_cmd_count - - instance->cmd_context.max_r1x_cmd_count; + U32 cmd_qdepth = 0; + instance->cmd_attr.cur_can_que = + instance->cmd_context.max_scsi_cmd_count - + instance->cmd_context.max_r1x_cmd_count; #ifndef _WINDOWS - cmd_qdepth = ps3_throttle_qdepth_query(); - if ((cmd_qdepth != 0) && cmd_qdepth <= instance->cmd_attr.cur_can_que) { - instance->cmd_attr.throttle_que_depth = cmd_qdepth; - } else { - instance->cmd_attr.throttle_que_depth = - PS3_DEVICE_QDEPTH_DEFAULT_VALUE; - } + cmd_qdepth = ps3_throttle_qdepth_query(); + if ((cmd_qdepth != 0) && + cmd_qdepth <= instance->cmd_attr.cur_can_que) { + instance->cmd_attr.throttle_que_depth = cmd_qdepth; + } + else { + instance->cmd_attr.throttle_que_depth = + PS3_DEVICE_QDEPTH_DEFAULT_VALUE; + } #else - instance->cmd_attr.throttle_que_depth = PS3_DEVICE_QDEPTH_DEFAULT_VALUE; + instance->cmd_attr.throttle_que_depth = + PS3_DEVICE_QDEPTH_DEFAULT_VALUE; #endif - instance->cmd_attr.vd_io_threshold = 0; - instance->cmd_attr.is_support_direct_cmd = PS3_FALSE; + instance->cmd_attr.vd_io_threshold = 0; + instance->cmd_attr.is_support_direct_cmd = PS3_FALSE; } -static int ps3_init_ioc_prepare(struct ps3_instance *instance) +static S32 ps3_init_ioc_prepare(struct ps3_instance *instance) { - ps3_ioc_mgr_req_queue_lock_init(instance); - ps3_err_fault_context_init(instance); + ps3_ioc_mgr_req_queue_lock_init(instance); + ps3_err_fault_context_init(instance); - if (!ps3_ioc_fw_version_get(instance)) + if (!ps3_ioc_fw_version_get(instance)) { goto l_fail; + } - if (!ps3_ioc_state_halt_support_get(instance)) + if (!ps3_ioc_state_halt_support_get(instance)) { goto l_fail; + } - if (!ps3_ioc_recovery_support_get(instance)) + if (!ps3_ioc_recovery_support_get(instance)) { goto l_fail; + } - if (ps3_recovery_context_init(instance) != PS3_SUCCESS) - goto l_fail; + if (ps3_recovery_context_init(instance) != PS3_SUCCESS) { + goto l_fail; + } - if (ps3_ioc_init_cmd_context_init(instance) != PS3_SUCCESS) - goto l_fail; + if (ps3_ioc_init_cmd_context_init(instance) != PS3_SUCCESS) { + goto l_fail; + } - if (ps3_ctrl_info_buf_alloc(instance) != PS3_SUCCESS) - goto l_fail; + if (ps3_ctrl_info_buf_alloc(instance) != PS3_SUCCESS) { + goto l_fail; + } - if (ps3_cmd_context_init(instance) != PS3_SUCCESS) - goto l_fail; + if (ps3_cmd_context_init(instance) != PS3_SUCCESS) { + goto l_fail; + } - ps3_cmd_attr_context_init(instance); + ps3_cmd_attr_context_init(instance); - if (ps3_event_context_init(instance) != PS3_SUCCESS) - goto l_fail; + if (ps3_event_context_init(instance) != PS3_SUCCESS) { + goto l_fail; + } - if (ps3_cmd_statistics_init(instance) != PS3_SUCCESS) - goto l_fail; + if (ps3_cmd_statistics_init(instance) != PS3_SUCCESS) { + goto l_fail; + } - if (ps3_dump_init(instance) != PS3_SUCCESS) - goto l_fail; + if (ps3_dump_init(instance) != PS3_SUCCESS) { + goto l_fail; + } - return PS3_SUCCESS; + return PS3_SUCCESS; l_fail: - ps3_init_ioc_prepare_exit(instance); - return -PS3_FAILED; + ps3_init_ioc_prepare_exit(instance); + return -PS3_FAILED; } static void ps3_init_ioc_prepare_exit(struct ps3_instance *instance) { - ps3_ioc_init_cmd_context_exit(instance); - ps3_err_fault_context_exit(instance); - ps3_ctrl_info_buf_free(instance); - ps3_cmd_statistics_exit(instance); - ps3_event_context_exit(instance); - ps3_recovery_context_exit(instance); - ps3_cmd_context_exit(instance); + ps3_ioc_init_cmd_context_exit(instance); + ps3_err_fault_context_exit(instance); + ps3_ctrl_info_buf_free(instance); + ps3_cmd_statistics_exit(instance); + ps3_event_context_exit(instance); + ps3_recovery_context_exit(instance); + ps3_cmd_context_exit(instance); ps3_dump_dma_buf_free(instance); - ps3_dump_exit(instance); + ps3_dump_exit(instance); #ifndef _WINDOWS - (void)ps3_debug_mem_free(instance); + (void)ps3_debug_mem_free(instance); #endif } -static int ps3_init_ioc_complete(struct ps3_instance *instance) +static S32 ps3_init_ioc_complete(struct ps3_instance *instance) { - if (ps3_mgr_cmd_init(instance) != PS3_SUCCESS) - goto l_failed; + if (ps3_mgr_cmd_init(instance) != PS3_SUCCESS) { + goto l_failed; + } - if (ps3_device_mgr_init(instance) != PS3_SUCCESS) - goto l_failed; + if (ps3_device_mgr_init(instance) != PS3_SUCCESS) { + goto l_failed; + } #ifndef _WINDOWS - if (ps3_sas_device_mgr_init(instance) != PS3_SUCCESS) - goto l_failed; + if (ps3_sas_device_mgr_init(instance) != PS3_SUCCESS) { + goto l_failed; + } #endif - return PS3_SUCCESS; + return PS3_SUCCESS; l_failed: - ps3_init_ioc_complete_exit(instance); - return -PS3_FAILED; + ps3_init_ioc_complete_exit(instance); + return -PS3_FAILED; } static void ps3_init_ioc_complete_exit(struct ps3_instance *instance) { #ifndef _WINDOWS - ps3_sas_device_mgr_exit(instance); + ps3_sas_device_mgr_exit(instance); #endif - ps3_device_mgr_exit(instance); - ps3_mgr_cmd_exit(instance); + ps3_device_mgr_exit(instance); + ps3_mgr_cmd_exit(instance); + + return; } -static int ps3_pci_init_complete(struct ps3_instance *instance) +static S32 ps3_pci_init_complete(struct ps3_instance *instance) { - if (ps3_irq_context_init(instance) != PS3_SUCCESS) - goto l_failed; - if (instance->ioc_adpter->irq_init) { - if (instance->ioc_adpter->irq_init(instance) != PS3_SUCCESS) - goto l_failed; - } else { - if (ps3_irqs_init(instance) != PS3_SUCCESS) - goto l_failed; - } + if (ps3_irq_context_init(instance) != PS3_SUCCESS) { + goto l_failed; + } + if (instance->ioc_adpter->irq_init) { + if (instance->ioc_adpter->irq_init(instance) != PS3_SUCCESS) { + goto l_failed; + } + } else { + if (ps3_irqs_init(instance) != PS3_SUCCESS) { + goto l_failed; + } + } - return PS3_SUCCESS; + return PS3_SUCCESS; l_failed: - ps3_pci_init_complete_exit(instance); - return -PS3_FAILED; + ps3_pci_init_complete_exit(instance); + return -PS3_FAILED; } static void ps3_pci_init_complete_exit(struct ps3_instance *instance) { - ps3_irqs_exit(instance); - ps3_irq_context_exit(instance); + ps3_irqs_exit(instance); + ps3_irq_context_exit(instance); } #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_load.h b/drivers/scsi/linkdata/ps3stor/ps3_load.h index d703519de236..c4bbe475e801 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_load.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_load.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_LOAD_H_ #define _PS3_LOAD_H_ @@ -9,7 +8,7 @@ struct ps3_instance; -int ps3_firmware_init(struct ps3_instance *instance); +S32 ps3_firmware_init(struct ps3_instance *instance); void ps3_firmware_exit(struct ps3_instance *instance); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.c b/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.c index 0d04dbc3476b..79d0e7e15a02 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #ifdef _WINDOWS #include "ps3_def.h" @@ -30,51 +29,49 @@ #include "ps3_driver_log.h" #include "ps3_instance_manager.h" #include "ps3_cmd_statistics.h" -#include "ps3_kernel_version.h" +#include "ps3_err_inject.h" #ifndef _WINDOWS -#if defined(PS3_LINUX_SIGNAL) +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4,9,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) #include #else #include #endif #endif -#define CMD_MAX_RETRY_COUNT (10) +#define CMD_MAX_RETRY_COUNT (10) -#define SEND_IOCTL_CMD_CHECK(instance, cmd) \ - ((PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) && (instance)->is_support_irq) +#define SEND_IOCTL_CMD_CHECK(instance, cmd) ((PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL)\ + && (instance)->is_support_irq) -static inline unsigned char is_interrupt_signal(struct task_struct *p) +static inline Bool is_interrupt_signal(struct task_struct *p) { if (sigismember(&p->pending.signal, SIGINT) || - sigismember(&p->pending.signal, SIGKILL) || - sigismember(&p->pending.signal, SIGQUIT)) { + sigismember(&p->pending.signal, SIGKILL) || + sigismember(&p->pending.signal, SIGQUIT)) { return PS3_TRUE; } return PS3_FALSE; } void ps3_wait_cmd_for_completion_interrupt(struct ps3_instance *instance, - struct ps3_cmd *cmd) + struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - unsigned long flags = 0; - unsigned char is_send_cancel = PS3_FALSE; - int cur_state = PS3_INSTANCE_STATE_INIT; - int retry_count = 0; - - while (1) { + S32 ret = PS3_SUCCESS; + ULong flags = 0; + Bool is_send_cancel = PS3_FALSE; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + S32 retry_count = 0; + + while(1) { + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_FORCE_DONE, cmd) ret = wait_for_completion_interruptible(&cmd->sync_done); + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_INTERRUPT, &ret) if (ret == PS3_SUCCESS) { - LOG_DEBUG( - "host_no:%u wait_for_completion_interrupted success\n", + LOG_DEBUG("host_no:%u wait_for_completion_interrupted success\n", PS3_HOST(instance)); - if ((cmd->resp_frame->normalRespFrame.respStatus == - PS3_DRV_MGR_BUSY) && - is_send_cancel) { - cmd->resp_frame->normalRespFrame.respStatus = - PS3_MGR_REC_FORCE; + if((cmd->resp_frame->normalRespFrame.respStatus == PS3_DRV_MGR_BUSY) && is_send_cancel) { + cmd->resp_frame->normalRespFrame.respStatus = PS3_MGR_REC_FORCE; } break; } @@ -82,112 +79,104 @@ void ps3_wait_cmd_for_completion_interrupt(struct ps3_instance *instance, ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); ret = signal_pending(current); - if (!ret) { + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_PENDING, &ret) + if(!ret) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); ps3_msleep(100); continue; } ret = is_interrupt_signal(current); + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_SIG_INTERRUPT, &ret) if (ret) { - cur_state = - ps3_atomic_read(&instance->state_machine.state); + cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_DEAD) { - LOG_INFO_IN_IRQ( - instance, "host_no:%u cur_state:%s\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state)); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, - flags); + cur_state == PS3_INSTANCE_STATE_DEAD) { + LOG_INFO_IN_IRQ(instance, "host_no:%u cur_state:%s\n", + PS3_HOST(instance),namePS3InstanceState(cur_state)); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); break; } ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_INFO_LIM( - "host_no:%u wait_for_completion_interrupted by SIG INT OR KILL, QUIT\n", + LOG_INFO_LIM("host_no:%u wait_for_completion_interrupted by SIG INT OR KILL, QUIT\n", PS3_HOST(instance)); - if (is_send_cancel) { + if(is_send_cancel) { ps3_msleep(100); continue; } is_send_cancel = PS3_TRUE; cancel: ret = ps3_mgr_cmd_cancel(instance, cmd->index); + INJECT_START(PS3_ERR_IJ_FORCE_CANCEL_CMD_RET_RECOVERY, &ret); + INJECT_START(PS3_ERR_IJ_FORCE_CANCEL_CMD_PCIE_ERR, &ret); if (ret != PS3_SUCCESS) { if (ret == -PS3_RECOVERED) { - LOG_INFO_LIM( - "host_no:%u cancel cmd %u send failed, wait\n", + LOG_INFO_LIM("host_no:%u cancel cmd %u send failed, wait\n", PS3_HOST(instance), cmd->index); ps3_msleep(100); continue; - } else if (ret == -PS3_EBUSY) { + } else if(ret == -PS3_EBUSY) { ps3_msleep(100); - if (retry_count++ < - CMD_MAX_RETRY_COUNT) { + if(retry_count++ < CMD_MAX_RETRY_COUNT) { goto cancel; } continue; } - LOG_INFO( - "host_no:%u cancel cmd %u failed, QUIT, ret:%d\n", + LOG_INFO("host_no:%u cancel cmd %u failed, QUIT, ret:%d\n", PS3_HOST(instance), cmd->index, ret); } else { - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, - &flags); + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, - flags); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } break; + } else { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + ps3_msleep(100); } - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - ps3_msleep(100); } + + return ; } -static int ps3_mgr_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd) +static S32 ps3_mgr_cmd_send(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - int cur_state = PS3_INSTANCE_STATE_INIT; + S32 ret = PS3_SUCCESS; + S32 cur_state = PS3_INSTANCE_STATE_INIT; if (!instance->state_machine.is_load) { - if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT) { - LOG_WARN( - "host_no:%u instance state is unloading or suspend\n", + if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT){ + LOG_WARN("host_no:%u instance state is unloading or suspend\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } } + INJECT_START(PS3_ERR_IJ_IOCTL_WAIT_UNNORMAL, instance) + INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, instance) if (!ps3_is_instance_state_allow_cmd_execute(instance)) { - LOG_WARN("host_no:%u cannot send block cmd\n", - PS3_HOST(instance)); + LOG_WARN("host_no:%u cannot send block cmd\n", PS3_HOST(instance)); ret = -PS3_RECOVERED; if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) { - cur_state = - ps3_atomic_read(&instance->state_machine.state); + cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_DEAD) { - LOG_WARN("host_no:%u cur_state:%s\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state)); + cur_state == PS3_INSTANCE_STATE_DEAD) { + LOG_WARN("host_no:%u cur_state:%s\n", PS3_HOST(instance),namePS3InstanceState(cur_state)); goto l_out; } - cmd->resp_frame->normalRespFrame.respStatus = - PS3_DRV_MGR_BUSY; - LOG_WARN( - "host_no:%u ioctl cannot send block cmd:%u,resp:%d, will retry\n", - PS3_HOST(instance), cmd->index, - cmd->resp_frame->normalRespFrame.respStatus); + cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; + LOG_WARN("host_no:%u ioctl cannot send block cmd:%u,resp:%d, will retry\n", + PS3_HOST(instance), cmd->index, cmd->resp_frame->normalRespFrame.respStatus); ret = -PS3_RESP_ERR; } goto l_out; } + INJECT_START(PS3_ERR_IJ_PCI_ERR_RECOVERY, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN( - "host_no:%u cannot send block cmd due to pci recovery\n", + LOG_WARN("host_no:%u cannot send block cmd due to pci recovery\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; @@ -196,41 +185,37 @@ static int ps3_mgr_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd) PS3_MGR_CMD_STAT_INC(instance, cmd); LOG_FILE_INFO("host_no:%u CFID:%d trace_id:0x%llx ready send\n", - PS3_HOST(instance), cmd->cmd_word.cmdFrameID, - cmd->trace_id); + PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id); LOG_DEBUG("host_no:%u req cmd info:\n" - "\t reqFrameBufBase = 0x%llx, function = %d\n", - PS3_HOST(instance), - cpu_to_le64(instance->cmd_context.req_frame_buf_phys), - ps3_get_pci_function(instance->pdev)); + "\t reqFrameBufBase = 0x%llx, function = %d\n", + PS3_HOST(instance), + cpu_to_le64(instance->cmd_context.req_frame_buf_phys), + ps3_get_pci_function(instance->pdev)); instance->ioc_adpter->cmd_send(instance, &cmd->cmd_word); l_out: return ret; } -static int ps3_blocked_unload_cmd_send(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static S32 ps3_blocked_unload_cmd_send(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - + S32 ret = PS3_SUCCESS; PS3_MGR_CMD_STAT_INC(instance, cmd); instance->ioc_adpter->cmd_send(instance, &cmd->cmd_word); ret = ps3_block_cmd_wait(instance, cmd, 0); + INJECT_START(PS3_ERR_IJ_UNLOAD_TIMEOUT, &ret) LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx ret:%d\n", - PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id, - ret); + PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id, ret); return ret; } -static int ps3_blocked_cmd_wake(struct ps3_cmd *cmd) +static S32 ps3_blocked_cmd_wake(struct ps3_cmd *cmd) { - unsigned long flags = 0; - + ULong flags = 0; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); if (cmd->cmd_state.state == PS3_CMD_STATE_DEAD) { - LOG_WARN_IN_IRQ( - cmd->instance, + LOG_WARN_IN_IRQ(cmd->instance, "host_no:%u CFID:%d trace_id:0x%llx dead free\n", PS3_HOST(cmd->instance), cmd->index, cmd->trace_id); @@ -243,11 +228,11 @@ static int ps3_blocked_cmd_wake(struct ps3_cmd *cmd) cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; complete(&cmd->sync_done); + INJECT_START(PS3_ERR_IJ_IGNORE_TASK_ABORT, cmd); PS3_MGR_CMD_BACK_INC(cmd->instance, cmd, 0); } else { - LOG_ERROR_IN_IRQ( - cmd->instance, + LOG_ERROR_IN_IRQ(cmd->instance, "host_no:%u CFID:%d trace_id:0x%llx repeat reply\n", PS3_HOST(cmd->instance), cmd->index, cmd->trace_id); } @@ -257,28 +242,27 @@ static int ps3_blocked_cmd_wake(struct ps3_cmd *cmd) return PS3_SUCCESS; } -static int ps3_polled_cmd_send(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static S32 ps3_polled_cmd_send(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; if (!instance->state_machine.is_load) { - if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT) { - LOG_WARN( - "host_no:%u instance state is unloading or suspend\n", + if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT){ + LOG_WARN("host_no:%u instance state is unloading or suspend\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } } + INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, instance); if (!ps3_is_instance_state_allow_cmd_execute(instance)) { ret = -PS3_RECOVERED; goto l_out; } if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN( - "host_no:%u cannot send block cmd due to pci recovery\n", + LOG_WARN("host_no:%u cannot send block cmd due to pci recovery\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; @@ -289,95 +273,99 @@ static int ps3_polled_cmd_send(struct ps3_instance *instance, l_out: return ret; } -static int ps3_polled_unload_cmd_send(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static S32 ps3_polled_unload_cmd_send(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; PS3_MGR_CMD_STAT_INC(instance, cmd); instance->ioc_adpter->cmd_send(instance, &cmd->cmd_word); ret = ps3_cmd_reply_polling(instance, cmd, 0, PS3_TRUE); + INJECT_START(PS3_ERR_IJ_UNLOAD_TIMEOUT, &ret) if (ret != -PS3_TIMEOUT) { - PS3_MGR_CMD_BACK_INC(instance, cmd, - (ret == PS3_SUCCESS) ? - PS3_REPLY_WORD_FLAG_SUCCESS : - PS3_REPLY_WORD_FLAG_FAIL); + PS3_MGR_CMD_BACK_INC(instance, cmd, (ret == PS3_SUCCESS) ? + PS3_REPLY_WORD_FLAG_SUCCESS : PS3_REPLY_WORD_FLAG_FAIL); } return ret; } -static int ps3_blocked_cmd_cb(struct ps3_cmd *cmd, unsigned short reply_flags) +static S32 ps3_blocked_cmd_cb(struct ps3_cmd *cmd, U16 reply_flags) { - if ((cmd->req_frame->mgrReq.reqHead.noReplyWord == - PS3_CMD_WORD_NEED_REPLY_WORD) && - (reply_flags == PS3_REPLY_WORD_FLAG_SUCCESS)) { + if((cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) + && (reply_flags == PS3_REPLY_WORD_FLAG_SUCCESS)) { cmd->resp_frame->normalRespFrame.respStatus = SCSI_STATUS_GOOD; } return ps3_blocked_cmd_wake(cmd); } -int ps3_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) +S32 ps3_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) { - if ((cmd->is_force_polling == 0 && - ps3_irq_is_enable(&cmd->instance->irq_context)) || - SEND_IOCTL_CMD_CHECK(instance, cmd)) { + if ((cmd->is_force_polling == 0 && ps3_irq_is_enable(&cmd->instance->irq_context)) + || SEND_IOCTL_CMD_CHECK(instance, cmd)){ + INJECT_START(PS3_ERR_IJ_SEND_IOCTL_BLOCK_MODE_FLAG, cmd); cmd->cmd_receive_cb = ps3_blocked_cmd_cb; - cmd->req_frame->mgrReq.reqHead.noReplyWord = - PS3_CMD_WORD_NEED_REPLY_WORD; + cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; return ps3_mgr_cmd_send(instance, cmd); + } else { + cmd->cmd_receive_cb = NULL; + cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NO_REPLY_WORD; + return ps3_polled_cmd_send(instance, cmd); } - cmd->cmd_receive_cb = NULL; - cmd->req_frame->mgrReq.reqHead.noReplyWord = - PS3_CMD_WORD_NO_REPLY_WORD; - return ps3_polled_cmd_send(instance, cmd); } -int ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) +S32 ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == - PS3_CMD_WORD_NEED_REPLY_WORD) { + S32 ret = PS3_SUCCESS; + + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { + INJECT_START(PS3_ERR_IJ_ABORT_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_RESET_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_ABORT_CMD_NORMAL, cmd); + INJECT_START(PS3_ERR_IJ_RESET_CMD_NORMAL, cmd); + INJECT_START(PS3_ERR_IJ_SMP_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_PHY_CTRL_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_PD_LIST_RESP_RETRY, cmd); ret = ps3_block_cmd_wait(instance, cmd, 0); + INJECT_START(PS3_ERR_IJ_PD_LIST_CMD_NO_RESP, &ret); } else { + INJECT_START(PS3_ERR_IJ_ABORT_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_RESET_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_ABORT_CMD_NORMAL, cmd); + INJECT_START(PS3_ERR_IJ_RESET_CMD_NORMAL, cmd); ret = ps3_cmd_reply_polling(instance, cmd, 0, PS3_FALSE); if (ret != -PS3_TIMEOUT) { - PS3_MGR_CMD_BACK_INC( - instance, cmd, - (ret == PS3_SUCCESS) ? - PS3_REPLY_WORD_FLAG_SUCCESS : - PS3_REPLY_WORD_FLAG_FAIL); + PS3_MGR_CMD_BACK_INC(instance, cmd, (ret == PS3_SUCCESS) ? + PS3_REPLY_WORD_FLAG_SUCCESS : PS3_REPLY_WORD_FLAG_FAIL); } } LOG_FILE_INFO("host_no:%u CFID:%d trace_id:0x%llx recv ret:%d\n", - PS3_HOST(instance), cmd->cmd_word.cmdFrameID, - cmd->trace_id, ret); + PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id, ret); return ret; } -int ps3_unload_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) +S32 ps3_unload_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) { if (cmd->is_force_polling == 0 && - ps3_irq_is_enable(&cmd->instance->irq_context)) { + ps3_irq_is_enable(&cmd->instance->irq_context)) { cmd->cmd_receive_cb = ps3_blocked_cmd_cb; - cmd->req_frame->mgrReq.reqHead.noReplyWord = - PS3_CMD_WORD_NEED_REPLY_WORD; + cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; return ps3_blocked_unload_cmd_send(instance, cmd); + } else { + cmd->cmd_receive_cb = NULL; + cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NO_REPLY_WORD; + return ps3_polled_unload_cmd_send(instance, cmd); } - cmd->cmd_receive_cb = NULL; - cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NO_REPLY_WORD; - return ps3_polled_unload_cmd_send(instance, cmd); } -int ps3_cmd_no_block_send(struct ps3_instance *instance, struct ps3_cmd *cmd) +S32 ps3_cmd_no_block_send(struct ps3_instance *instance, struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; cmd->cmd_receive_cb = ps3_blocked_cmd_cb; - cmd->req_frame->mgrReq.reqHead.noReplyWord = - PS3_CMD_WORD_NEED_REPLY_WORD; + cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; if (!ps3_is_instance_state_allow_cmd_execute(instance)) { ret = -PS3_FAILED; @@ -391,32 +379,28 @@ int ps3_cmd_no_block_send(struct ps3_instance *instance, struct ps3_cmd *cmd) return ret; } -int ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, - unsigned long timeout) +S32 ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, ULong timeout) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; if (cmd->is_interrupt) { #ifdef WINDOWS_DELAY ps3_wait_cmd_for_completion_interrupt(instance, cmd); #endif } else { - ret = ps3_wait_cmd_for_completion_timeout(instance, cmd, - timeout); + ret = ps3_wait_cmd_for_completion_timeout(instance, cmd, timeout); if (ret == -PS3_TIMEOUT) { - LOG_ERROR( - "host_no:%u CFID:%d trace_id:0x%llx time out\n", - PS3_HOST(instance), cmd->cmd_word.cmdFrameID, - cmd->trace_id); + LOG_ERROR("host_no:%u CFID:%d trace_id:0x%llx time out\n", + PS3_HOST(instance), + cmd->cmd_word.cmdFrameID, cmd->trace_id); goto l_out; } } if (cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { - LOG_INFO( - "host_no:%u CFID:%d trace_id:0x%llx not complete,state:%u\n", - PS3_HOST(instance), cmd->cmd_word.cmdFrameID, - cmd->trace_id, cmd->cmd_state.state); + LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx not complete,state:%u\n", + PS3_HOST(instance), + cmd->cmd_word.cmdFrameID, cmd->trace_id, cmd->cmd_state.state); ret = -PS3_TIMEOUT; goto l_out; } @@ -424,15 +408,16 @@ int ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, if (ps3_cmd_resp_status(cmd) != SCSI_STATUS_GOOD) { ret = -PS3_RESP_ERR; LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx resp err:0x%x\n", - PS3_HOST(instance), cmd->cmd_word.cmdFrameID, - cmd->trace_id, ps3_cmd_resp_status(cmd)); + PS3_HOST(instance), + cmd->cmd_word.cmdFrameID, cmd->trace_id, + ps3_cmd_resp_status(cmd)); } l_out: return ret; } -int ps3_cmd_send_async(struct ps3_instance *instance, struct ps3_cmd *cmd, - int (*cmd_receive_cb)(struct ps3_cmd *, unsigned short)) +S32 ps3_cmd_send_async(struct ps3_instance *instance, struct ps3_cmd *cmd, + S32 (*cmd_receive_cb)(struct ps3_cmd *, U16)) { cmd->cmd_receive_cb = cmd_receive_cb; PS3_MGR_CMD_STAT_INC(instance, cmd); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.h b/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.h index 3bc7f2080197..2b407a6e11b4 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.h @@ -1,33 +1,27 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_MGR_CHANNEL_H_ #define _PS3_MGR_CHANNEL_H_ #include "ps3_cmd_channel.h" -int ps3_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); -int ps3_unload_cmd_send_sync(struct ps3_instance *instance, - struct ps3_cmd *cmd); -int ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, - unsigned long timeout); -int ps3_cmd_send_async(struct ps3_instance *instance, struct ps3_cmd *cmd, - int (*cmd_receive_cb)(struct ps3_cmd *, unsigned short)); +S32 ps3_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); +S32 ps3_unload_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); +S32 ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, ULong timeout); +S32 ps3_cmd_send_async(struct ps3_instance *instance, struct ps3_cmd *cmd, +S32 (*cmd_receive_cb)(struct ps3_cmd *, U16)); -int ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); +S32 ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); -int ps3_cmd_no_block_send(struct ps3_instance *instance, struct ps3_cmd *cmd); +S32 ps3_cmd_no_block_send(struct ps3_instance *instance, struct ps3_cmd *cmd); #ifndef _WINDOWS -void ps3_wait_cmd_for_completion_interrupt(struct ps3_instance *instance, - struct ps3_cmd *cmd); +void ps3_wait_cmd_for_completion_interrupt(struct ps3_instance *instance, struct ps3_cmd *cmd); #endif -static inline union PS3RespFrame *ps3_cmd_resp_frame_get(struct ps3_cmd *cmd) -{ +static inline PS3RespFrame_u * ps3_cmd_resp_frame_get(struct ps3_cmd *cmd){ return cmd->resp_frame; } -static inline unsigned int ps3_cmd_resp_status(struct ps3_cmd *cmd) -{ +static inline U32 ps3_cmd_resp_status(struct ps3_cmd *cmd){ return le32_to_cpu(cmd->resp_frame->normalRespFrame.respStatus); }; diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.c b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.c index 7ffdbef66ffd..92ff324046c6 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #ifndef _WINDOWS #include #include @@ -24,22 +23,22 @@ #include "ps3_scsih.h" #include "ps3_util.h" #include "ps3_ioc_manager.h" +#include "ps3_err_inject.h" #include "ps3_ioc_state.h" #include "ps3_ioctl.h" -static int ps3_mgr_cmd_sync_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd, unsigned short time_out); +static S32 ps3_mgr_cmd_sync_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd, U16 time_out); -int ps3_ctrl_info_buf_alloc(struct ps3_instance *instance) +S32 ps3_ctrl_info_buf_alloc(struct ps3_instance *instance) { - instance->ctrl_info_buf = - (struct PS3IocCtrlInfo *)ps3_dma_alloc_coherent( - instance, sizeof(struct PS3IocCtrlInfo), - (unsigned long long *)&instance->ctrl_info_buf_h); + instance->ctrl_info_buf = (struct PS3IocCtrlInfo *) + ps3_dma_alloc_coherent(instance, sizeof(struct PS3IocCtrlInfo), + &instance->ctrl_info_buf_h); if (instance->ctrl_info_buf == NULL) { LOG_ERROR("host_no:%u alloc ctrl info buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_fail; } return PS3_SUCCESS; @@ -52,62 +51,65 @@ void ps3_ctrl_info_buf_free(struct ps3_instance *instance) if (instance->ctrl_info_buf != NULL) { LOG_INFO("ctrl_info_buf = %p\n", instance->ctrl_info_buf); ps3_dma_free_coherent(instance, sizeof(struct PS3IocCtrlInfo), - instance->ctrl_info_buf, - instance->ctrl_info_buf_h); + instance->ctrl_info_buf, + instance->ctrl_info_buf_h); instance->ctrl_info_buf = NULL; } memset(&instance->ctrl_info, 0, sizeof(struct PS3IocCtrlInfo)); } -static int ps3_mgr_pd_list_init(struct ps3_instance *instance) +static S32 ps3_mgr_pd_list_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_dev_context *dev_context = &instance->dev_context; - dev_context->pd_list_buf = (struct PS3DevList *)ps3_dma_alloc_coherent( - instance, - PS3_MAX_PD_COUNT(instance) * sizeof(struct PS3PhyDevice) + - sizeof(struct PS3DevList), - (unsigned long long *)&dev_context->pd_list_buf_phys); + dev_context->pd_list_buf = (struct PS3DevList *) + ps3_dma_alloc_coherent(instance, + PS3_MAX_PD_COUNT(instance) * + sizeof(struct PS3PhyDevice) + sizeof(struct PS3DevList), + &dev_context->pd_list_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_PD_LIST_BUF_ALLOC, &dev_context->pd_list_buf); if (dev_context->pd_list_buf == NULL) { LOG_ERROR("host_no:%u alloc pd list buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; } return ret; } -static int ps3_mgr_vd_list_init(struct ps3_instance *instance) +static S32 ps3_mgr_vd_list_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_dev_context *dev_context = &instance->dev_context; - dev_context->vd_list_buf = (struct PS3DevList *)ps3_dma_alloc_coherent( - instance, - PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VirtDevice) + - sizeof(struct PS3DevList), - (unsigned long long *)&dev_context->vd_list_buf_phys); + dev_context->vd_list_buf = (struct PS3DevList *) + ps3_dma_alloc_coherent(instance, + PS3_MAX_VD_COUNT(instance) * + sizeof(struct PS3VirtDevice) + sizeof(struct PS3DevList), + &dev_context->vd_list_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_VD_LIST_BUF_ALLOC, &dev_context->vd_list_buf); if (dev_context->vd_list_buf == NULL) { LOG_ERROR("host_no:%u alloc vd list buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; } return ret; } -static int ps3_mgr_pd_info_init(struct ps3_instance *instance) +static S32 ps3_mgr_pd_info_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_dev_context *dev_context = &instance->dev_context; - dev_context->pd_info_buf = (struct PS3PDInfo *)ps3_dma_alloc_coherent( - instance, sizeof(struct PS3PDInfo), - (unsigned long long *)&dev_context->pd_info_buf_phys); + dev_context->pd_info_buf = (struct PS3PDInfo *) + ps3_dma_alloc_coherent(instance, sizeof(struct PS3PDInfo), + &dev_context->pd_info_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_PD_INFO_BUF_ALLOC, &dev_context->pd_info_buf); if (dev_context->pd_info_buf == NULL) { LOG_ERROR("host_no:%u alloc pd info buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; } return ret; @@ -118,11 +120,10 @@ static inline void ps3_mgr_pd_list_exit(struct ps3_instance *instance) struct ps3_dev_context *dev_context = &instance->dev_context; if (dev_context->pd_list_buf != NULL) { - ps3_dma_free_coherent( - instance, + ps3_dma_free_coherent(instance, PS3_MAX_PD_COUNT(instance) * - sizeof(struct PS3PhyDevice) + - sizeof(struct PS3DevList), + sizeof(struct PS3PhyDevice) + + sizeof(struct PS3DevList), dev_context->pd_list_buf, dev_context->pd_list_buf_phys); dev_context->pd_list_buf = NULL; @@ -134,11 +135,10 @@ static inline void ps3_mgr_vd_list_exit(struct ps3_instance *instance) struct ps3_dev_context *dev_context = &instance->dev_context; if (dev_context->vd_list_buf != NULL) { - ps3_dma_free_coherent( - instance, + ps3_dma_free_coherent(instance, PS3_MAX_VD_COUNT(instance) * - sizeof(struct PS3VirtDevice) + - sizeof(struct PS3DevList), + sizeof(struct PS3VirtDevice) + + sizeof(struct PS3DevList), dev_context->vd_list_buf, dev_context->vd_list_buf_phys); dev_context->vd_list_buf = NULL; @@ -151,8 +151,8 @@ static inline void ps3_mgr_pd_info_exit(struct ps3_instance *instance) if (dev_context->pd_info_buf != NULL) { ps3_dma_free_coherent(instance, sizeof(struct PS3PDInfo), - dev_context->pd_info_buf, - dev_context->pd_info_buf_phys); + dev_context->pd_info_buf, + dev_context->pd_info_buf_phys); dev_context->pd_info_buf = NULL; } } @@ -162,55 +162,53 @@ static inline void ps3_mgr_vd_info_exit(struct ps3_instance *instance) struct ps3_dev_context *dev_context = &instance->dev_context; if (dev_context->vd_info_buf_sync != NULL) { - ps3_dma_free_coherent( - instance, - PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + - sizeof(struct PS3VDInfo), + ps3_dma_free_coherent(instance, PS3_MAX_VD_COUNT(instance) + * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo), dev_context->vd_info_buf_sync, dev_context->vd_info_buf_phys_sync); dev_context->vd_info_buf_sync = NULL; } if (dev_context->vd_info_buf_async != NULL) { - ps3_dma_free_coherent( - instance, - PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + - sizeof(struct PS3VDInfo), + ps3_dma_free_coherent(instance, PS3_MAX_VD_COUNT(instance) + * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo), dev_context->vd_info_buf_async, dev_context->vd_info_buf_phys_async); dev_context->vd_info_buf_async = NULL; } + } -static int ps3_mgr_vd_info_init(struct ps3_instance *instance) +static S32 ps3_mgr_vd_info_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_dev_context *dev_context = &instance->dev_context; dev_context->vd_table_idx = 0; - dev_context - ->vd_info_buf_sync = (struct PS3VDInfo *)ps3_dma_alloc_coherent( - instance, - PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + - sizeof(struct PS3VDInfo), - (unsigned long long *)&dev_context->vd_info_buf_phys_sync); + dev_context->vd_info_buf_sync = (struct PS3VDInfo *) + ps3_dma_alloc_coherent(instance, + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo), + &dev_context->vd_info_buf_phys_sync); + INJECT_START(PS3_ERR_IJ_PS3_VD_INFO_BUF_SYNC_ALLOC, &dev_context->vd_info_buf_sync); if (dev_context->vd_info_buf_sync == NULL) { LOG_ERROR("host_no:%u alloc vd sync info buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_out; } - dev_context->vd_info_buf_async = - (struct PS3VDInfo *)ps3_dma_alloc_coherent( - instance, - PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + - sizeof(struct PS3VDInfo), - (unsigned long long *)&dev_context - ->vd_info_buf_phys_async); + dev_context->vd_info_buf_async = (struct PS3VDInfo *) + ps3_dma_alloc_coherent(instance, + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo), + &dev_context->vd_info_buf_phys_async); + INJECT_START(PS3_ERR_IJ_PS3_VD_INFO_BUF_ASYNC_ALLOC, &dev_context->vd_info_buf_async); if (dev_context->vd_info_buf_async == NULL) { LOG_ERROR("host_no:%u alloc vd async info buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_failed; } @@ -223,27 +221,31 @@ static int ps3_mgr_vd_info_init(struct ps3_instance *instance) return ret; } -int ps3_mgr_cmd_init(struct ps3_instance *instance) +S32 ps3_mgr_cmd_init(struct ps3_instance *instance) { LOG_INFO("host_no:%u, Soc VD max is:%d\n", PS3_HOST(instance), - PS3_MAX_VD_COUNT(instance)); + PS3_MAX_VD_COUNT(instance)); LOG_INFO("host_no:%u, Soc PD max is:%d\n", PS3_HOST(instance), - PS3_MAX_PD_COUNT(instance)); + PS3_MAX_PD_COUNT(instance)); if (PS3_MAX_PD_COUNT(instance) > 0) { - if (ps3_mgr_pd_list_init(instance) != PS3_SUCCESS) + if (ps3_mgr_pd_list_init(instance) != PS3_SUCCESS) { goto free_mgr_cmd; + } - if (ps3_mgr_pd_info_init(instance) != PS3_SUCCESS) + if (ps3_mgr_pd_info_init(instance) != PS3_SUCCESS) { goto free_mgr_cmd; + } } if (PS3_MAX_VD_COUNT(instance) > 0) { - if (ps3_mgr_vd_list_init(instance) != PS3_SUCCESS) + if (ps3_mgr_vd_list_init(instance) != PS3_SUCCESS) { goto free_mgr_cmd; + } - if (ps3_mgr_vd_info_init(instance) != PS3_SUCCESS) + if (ps3_mgr_vd_info_init(instance) != PS3_SUCCESS) { goto free_mgr_cmd; + } } return PS3_SUCCESS; @@ -259,12 +261,13 @@ void ps3_mgr_cmd_exit(struct ps3_instance *instance) ps3_mgr_vd_list_exit(instance); ps3_mgr_pd_info_exit(instance); ps3_mgr_vd_info_exit(instance); + + return ; } void ps3_mgr_cmd_word_build(struct ps3_cmd *cmd) { struct PS3CmdWord *cmd_word = &cmd->cmd_word; - memset(cmd_word, 0, sizeof(*cmd_word)); cmd_word->type = PS3_CMDWORD_TYPE_MGR; @@ -277,23 +280,20 @@ void ps3_mgr_cmd_word_build(struct ps3_cmd *cmd) #endif } -static void ps3_mgr_print_cmd(struct ps3_cmd *cmd, const char *cmd_type, - unsigned char is_send) +static void ps3_mgr_print_cmd(struct ps3_cmd *cmd, const S8 *cmd_type, Bool is_send) { - LOG_DEBUG( - "host_no:%u t_id:0x%llx mgr:%s:%s cmd word type:%d\n" - "\tdirect:%d qmask:0x%x CFID:%d isr_sn:%d vid:%d pid:%d function:%d\n", + LOG_DEBUG("host_no:%u t_id:0x%llx mgr:%s:%s cmd word type:%d " + "direct:%d qmask:0x%x CFID:%d isr_sn:%d vid:%d pid:%d function:%d\n", PS3_HOST(cmd->instance), cmd->trace_id, - (is_send) ? "send" : "recv", cmd_type, cmd->cmd_word.type, - cmd->cmd_word.direct, cmd->cmd_word.qMask, - cmd->cmd_word.cmdFrameID, cmd->cmd_word.isrSN, - cmd->cmd_word.virtDiskID, cmd->cmd_word.phyDiskID, - ps3_get_pci_function(cmd->instance->pdev)); + (is_send) ? "send" : "recv", cmd_type, + cmd->cmd_word.type, cmd->cmd_word.direct, + cmd->cmd_word.qMask, cmd->cmd_word.cmdFrameID, + cmd->cmd_word.isrSN, cmd->cmd_word.virtDiskID, + cmd->cmd_word.phyDiskID, ps3_get_pci_function(cmd->instance->pdev)); } static inline void ps3_mgr_req_head_init(struct ps3_cmd *cmd, - struct PS3ReqFrameHead *req_header, - unsigned char cmdSubType) + PS3ReqFrameHead_s *req_header, U8 cmdSubType) { req_header->timeout = PS3_DEFAULT_MGR_CMD_TIMEOUT; req_header->traceID = ps3_cmd_trace_id(cmd); @@ -305,25 +305,23 @@ static inline void ps3_mgr_req_head_init(struct ps3_cmd *cmd, req_header->noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; } -static inline void -ps3_mgr_req_frame_sge_build(struct PS3MgrReqFrame *mgr_req_frame, - dma_addr_t dma_addr, unsigned int dma_len) +static inline void ps3_mgr_req_frame_sge_build(PS3MgrReqFrame_s *mgr_req_frame, + dma_addr_t dma_addr, U32 dma_len) { struct PS3Sge *p_sge = mgr_req_frame->sgl; - mgr_req_frame->sgeOffset = offsetof(struct PS3MgrReqFrame, sgl) >> - PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; + mgr_req_frame->sgeOffset = offsetof(PS3MgrReqFrame_s, sgl) >> PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; mgr_req_frame->sgeCount = 1; p_sge->addr = cpu_to_le64(dma_addr); p_sge->length = cpu_to_le32(dma_len); - p_sge->lastSge = 1; - p_sge->ext = 0; + p_sge->lastSge = 1; + p_sge->ext = 0; } -static int ps3_mgr_unload_cmd_send(struct ps3_cmd *cmd, unsigned short time_out) +static S32 ps3_mgr_unload_cmd_send(struct ps3_cmd *cmd, U16 time_out) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; enum PS3MgrCmdSubType cmd_type = (enum PS3MgrCmdSubType)cmd->req_frame->mgrReq.reqHead.cmdSubType; @@ -335,42 +333,41 @@ static int ps3_mgr_unload_cmd_send(struct ps3_cmd *cmd, unsigned short time_out) ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(cmd_type), PS3_DRV_FALSE); if (ret == PS3_SUCCESS) { - LOG_INFO("host_no:%u send %s success\n", - PS3_HOST(cmd->instance), - namePS3MgrCmdSubType(cmd_type)); + LOG_INFO("host_no:%u send %s success\n", PS3_HOST(cmd->instance), + namePS3MgrCmdSubType(cmd_type)); } else { - LOG_ERROR("host_no:%u send %s %s respStatus:%d\n", - PS3_HOST(cmd->instance), - namePS3MgrCmdSubType(cmd_type), - (ret == -PS3_TIMEOUT) ? "timeout" : "failed", - ps3_cmd_resp_status(cmd)); + LOG_ERROR("host_no:%u send %s %s respStatus:%d\n", PS3_HOST(cmd->instance), + namePS3MgrCmdSubType(cmd_type), + (ret == -PS3_TIMEOUT) ? "timeout" : "failed", + ps3_cmd_resp_status(cmd)); } return ret; } -int ps3_pd_list_get(struct ps3_instance *instance) +S32 ps3_pd_list_get(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; - unsigned int pd_list_size = - PS3_MAX_PD_COUNT(instance) * sizeof(struct PS3PhyDevice) + - sizeof(struct PS3DevList); + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U32 pd_list_size = PS3_MAX_PD_COUNT(instance) * + sizeof(struct PS3PhyDevice) + sizeof(struct PS3DevList); LOG_INFO("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u pd list cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -380,57 +377,56 @@ int ps3_pd_list_get(struct ps3_instance *instance) memset(instance->dev_context.pd_list_buf, 0, pd_list_size); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_GET_PD_LIST); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_PD_LIST); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; mgr_req_frame->value.dev.devID.diskDev.diskID = 0; mgr_req_frame->value.dev.num = PS3_MAX_PD_COUNT(instance); ps3_mgr_req_frame_sge_build(mgr_req_frame, - instance->dev_context.pd_list_buf_phys, - pd_list_size); + instance->dev_context.pd_list_buf_phys, + pd_list_size); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, - PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_GET_PD_LIST), - PS3_DRV_FALSE); + namePS3MgrCmdSubType(PS3_MGR_CMD_GET_PD_LIST), PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { ps3_mgr_cmd_free(instance, cmd); + } LOG_INFO("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -int ps3_vd_list_get(struct ps3_instance *instance) +S32 ps3_vd_list_get(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; - unsigned int vd_list_size = - PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VirtDevice) + - sizeof(struct PS3DevList); + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U32 vd_list_size = PS3_MAX_VD_COUNT(instance) * + sizeof(struct PS3VirtDevice) + sizeof(struct PS3DevList); LOG_INFO("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u vd list cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -440,55 +436,54 @@ int ps3_vd_list_get(struct ps3_instance *instance) memset(instance->dev_context.vd_list_buf, 0, vd_list_size); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_GET_VD_LIST); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_VD_LIST); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; mgr_req_frame->value.dev.devID.diskDev.diskID = 0; mgr_req_frame->value.dev.num = PS3_MAX_VD_COUNT(instance); ps3_mgr_req_frame_sge_build(mgr_req_frame, - instance->dev_context.vd_list_buf_phys, - vd_list_size); + instance->dev_context.vd_list_buf_phys, + vd_list_size); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, - PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_GET_VD_LIST), - PS3_DRV_FALSE); + namePS3MgrCmdSubType(PS3_MGR_CMD_GET_VD_LIST), PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { ps3_mgr_cmd_free(instance, cmd); + } LOG_INFO("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -int ps3_pd_info_get(struct ps3_instance *instance, unsigned short channel, - unsigned short target_id, unsigned short pd_disk_id) +S32 ps3_pd_info_get(struct ps3_instance *instance, U16 channel, U16 target_id, U16 pd_disk_id) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; - unsigned int pd_info_size = sizeof(struct PS3PDInfo); + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U32 pd_info_size = sizeof(struct PS3PDInfo); LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u pd info cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -498,8 +493,7 @@ int ps3_pd_info_get(struct ps3_instance *instance, unsigned short channel, memset(instance->dev_context.pd_info_buf, 0, pd_info_size); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_GET_PD_INFO); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_PD_INFO); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; @@ -510,58 +504,59 @@ int ps3_pd_info_get(struct ps3_instance *instance, unsigned short channel, mgr_req_frame->value.dev.devID.diskDev.ps3Dev.phyDiskID = pd_disk_id; ps3_mgr_req_frame_sge_build(mgr_req_frame, - instance->dev_context.pd_info_buf_phys, - pd_info_size); + instance->dev_context.pd_info_buf_phys, + pd_info_size); LOG_INFO("host_no:%u ready send, reqFrameId=%d, [%d:%d:%d]!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), channel, target_id, - pd_disk_id); + PS3_HOST(instance), ps3_cmd_frame_id(cmd), channel, target_id, + pd_disk_id); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, - PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_GET_PD_INFO), - PS3_DRV_FALSE); + namePS3MgrCmdSubType(PS3_MGR_CMD_GET_PD_INFO), PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); LOG_INFO("host_no:%u get pd info [%d:%d:%d] finished!:ret = %d\n", - PS3_HOST(instance), channel, target_id, pd_disk_id, ret); + PS3_HOST(instance), channel, target_id, pd_disk_id, ret); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { ps3_mgr_cmd_free(instance, cmd); + } + INJECT_START(PS3_ERR_IJ_GET_PD_INFO_RETURN_FAILED, &ret); LOG_DEBUG("host_no:%u exit ret[%d]!\n", PS3_HOST(instance), ret); return ret; } -int ps3_vd_info_sync_get(struct ps3_instance *instance, unsigned int disk_id, - unsigned short vd_num) +S32 ps3_vd_info_sync_get(struct ps3_instance *instance, U32 disk_id, + U16 vd_num) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; - unsigned int vd_info_size = - PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + - sizeof(struct PS3VDInfo); + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U32 vd_info_size = PS3_MAX_VD_COUNT(instance) * + sizeof(struct PS3VDEntry) + sizeof(struct PS3VDInfo); struct ps3_dev_context *dev_context = &instance->dev_context; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u vd info sync cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -571,49 +566,44 @@ int ps3_vd_info_sync_get(struct ps3_instance *instance, unsigned int disk_id, memset(dev_context->vd_info_buf_sync, 0, vd_info_size); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_GET_VD_INFO); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_VD_INFO); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; mgr_req_frame->value.dev.devID.diskDev.diskID = disk_id; mgr_req_frame->value.dev.num = vd_num; ps3_mgr_req_frame_sge_build(mgr_req_frame, - dev_context->vd_info_buf_phys_sync, - vd_info_size); + dev_context->vd_info_buf_phys_sync, + vd_info_size); - LOG_INFO( - "host_no:%u ready send, reqFrameId=%d, disk_id=0x%x, num=%d !\n", + LOG_INFO("host_no:%u ready send, reqFrameId=%d, disk_id=0x%x, num=%d !\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), disk_id, vd_num); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, - PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_GET_VD_INFO), - PS3_DRV_FALSE); + namePS3MgrCmdSubType(PS3_MGR_CMD_GET_VD_INFO), PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); - LOG_INFO( - "host_no:%u get vd info, reqFrameId=%d, disk_id=0x%x, num=%d finish!\n", + LOG_INFO("host_no:%u get vd info, reqFrameId=%d, disk_id=0x%x, num=%d finish!\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), disk_id, vd_num); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { ps3_mgr_cmd_free(instance, cmd); + } LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -int ps3_vd_info_async_get(struct ps3_instance *instance) +S32 ps3_vd_info_async_get(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; - unsigned int vd_info_size = - PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + - sizeof(struct PS3VDInfo); + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U32 vd_info_size = PS3_MAX_VD_COUNT(instance) * + sizeof(struct PS3VDEntry) + sizeof(struct PS3VDInfo); struct ps3_dev_context *dev_context = &instance->dev_context; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); @@ -621,65 +611,60 @@ int ps3_vd_info_async_get(struct ps3_instance *instance) cmd = dev_context->vd_pending_cmd; if (cmd == NULL) { cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_PS3_VD_PENDING_CMD_ALLOC, &cmd); if (cmd == NULL) { LOG_FILE_ERROR("host_no:%u mgr cmd get failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_EBUSY; goto l_out; } mgr_req_frame = &cmd->req_frame->mgrReq; - memset(dev_context->vd_info_buf_async, 0, vd_info_size); + memset(dev_context->vd_info_buf_async, + 0, vd_info_size); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_GET_VD_INFO); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_VD_INFO); mgr_req_frame->reqHead.timeout = 0; mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 0; mgr_req_frame->pendingFlag = 1; ps3_mgr_req_frame_sge_build(mgr_req_frame, - dev_context->vd_info_buf_phys_async, - vd_info_size); + dev_context->vd_info_buf_phys_async, + vd_info_size); - ps3_vd_pending_filter_table_build( - (unsigned char *)dev_context->vd_info_buf_async); + ps3_vd_pending_filter_table_build((U8*) + dev_context->vd_info_buf_async); ps3_mgr_cmd_word_build(cmd); - LOG_FILE_INFO( - "host_no:%u ready send, reqFrameId=%d, t_id:0x%llx!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), - cmd->trace_id); + LOG_FILE_INFO("host_no:%u ready send, reqFrameId=%d, t_id:0x%llx!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id); ps3_mgr_print_cmd(cmd, "vd info async", PS3_DRV_TRUE); dev_context->vd_pending_cmd = cmd; - ret = ps3_cmd_send_async(instance, cmd, - ps3_dev_vd_pending_proc); + ret = ps3_cmd_send_async(instance, cmd, ps3_dev_vd_pending_proc); + INJECT_START(PS3_ERR_IJ_FORCE_VDINFO_SUB_FAIL, &ret) ps3_mgr_print_cmd(cmd, "vd info async", PS3_DRV_FALSE); if (ret != PS3_SUCCESS) { - LOG_FILE_ERROR( - "host_no:%u send error, reqFrameId=%d, t_id:0x%llx ret:%d!\n", + LOG_FILE_ERROR("host_no:%u send error, reqFrameId=%d, t_id:0x%llx ret:%d!\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id, ret); dev_context->vd_pending_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); } } else { - LOG_FILE_INFO("host_no:%u vd info already subscribed\n", - PS3_HOST(instance)); + LOG_FILE_INFO("host_no:%u vd info already subscribed\n", PS3_HOST(instance)); } l_out: LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -static inline void ps3_ctrl_info_capability_dump(struct ps3_instance *instance) +static inline void ps3_ctrl_info_capablity_dump(struct ps3_instance *instance) { - LOG_WARN( - "host_no:%u ctrl info--supportUnevenSpans:%d supportJbodSecure:%d\n" - "\tsupportNvmePassthru:%d supportDirectCmd:%d\n" - "\tsupportAcceleration:%d supportSataDirectCmd:%d supportSataNcq:%d\n" - "\tioTimeOut:%u cancelTimeOut:%u isotoneTimeOut:%u\n", + LOG_WARN("host_no:%u ctrl info--supportUnevenSpans:%d supportJbodSecure:%d " + "supportNvmePassthru:%d supportDirectCmd:%d " + "supportAcceleration:%d supportSataDirectCmd:%d supportSataNcq:%d ioTimeOut:%u cancelTimeOut:%u isotoneTimeOut:%u\n", PS3_HOST(instance), instance->ctrl_info.capabilities.supportUnevenSpans, instance->ctrl_info.capabilities.supportJbodSecure, @@ -690,71 +675,75 @@ static inline void ps3_ctrl_info_capability_dump(struct ps3_instance *instance) instance->ctrl_info.capabilities.supportSataNcq, instance->ctrl_info.ioTimeOut, instance->ctrl_info.cancelTimeOut, - instance->ctrl_info.isotoneTimeOut); + instance->ctrl_info.isotoneTimeOut + ); } static void ps3_ctrl_info_update(struct ps3_instance *instance) { - unsigned char is_need_dump_info = - (memcmp(&instance->ctrl_info, instance->ctrl_info_buf, - sizeof(instance->ctrl_info)) != 0); + Bool is_need_dump_info = (0 != memcmp(&instance->ctrl_info, + instance->ctrl_info_buf, sizeof(instance->ctrl_info))); memcpy(&instance->ctrl_info, instance->ctrl_info_buf, - sizeof(instance->ctrl_info)); + sizeof(instance->ctrl_info)); - if (is_need_dump_info) - ps3_ctrl_info_capability_dump(instance); + if (is_need_dump_info) { + ps3_ctrl_info_capablity_dump(instance); + } if (instance->ctrl_info.capabilities.supportDirectCmd) { instance->cmd_attr.is_support_direct_cmd = PS3_DRV_TRUE; LOG_INFO("host_no:%u change is_support_direct_cmd to :%d !\n", - PS3_HOST(instance), - instance->cmd_attr.is_support_direct_cmd); + PS3_HOST(instance), + instance->cmd_attr.is_support_direct_cmd); } else { instance->cmd_attr.is_support_direct_cmd = PS3_DRV_FALSE; LOG_INFO("host_no:%u change is_support_direct_cmd to :%d !\n", - PS3_HOST(instance), - instance->cmd_attr.is_support_direct_cmd); + PS3_HOST(instance), + instance->cmd_attr.is_support_direct_cmd); } instance->cmd_attr.vd_io_threshold = le32_to_cpu(instance->ctrl_info.vdIOThreshold); LOG_INFO("host_no:%u change vdIOThreshold to :%d !\n", - PS3_HOST(instance), instance->cmd_attr.vd_io_threshold); + PS3_HOST(instance), + instance->cmd_attr.vd_io_threshold); ps3_perf_update(instance, instance->ctrl_info.iocPerfMode); if (instance->ctrl_info.vdQueueNum == 0) { LOG_ERROR("host_no:%u ctrl info update vd Queue Num is 0!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); instance->ctrl_info.vdQueueNum = 1; } - LOG_DEBUG("host_no:%u offsetOfVDID:%u\n", PS3_HOST(instance), - instance->ctrl_info.offsetOfVDID); + LOG_DEBUG("host_no:%u offsetOfVDID:%u\n", + PS3_HOST(instance), instance->ctrl_info.offsetOfVDID); LOG_INFO("host_no:%u change is_balance_current_perf_mode to :%d !\n", - PS3_HOST(instance), - instance->irq_context.is_balance_current_perf_mode); + PS3_HOST(instance), + instance->irq_context.is_balance_current_perf_mode); } -int ps3_ctrl_info_get(struct ps3_instance *instance) +S32 ps3_ctrl_info_get(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u ctrl info cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -764,23 +753,21 @@ int ps3_ctrl_info_get(struct ps3_instance *instance) memset(instance->ctrl_info_buf, 0, sizeof(struct PS3IocCtrlInfo)); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_GET_CTRL_INFO); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_CTRL_INFO); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; cmd->is_force_polling = 1; - ps3_mgr_req_frame_sge_build(mgr_req_frame, instance->ctrl_info_buf_h, - sizeof(struct PS3IocCtrlInfo)); + ps3_mgr_req_frame_sge_build(mgr_req_frame, + instance->ctrl_info_buf_h, + sizeof(struct PS3IocCtrlInfo)); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, - PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); - ps3_mgr_print_cmd( - cmd, namePS3MgrCmdSubType(PS3_MGR_CMD_GET_CTRL_INFO), - PS3_DRV_FALSE); + ps3_mgr_print_cmd(cmd, + namePS3MgrCmdSubType(PS3_MGR_CMD_GET_CTRL_INFO), PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret != PS3_SUCCESS) { @@ -789,18 +776,18 @@ int ps3_ctrl_info_get(struct ps3_instance *instance) } ps3_ctrl_info_update(instance); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { ps3_mgr_cmd_free(instance, cmd); + } LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -int ps3_soc_unload(struct ps3_instance *instance, unsigned char is_polling, - unsigned char type, unsigned char suspend_type) +S32 ps3_soc_unload(struct ps3_instance *instance, Bool is_polling, U8 type, U8 suspend_type) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); @@ -813,8 +800,10 @@ int ps3_soc_unload(struct ps3_instance *instance, unsigned char is_polling, ps3_wait_mgr_cmd_done(instance, PS3_TRUE); cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_ROMOVE_UNLOAD_FAIL, &cmd) if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ret = -PS3_EBUSY; goto l_out; } @@ -832,31 +821,32 @@ int ps3_soc_unload(struct ps3_instance *instance, unsigned char is_polling, mgr_req_frame->suspend_type = suspend_type; cmd->is_force_polling = is_polling; - LOG_WARN( - "host_no:%u ready send unload, reqFrameId=%d suspend_type:%d!\n", + LOG_WARN("host_no:%u ready send unload, reqFrameId=%d suspend_type:%d!\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), suspend_type); ret = ps3_mgr_unload_cmd_send(cmd, instance->unload_timeout); + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY, &ret) LOG_WARN("host_no:%u reqFrameId=%d finished ret:%d!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), ret); + PS3_HOST(instance), ps3_cmd_frame_id(cmd), ret); l_out: - if (cmd != NULL) + if (cmd != NULL) { ps3_mgr_cmd_free(instance, cmd); + } LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } struct ps3_cmd *ps3_dump_notify_cmd_build(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; struct ps3_dump_context *dump_context = &instance->dump_context; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); cmd = ps3_mgr_cmd_alloc(instance); if (cmd == NULL) { LOG_ERROR("host_no:%u mgr cmd get failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -864,47 +854,47 @@ struct ps3_cmd *ps3_dump_notify_cmd_build(struct ps3_instance *instance) memset(dump_context->dump_dma_buf, 0, PS3_DUMP_DMA_BUF_SIZE); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_AUTODUMP_NOTIFY); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_AUTODUMP_NOTIFY); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 0; mgr_req_frame->pendingFlag = 1; ps3_mgr_req_frame_sge_build(mgr_req_frame, dump_context->dump_dma_addr, - PS3_DUMP_DMA_BUF_SIZE); + PS3_DUMP_DMA_BUF_SIZE); ps3_mgr_cmd_word_build(cmd); - LOG_DEBUG("host_no:%u reqFrameId=%d !\n", PS3_HOST(instance), - ps3_cmd_frame_id(cmd)); + LOG_DEBUG("host_no:%u reqFrameId=%d !\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd)); l_out: LOG_DEBUG("host_no:%u exit ! ret %d\n", PS3_HOST(instance), ret); return cmd; } -int ps3_scsi_remove_device_done(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, - unsigned char dev_type) +S32 ps3_scsi_remove_device_done(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, U8 dev_type) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u remove done cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -913,8 +903,7 @@ int ps3_scsi_remove_device_done(struct ps3_instance *instance, mgr_req_frame = &cmd->req_frame->mgrReq; memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_DEV_DEL_DONE); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_DEV_DEL_DONE); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; mgr_req_frame->reqHead.devID.ps3Dev = disk_pos->diskDev.ps3Dev; @@ -922,65 +911,65 @@ int ps3_scsi_remove_device_done(struct ps3_instance *instance, mgr_req_frame->value.dev.devID.diskMagicNum = disk_pos->diskMagicNum; mgr_req_frame->value.dev.devType = dev_type; - LOG_INFO( - "host_no:%u ready send, t_id:0x%llx reqFrameId=%d, dev_type=%d,\n" - "\t[%d:%d:%d:%u]!\n", - PS3_HOST(instance), cmd->trace_id, ps3_cmd_frame_id(cmd), - dev_type, PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), + + LOG_INFO("host_no:%u ready send, t_id:0x%llx reqFrameId=%d, dev_type=%d, " + "[%d:%d:%d:%u]!\n", + PS3_HOST(instance), cmd->trace_id, ps3_cmd_frame_id(cmd), dev_type, + PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_VDID(disk_pos), disk_pos->diskMagicNum); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, - PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); - ps3_mgr_print_cmd( - cmd, namePS3MgrCmdSubType(PS3_MGR_CMD_DEV_DEL_DONE), - PS3_DRV_FALSE); + ps3_mgr_print_cmd(cmd, + namePS3MgrCmdSubType(PS3_MGR_CMD_DEV_DEL_DONE), PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret != PS3_SUCCESS) { - LOG_INFO( - "host_no:%u send [%u:%u:%u:%u][type:%d] del done failed!:ret = %d\n", + LOG_INFO("host_no:%u send [%u:%u:%u:%u][type:%d] del done failed!:ret = %d\n", PS3_HOST(instance), PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_VDID(disk_pos), - disk_pos->diskMagicNum, dev_type, ret); + disk_pos->diskMagicNum, + dev_type, ret); } l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { ps3_mgr_cmd_free(instance, cmd); + } LOG_INFO("host_no:%u send [%d:%d:%d:%u] finish!:ret = %d\n", - PS3_HOST(instance), PS3_CHANNEL(disk_pos), - PS3_TARGET(disk_pos), PS3_VDID(disk_pos), - disk_pos->diskMagicNum, ret); + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_VDID(disk_pos), + disk_pos->diskMagicNum, ret); LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -int ps3_scsi_add_device_ack(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, - unsigned char dev_type) +S32 ps3_scsi_add_device_ack(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, U8 dev_type) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u add ack cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -989,8 +978,7 @@ int ps3_scsi_add_device_ack(struct ps3_instance *instance, mgr_req_frame = &cmd->req_frame->mgrReq; memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_DEV_ADD_ACK); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_DEV_ADD_ACK); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; mgr_req_frame->reqHead.devID.ps3Dev = disk_pos->diskDev.ps3Dev; @@ -998,73 +986,73 @@ int ps3_scsi_add_device_ack(struct ps3_instance *instance, mgr_req_frame->value.dev.devID.diskMagicNum = disk_pos->diskMagicNum; mgr_req_frame->value.dev.devType = dev_type; - LOG_INFO("t_id:0x%llx host_no:%u ready send, CFID:%d dev_type:%d\n" - "\t[%u:%u:%u:%u]!\n", - cmd->trace_id, PS3_HOST(instance), ps3_cmd_frame_id(cmd), - dev_type, PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), - PS3_VDID(disk_pos), disk_pos->diskMagicNum); + LOG_INFO("t_id:0x%llx host_no:%u ready send, CFID:%d dev_type:%d " + "[%u:%u:%u:%u]!\n", + cmd->trace_id, PS3_HOST(instance), ps3_cmd_frame_id(cmd), dev_type, + PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), + PS3_VDID(disk_pos), disk_pos->diskMagicNum); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, - PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_DEV_ADD_ACK), - PS3_DRV_FALSE); + namePS3MgrCmdSubType(PS3_MGR_CMD_DEV_ADD_ACK), PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "host_no:%u send [%u:%u:%u:%u][type:%d] add ack NOK!:ret = %d\n", + LOG_ERROR("host_no:%u send [%u:%u:%u:%u][type:%d] add ack NOK!:ret = %d\n", PS3_HOST(instance), PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_VDID(disk_pos), - disk_pos->diskMagicNum, dev_type, ret); + disk_pos->diskMagicNum, + dev_type, ret); } l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { ps3_mgr_cmd_free(instance, cmd); + } LOG_INFO("host_no:%u send [%u:%u:%u:%u] finish!:ret = %d\n", - PS3_HOST(instance), PS3_CHANNEL(disk_pos), - PS3_TARGET(disk_pos), PS3_VDID(disk_pos), - disk_pos->diskMagicNum, ret); + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_VDID(disk_pos), + disk_pos->diskMagicNum, ret); LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -int ps3_mgr_cmd_cancel(struct ps3_instance *instance, - unsigned short cancel_cmd_frame_id) +S32 ps3_mgr_cmd_cancel(struct ps3_instance *instance, U16 cancel_cmd_frame_id) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; - unsigned short cancel_time_out = PS3_CANCEL_MGR_CMD_TIMEOUT; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + U16 cancel_time_out = PS3_CANCEL_MGR_CMD_TIMEOUT; - LOG_DEBUG("host_no:%u enter, be cancel CFID:%d !\n", PS3_HOST(instance), - cancel_cmd_frame_id); + LOG_DEBUG("host_no:%u enter, be cancel CFID:%d !\n", + PS3_HOST(instance), cancel_cmd_frame_id); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u mgr cancel cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_task_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_FORCE_ALLOC_CANCEL_CMD_FAILED, &cmd) if (cmd == NULL) { LOG_FILE_ERROR("host_no:%u task cmd get failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } - if (instance->ctrl_info.cancelTimeOut > cancel_time_out) + if (instance->ctrl_info.cancelTimeOut > cancel_time_out) { cancel_time_out = instance->ctrl_info.cancelTimeOut; + } mgr_req_frame = &cmd->req_frame->mgrReq; memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); @@ -1077,43 +1065,41 @@ int ps3_mgr_cmd_cancel(struct ps3_instance *instance, mgr_req_frame->abortFlag = 0; mgr_req_frame->value.originalCmdFrameID = cancel_cmd_frame_id; - LOG_FILE_INFO( - "host_no:%u ready send, reqFrameId=%d cancel_cmd_frame_id:%u !\n", + LOG_FILE_INFO("host_no:%u ready send, reqFrameId=%d cancel_cmd_frame_id:%u !\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cancel_cmd_frame_id); + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_RECOVERY_CANCEL, cmd); send_result = ps3_mgr_cmd_sync_proc(instance, cmd, cancel_time_out); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); - ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(PS3_MGR_CMD_CANCEL), - PS3_DRV_FALSE); + ps3_mgr_print_cmd(cmd, + namePS3MgrCmdSubType(PS3_MGR_CMD_CANCEL), PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); - LOG_FILE_INFO( - "host_no:%u reqFrameId=%d cancel_cmd_frame_id:%u finished!\n", + LOG_FILE_INFO("host_no:%u reqFrameId=%d cancel_cmd_frame_id:%u finished!\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cancel_cmd_frame_id); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { ps3_task_cmd_free(instance, cmd); + } LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -int ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, - unsigned short cancel_cmd_frame_id, - unsigned char type) +S32 ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, + U16 cancel_cmd_frame_id, U8 type) { - int ret = PS3_SUCCESS; - struct PS3MgrReqFrame *mgr_req_frame = NULL; + S32 ret = PS3_SUCCESS; + PS3MgrReqFrame_s *mgr_req_frame = NULL; enum PS3MgrCmdSubType sub_type; struct ps3_cmd *cmd = NULL; - - LOG_DEBUG("host_no:%u enter, be cancel CFID:%d !\n", PS3_HOST(instance), - cancel_cmd_frame_id); + LOG_DEBUG("host_no:%u enter, be cancel CFID:%d !\n", + PS3_HOST(instance), cancel_cmd_frame_id); cmd = ps3_task_cmd_alloc(instance); if (cmd == NULL) { LOG_FILE_ERROR("host_no:%u task cmd get failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_out; } @@ -1128,8 +1114,7 @@ int ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, mgr_req_frame->abortFlag = 0; mgr_req_frame->value.originalCmdFrameID = cancel_cmd_frame_id; - LOG_FILE_INFO( - "host_no:%u ready send, reqFrameId=%d cancel_cmd_frame_id:%u !\n", + LOG_FILE_INFO("host_no:%u ready send, reqFrameId=%d cancel_cmd_frame_id:%u !\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cancel_cmd_frame_id); sub_type = (enum PS3MgrCmdSubType)PS3_MGR_CMD_SUBTYPE(cmd); @@ -1138,53 +1123,54 @@ int ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, cmd->is_interrupt = PS3_DRV_FALSE; ps3_mgr_cmd_word_build(cmd); - ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(sub_type), PS3_DRV_TRUE); - if (type == PS3_CANCEL_EVENT_CMD) + ps3_mgr_print_cmd(cmd, + namePS3MgrCmdSubType(sub_type), PS3_DRV_TRUE); + if(type == PS3_CANCEL_EVENT_CMD){ instance->event_context.event_abort_cmd = cmd; - else if (type == PS3_CANCEL_WEB_CMD) - instance->webSubscribe_context.web_abort_cmd = cmd; - else + }else if(type == PS3_CANCEL_WEB_CMD){ + instance->webSubscribe_context.web_abort_cmd = cmd; + }else{ instance->dev_context.vdpending_abort_cmd = cmd; + } ret = ps3_cmd_no_block_send(instance, cmd); if (ret != PS3_SUCCESS) { - LOG_FILE_INFO( - "host_no:%u CFID:%d trace_id:0x%llx send failed\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), - cmd->trace_id); + LOG_FILE_INFO("host_no:%u CFID:%d trace_id:0x%llx send failed\n", + PS3_HOST(instance), + ps3_cmd_frame_id(cmd), cmd->trace_id); } - ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(sub_type), PS3_DRV_FALSE); + ps3_mgr_print_cmd(cmd, + namePS3MgrCmdSubType(sub_type), PS3_DRV_FALSE); l_out: return ret; } -int ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, unsigned char type) +S32 ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, U8 type) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; - unsigned long flags = 0; - int send_result; - - if (type == PS3_CANCEL_EVENT_CMD) { + ULong flags = 0; + S32 send_result; + if (type == PS3_CANCEL_EVENT_CMD){ cmd = instance->event_context.event_abort_cmd; - if (cmd == NULL) { + if (cmd == NULL){ LOG_INFO("host_no:%u event abort cmd null!\n", - PS3_HOST(instance)); - ret = -PS3_FAILED; - goto l_out; - } - } else if (type == PS3_CANCEL_WEB_CMD) { - cmd = instance->webSubscribe_context.web_abort_cmd; - if (cmd == NULL) { - LOG_INFO("host_no:%u web abort cmd null!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - } else { + }else if(type == PS3_CANCEL_WEB_CMD){ + cmd = instance->webSubscribe_context.web_abort_cmd; + if (cmd == NULL){ + LOG_INFO("host_no:%u web abort cmd null!\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_out; + } + }else{ cmd = instance->dev_context.vdpending_abort_cmd; - if (cmd == NULL) { + if (cmd == NULL){ LOG_INFO("host_no:%u vdpending abort cmd null!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -1192,7 +1178,7 @@ int ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, unsigned char type) send_result = ps3_block_cmd_wait(instance, cmd, 0); ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { + if(cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE){ ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); ret = -PS3_RECOVERED; goto l_out; @@ -1201,43 +1187,47 @@ int ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, unsigned char type) ret = ps3_mgr_complete_proc(instance, cmd, send_result); - LOG_INFO("host_no:%u reqFrameId=%d finished!\n", PS3_HOST(instance), - ps3_cmd_frame_id(cmd)); + LOG_INFO("host_no:%u reqFrameId=%d finished!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd)); if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { - if (type == PS3_CANCEL_EVENT_CMD) { + if(type == PS3_CANCEL_EVENT_CMD){ abort_cmd = instance->event_context.event_abort_cmd; instance->event_context.event_abort_cmd = NULL; - if (abort_cmd != NULL) + if (abort_cmd != NULL) { ps3_task_cmd_free(instance, abort_cmd); - } else if (type == PS3_CANCEL_WEB_CMD) { - abort_cmd = - instance->webSubscribe_context.web_abort_cmd; - instance->webSubscribe_context.web_abort_cmd = NULL; - if (abort_cmd != NULL) - ps3_task_cmd_free(instance, abort_cmd); - } else { + } + }else if(type == PS3_CANCEL_WEB_CMD){ + abort_cmd = instance->webSubscribe_context.web_abort_cmd; + instance->webSubscribe_context.web_abort_cmd = NULL; + if (abort_cmd != NULL) { + ps3_task_cmd_free(instance, abort_cmd); + } + }else{ abort_cmd = instance->dev_context.vdpending_abort_cmd; instance->dev_context.vdpending_abort_cmd = NULL; - if (abort_cmd != NULL) + if (abort_cmd != NULL) { ps3_task_cmd_free(instance, abort_cmd); + } } } l_out: return ret; } -int ps3_event_register(struct ps3_instance *instance, struct PS3MgrEvent *event) +S32 ps3_event_register(struct ps3_instance *instance, + struct PS3MgrEvent *event) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; + PS3MgrReqFrame_s *mgr_req_frame = NULL; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { LOG_ERROR_IN_IRQ(instance, "host_no:%u mgr cmd get failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_EBUSY; goto l_out; } @@ -1245,33 +1235,32 @@ int ps3_event_register(struct ps3_instance *instance, struct PS3MgrEvent *event) mgr_req_frame = &cmd->req_frame->mgrReq; memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_SUBSCRIBE_EVENT); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_SUBSCRIBE_EVENT); mgr_req_frame->reqHead.timeout = 0; mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 0; mgr_req_frame->pendingFlag = 1; - mgr_req_frame->value.event.eventTypeMap = event->eventTypeMap; + mgr_req_frame->value.event.eventTypeMap = + event->eventTypeMap; mgr_req_frame->value.event.eventTypeMapProcResult = event->eventTypeMapProcResult; mgr_req_frame->value.event.eventLevel = event->eventLevel; - instance->event_context.event_info = - (struct PS3EventInfo *)cmd->ext_buf; + instance->event_context.event_info = (struct PS3EventInfo*)cmd->ext_buf; - ps3_mgr_req_frame_sge_build(mgr_req_frame, cmd->ext_buf_phys, - cmd->instance->cmd_context.ext_buf_size); + ps3_mgr_req_frame_sge_build(mgr_req_frame, + cmd->ext_buf_phys, + cmd->instance->cmd_context.ext_buf_size); memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); if (instance->ioc_adpter->event_filter_table_get != NULL) { - instance->ioc_adpter->event_filter_table_get( - (unsigned char *)cmd->ext_buf); + instance->ioc_adpter->event_filter_table_get((U8*)cmd->ext_buf); } ps3_mgr_cmd_word_build(cmd); LOG_INFO_IN_IRQ(instance, "host_no:%u ready send, reqFrameId=%d !\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd)); + PS3_HOST(instance), ps3_cmd_frame_id(cmd)); ps3_mgr_print_cmd(cmd, "event register", PS3_DRV_TRUE); instance->event_context.event_cmd = cmd; @@ -1286,79 +1275,71 @@ int ps3_event_register(struct ps3_instance *instance, struct PS3MgrEvent *event) return ret; } -int ps3_web_register(struct ps3_instance *instance) +S32 ps3_web_register(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - struct PS3MgrReqFrame *mgr_req_frame = NULL; - struct ps3_webSubscribe_context *web_context = - &instance->webSubscribe_context; + PS3MgrReqFrame_s *mgr_req_frame = NULL; + struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; cmd = web_context->webSubscribe_cmd; if (cmd == NULL) { ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); - if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != - PS3_SUCCESS) { + if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u web cmd pre check NOK\n", - PS3_HOST(instance)); - ps3_atomic_dec( - &instance->cmd_statistics.cmd_delivering); + PS3_HOST(instance)); + ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_FAILED; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_WARN_IN_IRQ( - instance, + LOG_WARN_IN_IRQ(instance, "host_no:%u ioctl req, Failed to get a cmd packet\n", PS3_HOST(instance)); - ps3_atomic_dec( - &instance->cmd_statistics.cmd_delivering); + ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_FAILED; goto l_out; } mgr_req_frame = &cmd->req_frame->mgrReq; memset(mgr_req_frame, 0, sizeof(struct PS3MgrReqFrame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, - PS3_MGR_CMD_WEBSUBSCRIBE_EVENT); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_WEBSUBSCRIBE_EVENT); mgr_req_frame->reqHead.timeout = 0; mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 0; mgr_req_frame->pendingFlag = 1; ps3_mgr_cmd_word_build(cmd); - LOG_INFO_IN_IRQ(instance, - "host_no:%u ready send, reqFrameId=%d !\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd)); + LOG_INFO_IN_IRQ(instance, "host_no:%u ready send, reqFrameId=%d !\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd)); ps3_mgr_print_cmd(cmd, "web event register", PS3_DRV_TRUE); web_context->webSubscribe_cmd = cmd; - ret = ps3_cmd_send_async(instance, cmd, - ps3_webSubscribe_service); + ret = ps3_cmd_send_async(instance, cmd, ps3_webSubscribe_service); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + INJECT_START(PS3_ERR_IJ_FORCE_WEB_SUB_FAIL, &ret) if (ret != PS3_SUCCESS) { web_context->webSubscribe_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); goto l_out; } } else { - LOG_INFO_IN_IRQ(instance, - "host_no:%u web event already subscribed\n", - PS3_HOST(instance)); + LOG_INFO_IN_IRQ(instance, "host_no:%u web event already subscribed\n", + PS3_HOST(instance)); } l_out: LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -static int ps3_scsi_task_abort_sync_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd, - struct ps3_cmd *abort_cmd, - struct ps3_scsi_priv_data *priv_data) +static S32 ps3_scsi_task_abort_sync_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd, struct ps3_cmd *abort_cmd, + struct ps3_scsi_priv_data *priv_data) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; cmd->cmd_word_value = abort_cmd->cmd_word_value; if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_INIT) { @@ -1371,21 +1352,21 @@ static int ps3_scsi_task_abort_sync_proc(struct ps3_instance *instance, cmd->time_out = priv_data->task_abort_timeout; cmd->is_interrupt = PS3_DRV_FALSE; + INJECT_START(PS3_ERR_IJ_ABORT_PRE_SEND_FORCE_ABORTED_CMD_DONE, abort_cmd->scmd) ret = ps3_cmd_send_sync(instance, cmd); end: return ret; } -static inline void -ps3_mgr_scsi_req_head_init(struct ps3_cmd *cmd, - struct PS3ReqFrameHead *req_header, - unsigned char cmdSubType, unsigned int disk_id, - struct ps3_scsi_priv_data *priv_data) +static inline void ps3_mgr_scsi_req_head_init(struct ps3_cmd *cmd, + PS3ReqFrameHead_s *req_header, U8 cmdSubType, U32 disk_id, + struct ps3_scsi_priv_data *priv_data) { - if (cmdSubType == PS3_TASK_CMD_SCSI_TASK_RESET) + if (cmdSubType == PS3_TASK_CMD_SCSI_TASK_RESET) { req_header->timeout = priv_data->task_reset_timeout; - else + } else { req_header->timeout = priv_data->task_abort_timeout; + } req_header->traceID = ps3_cmd_trace_id(cmd); req_header->cmdType = PS3_CMD_SCSI_TASK_MANAGEMENT; req_header->cmdSubType = cmdSubType; @@ -1394,26 +1375,26 @@ ps3_mgr_scsi_req_head_init(struct ps3_cmd *cmd, req_header->devID.diskID = disk_id; } -struct ps3_cmd * -ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data) +struct ps3_cmd * ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data) { struct ps3_cmd *cmd = NULL; - struct PS3MgrTaskReqFrame *mgr_task_req_frame = NULL; - unsigned int disk_id = priv_data->disk_pos.diskDev.diskID; + PS3MgrTaskReqFrame_s *mgr_task_req_frame = NULL; + U32 disk_id = priv_data->disk_pos.diskDev.diskID; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); if ((priv_data->dev_type == PS3_DEV_TYPE_UNKNOWN) || - (disk_id == PS3_INVALID_DEV_ID)) { - LOG_ERROR("host_no:%u unknown dev type !\n", PS3_HOST(instance)); + (disk_id == PS3_INVALID_DEV_ID)) { + LOG_ERROR("host_no:%u unknow dev type !\n", + PS3_HOST(instance)); goto l_out; } cmd = ps3_task_cmd_alloc(instance); if (cmd == NULL) { LOG_ERROR("host_no:%u task cmd get NOK !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -1421,11 +1402,9 @@ ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, mgr_task_req_frame->taskID = 0; memset(mgr_task_req_frame, 0, sizeof(*mgr_task_req_frame)); ps3_mgr_scsi_req_head_init(cmd, &mgr_task_req_frame->reqHead, - PS3_TASK_CMD_SCSI_TASK_RESET, disk_id, - priv_data); + PS3_TASK_CMD_SCSI_TASK_RESET, disk_id, priv_data); - LOG_WARN( - "host_no:%u ready send reset, CFID:%u t_id:0x%llx [%u:%u:%u]!\n", + LOG_WARN("host_no:%u ready send reset, CFID:%u t_id:0x%llx [%u:%u:%u]!\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id, PS3_CHANNEL(&priv_data->disk_pos), PS3_TARGET(&priv_data->disk_pos), @@ -1434,12 +1413,9 @@ ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, ps3_mgr_cmd_word_build(cmd); if (priv_data->dev_type == PS3_DEV_TYPE_VD) { - cmd->cmd_word.virtDiskID = - (unsigned char) - priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; + cmd->cmd_word.virtDiskID = (U8)priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; } else { - cmd->cmd_word.phyDiskID = - priv_data->disk_pos.diskDev.ps3Dev.phyDiskID; + cmd->cmd_word.phyDiskID = priv_data->disk_pos.diskDev.ps3Dev.phyDiskID; } cmd->time_out = priv_data->task_reset_timeout; @@ -1450,30 +1426,78 @@ ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, } #ifndef _WINDOWS -int ps3_scsi_task_mgr_abort(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, - unsigned short aborted_cmd_frame_id, - struct scsi_cmnd *scmd) +#if 0 +static void ps3_abort_req_frame_dump(struct ps3_cmd *cmd) +{ + PS3_BUG_ON((cmd->req_frame == NULL) || (cmd->scmd == NULL)); + + switch (cmd->cmd_word.type) + { + case PS3_CMDWORD_TYPE_MGR: + if ((cmd->req_frame->word[0] == PS3_CMD_VD_SCSI_IO_NORW) || + (cmd->req_frame->word[0] == PS3_CMD_PD_SCSI_IO_NORW)) { + LOG_DEBUG("t_id:0x%llx host_no:%u aborted_cmd CFID:%u " + "type:%d fe isr_sn:%d cmd_type:%d opcode:0x%x!\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->cmd_word.cmdFrameID, cmd->cmd_word.type, + cmd->cmd_word.isrSN, + cmd->req_frame->frontendReq.reqHead.cmdType, + cmd->scmd->cmnd[0]); + } else { + LOG_ERROR("host_no:%u abort_cmd no scsi cmd! cmd_type:%d\n", + PS3_HOST(cmd->instance), + (int)cmd->req_frame->word[0]); + } + break; + case PS3_CMDWORD_TYPE_READ: + case PS3_CMDWORD_TYPE_WRITE: + if (cmd->cmd_word.isHardCmd) { + LOG_DEBUG("t_id:0x%llx host_no:%u abort_cmd CFID:%u type:%d " + "hwReq isr_sn:%d opcode:0x%x!\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->cmd_word.cmdFrameID, cmd->cmd_word.type, + cmd->cmd_word.isrSN, cmd->scmd->cmnd[0]); + } else { + LOG_DEBUG("t_id:0x%llx host_no:%u abort_cmd CFID:%u type:%d " + "fe isr_sn:%d opcode:0x%x cmd_type:%u !\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->cmd_word.cmdFrameID, cmd->cmd_word.type, + cmd->cmd_word.isrSN, cmd->scmd->cmnd[0], + cmd->req_frame->frontendReq.reqHead.cmdType); + } + break; + default: + LOG_ERROR("host_no:%u abort_cmd no scsi cmd! \n", + PS3_HOST(cmd->instance)); + break; + } + return; +} +#endif +S32 ps3_scsi_task_mgr_abort(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data, U16 aborted_cmd_frame_id, struct scsi_cmnd *scmd) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_cmd *aborted_cmd = NULL; - struct PS3MgrTaskReqFrame *mgr_task_req_frame = NULL; - unsigned int disk_id = priv_data->disk_pos.diskDev.diskID; + PS3MgrTaskReqFrame_s *mgr_task_req_frame = NULL; + U32 disk_id = priv_data->disk_pos.diskDev.diskID; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); if ((priv_data->dev_type == PS3_DEV_TYPE_UNKNOWN) || - (disk_id == PS3_INVALID_DEV_ID)) { - LOG_ERROR("host_no:%u unknown dev type !\n", PS3_HOST(instance)); + (disk_id == PS3_INVALID_DEV_ID)) { + LOG_ERROR("host_no:%u unknow dev type !\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } + INJECT_START(PS3_ERR_IJ_ABORT_PRE_BULID_FORCE_ABORTED_CMD_DONE, scmd) aborted_cmd = ps3_cmd_find(instance, aborted_cmd_frame_id); if (aborted_cmd == NULL || aborted_cmd->scmd == NULL) { LOG_ERROR("host_no:%u there is no aborted cmd CFID:%u\n", - PS3_HOST(instance), aborted_cmd_frame_id); + PS3_HOST(instance), aborted_cmd_frame_id); ret = PS3_SUCCESS; goto l_out; @@ -1481,45 +1505,41 @@ int ps3_scsi_task_mgr_abort(struct ps3_instance *instance, ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u aborted cmd pre check NOK CFID:%d\n", - PS3_HOST(instance), aborted_cmd_frame_id); + PS3_HOST(instance), aborted_cmd_frame_id); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_task_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { LOG_ERROR("host_no:%u task cmd get NOK !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } - LOG_DEBUG( - "t_id:0x%llx aborted_t_id:0x%llx host_no:%u mgr abort CFID:%d\n", - cmd->trace_id, aborted_cmd->trace_id, PS3_HOST(instance), - cmd->index); + LOG_DEBUG("t_id:0x%llx aborted_t_id:0x%llx host_no:%u mgr abort CFID:%d\n", + cmd->trace_id, aborted_cmd->trace_id, PS3_HOST(instance), cmd->index); mgr_task_req_frame = &cmd->req_frame->taskReq; memset(mgr_task_req_frame, 0, sizeof(*mgr_task_req_frame)); ps3_mgr_scsi_req_head_init(cmd, &mgr_task_req_frame->reqHead, - PS3_TASK_CMD_SCSI_TASK_ABORT, disk_id, - priv_data); + PS3_TASK_CMD_SCSI_TASK_ABORT, disk_id, priv_data); mgr_task_req_frame->taskID = aborted_cmd_frame_id; mgr_task_req_frame->abortedCmdType = aborted_cmd->cmd_word.direct; - mgr_task_req_frame->reqHead.reqFrameFormat = - PS3_REQFRAME_FORMAT_FRONTEND; + mgr_task_req_frame->reqHead.reqFrameFormat = PS3_REQFRAME_FORMAT_FRONTEND; - LOG_WARN( - "host_no:%u ready send abort, CFID:%d t_id:0x%llx aborted cmd info:\n" - "\tCFID:%d t_id:0x%llx op:0x%x is_retry_cmd:%d timeout:%d dev[%u:%u:%u:%u],\n" - "\tcmdword[0x%08llx]{type:%d direct:%d que:%d isr_sn:%d}!\n ", + LOG_WARN("host_no:%u ready send abort, CFID:%d t_id:0x%llx aborted cmd info:" + "CFID:%d t_id:0x%llx op:0x%x is_retry_cmd:%d timeout:%d dev[%u:%u:%u:%u], " + "cmdword[0x%08llx]{type:%d direct:%d que:%d isr_sn:%d}!\n ", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id, aborted_cmd_frame_id, aborted_cmd->trace_id, - scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff, scmd->retries, - SCMD_GET_REQUEST(scmd)->timeout, - PS3_CHANNEL(&priv_data->disk_pos), + scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff, + scmd->retries, + SCMD_GET_REQUEST(scmd)->timeout, PS3_CHANNEL(&priv_data->disk_pos), PS3_TARGET(&priv_data->disk_pos), PS3_VDID(&priv_data->disk_pos), priv_data->disk_pos.diskMagicNum, aborted_cmd->cmd_word_value, @@ -1527,25 +1547,27 @@ int ps3_scsi_task_mgr_abort(struct ps3_instance *instance, aborted_cmd->cmd_word.qMask, aborted_cmd->cmd_word.isrSN); ps3_scsih_print_req(aborted_cmd, LEVEL_INFO); + INJECT_START(PS3_ERR_IJ_ABORT_PRE_BULID1_FORCE_ABORTED_CMD_DONE, scmd) + INJECT_START(PS3_ERR_IJ_SET_ABORT_COUNT, scmd); - send_result = ps3_scsi_task_abort_sync_proc(instance, cmd, aborted_cmd, - priv_data); + send_result = ps3_scsi_task_abort_sync_proc(instance, cmd, aborted_cmd, priv_data); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); + ret = ps3_mgr_complete_proc(instance, cmd, send_result); - LOG_WARN( - "host_no:%u abort finish, CFID:%d aborted CFID:%d aborted cmdword[0x%08llx],\n" - "\t[%u:%u:%u:%u]!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), aborted_cmd_frame_id, - aborted_cmd->cmd_word_value, PS3_CHANNEL(&priv_data->disk_pos), + LOG_WARN("host_no:%u abort finish, CFID:%d aborted CFID:%d aborted cmdword[0x%08llx], " + "[%u:%u:%u:%u]!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), aborted_cmd_frame_id, aborted_cmd->cmd_word_value, + PS3_CHANNEL(&priv_data->disk_pos), PS3_TARGET(&priv_data->disk_pos), PS3_VDID(&priv_data->disk_pos), priv_data->disk_pos.diskMagicNum); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { ps3_task_cmd_free(instance, cmd); + } LOG_WARN("host_no:%u exit !, ret:%d\n", PS3_HOST(instance), ret); return ret; } @@ -1553,12 +1575,9 @@ int ps3_scsi_task_mgr_abort(struct ps3_instance *instance, #ifndef _WINDOWS static inline void ps3_sas_info_reqframe_build(struct ps3_cmd *cmd, - enum PS3MgrCmdSubType sub_type, - dma_addr_t *sge_addr, - struct PS3SasMgr *sas_req) + enum PS3MgrCmdSubType sub_type, dma_addr_t *sge_addr, struct PS3SasMgr *sas_req) { - struct PS3MgrReqFrame *mgrReq = &cmd->req_frame->mgrReq; - + PS3MgrReqFrame_s *mgrReq = &cmd->req_frame->mgrReq; mgrReq->reqHead.timeout = PS3_DEFAULT_MGR_CMD_TIMEOUT; mgrReq->reqHead.traceID = cmd->trace_id; mgrReq->reqHead.cmdType = PS3_CMD_SAS_MANAGEMENT; @@ -1567,8 +1586,8 @@ static inline void ps3_sas_info_reqframe_build(struct ps3_cmd *cmd, mgrReq->reqHead.control = 0; mgrReq->syncFlag = 1; mgrReq->timeout = 0; - mgrReq->sgeOffset = offsetof(struct PS3MgrReqFrame, sgl) >> - PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; + mgrReq->sgeOffset = + offsetof(PS3MgrReqFrame_s, sgl) >> PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; mgrReq->sgeCount = 1; mgrReq->sgl[0].length = cpu_to_le32(PS3_SAS_REQ_BUFF_LEN); mgrReq->sgl[0].addr = cpu_to_le64(*sge_addr); @@ -1576,33 +1595,34 @@ static inline void ps3_sas_info_reqframe_build(struct ps3_cmd *cmd, mgrReq->sgl[0].ext = 0; if (sas_req != NULL) { - mgrReq->value.sasMgr.sasAddr = cpu_to_le64(sas_req->sasAddr); + mgrReq->value.sasMgr.sasAddr = + cpu_to_le64(sas_req->sasAddr); mgrReq->value.sasMgr.enclID = sas_req->enclID; mgrReq->value.sasMgr.startPhyID = sas_req->startPhyID; mgrReq->value.sasMgr.phyCount = sas_req->phyCount; } } -static int __ps3_sas_info_get(struct ps3_instance *instance, - enum PS3MgrCmdSubType sub_type, - dma_addr_t *sge_addr, struct PS3SasMgr *sas_req) +static S32 __ps3_sas_info_get(struct ps3_instance *instance, + enum PS3MgrCmdSubType sub_type, dma_addr_t *sge_addr, struct PS3SasMgr *sas_req) { - int ret = 0; - int send_result = PS3_SUCCESS; + S32 ret = 0; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u sas info cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_FAILED; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { LOG_WARN("host_no:%u not get a cmd packet\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_FAILED; goto l_out; @@ -1612,113 +1632,113 @@ static int __ps3_sas_info_get(struct ps3_instance *instance, ps3_mgr_cmd_word_build(cmd); LOG_INFO("host_no:%u ready send t_id:0x%llx CFID:%u req type:%s\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - namePS3MgrCmdSubType((enum PS3MgrCmdSubType)sub_type)); + PS3_HOST(instance), cmd->trace_id, cmd->index, + namePS3MgrCmdSubType((enum PS3MgrCmdSubType)sub_type)); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, - PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); - ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(sub_type), - PS3_DRV_FALSE); + ps3_mgr_print_cmd(cmd, + namePS3MgrCmdSubType(sub_type), PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "host_no:%u %d respStatus NOK CFID:%d respStatus:%d\n", - PS3_HOST(cmd->instance), ret, cmd->cmd_word.cmdFrameID, + LOG_ERROR("host_no:%u %d respStatus NOK CFID:%d respStatus:%d\n", + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); } LOG_INFO("host_no:%u t_id:0x%llx CFID :%u type:%s end, ret:%d\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - namePS3MgrCmdSubType((enum PS3MgrCmdSubType)sub_type), ret); + PS3_HOST(instance), cmd->trace_id, cmd->index, + namePS3MgrCmdSubType((enum PS3MgrCmdSubType)sub_type), ret); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { ps3_mgr_cmd_free(instance, cmd); + } return ret; } -int ps3_sas_expander_all_get(struct ps3_instance *instance) +S32 ps3_sas_expander_all_get(struct ps3_instance *instance) { LOG_DEBUG("host_no:%u\n", PS3_HOST(instance)); - return __ps3_sas_info_get( - instance, PS3_SAS_GET_EXPANDERS, - &instance->sas_dev_context.ps3_sas_buff_dma_addr, NULL); + return __ps3_sas_info_get(instance, PS3_SAS_GET_EXPANDERS, + &instance->sas_dev_context.ps3_sas_buff_dma_addr, + NULL); } -int ps3_sas_phy_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req) +S32 ps3_sas_phy_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req) { LOG_DEBUG("host_no:%u\n", PS3_HOST(instance)); if (sas_req->phyCount == 0) { LOG_WARN("host_no:%u unexpect phyCount:%d !\n", - PS3_HOST(instance), sas_req->phyCount); + PS3_HOST(instance), sas_req->phyCount); return -PS3_FAILED; } - return __ps3_sas_info_get( - instance, PS3_SAS_GET_PHY_INFO, - &instance->sas_dev_context.ps3_sas_phy_buff_dma_addr, sas_req); + return __ps3_sas_info_get(instance, PS3_SAS_GET_PHY_INFO, + &instance->sas_dev_context.ps3_sas_phy_buff_dma_addr, + sas_req); } -int ps3_sas_expander_get(struct ps3_instance *instance, - struct PS3SasMgr *sas_req) +S32 ps3_sas_expander_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req) { LOG_DEBUG("host_no:%u\n", PS3_HOST(instance)); - return __ps3_sas_info_get( - instance, PS3_SAS_GET_EXPANDER_INFO, - &instance->sas_dev_context.ps3_sas_buff_dma_addr, sas_req); + return __ps3_sas_info_get(instance, PS3_SAS_GET_EXPANDER_INFO, + &instance->sas_dev_context.ps3_sas_buff_dma_addr, + sas_req); } #endif -static int ps3_mgr_cmd_sync_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd, unsigned short time_out) +static S32 ps3_mgr_cmd_sync_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd, U16 time_out) { - enum PS3MgrCmdSubType sub_type = - (enum PS3MgrCmdSubType)PS3_MGR_CMD_SUBTYPE(cmd); + enum PS3MgrCmdSubType sub_type = (enum PS3MgrCmdSubType)PS3_MGR_CMD_SUBTYPE(cmd); cmd->time_out = time_out; cmd->is_interrupt = PS3_DRV_FALSE; ps3_mgr_cmd_word_build(cmd); - ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(sub_type), PS3_DRV_TRUE); + ps3_mgr_print_cmd(cmd, + namePS3MgrCmdSubType(sub_type), PS3_DRV_TRUE); + INJECT_START(PS3_ERR_IJ_PD_LIST_WAIT_IRQ_DISABLE, cmd); return ps3_cmd_send_sync(instance, cmd); } -static int ps3_no_resp_cmd_dead_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static S32 ps3_no_resp_cmd_dead_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - unsigned long flags = 0; - int ret = PS3_SUCCESS; + ULong flags = 0; + S32 ret = PS3_SUCCESS; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); if (cmd->cmd_state.state == PS3_CMD_STATE_INIT || - cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { + cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("host_no:%u CFID:%d finished\n", PS3_HOST(instance), - cmd->index); + LOG_WARN("host_no:%u CFID:%d finished\n", + PS3_HOST(instance), cmd->index); ret = -PS3_FAILED; goto l_out; } cmd->cmd_state.state = PS3_CMD_STATE_DEAD; ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("host_no:%u cmd_dead_proc entry reset due to cmd not resp!\n", - PS3_HOST(instance)); + LOG_WARN("host_no:%u cmd_dead_proc entry reset due to cmd not resp!\n", PS3_HOST(instance)); - if (!instance->is_probe_finish || !instance->state_machine.is_load) { + if (!instance->is_probe_finish || + !instance->state_machine.is_load) { ps3_need_wait_hard_reset_request(instance); ret = ps3_hard_recovery_request_with_retry(instance); if (ret == PS3_SUCCESS) { ps3_instance_wait_for_dead_or_pre_operational(instance); } else { LOG_WARN("host_no:%u hard recovery request NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } } else { @@ -1727,62 +1747,59 @@ static int ps3_no_resp_cmd_dead_proc(struct ps3_instance *instance, } LOG_ERROR("t_id:0x%llx CFID:%d host_no:%u state %u, recovery request\n", - cmd->trace_id, cmd->index, PS3_HOST(instance), - cmd->cmd_state.state); + cmd->trace_id, cmd->index, PS3_HOST(instance),cmd->cmd_state.state); ret = -PS3_CMD_NO_RESP; l_out: return ret; } -static int ps3_no_resp_cmd_wait_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static S32 ps3_no_resp_cmd_wait_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - unsigned long flags = 0; - int ret = PS3_SUCCESS; - unsigned char is_probe_finish = PS3_FALSE; - + ULong flags = 0; + S32 ret = PS3_SUCCESS; + Bool is_probe_finish = PS3_FALSE; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); if (cmd->cmd_state.state == PS3_CMD_STATE_INIT || - cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { + cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); LOG_WARN("host_no:%u CFID:%d finished, retries:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + PS3_HOST(instance), cmd->index, cmd->retry_cnt); ret = -PS3_FAILED; goto l_out; } else { - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == - PS3_CMD_WORD_NEED_REPLY_WORD) { + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { init_completion(&cmd->sync_done); } ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - LOG_WARN( - "host_no:%u cmd_wait_proc entry reset due to cmd not resp, CFID:%d t_id:0x%llx !\n", + LOG_WARN("host_no:%u cmd_wait_proc entry reset due to cmd not resp, CFID:%d t_id:0x%llx !\n", PS3_HOST(instance), cmd->index, cmd->trace_id); is_probe_finish = instance->is_probe_finish; ps3_need_wait_hard_reset_request(instance); - if (!is_probe_finish) + if (!is_probe_finish) { ret = ps3_hard_recovery_request_with_retry(instance); - else + } else { ret = ps3_recovery_request_with_retry(instance); + } if (ret == -PS3_FAILED) { ret = -PS3_CMD_NO_RESP; LOG_ERROR("host_no:%u recovery request NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_dead; } + INJECT_START(PS3_ERR_IJ_WAIT_HARD_RESET, instance) if (!is_probe_finish) ps3_instance_wait_for_dead_or_pre_operational(instance); LOG_WARN("host_no:%u CFID:%d wait again, retries:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + PS3_HOST(instance), cmd->index, cmd->retry_cnt); - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == - PS3_CMD_WORD_NEED_REPLY_WORD) { + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { ret = ps3_block_cmd_wait(instance, cmd, 0); } else { ret = ps3_cmd_reply_polling_when_recovery(instance, cmd, 0); @@ -1790,99 +1807,91 @@ static int ps3_no_resp_cmd_wait_proc(struct ps3_instance *instance, ret = ps3_err_mgr_cmd_proc(instance, ret, cmd); if (ret == -PS3_CMD_NO_RESP) { - LOG_WARN("host_no:%u CFID:%d wait again, retries:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + LOG_WARN("host_no:%u CFID:%d wait again, retries:%d\n", + PS3_HOST(instance), cmd->index, cmd->retry_cnt); } l_dead: - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state != PS3_CMD_STATE_INIT && - cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { - LOG_FILE_ERROR("host_no:%u CFID:%d is dead\n", - PS3_HOST(instance), cmd->index); - cmd->cmd_state.state = PS3_CMD_STATE_DEAD; - } - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state != PS3_CMD_STATE_INIT && + cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { + LOG_FILE_ERROR("host_no:%u CFID:%d is dead\n", + PS3_HOST(instance), cmd->index); + cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + } + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); l_out: - LOG_INFO("host_no:%u noresp cmd deal ret:%d\n", PS3_HOST(instance), - ret); + LOG_INFO("host_no:%u noresp cmd deal ret:%d\n", + PS3_HOST(instance),ret); return ret; } -static int ps3_no_resp_scsi_task_cmd_wait_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static S32 ps3_no_resp_scsi_task_cmd_wait_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - unsigned long flags = 0; - int ret = PS3_SUCCESS; - + ULong flags = 0; + S32 ret = PS3_SUCCESS; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); if (cmd->cmd_state.state == PS3_CMD_STATE_INIT || - cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { + cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); LOG_WARN("host_no:%u CFID:%d finished, retries:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + PS3_HOST(instance), cmd->index, cmd->retry_cnt); ret = -PS3_FAILED; goto l_out; } else { - if (cmd->req_frame->frontendReq.reqHead.noReplyWord == - PS3_CMD_WORD_NEED_REPLY_WORD) { + if (cmd->req_frame->frontendReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { init_completion(&cmd->sync_done); } ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } ps3_need_wait_hard_reset_request(instance); - LOG_WARN( - "host_no:%u scsi_task_cmd_wait_proc entry reset due to cmd not resp, CFID:%d t_id:0x%llx !\n", + LOG_WARN("host_no:%u scsi_task_cmd_wait_proc entry reset due to cmd not resp, CFID:%d t_id:0x%llx !\n", PS3_HOST(instance), cmd->index, cmd->trace_id); ret = ps3_hard_recovery_request_with_retry(instance); if (ret == -PS3_FAILED) { ret = -PS3_CMD_NO_RESP; LOG_ERROR("host_no:%u hard recovery request NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_dead; } - if (cmd->req_frame->frontendReq.reqHead.noReplyWord == - PS3_CMD_WORD_NEED_REPLY_WORD) { - ret = ps3_block_cmd_wait( - instance, cmd, - PS3_HARD_RESET_FORCE_STOP_MAX_TIME(instance)); + if (cmd->req_frame->frontendReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { + ret = ps3_block_cmd_wait(instance, cmd, PS3_HARD_RESET_FORCE_STOP_MAX_TIME(instance)); } else { - ret = ps3_cmd_reply_polling_when_recovery( - instance, cmd, - PS3_HARD_RESET_FORCE_STOP_MAX_TIME(instance)); + ret = ps3_cmd_reply_polling_when_recovery(instance, cmd, PS3_HARD_RESET_FORCE_STOP_MAX_TIME(instance)); } ret = ps3_err_mgr_cmd_proc(instance, ret, cmd); - if (ret == -PS3_CMD_NO_RESP) { - LOG_ERROR( - "host_no:%u hard recovery request,cmd timeout again\n", + if (ret == -PS3_CMD_NO_RESP) { + LOG_ERROR("host_no:%u hard recovery request,cmd timeout again\n", PS3_HOST(instance)); goto l_dead; - } else { + }else{ goto l_out; } l_dead: - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state != PS3_CMD_STATE_INIT && - cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { - LOG_FILE_ERROR("host_no:%u CFID:%d is dead\n", - PS3_HOST(instance), cmd->index); - cmd->cmd_state.state = PS3_CMD_STATE_DEAD; - } - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state != PS3_CMD_STATE_INIT && + cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { + LOG_FILE_ERROR("host_no:%u CFID:%d is dead\n", + PS3_HOST(instance), cmd->index); + cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + } + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); l_out: - LOG_INFO("host_no:%u noresp cmd deal ret:%d\n", PS3_HOST(instance), - ret); + LOG_INFO("host_no:%u noresp cmd deal ret:%d\n", + PS3_HOST(instance),ret); return ret; } -int ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, struct ps3_cmd *cmd) +S32 ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - - switch (PS3_MGR_CMD_TYPE(cmd)) { + S32 ret = PS3_SUCCESS; + switch (PS3_MGR_CMD_TYPE(cmd)) + { case PS3_CMD_MANAGEMENT: ret = ps3_no_resp_cmd_dead_proc(instance, cmd); break; @@ -1894,18 +1903,16 @@ int ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, struct ps3_cmd *cmd) break; case PS3_CMD_SAS_MANAGEMENT: if ((PS3_MGR_CMD_SUBTYPE(cmd) == PS3_SAS_SMP_REQUEST) || - (PS3_MGR_CMD_SUBTYPE(cmd) == PS3_SAS_GET_LINK_ERR) || - (PS3_MGR_CMD_SUBTYPE(cmd) == PS3_SAS_PHY_CTRL)) { + (PS3_MGR_CMD_SUBTYPE(cmd) == PS3_SAS_GET_LINK_ERR) || + (PS3_MGR_CMD_SUBTYPE(cmd) == PS3_SAS_PHY_CTRL) ) { ret = ps3_no_resp_cmd_wait_proc(instance, cmd); } else { ret = ps3_no_resp_cmd_dead_proc(instance, cmd); } break; default: - LOG_ERROR( - "host_no:%u UNEXPEXT!!!! no response proc cmd_type:%d, sub_type:%d\n", - PS3_HOST(instance), PS3_MGR_CMD_TYPE(cmd), - PS3_MGR_CMD_SUBTYPE(cmd)); + LOG_ERROR("host_no:%u UNEXPEXT!!!! no response proc cmd_type:%d, sub_type:%d \n", + PS3_HOST(instance), PS3_MGR_CMD_TYPE(cmd), PS3_MGR_CMD_SUBTYPE(cmd)); ret = -PS3_FAILED; break; } @@ -1913,66 +1920,61 @@ int ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, struct ps3_cmd *cmd) return ret; } -int ps3_mgr_complete_proc(struct ps3_instance *instance, struct ps3_cmd *cmd, - int send_result) +S32 ps3_mgr_complete_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd, S32 send_result) { - int ret = PS3_SUCCESS; - unsigned long flags = 0; + S32 ret = PS3_SUCCESS; + ULong flags = 0; - while (cmd->retry_cnt < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { + while(cmd->retry_cnt < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { if (send_result == PS3_SUCCESS) { - LOG_FILE_INFO( - "host_no:%u externel mgr CFID:%d respStatus:%d success\n", - PS3_HOST(instance), cmd->index, + LOG_FILE_INFO("host_no:%u externel mgr CFID:%d respStatus:%d success\n", + PS3_HOST(instance), + cmd->index, ps3_cmd_resp_status(cmd)); ret = PS3_SUCCESS; break; } - if (send_result == -PS3_RECOVERED) { - LOG_INFO( - "host_no:%u mgr CFID:%d respStatus:%d cannot send because recovery process\n", - PS3_HOST(instance), cmd->index, + if(send_result == -PS3_RECOVERED) { + LOG_INFO("host_no:%u mgr CFID:%d respStatus:%d cannot send because recovery process\n", + PS3_HOST(instance), + cmd->index, ps3_cmd_resp_status(cmd)); ret = -PS3_RECOVERED; break; } ret = ps3_err_mgr_cmd_proc(instance, send_result, cmd); - if (ret == -PS3_CMD_NO_RESP) + if (ret == -PS3_CMD_NO_RESP) { ret = ps3_mgr_cmd_no_resp_proc(instance, cmd); + } if (ret != -PS3_RETRY) { if ((PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_MANAGEMENT) && - (PS3_MGR_CMD_SUBTYPE(cmd) == - PS3_MGR_CMD_DEV_DEL_DONE)) { - LOG_FILE_INFO( - "host_no:%u CFID:%d retry, retries:%d, ret:%d\n", - PS3_HOST(instance), cmd->index, - cmd->retry_cnt, ret); + (PS3_MGR_CMD_SUBTYPE(cmd) == PS3_MGR_CMD_DEV_DEL_DONE)) { + LOG_FILE_INFO("host_no:%u CFID:%d retry, retries:%d, ret:%d\n", + PS3_HOST(instance), cmd->index, cmd->retry_cnt, ret); } else { - LOG_INFO( - "host_no:%u cmd:%s CFID:%d retry, retries:%d, ret:%d\n", - PS3_HOST(instance), - namePS3MgrCmdSubType( - (enum PS3MgrCmdSubType) - PS3_MGR_CMD_SUBTYPE( - cmd)), + LOG_INFO("host_no:%u cmd:%s CFID:%d retry, retries:%d, ret:%d\n", + PS3_HOST(instance), namePS3MgrCmdSubType( + (enum PS3MgrCmdSubType)PS3_MGR_CMD_SUBTYPE(cmd)), cmd->index, cmd->retry_cnt, ret); } break; } cmd->retry_cnt++; - if (cmd->retry_cnt >= PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_RETRY_DONE, cmd) + if (cmd->retry_cnt >= PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { break; + } LOG_INFO("host_no:%u mgr CFID:%d retry:%u\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + PS3_HOST(instance), cmd->index, cmd->retry_cnt); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); send_result = ps3_mgr_cmd_send_check(instance, cmd); if (send_result != PS3_SUCCESS) { - ps3_atomic_dec( - &instance->cmd_statistics.cmd_delivering); + ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); continue; } cmd->resp_frame->normalRespFrame.respStatus = 0xff; @@ -1989,32 +1991,36 @@ int ps3_mgr_complete_proc(struct ps3_instance *instance, struct ps3_cmd *cmd, if (cmd->retry_cnt >= PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { ret = -PS3_FAILED; - LOG_ERROR("host_no:%u cmd request NOK.\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u cmd request NOK.\n", + PS3_HOST(instance)); } return ret; } -unsigned char -ps3_check_ioc_state_is_normal_in_unload(struct ps3_instance *instance) +Bool ps3_check_ioc_state_is_normal_in_unload( + struct ps3_instance *instance) { - unsigned char ret = PS3_TRUE; - unsigned int ioc_state = PS3_FW_STATE_UNDEFINED; + Bool ret = PS3_TRUE; + U32 ioc_state = PS3_FW_STATE_UNDEFINED; - if (instance->state_machine.is_load) + if (instance->state_machine.is_load) { goto l_out; + } if (!ps3_ioc_state_get_with_check(instance, &ioc_state)) { ret = PS3_FALSE; goto l_out; } - if (ioc_state != PS3_FW_STATE_RUNNING) { + INJECT_START(PS3_ERR_IJ_IOC_IS_NOT_NORMAL_IN_UNLOAD, &ioc_state) + if ((ioc_state != PS3_FW_STATE_RUNNING)) { LOG_ERROR("host_no:%d ioc_state:%d is not running.\n", - PS3_HOST(instance), ioc_state); + PS3_HOST(instance), ioc_state); ret = PS3_FALSE; goto l_out; } l_out: return ret; + } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.h b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.h index d3247739ba97..aa4e1371818a 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.h @@ -1,96 +1,85 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ -#ifndef _PS3_MANAGEMENT_CMD_H_ -#define _PS3_MANAGEMENT_CMD_H_ + +#ifndef _PS3_MANAGMENT_CMD_H_ +#define _PS3_MANAGMENT_CMD_H_ #include "ps3_instance_manager.h" #include "ps3_device_manager.h" -#define PS3_MGR_BASE_DATA_SIZE (64) +#define PS3_MGR_BASE_DATA_SIZE (64) #define PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT (2) #define PS3_MGR_CMD_TYPE(cmd) ((cmd)->req_frame->mgrReq.reqHead.cmdType) #define PS3_MGR_CMD_SUBTYPE(cmd) ((cmd)->req_frame->mgrReq.reqHead.cmdSubType) -enum { +enum{ PS3_CANCEL_EVENT_CMD = 1, PS3_CANCEL_VDPENDING_CMD, - PS3_CANCEL_WEB_CMD, + PS3_CANCEL_WEB_CMD, }; -int ps3_ctrl_info_buf_alloc(struct ps3_instance *instance); +S32 ps3_ctrl_info_buf_alloc(struct ps3_instance *instance); void ps3_ctrl_info_buf_free(struct ps3_instance *instance); -int ps3_mgr_cmd_init(struct ps3_instance *instance); +S32 ps3_mgr_cmd_init(struct ps3_instance *instance); void ps3_mgr_cmd_exit(struct ps3_instance *instance); -int ps3_pd_list_get(struct ps3_instance *instance); - -int ps3_vd_list_get(struct ps3_instance *instance); +S32 ps3_pd_list_get(struct ps3_instance *instance); -int ps3_pd_info_get(struct ps3_instance *instance, unsigned short channel, - unsigned short target_id, unsigned short pd_disk_id); +S32 ps3_vd_list_get(struct ps3_instance *instance); -int ps3_vd_info_sync_get(struct ps3_instance *instance, unsigned int disk_id, - unsigned short vd_num); +S32 ps3_pd_info_get(struct ps3_instance *instance, U16 channel, U16 target_id, U16 pd_disk_id); -int ps3_vd_info_async_get(struct ps3_instance *instance); +S32 ps3_vd_info_sync_get(struct ps3_instance *instance, U32 disk_id, + U16 vd_num); -int ps3_ctrl_info_get(struct ps3_instance *instance); +S32 ps3_vd_info_async_get(struct ps3_instance *instance); -int ps3_soc_unload(struct ps3_instance *instance, unsigned char is_polling, - unsigned char type, unsigned char suspend_type); +S32 ps3_ctrl_info_get(struct ps3_instance *instance); -int ps3_scsi_remove_device_done(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, - unsigned char dev_type); +S32 ps3_soc_unload(struct ps3_instance *instance, Bool is_polling, U8 type, U8 suspend_type); -int ps3_scsi_add_device_ack(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, - unsigned char dev_type); +S32 ps3_scsi_remove_device_done(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, U8 dev_type); -int ps3_mgr_cmd_cancel(struct ps3_instance *instance, - unsigned short cancel_cmd_frame_id); +S32 ps3_scsi_add_device_ack(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, U8 dev_type); -int ps3_event_register(struct ps3_instance *instance, - struct PS3MgrEvent *event); +S32 ps3_mgr_cmd_cancel(struct ps3_instance *instance, U16 cancel_cmd_frame_id); -int ps3_web_register(struct ps3_instance *instance); +S32 ps3_event_register(struct ps3_instance *instance, + struct PS3MgrEvent *event); +S32 ps3_web_register(struct ps3_instance *instance); -int ps3_scsi_task_mgr_abort(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, - unsigned short aborted_cmd_frame_id, - struct scsi_cmnd *scmd); +S32 ps3_scsi_task_mgr_abort(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data, U16 aborted_cmd_frame_id, struct scsi_cmnd *scmd); void ps3_mgr_cmd_word_build(struct ps3_cmd *cmd); -int ps3_sas_expander_all_get(struct ps3_instance *instance); +S32 ps3_sas_expander_all_get(struct ps3_instance *instance); -int ps3_sas_phy_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req); +S32 ps3_sas_phy_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req); -int ps3_sas_expander_get(struct ps3_instance *instance, - struct PS3SasMgr *sas_req); +S32 ps3_sas_expander_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req); -int ps3_mgr_complete_proc(struct ps3_instance *instance, struct ps3_cmd *cmd, - int send_result); +S32 ps3_mgr_complete_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd, S32 send_result); struct ps3_cmd *ps3_dump_notify_cmd_build(struct ps3_instance *instance); +struct ps3_cmd * ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data); -struct ps3_cmd * -ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data); - -int ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd); +struct ps3_cmd * ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data); -unsigned char -ps3_check_ioc_state_is_normal_in_unload(struct ps3_instance *instance); +S32 ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd); -int ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, - unsigned short cancel_cmd_frame_id, - unsigned char type); +Bool ps3_check_ioc_state_is_normal_in_unload( + struct ps3_instance *instance); -int ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, unsigned char type); +S32 ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, + U16 cancel_cmd_frame_id, U8 type); +S32 ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, U8 type); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.c b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.c index 8567843b6b9b..284fa6ad779f 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include "ps3_mgr_cmd_err.h" #ifndef _WINDOWS @@ -20,55 +18,56 @@ #include "ps3_recovery.h" enum ps3_fault_action { - PS3_FAULT_STRATEGY_NONE = 0, + PS3_FAULT_STRATEGY_NONE = 0, PS3_FAULT_STRATEGY_RETRY, }; enum ps3_reset_type { - PS3_RESET_TYPE_SOFT, - PS3_RESET_TYPE_HARD, + PS3_RESET_TYPE_SOFT, + PS3_RESET_TYPE_HARD, }; struct ps3_fault_strategy { - unsigned int resp_status; + U32 resp_status; enum ps3_fault_action fault_action; }; static struct ps3_fault_strategy ps3_fault_strategy_desc[] = { - { PS3_DRV_MGR_UNRUNING, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_INVAL_CMD, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_NORESOURCE, PS3_FAULT_STRATEGY_RETRY }, - { PS3_DRV_MGR_INVAL_PARAM, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_DEV_NOEXIST, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_DEV_DATA_ERR, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_EVT_REPEAT, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_EVT_CANCEL_ERR, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_FLUSH_FAILED, PS3_FAULT_STRATEGY_RETRY }, - { PS3_DRV_MGR_BUSY, PS3_FAULT_STRATEGY_RETRY }, - { PS3_DRV_MGR_TIMEOUT, PS3_FAULT_STRATEGY_RETRY }, - { PS3_DRV_MGR_SMP_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_LINK_GET_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_PHY_CTL_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_RESTART_COMMAND_RSP, PS3_FAULT_STRATEGY_NONE }, - { PS3_DRV_MGR_TM_FAILED, PS3_FAULT_STRATEGY_NONE }, - { U32_MAX, PS3_FAULT_STRATEGY_NONE } + {PS3_DRV_MGR_UNRUNING ,PS3_FAULT_STRATEGY_NONE }, + {PS3_DRV_MGR_INVAL_CMD ,PS3_FAULT_STRATEGY_NONE }, + {PS3_DRV_MGR_NORESOURCE ,PS3_FAULT_STRATEGY_RETRY}, + {PS3_DRV_MGR_INVAL_PARAM ,PS3_FAULT_STRATEGY_NONE }, + {PS3_DRV_MGR_DEV_NOEXIST ,PS3_FAULT_STRATEGY_NONE }, + {PS3_DRV_MGR_DEV_DATA_ERR ,PS3_FAULT_STRATEGY_NONE }, + {PS3_DRV_MGR_EVT_REPEAT ,PS3_FAULT_STRATEGY_NONE }, + {PS3_DRV_MGR_EVT_CANCLE_ERR ,PS3_FAULT_STRATEGY_NONE }, + {PS3_DRV_MGR_FLUSH_FAIELD ,PS3_FAULT_STRATEGY_RETRY}, + {PS3_DRV_MGR_BUSY ,PS3_FAULT_STRATEGY_RETRY}, + {PS3_DRV_MGR_TIMEOUT ,PS3_FAULT_STRATEGY_RETRY}, + {PS3_DRV_MGR_SMP_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE}, + {PS3_DRV_MGR_LINK_GET_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE}, + {PS3_DRV_MGR_PHY_CTL_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE}, + {PS3_DRV_MGR_RESTART_COMMAND_RSP, PS3_FAULT_STRATEGY_NONE}, + {PS3_DRV_MGR_TM_FAILED, PS3_FAULT_STRATEGY_NONE}, + {U32_MAX ,PS3_FAULT_STRATEGY_NONE} }; -static inline const char *ps3_err_action_print(enum ps3_fault_action action) +static inline const S8 *ps3_err_action_print(enum ps3_fault_action action) { - static const char * const action_string[] = { - [PS3_FAULT_STRATEGY_NONE] = "PS3_FAULT_STRATEGY_NONE", - [PS3_FAULT_STRATEGY_RETRY] = "PS3_FAULT_STRATEGY_RETRY" + static const S8 *action_string[] = { + [PS3_FAULT_STRATEGY_NONE] = "PS3_FAULT_STRATEGY_NONE", + [PS3_FAULT_STRATEGY_RETRY] = "PS3_FAULT_STRATEGY_RETRY" }; return action_string[action]; } -const char *ps3_err_mgr_fault_proc_result_print(int result) +const S8 *ps3_err_mgr_fault_proc_result_print(S32 result) { - const char *proc_result_string = NULL; + const S8 *proc_result_string = NULL; - switch (result) { + switch (result) + { case PS3_SUCCESS: proc_result_string = "SUCCESS"; break; @@ -98,34 +97,34 @@ const char *ps3_err_mgr_fault_proc_result_print(int result) return proc_result_string; } -static enum ps3_fault_action -ps3_err_fault_strategy_lookup(struct ps3_instance *instance, - unsigned int resp_status, unsigned int retry_cnt) +static enum ps3_fault_action ps3_err_fault_strategy_lookup( + struct ps3_instance *instance, U32 resp_status, U32 retry_cnt) { - unsigned int idx = 0; + U32 idx = 0; enum ps3_fault_action fault_action = PS3_FAULT_STRATEGY_RETRY; - for (idx = 0; idx < ARRAY_SIZE(ps3_fault_strategy_desc); idx++) { + for (idx = 0;idx < ARRAY_SIZE(ps3_fault_strategy_desc);idx++) { if (ps3_fault_strategy_desc[idx].resp_status == resp_status) { - fault_action = - ps3_fault_strategy_desc[idx].fault_action; + fault_action + = ps3_fault_strategy_desc[idx].fault_action; break; } } - if ((fault_action == PS3_FAULT_STRATEGY_RETRY) && (retry_cnt > 0)) + if ((fault_action == PS3_FAULT_STRATEGY_RETRY) + && (retry_cnt > 0)) { fault_action = PS3_FAULT_STRATEGY_NONE; + } - LOG_INFO("host_no:%u error_no:%d fault_action is %s!\n", - PS3_HOST(instance), resp_status, - ps3_err_action_print(fault_action)); + LOG_INFO("host_no:%u error_no:%d fault_action is %s!\n", PS3_HOST(instance), + resp_status,ps3_err_action_print(fault_action)); return fault_action; } -static int ps3_err_fault_strategy_exec(struct ps3_instance *instance, - enum ps3_fault_action fault_action) +static S32 ps3_err_fault_strategy_exec(struct ps3_instance *instance, + enum ps3_fault_action fault_action) { - int proc_result = -PS3_FAILED; + S32 proc_result = -PS3_FAILED; switch (fault_action) { case PS3_FAULT_STRATEGY_RETRY: @@ -137,25 +136,23 @@ static int ps3_err_fault_strategy_exec(struct ps3_instance *instance, } LOG_INFO("host_no:%u proc result for mgr cmd fault is %s!\n", - PS3_HOST(instance), - ps3_err_mgr_fault_proc_result_print(proc_result)); + PS3_HOST(instance), ps3_err_mgr_fault_proc_result_print(proc_result)); return proc_result; } -int ps3_err_mgr_cmd_failed_check(struct ps3_instance *instance, - struct ps3_cmd *cmd) +S32 ps3_err_mgr_cmd_failed_check(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; enum ps3_fault_action fault_action = PS3_FAULT_STRATEGY_NONE; - unsigned int resp_status = cmd->resp_frame->normalRespFrame.respStatus; + U32 resp_status = cmd->resp_frame->normalRespFrame.respStatus; if (!ps3_is_instance_state_allow_cmd_execute(instance)) { ret = -PS3_FAILED; goto l_out; } - fault_action = ps3_err_fault_strategy_lookup(instance, resp_status, - cmd->retry_cnt); + fault_action = ps3_err_fault_strategy_lookup(instance, resp_status, cmd->retry_cnt); ret = ps3_err_fault_strategy_exec(instance, fault_action); l_out: return ret; @@ -167,6 +164,7 @@ void ps3_err_fault_context_init(struct ps3_instance *instance) memset(fault_context, 0, sizeof(*fault_context)); ps3_atomic_set(&instance->is_err_scsi_processing, 0); + } void ps3_err_fault_context_exit(struct ps3_instance *instance) @@ -176,66 +174,54 @@ void ps3_err_fault_context_exit(struct ps3_instance *instance) memset(fault_context, 0, sizeof(*fault_context)); } -int ps3_err_mgr_cmd_proc(struct ps3_instance *instance, int fault_type, - struct ps3_cmd *cmd) +S32 ps3_err_mgr_cmd_proc(struct ps3_instance *instance, + S32 fault_type, struct ps3_cmd *cmd) { - int proc_result = PS3_SUCCESS; - int cur_state = PS3_INSTANCE_STATE_INIT; - - LOG_INFO("host_no:%u fault_type: %s, retries:%d!\n", PS3_HOST(instance), - ps3_err_mgr_fault_proc_result_print(fault_type), - cmd->retry_cnt); + S32 proc_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + LOG_INFO("host_no:%u fault_type: %s, retries:%d!\n", + PS3_HOST(instance), + ps3_err_mgr_fault_proc_result_print(fault_type), cmd->retry_cnt); switch (fault_type) { case PS3_SUCCESS: break; case -PS3_RESP_ERR: if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) { - LOG_INFO( - "host_no:%u CFID:%d trace_id:0x%llx cli return err:%u\n", - PS3_HOST(instance), cmd->cmd_word.cmdFrameID, - cmd->trace_id, ps3_cmd_resp_status(cmd)); + LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx cli return err:%u\n", + PS3_HOST(instance), + cmd->cmd_word.cmdFrameID, cmd->trace_id, ps3_cmd_resp_status(cmd)); if (instance->is_probe_finish) { - if (ps3_cmd_resp_status(cmd) == - PS3_DRV_MGR_BUSY) { - LOG_INFO( - "host_no:%u CFID:%d trace_id:0x%llx cli return busy\n", + if (ps3_cmd_resp_status(cmd) == PS3_DRV_MGR_BUSY) { + LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx cli return busy\n", PS3_HOST(instance), - cmd->cmd_word.cmdFrameID, - cmd->trace_id); - if (ps3_instance_wait_for_normal( - instance) == PS3_SUCCESS) { - cmd->req_frame->mgrReq.value - .isRetry = PS3_TRUE; + cmd->cmd_word.cmdFrameID, cmd->trace_id); + if (ps3_instance_wait_for_normal(instance) == PS3_SUCCESS){ + cmd->req_frame->mgrReq.value.isRetry = PS3_TRUE; proc_result = -PS3_RETRY; } else { proc_result = -PS3_FAILED; } - } else if (ps3_cmd_resp_status(cmd) == - PS3_DRV_MGR_RESTART_COMMAND_RSP) { - LOG_WARN( - "host_no:%u CFID:%d trace_id:0x%llx cli cx restart return success\n", + } else if(ps3_cmd_resp_status(cmd) == PS3_DRV_MGR_RESTART_COMMAND_RSP){ + LOG_WARN("host_no:%u CFID:%d trace_id:0x%llx cli cx restart return success\n", PS3_HOST(instance), - cmd->cmd_word.cmdFrameID, - cmd->trace_id); - ps3_need_wait_hard_reset_request( - instance); - if (ps3_recovery_state_wait_for_normal( - instance) != PS3_SUCCESS) { + cmd->cmd_word.cmdFrameID, cmd->trace_id); + ps3_need_wait_hard_reset_request(instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_2, instance) + if (ps3_recovery_state_wait_for_normal(instance) == PS3_SUCCESS){ + ret = ps3_hard_recovery_request_with_retry(instance); + if (ret != PS3_SUCCESS){ + LOG_WARN("host_no:%u hard recovery request NOK\n", + PS3_HOST(instance)); + } + } else { proc_result = -PS3_FAILED; - } else if (ps3_hard_recovery_request_with_retry(instance) - != PS3_SUCCESS) { - LOG_WARN( - "host_no:%u hard recovery request NOK\n", - PS3_HOST(instance)); } } else { - cur_state = ps3_atomic_read( - &instance->state_machine.state); - if (cur_state == - PS3_INSTANCE_STATE_QUIT || - cur_state == - PS3_INSTANCE_STATE_DEAD) { + cur_state = ps3_atomic_read(&instance->state_machine.state); + if (cur_state == PS3_INSTANCE_STATE_QUIT || + cur_state == PS3_INSTANCE_STATE_DEAD) { proc_result = -PS3_ENODEV; } else { proc_result = -PS3_FAILED; @@ -257,13 +243,13 @@ int ps3_err_mgr_cmd_proc(struct ps3_instance *instance, int fault_type, break; } - if (proc_result != -PS3_CMD_NO_RESP) + if (proc_result != -PS3_CMD_NO_RESP) { cmd->cmd_state.reset_flag = 0; + } LOG_INFO("host_no:%u proc_result: %s, retries:%d!\n", - PS3_HOST(instance), - ps3_err_mgr_fault_proc_result_print(proc_result), - cmd->retry_cnt); + PS3_HOST(instance), + ps3_err_mgr_fault_proc_result_print(proc_result), cmd->retry_cnt); return proc_result; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.h b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.h index 13ea2258da34..772a9bd54d2d 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.h @@ -1,29 +1,27 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_MGR_CMD_ERR_H_ #define _PS3_MGR_CMD_ERR_H_ #ifndef _WINDOWS #include #include -#include "linux/kernel.h" #endif #include "ps3_htp_def.h" #include "ps3_instance_manager.h" -#define PS3_ERR_MGR_CMD_FAULT_RETRY_MAX (3) +#define PS3_ERR_MGR_CMD_FAULT_RETRY_MAX (3) #define PS3_ERR_MGR_CMD_DELAY_TIME_BEFORE_RERTY (500) void ps3_err_fault_context_init(struct ps3_instance *instance); void ps3_err_fault_context_exit(struct ps3_instance *instance); -int ps3_err_mgr_cmd_proc(struct ps3_instance *instance, int fault_type, - struct ps3_cmd *cmd); +S32 ps3_err_mgr_cmd_proc(struct ps3_instance *instance, + S32 fault_type, struct ps3_cmd *cmd); -int ps3_err_mgr_cmd_failed_check(struct ps3_instance *instance, - struct ps3_cmd *cmd); +S32 ps3_err_mgr_cmd_failed_check(struct ps3_instance *instance, + struct ps3_cmd *cmd); -const char *ps3_err_mgr_fault_proc_result_print(int result); +const S8 *ps3_err_mgr_fault_proc_result_print(S32 result); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_module_para.c b/drivers/scsi/linkdata/ps3stor/ps3_module_para.c index 8f1d3e2d8412..d6a682ba0025 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_module_para.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_module_para.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #ifndef _WINDOWS #include "linux/moduleparam.h" #endif @@ -8,623 +7,638 @@ #include "ps3_driver_log.h" #include "ps3_drv_ver.h" #include "ps3_ioc_state.h" -#include "ps3_kernel_version.h" #ifndef _WINDOWS -static unsigned int cli_ver = PS3_IOCTL_VERSION; -module_param(cli_ver, uint, 0444); +static U32 cli_ver = PS3_IOCTL_VERSION; +module_param(cli_ver, uint, S_IRUGO | S_IRUSR); MODULE_PARM_DESC(cli_ver, - "The version for communication between driver and CLI"); + "The version for communication between driver and CLI"); #endif -static unsigned int g_throttle_que_depth = PS3_DEVICE_QDEPTH_DEFAULT_VALUE; +static U32 g_throttle_que_depth = PS3_DEVICE_QDEPTH_DEFAULT_VALUE; #ifndef _WINDOWS -module_param(g_throttle_que_depth, uint, 0644); -MODULE_PARM_DESC( - g_throttle_que_depth, +module_param(g_throttle_que_depth, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_throttle_que_depth, "IOC queue depth when throttled due to SCSI cmd timeout. Default: 16"); #endif -static unsigned int g_debug_mem_size; +static U32 g_debug_mem_size = 0; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_debug_mem_size, uint, 0644); -MODULE_PARM_DESC( - g_debug_mem_size, +module_param(g_debug_mem_size, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_debug_mem_size, "Allocate DMA memory for IOC debugging little than 65535KB. Default: 0KB"); #endif #endif -static unsigned int g_use_clustering = 1; +static U32 g_use_clustering = 1; #ifndef _WINDOWS -module_param(g_use_clustering, uint, 0644); -MODULE_PARM_DESC( - g_use_clustering, +module_param(g_use_clustering, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_use_clustering, "SCSI mid-layer bio merge feature enable/disable. Default: enable(1)"); #endif -static unsigned int g_scsi_cmd_timeout; +static U32 g_scsi_cmd_timeout = 0; #ifndef _WINDOWS -module_param(g_scsi_cmd_timeout, uint, 0644); -MODULE_PARM_DESC( - g_scsi_cmd_timeout, +module_param(g_scsi_cmd_timeout, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_scsi_cmd_timeout, "SCSI cmd timeout (10-255s). Default: 0(No specify default 90s)"); #endif -extern unsigned int g_ps3_r1x_lock_flag; -extern unsigned int g_ps3_r1x_lock_enable; +extern U32 g_ps3_r1x_lock_flag; +extern U32 g_ps3_r1x_lock_enable; #ifndef _WINDOWS -module_param(g_ps3_r1x_lock_enable, uint, 0644); -MODULE_PARM_DESC( - g_ps3_r1x_lock_enable, +#if 0 +module_param(g_ps3_r1x_lock_flag, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_ps3_r1x_lock_flag, + "R1X write conflict check func. 0 - hash+bitmap, 1 - " + "hash+rangetree. Default: 0"); +#endif +module_param(g_ps3_r1x_lock_enable, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_ps3_r1x_lock_enable, "R1x write conflict check feature enable/disable. Default: enable(1)"); #endif -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -extern unsigned int g_ps3_qos_hdd_pd_quota; -extern unsigned int g_ps3_qos_nvme_pd_quota; +extern U32 g_ps3_qos_hdd_pd_quota; +extern U32 g_ps3_qos_nvme_pd_quota; #ifndef _WINDOWS -module_param(g_ps3_qos_hdd_pd_quota, uint, 0644); -MODULE_PARM_DESC(g_ps3_qos_hdd_pd_quota, "Qos pd quota. Default: 40"); -module_param(g_ps3_qos_nvme_pd_quota, uint, 0644); -MODULE_PARM_DESC(g_ps3_qos_nvme_pd_quota, "Qos nvme pd quota. Default: 127"); +module_param(g_ps3_qos_hdd_pd_quota, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_ps3_qos_hdd_pd_quota, + "Qos pd quota. Default: 40"); +module_param(g_ps3_qos_nvme_pd_quota, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_ps3_qos_nvme_pd_quota, + "Qos nvme pd quota. Default: 127"); #endif -extern unsigned int g_ps3_r1x_rb_diff_cmds; +extern U32 g_ps3_r1x_rb_diff_cmds; #ifndef _WINDOWS -module_param(g_ps3_r1x_rb_diff_cmds, uint, 0644); +module_param(g_ps3_r1x_rb_diff_cmds, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_ps3_r1x_rb_diff_cmds, - "R1x read balancing outstanding threshold. Default: 4"); + "R1x read balancing outstanding threshold. Default: 4"); #endif #endif -static unsigned int g_direct_to_normal_enable = 1; +static U32 g_direct_to_normal_enable = 1; #ifndef _WINDOWS -module_param(g_direct_to_normal_enable, uint, 0644); +module_param(g_direct_to_normal_enable, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_direct_to_normal_enable, - "Direct to normal feature enable/disable. Default: enable(1)"); + "Direct to normal feature enable/disable. Default: enable(1)"); #endif -static unsigned int g_hba_check_time = 10; +static U32 g_hba_check_time = 10; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_hba_check_time, uint, 0644); -MODULE_PARM_DESC(g_hba_check_time, - "HBA device id check time out. Default: 10s"); +module_param(g_hba_check_time, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_hba_check_time, "HBA device id check time out. Default: 10s"); #endif #endif -static unsigned int g_task_reset_delay_time = 50; +static U32 g_task_reset_delay_time = 50; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_task_reset_delay_time, uint, 0644); +module_param(g_task_reset_delay_time, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_task_reset_delay_time, - "Task reset delay time (0-1000ms). Default: 50ms"); + "Task reset delay time (0-1000ms). Default: 50ms"); #endif #endif -static unsigned int g_r1x_ring_size = 16; +static U32 g_r1x_ring_size = 16; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_r1x_ring_size, uint, 0644); -MODULE_PARM_DESC( - g_r1x_ring_size, +module_param(g_r1x_ring_size, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_r1x_ring_size, "If R1X direct read more than g_r1x_ring_size, read from spare. Default: 16MB"); #endif #endif -static unsigned int g_direct_check_stream_enable = PS3_TRUE; +static U32 g_direct_check_stream_enable = PS3_TRUE; #ifndef _WINDOWS -module_param(g_direct_check_stream_enable, uint, 0644); -MODULE_PARM_DESC( - g_direct_check_stream_enable, +module_param(g_direct_check_stream_enable, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_direct_check_stream_enable, "Direct detect stream or not feature enable/disable. Default: enable(1)"); #endif -static int g_device_busy_threshold = PS3_DEVICE_IO_BUSY_THRESHOLD; +static S32 g_device_busy_threshold = PS3_DEVICE_IO_BUSY_THRESHOLD; #ifndef _WINDOWS module_param(g_device_busy_threshold, int, 0644); MODULE_PARM_DESC(g_device_busy_threshold, - "Device busy threshold value. Default: 8"); + "Device busy threshold value. Default: 8"); #endif #ifndef __cplusplus -static char g_log_path[80] = { 0 }; +static char g_log_path[80] = {0}; #ifndef _WINDOWS -module_param_string(g_log_path, g_log_path, 80, 0644); -MODULE_PARM_DESC( - g_log_path, - "The log path of host driver will be saved little than 80 chars. Default: /var/log"); +module_param_string(g_log_path, g_log_path, 80, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_log_path, "The log path of host driver will be saved little than 80 chars. Default: /var/log"); #endif #endif -static unsigned int g_log_file_size = 200; +static U32 g_log_file_size = 200; #ifdef PS3_CFG_RELEASE -static unsigned int g_log_level = LEVEL_INFO; +static U32 g_log_level = LEVEL_INFO; #else -static unsigned int g_log_level = LEVEL_DEBUG; +static U32 g_log_level = LEVEL_DEBUG; #endif -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #ifndef _WINDOWS -module_param(g_log_file_size, uint, 0644); +module_param(g_log_file_size, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_log_file_size, - "Single driver log file size (10-200MB). Default: 200MB"); + "Single driver log file size (10-200MB). Default: 200MB"); -module_param(g_log_level, uint, 0644); +module_param(g_log_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_log_level, - "Specify driver log level." + "Specify driver log level." #ifdef PS3_CFG_RELEASE - "0 - error, 1 - warn, 2 - info, 3 - debug. Default: 2"); + "0 - error, 1 - warn, 2 - info, 3 - debug. Default: 2"); #else - "0 - error, 1 - warn, 2 - info, 3 - debug. Default: 3"); + "0 - error, 1 - warn, 2 - info, 3 - debug. Default: 3"); #endif #endif #endif -static unsigned int g_r1x_time_out = 3000; +static U32 g_r1x_time_out = 3000; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_r1x_time_out, uint, 0644); +module_param(g_r1x_time_out, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_r1x_time_out, - "R1X conflict in queue after time. Default: 3000ms"); + "R1X conflict in queue after time. Default: 3000ms"); #endif #endif -static unsigned int g_r1x_conflict_queue_enable = PS3_TRUE; +static U32 g_r1x_conflict_queue_enable = PS3_TRUE; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_r1x_conflict_queue_enable, uint, 0644); -MODULE_PARM_DESC( - g_r1x_conflict_queue_enable, +module_param(g_r1x_conflict_queue_enable, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_r1x_conflict_queue_enable, "R1X conflict queue function feature enable/disable. Default: enable(1)"); #endif #endif #ifndef _WINDOWS +#ifdef PS3_SUPPORT_INJECT +#define PS3_MAX_ERR_INJECT (16) +static U32 g_err_inject[PS3_MAX_ERR_INJECT]; +static U32 num_inject; +static U32 g_enable_inject = 0; +module_param_array(g_err_inject, uint, &num_inject, 0); +MODULE_PARM_DESC(g_err_inject, + "Err inject array. Default: 0"); +module_param(g_enable_inject, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_enable_inject, + "Err inject feature enable/disable. Default: disable(0)"); + +U32 ps3_err_inject_num_query(void) +{ + return num_inject; +} +U32* ps3_err_inject_array_query(void) +{ + return &g_err_inject[0]; +} +U32 ps3_err_inject_state_query(void) +{ + return g_enable_inject; +} + #endif -static unsigned int g_log_space_size; +#endif +static U32 g_log_space_size = 0; -static unsigned int g_log_tty; +static U32 g_log_tty = 0; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_log_tty, uint, 0644); -MODULE_PARM_DESC( - g_log_tty, +module_param(g_log_tty, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_log_tty, "Allow driver log output to tty console feature enable/disable. Default: disable(0)"); #endif #endif #if defined PS3_HARDWARE_ASIC -static unsigned int g_hard_reset_enable = 1; -static unsigned int g_deep_soft_reset_enable; -#elif (((defined PS3_HARDWARE_FPGA || defined PS3_HARDWARE_ASIC) && \ - defined PS3_MODEL_V200) || \ - defined(PS3_HARDWARE_HAPS_V200)) -static unsigned int g_hard_reset_enable = 1; -static unsigned int g_deep_soft_reset_enable; +static U32 g_hard_reset_enable = 1; +static U32 g_deep_soft_reset_enable = 0; +#elif (((defined PS3_HARDWARE_FPGA || defined PS3_HARDWARE_ASIC) \ + && defined PS3_MODEL_V200)\ + || defined(PS3_HARDWARE_HAPS_V200)) +static U32 g_hard_reset_enable = 1; +static U32 g_deep_soft_reset_enable = 0; #else -static unsigned int g_hard_reset_enable; -static unsigned int g_deep_soft_reset_enable; +static U32 g_hard_reset_enable = 0; +static U32 g_deep_soft_reset_enable = 0; #endif #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_hard_reset_enable, uint, 0644); +module_param(g_hard_reset_enable, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_hard_reset_enable, - "Hard reset feature enable/disable. Default: enable(1)"); -module_param(g_deep_soft_reset_enable, uint, 0644); + "Hard reset feature enable/disable. Default: enable(1)"); +module_param(g_deep_soft_reset_enable, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_deep_soft_reset_enable, - "Deep soft reset feature enable/disable. Default: disable(0)"); + "Deep soft reset feature enable/disable. Default: disable(0)"); #endif #endif -static unsigned int g_aer_handle_support = 1; +static U32 g_aer_handle_support = 1; #ifndef _WINDOWS -module_param(g_aer_handle_support, uint, 0644); -MODULE_PARM_DESC( - g_aer_handle_support, +module_param(g_aer_handle_support, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_aer_handle_support, "Driver aer handle support feature enable/disable. Default: enable(1)"); #endif #ifndef __cplusplus -static char g_version_verbose[512] = { 0 }; +static char g_version_verbose[512] = {0}; #ifndef _WINDOWS -module_param_string(g_version_verbose, g_version_verbose, 511, 0444); -MODULE_PARM_DESC(g_version_verbose, - "Display detailed version information about ps3stor driver"); +module_param_string(g_version_verbose, g_version_verbose, 511, S_IRUGO); +MODULE_PARM_DESC(g_version_verbose, "Display detailed version information about ps3stor driver"); #endif #endif -static unsigned int g_hard_reset_waiting; -static unsigned int g_use_hard_reset_reg = 1; -static unsigned int g_use_hard_reset_max_retry = PS3_HARD_RESET_MAX_RETRY; +static U32 g_hard_reset_waiting = 0; +static U32 g_use_hard_reset_reg = 1; +static U32 g_use_hard_reset_max_retry = PS3_HARD_RESET_MAX_RETRY; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_hard_reset_waiting, uint, 0644); +module_param(g_hard_reset_waiting, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_hard_reset_waiting, - "Allow to access PCIe Config/BAR after xxx ms. Default: 0"); -module_param(g_use_hard_reset_reg, uint, 0644); -MODULE_PARM_DESC( - g_use_hard_reset_reg, + "Allow to access PCIe Config/BAR after xxx ms. Default: 0"); +module_param(g_use_hard_reset_reg, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_use_hard_reset_reg, "Write hard reset reg triggered feature enable/disable. Default: enable(1)"); -module_param(g_use_hard_reset_max_retry, uint, 0644); +module_param(g_use_hard_reset_max_retry, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_use_hard_reset_max_retry, - "Hard reset retry max count. Default: 2"); + "Hard reset retry max count. Default: 2"); #endif #endif -#if ((defined PS3_HARDWARE_FPGA && defined PS3_MODEL_V200) || \ - defined(PS3_HARDWARE_HAPS_V200) || defined(PS3_HARDWARE_ASIC)) -static unsigned int g_enable_heartbeat = 1; +#if ((defined PS3_HARDWARE_FPGA && defined PS3_MODEL_V200) \ + || defined(PS3_HARDWARE_HAPS_V200) || defined(PS3_HARDWARE_ASIC)) +static U32 g_enable_heartbeat = 1; module_param(g_enable_heartbeat, uint, 0644); MODULE_PARM_DESC(g_enable_heartbeat, - "Heartbeat query feature enable/disable. Default: enable(1)"); + "Heartbeat query feature enable/disable. Default: enable(1)"); #else -static unsigned int g_enable_heartbeat; -module_param(g_enable_heartbeat, uint, 0644); +static U32 g_enable_heartbeat = 0; +module_param(g_enable_heartbeat, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_enable_heartbeat, - "Heartbeat query feature enable/disable. Default: disable(0)"); + "Heartbeat query feature enable/disable. Default: disable(0)"); #endif -static unsigned int g_hil_mode = 0xFFFF; +static U32 g_hil_mode = 0xFFFF; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_hil_mode, uint, 0644); -MODULE_PARM_DESC( -g_hil_mode, -"Set HIL operational mode.\n" -"\t0 - SW mode, 1 - HW mode, 2 - Enhanced HW mode, 3 - SW assist mode. Default: 65535(0xFFFF)"); +module_param(g_hil_mode, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_hil_mode, + "Set HIL operational mode." + "0 - SW mode, 1 - HW mode, 2 - Enhanced HW mode, 3 - SW assist mode. Default: 65535(0xFFFF)"); #endif #endif -static unsigned int g_available_func_id = 0xFF; +static U32 g_avaliable_func_id = 0xFF; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_available_func_id, uint, 0644); -MODULE_PARM_DESC(g_available_func_id, - "Set function id.\n" - "\t0 - Func0, 1 - Func1, 2 - Unlimited. Default: 255(0xFF)"); +module_param(g_avaliable_func_id, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_avaliable_func_id, + "Set function id." + "0 - Func0, 1 - Func1, 2 - Unlimited. Default: 255(0xFF)"); #endif #endif -static unsigned int g_pci_irq_mode = PS3_PCI_IRQ_MODE_NONE_SPE; +static U32 g_pci_irq_mode = PS3_PCI_IRQ_MODE_NONE_SPE; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_pci_irq_mode, uint, 0644); +module_param(g_pci_irq_mode, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(g_pci_irq_mode, - "Specify pci irq mode.\n" - "\t0 - none specify, 1 - legacy, 2 - msi, 3 - msix. Default: 0"); + "Specify pci irq mode." + "0 - none specify, 1 - legacy, 2 - msi, 3 - msix. Default: 0"); #endif #endif #if defined(PS3_TAGSET_SUPPORT) -#if defined(PS3_SUPPORT_TAGSET) -static int g_ps3_tagset_enable = 1; +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR > 5)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 1)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0))) +S32 g_ps3_tagset_enable = 1; module_param(g_ps3_tagset_enable, int, 0444); -MODULE_PARM_DESC(g_ps3_tagset_enable, - "Shared host tagset enable/disable. Default: enable(1)"); +MODULE_PARM_DESC(g_ps3_tagset_enable, "Shared host tagset enable/disable. Default: enable(1)"); #else -static int g_ps3_tagset_enable; +S32 g_ps3_tagset_enable = 0; module_param(g_ps3_tagset_enable, int, 0444); -MODULE_PARM_DESC(g_ps3_tagset_enable, - "Shared host tagset enable/disable. Default: disable(0)"); +MODULE_PARM_DESC(g_ps3_tagset_enable, "Shared host tagset enable/disable. Default: disable(0)"); #endif #endif -static unsigned int g_smp_affinity_enable = 1; +static U32 g_smp_affinity_enable = 1; module_param(g_smp_affinity_enable, int, 0444); -MODULE_PARM_DESC(g_smp_affinity_enable, - "SMP affinity feature enable/disable. Default: enable(1)"); +MODULE_PARM_DESC(g_smp_affinity_enable, "SMP affinity feature enable/disable. Default: enable(1)"); void ps3_version_verbose_fill(void) { #ifndef __cplusplus - int len = 0; - int total_len = sizeof(g_version_verbose) - 1; + S32 len = 0; + S32 total_len = sizeof(g_version_verbose) - 1; memset(g_version_verbose, 0, sizeof(g_version_verbose)); len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", - "version", PS3_DRV_VERSION); + "version", PS3_DRV_VERSION); len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", - "commit_id", PS3_DRV_COMMIT_ID); + "commit_id", PS3_DRV_COMMIT_ID); len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", - "toolchain_id", PS3_DRV_TOOLCHAIN_ID); + "toolchain_id", PS3_DRV_TOOLCHAIN_ID); len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", - "build_time", PS3_DRV_BUILD_TIME); + "build_time", PS3_DRV_BUILD_TIME); len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", - "product_support", PS3_DRV_PRODUCT_SUPPORT); + "product_support", PS3_DRV_PRODUCT_SUPPORT); #endif } -unsigned int ps3_throttle_qdepth_query(void) +U32 ps3_throttle_qdepth_query(void) { return g_throttle_que_depth; } -void ps3_debug_mem_size_modify(unsigned int size) +void ps3_debug_mem_size_modify(U32 size) { g_debug_mem_size = size; } -unsigned int ps3_debug_mem_size_query(void) +U32 ps3_debug_mem_size_query(void) { return g_debug_mem_size; } -unsigned short ps3_use_clustering_query(void) +U16 ps3_use_clustering_query(void) { - return (unsigned short)g_use_clustering; + return (U16)g_use_clustering; } -void ps3_scsi_cmd_timeout_modify(unsigned int val) +void ps3_scsi_cmd_timeout_modify(U32 val) { g_scsi_cmd_timeout = val; } void ps3_scsi_cmd_timeout_adjust(void) { - if (g_scsi_cmd_timeout != 0 && - (g_scsi_cmd_timeout < PS3_SCSI_CMD_TIMEOUT_MIN || - g_scsi_cmd_timeout > PS3_SCSI_CMD_TIMEOUT_MAX)) { + + if (g_scsi_cmd_timeout != 0 && ( + g_scsi_cmd_timeout < PS3_SCSI_CMD_TIMEOUT_MIN || + g_scsi_cmd_timeout > PS3_SCSI_CMD_TIMEOUT_MAX)) { g_scsi_cmd_timeout = PS3_SCSI_CMD_TIMEOUT_DEFAULT; } } -unsigned int ps3_scsi_cmd_timeout_query(void) +U32 ps3_scsi_cmd_timeout_query(void) { return g_scsi_cmd_timeout; } -unsigned int ps3_r1x_lock_flag_quiry(void) +U32 ps3_r1x_lock_flag_quiry(void) { return g_ps3_r1x_lock_flag; } -void ps3_r1x_lock_flag_modify(unsigned int val) +void ps3_r1x_lock_flag_modify(U32 val) { g_ps3_r1x_lock_flag = val; } -unsigned int ps3_direct_to_normal_query(void) +U32 ps3_direct_to_normal_query(void) { return g_direct_to_normal_enable; } -void ps3_direct_to_normal_modify(unsigned int val) +void ps3_direct_to_normal_modify(U32 val) { g_direct_to_normal_enable = val; } -unsigned int ps3_hba_check_time_query(void) +U32 ps3_hba_check_time_query(void) { return g_hba_check_time; } -unsigned int ps3_task_reset_delay_time_query(void) +U32 ps3_task_reset_delay_time_query(void) { return g_task_reset_delay_time; } -unsigned long long ps3_r1x_ring_size_query(void) +U64 ps3_r1x_ring_size_query(void) { - unsigned long long ring_size_byte = (unsigned long long)g_r1x_ring_size; - + U64 ring_size_byte = (U64)g_r1x_ring_size; ring_size_byte = MB_TO_BYTE(ring_size_byte); return ring_size_byte; } -void ps3_r1x_ring_size_modify(unsigned int size) +void ps3_r1x_ring_size_modify(U32 size) { g_r1x_ring_size = size; } -unsigned int ps3_direct_check_stream_query(void) +U32 ps3_direct_check_stream_query(void) { return g_direct_check_stream_enable; } -void ps3_direct_check_stream_modify(unsigned int val) +void ps3_direct_check_stream_modify(U32 val) { g_direct_check_stream_enable = val; } -int ps3_device_busy_threshold_query(void) +S32 ps3_device_busy_threshold_query(void) { return g_device_busy_threshold; } -void ps3_device_busy_threshold_modify(int busy) +void ps3_device_busy_threshold_modify(S32 busy) { g_device_busy_threshold = busy; } -void ps3_log_level_modify(unsigned int level) +void ps3_log_level_modify(U32 level) { - ps3_level_set(level); + ps3_level_set(level); } -char *ps3_log_path_query(void) +char* ps3_log_path_query(void) { #ifndef __cplusplus - return g_log_path; + return g_log_path; #else - return NULL; + return NULL; #endif } -unsigned int ps3_log_space_size_query(void) +U32 ps3_log_space_size_query(void) { - return g_log_space_size; + return g_log_space_size; } -unsigned int ps3_log_file_size_query(void) +U32 ps3_log_file_size_query(void) { - return g_log_file_size; + return g_log_file_size; } -unsigned int ps3_log_level_query(void) +U32 ps3_log_level_query(void) { return g_log_level; } -void ps3_log_file_size_modify(unsigned int size) +void ps3_log_file_size_modify(U32 size) { - g_log_file_size = size; + g_log_file_size = size; } -unsigned int ps3_log_tty_query(void) +U32 ps3_log_tty_query(void) { - return g_log_tty; + return g_log_tty; } -void ps3_log_tty_modify(unsigned int enable) +void ps3_log_tty_modify(U32 enable) { - g_log_tty = enable; + g_log_tty = enable; } -void ps3_hard_reset_enable_modify(unsigned int val) +void ps3_hard_reset_enable_modify(U32 val) { g_hard_reset_enable = val; } -unsigned int ps3_hard_reset_enable_query(void) +U32 ps3_hard_reset_enable_query(void) { return g_hard_reset_enable; } -unsigned int ps3_deep_soft_reset_enable_query(void) +U32 ps3_deep_soft_reset_enable_query(void) { return g_deep_soft_reset_enable; } -void ps3_deep_soft_reset_enable_modify(unsigned int val) +void ps3_deep_soft_reset_enable_modify(U32 val) { g_deep_soft_reset_enable = val; } -unsigned int ps3_aer_handle_support_query(void) +U32 ps3_aer_handle_support_query(void) { return g_aer_handle_support; } -void ps3_aer_handle_support_set(unsigned int aer_handle_support) +void ps3_aer_handle_support_set(U32 aer_handle_support) { g_aer_handle_support = aer_handle_support; } -unsigned int ps3_hard_reset_waiting_query(void) +U32 ps3_hard_reset_waiting_query(void) { return g_hard_reset_waiting; } -unsigned int ps3_use_hard_reset_reg_query(void) +U32 ps3_use_hard_reset_reg_query(void) { return g_use_hard_reset_reg; } -unsigned int ps3_use_hard_reset_max_retry(void) +U32 ps3_use_hard_reset_max_retry(void) { return g_use_hard_reset_max_retry; } -unsigned int ps3_enable_heartbeat_query(void) +U32 ps3_enable_heartbeat_query(void) { return g_enable_heartbeat; } -unsigned int ps3_enable_heartbeat_set(unsigned int val) +U32 ps3_enable_heartbeat_set(U32 val) { return g_enable_heartbeat = val; } -unsigned int ps3_hil_mode_query(void) +U32 ps3_hil_mode_query(void) { return g_hil_mode; } -void ps3_hil_mode_modify(unsigned int val) +void ps3_hil_mode_modify(U32 val) { g_hil_mode = val; + return; } -unsigned int ps3_available_func_id_query(void) +U32 ps3_available_func_id_query(void) { - return g_available_func_id; + return g_avaliable_func_id; } -void ps3_available_func_id_modify(unsigned int val) +void ps3_available_func_id_modify(U32 val) { - g_available_func_id = val; + g_avaliable_func_id = val; + return; } -unsigned int ps3_r1x_tmo_query(void) +U32 ps3_r1x_tmo_query(void) { - if (unlikely(g_r1x_time_out > 360000)) + if (unlikely(g_r1x_time_out > 360000)) { g_r1x_time_out = 360000; + } return g_r1x_time_out * HZ / 1000; } -unsigned int ps3_r1x_conflict_queue_support_query(void) +U32 ps3_r1x_conflict_queue_support_query(void) { return g_r1x_conflict_queue_enable; } -unsigned int ps3_pci_irq_mode_query(void) +U32 ps3_pci_irq_mode_query(void) { return g_pci_irq_mode; } -unsigned int ps3_cli_ver_query(void) +U32 ps3_cli_ver_query(void) { return cli_ver; } #if defined(PS3_TAGSET_SUPPORT) -void ps3_tagset_enable_modify(unsigned char enable) +Bool ps3_tagset_enable_query(void) { - g_ps3_tagset_enable = enable; -} - -unsigned char ps3_tagset_enable_query(void) -{ - return (g_ps3_tagset_enable == 1) ? PS3_TRUE : PS3_FALSE; + return (g_ps3_tagset_enable == 1) ? PS3_TRUE: PS3_FALSE; } #endif -unsigned char ps3_smp_affinity_query(void) +Bool ps3_smp_affinity_query(void) { return (g_smp_affinity_enable == 1) ? PS3_TRUE : PS3_FALSE; } + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_module_para.h b/drivers/scsi/linkdata/ps3stor/ps3_module_para.h index 354c80c3d9ba..51b334d16621 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_module_para.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_module_para.h @@ -1,103 +1,121 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_MODULE_PARA_H_ #define _PS3_MODULE_PARA_H_ +#include "ps3_types.h" + #define MB_TO_BYTE(MB) ((MB) << 20) -#define PS3_MAX_FUNC_ID (2) +#define PS3_MAX_FUNC_ID (2) -unsigned int ps3_throttle_qdepth_query(void); +U32 ps3_throttle_qdepth_query(void); -void ps3_debug_mem_size_modify(unsigned int size); +void ps3_debug_mem_size_modify(U32 size); -unsigned int ps3_debug_mem_size_query(void); +U32 ps3_debug_mem_size_query(void); -unsigned int ps3_sata_direct_query(void); +U32 ps3_sata_direct_query(void); -void ps3_sata_direct_modify(unsigned int val); +void ps3_sata_direct_modify(U32 val); -unsigned short ps3_use_clustering_query(void); +U16 ps3_use_clustering_query(void); -void ps3_scsi_cmd_timeout_modify(unsigned int val); +void ps3_scsi_cmd_timeout_modify(U32 val); -unsigned int ps3_scsi_cmd_timeout_query(void); +U32 ps3_scsi_cmd_timeout_query(void); void ps3_scsi_cmd_timeout_adjust(void); -unsigned int ps3_r1x_lock_flag_quiry(void); +U32 ps3_r1x_lock_flag_quiry(void); + +void ps3_r1x_lock_flag_modify(U32 val); -void ps3_r1x_lock_flag_modify(unsigned int val); +U32 ps3_direct_to_normal_query(void); -unsigned int ps3_direct_to_normal_query(void); +void ps3_direct_to_normal_modify(U32 val); -void ps3_direct_to_normal_modify(unsigned int val); +U32 ps3_hba_check_time_query(void); -unsigned int ps3_hba_check_time_query(void); +U32 ps3_task_reset_delay_time_query(void); -unsigned int ps3_task_reset_delay_time_query(void); +U64 ps3_r1x_ring_size_query(void); -unsigned long long ps3_r1x_ring_size_query(void); +void ps3_r1x_ring_size_modify(U32 size); -void ps3_r1x_ring_size_modify(unsigned int size); +U32 ps3_direct_check_stream_query(void); -unsigned int ps3_direct_check_stream_query(void); +S32 ps3_device_busy_threshold_query(void); -int ps3_device_busy_threshold_query(void); +void ps3_device_busy_threshold_modify(S32 busy); -void ps3_device_busy_threshold_modify(int busy); +void ps3_log_level_modify(U32 level); -void ps3_log_level_modify(unsigned int level); +char* ps3_log_path_query(void); -char *ps3_log_path_query(void); +U32 ps3_log_space_size_query(void); -unsigned int ps3_log_space_size_query(void); +U32 ps3_log_file_size_query(void); -unsigned int ps3_log_file_size_query(void); +void ps3_log_file_size_modify(U32 size); -void ps3_log_file_size_modify(unsigned int size); +U32 ps3_log_level_query(void); -unsigned int ps3_log_level_query(void); +U32 ps3_log_tty_query(void); -unsigned int ps3_log_tty_query(void); +void ps3_log_tty_modify(U32 enable); -void ps3_log_tty_modify(unsigned int enable); +void ps3_hard_reset_enable_modify(U32 val); +void ps3_deep_soft_reset_enable_modify(U32 val); -void ps3_hard_reset_enable_modify(unsigned int val); -void ps3_deep_soft_reset_enable_modify(unsigned int val); +U32 ps3_hard_reset_enable_query(void); +U32 ps3_deep_soft_reset_enable_query(void); -unsigned int ps3_hard_reset_enable_query(void); -unsigned int ps3_deep_soft_reset_enable_query(void); +U32 ps3_log_level_query(void); -unsigned int ps3_log_level_query(void); +U32 ps3_aer_handle_support_query(void); -unsigned int ps3_aer_handle_support_query(void); -void ps3_aer_handle_support_set(unsigned int aer_handle_support); +void ps3_aer_handle_support_set(U32 aer_handle_support); void ps3_version_verbose_fill(void); -unsigned int ps3_hard_reset_waiting_query(void); -unsigned int ps3_use_hard_reset_reg_query(void); -unsigned int ps3_use_hard_reset_max_retry(void); -unsigned int ps3_enable_heartbeat_query(void); -unsigned int ps3_enable_heartbeat_set(unsigned int val); -unsigned int ps3_hil_mode_query(void); -void ps3_hil_mode_modify(unsigned int val); -unsigned int ps3_available_func_id_query(void); -void ps3_available_func_id_modify(unsigned int val); -void ps3_direct_check_stream_modify(unsigned int val); -unsigned int ps3_r1x_tmo_query(void); -unsigned int ps3_r1x_conflict_queue_support_query(void); -unsigned int ps3_pci_irq_mode_query(void); +U32 ps3_hard_reset_waiting_query(void); -#if defined(PS3_TAGSET_SUPPORT) +U32 ps3_use_hard_reset_reg_query(void); +U32 ps3_use_hard_reset_max_retry(void); + +U32 ps3_enable_heartbeat_query(void); + +U32 ps3_enable_heartbeat_set(U32 val); + +U32 ps3_hil_mode_query(void); + +void ps3_hil_mode_modify(U32 val); + +U32 ps3_available_func_id_query(void); -void ps3_tagset_enable_modify(unsigned char enable); +void ps3_available_func_id_modify(U32 val); -unsigned char ps3_tagset_enable_query(void); +void ps3_direct_check_stream_modify(U32 val); + +U32 ps3_r1x_tmo_query(void); + +U32 ps3_r1x_conflict_queue_support_query(void); + +U32 ps3_pci_irq_mode_query(void); + +#if defined(PS3_TAGSET_SUPPORT) + +Bool ps3_tagset_enable_query(void); #endif -unsigned char ps3_smp_affinity_query(void); + +Bool ps3_smp_affinity_query(void); #ifndef _WINDOWS +#ifdef PS3_SUPPORT_INJECT +U32 ps3_err_inject_num_query(void); +U32* ps3_err_inject_array_query(void); +U32 ps3_err_inject_state_query(void); + +#endif #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.c b/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.c index 9914dd10e9a8..e4a63d72685d 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.c @@ -1,146 +1,143 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #include -#include "ps3_htp_nvme_spec.h" +#include "ps3_nvme_spec.h" #include "ps3_nvme_resp_to_scsi.h" #include "ps3_instance_manager.h" #include "ps3_htp_def.h" #include "ps3_htp.h" enum { - SENSE_KEY_NO_SENSE = 0x00, + SENSE_KEY_NO_SENSE = 0x00, SENSE_KEY_RECOVERED_ERROR = 0x01, - SENSE_KEY_NOT_READY = 0x02, - SENSE_KEY_MEDIUM_ERROR = 0x03, - SENSE_KEY_HARDWARE_ERROR = 0x04, + SENSE_KEY_NOT_READY = 0x02, + SENSE_KEY_MEDIUM_ERROR = 0x03, + SENSE_KEY_HARDWARE_ERROR = 0x04, SENSE_KEY_ILLEGAL_REQUEST = 0x05, - SENSE_KEY_UNIT_ATTENTION = 0x06, - SENSE_KEY_DATA_PROTECT = 0x07, - SENSE_KEY_BLANK_CHECK = 0x08, + SENSE_KEY_UNIT_ATTENTION = 0x06, + SENSE_KEY_DATA_PROTECT = 0x07, + SENSE_KEY_BLANK_CHECK = 0x08, SENSE_KEY_VENDOR_SPECIFIC = 0x09, - SENSE_KEY_COPY_ABORTED = 0x0a, + SENSE_KEY_COPY_ABORTED = 0x0a, SENSE_KEY_ABORTED_COMMAND = 0x0b, SENSE_KEY_VOLUME_OVERFLOW = 0x0d, - SENSE_KEY_MISCOMPARE = 0x0e, -}; + SENSE_KEY_MISCOMPARE = 0x0e, +} ; enum { - SCSI_ASC_NO_ADDITIONAL_SENSE = 0x00, - SCSI_ASC_PERIPHERAL_DEVICE_WRITE_FAULT = 0x03, - SCSI_ASC_LOGICAL_UNIT_NOT_READY = 0x04, - SCSI_ASC_WARNING = 0x0b, - SCSI_ASC_LOGICAL_BLOCK_GUARD_CHECK_FAILED = 0x10, - SCSI_ASC_LOGICAL_BLOCK_APPTAG_CHECK_FAILED = 0x10, - SCSI_ASC_LOGICAL_BLOCK_REFTAG_CHECK_FAILED = 0x10, - SCSI_ASC_UNRECOVERED_READ_ERROR = 0x11, + SCSI_ASC_NO_ADDITIONAL_SENSE = 0x00, + SCSI_ASC_PERIPHERAL_DEVICE_WRITE_FAULT = 0x03, + SCSI_ASC_LOGICAL_UNIT_NOT_READY = 0x04, + SCSI_ASC_WARNING = 0x0b, + SCSI_ASC_LOGICAL_BLOCK_GUARD_CHECK_FAILED = 0x10, + SCSI_ASC_LOGICAL_BLOCK_APPTAG_CHECK_FAILED = 0x10, + SCSI_ASC_LOGICAL_BLOCK_REFTAG_CHECK_FAILED = 0x10, + SCSI_ASC_UNRECOVERED_READ_ERROR = 0x11, SCSI_ASC_MISCOMPARE_DURING_VERIFY_OPERATION = 0x1d, - SCSI_ASC_INVALID_COMMAND_OPERATION_CODE = 0x20, - SCSI_ASC_ACCESS_DENIED = 0x20, + SCSI_ASC_INVALID_COMMAND_OPERATION_CODE = 0x20, + SCSI_ASC_ACCESS_DENIED = 0x20, SCSI_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE = 0x21, - SCSI_ASC_INVALID_FIELD_IN_CDB = 0x24, - SCSI_ASC_LOGICAL_UNIT_NOT_SUPPORTED = 0x25, - SCSI_ASC_WRITE_PROTECTED = 0x27, - SCSI_ASC_FORMAT_COMMAND_FAILED = 0x31, - SCSI_ASC_SAVING_PARAMETERS_NOT_SUPPORTED = 0x39, - SCSI_ASC_INTERNAL_TARGET_FAILURE = 0x44, - SCSI_ASC_DATA_PHASE_ERROR = 0x4b, -}; + SCSI_ASC_INVALID_FIELD_IN_CDB = 0x24, + SCSI_ASC_LOGICAL_UNIT_NOT_SUPPORTED = 0x25, + SCSI_ASC_WRITE_PROTECTED = 0x27, + SCSI_ASC_FORMAT_COMMAND_FAILED = 0x31, + SCSI_ASC_SAVING_PARAMETERS_NOT_SUPPORTED = 0x39, + SCSI_ASC_INTERNAL_TARGET_FAILURE = 0x44, + SCSI_ASC_DATA_PHASE_ERROR = 0x4b, +} ; -enum ScsiAscq { - SCSI_ASCQ_CAUSE_NOT_REPORTABLE = 0x00, - SCSI_ASCQ_BECOMING_READY = 0x01, - SCSI_ASCQ_FORMAT_COMMAND_FAILED = 0x01, - SCSI_ASCQ_LOGICAL_BLOCK_GUARD_CHECK_FAILED = 0x01, +typedef enum ScsiAscq { + SCSI_ASCQ_CAUSE_NOT_REPORTABLE = 0x00, + SCSI_ASCQ_BECOMING_READY = 0x01, + SCSI_ASCQ_FORMAT_COMMAND_FAILED = 0x01, + SCSI_ASCQ_LOGICAL_BLOCK_GUARD_CHECK_FAILED = 0x01, SCSI_ASCQ_LOGICAL_BLOCK_APPTAG_CHECK_FAILED = 0x02, - SCSI_ASCQ_NO_ACCESS_RIGHTS = 0x02, + SCSI_ASCQ_NO_ACCESS_RIGHTS = 0x02, SCSI_ASCQ_LOGICAL_BLOCK_REFTAG_CHECK_FAILED = 0x03, - SCSI_ASCQ_SANITIZE_COMMAND_FAILED = 0x03, + SCSI_ASCQ_SANITIZE_COMMAND_FAILED = 0x03, SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_FORMAT_IN_PROGRESS = 0x04, - SCSI_ASCQ_DATA_OFFSET_ERROR = 0x05, - SCSI_ASCQ_POWER_LOSS_EXPECTED = 0x08, - SCSI_ASCQ_INVALID_LU_IDENTIFIER = 0x09, - SCSI_ASCQ_SDBP_INCOMING_BUFFER_OVERFLOW = 0x0C, - SCSI_ASCQ_WARNING_MICROCODE_DIGITAL_SIGNATURE_VALIDATION_FAILURE = 0x13, - SCSI_ASCQ_ERASE_OPEARTION_IN_PROGRESS = 0x18, + SCSI_ASCQ_DATA_OFFSET_ERROR = 0x05, + SCSI_ASCQ_POWER_LOSS_EXPECTED = 0x08, + SCSI_ASCQ_INVALID_LU_IDENTIFIER = 0x09, + SCSI_ASCQ_SDBP_INCOMING_BUFFER_OVERFLOW = 0x0C, + SCSI_ASCQ_WARNING_MICROCODE_DIGITAL_SIGNATURE_VALIDATION_FAILURE = 0x13, + SCSI_ASCQ_ERASE_OPEARTION_IN_PROGRESS = 0x18, SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_SANITIZE_IN_PROGRESS = 0x1b, -}; +} ScsiAscq_e; -#define PS3_MEDIUM_ERROR_LEN (4) -static void -ps3_nvme_generic_error_to_scsi_status(unsigned char nvmeSc, - struct ps3_nvme_scsi_status *cpl) +#define PS3_MEDIUM_ERROR_LEN (4) +static void ps3_nvme_generic_error_to_scsi_status(U8 nvmeSc, ps3_nvme_scsi_status *cpl) { switch (nvmeSc) { case NVME_SC_SUCCESS: - cpl->status = SCSI_STATUS_GOOD; + cpl->status = SCSI_STATUS_GOOD; cpl->senseKey = SENSE_KEY_NO_SENSE; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_INVALID_OPCODE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_INVALID_COMMAND_OPERATION_CODE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_INVALID_COMMAND_OPERATION_CODE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_INVALID_FIELD: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_DATA_TRANSFER_ERROR: case NVME_SC_CAPACITY_EXCEEDED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MEDIUM_ERROR; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_ABORTED_POWER_LOSS: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_WARNING; - cpl->ascq = SCSI_ASCQ_POWER_LOSS_EXPECTED; + cpl->asc = SCSI_ASC_WARNING; + cpl->ascq = SCSI_ASCQ_POWER_LOSS_EXPECTED; break; case NVME_SC_INTERNAL_DEVICE_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_HARDWARE_ERROR; - cpl->asc = SCSI_ASC_INTERNAL_TARGET_FAILURE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_INTERNAL_TARGET_FAILURE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_ABORTED_BY_REQUEST: case NVME_SC_ABORTED_SQ_DELETION: case NVME_SC_ABORTED_FAILED_FUSED: case NVME_SC_ABORTED_MISSING_FUSED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_INVALID_NAMESPACE_OR_FORMAT: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_ACCESS_DENIED; - cpl->ascq = SCSI_ASCQ_INVALID_LU_IDENTIFIER; + cpl->asc = SCSI_ASC_ACCESS_DENIED; + cpl->ascq = SCSI_ASCQ_INVALID_LU_IDENTIFIER; break; case NVME_SC_LBA_OUT_OF_RANGE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_NAMESPACE_NOT_READY: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_NOT_READY; - cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_RESERVATION_CONFLICT: - cpl->status = SCSI_STATUS_RESERVATION_CONFLICT; + cpl->status = SCSI_STATUS_RESERVATION_CONFLICT; cpl->senseKey = SENSE_KEY_NO_SENSE; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_COMMAND_ID_CONFLICT: case NVME_SC_COMMAND_SEQUENCE_ERROR: @@ -151,10 +148,10 @@ ps3_nvme_generic_error_to_scsi_status(unsigned char nvmeSc, case NVME_SC_SGL_DESCRIPTOR_TYPE_INVALID: case NVME_SC_INVALID_CONTROLLER_MEM_BUF: case NVME_SC_INVALID_PRP_OFFSET: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_DATA_PHASE_ERROR; - cpl->ascq = SCSI_ASCQ_DATA_OFFSET_ERROR; + cpl->asc = SCSI_ASC_DATA_PHASE_ERROR; + cpl->ascq = SCSI_ASCQ_DATA_OFFSET_ERROR; break; case NVME_SC_ATOMIC_WRITE_UNIT_EXCEEDED: case NVME_SC_INVALID_SGL_OFFSET: @@ -162,74 +159,72 @@ ps3_nvme_generic_error_to_scsi_status(unsigned char nvmeSc, case NVME_SC_KEEP_ALIVE_EXPIRED: case NVME_SC_KEEP_ALIVE_INVALID: case NVME_SC_FORMAT_IN_PROGRESS: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_NOT_READY; - cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; - cpl->ascq = SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_FORMAT_IN_PROGRESS; + cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; + cpl->ascq = SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_FORMAT_IN_PROGRESS; break; case NVME_SC_SANITIZE_FAILED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MEDIUM_ERROR; - cpl->asc = SCSI_ASC_FORMAT_COMMAND_FAILED; - cpl->ascq = SCSI_ASCQ_SANITIZE_COMMAND_FAILED; + cpl->asc = SCSI_ASC_FORMAT_COMMAND_FAILED; + cpl->ascq = SCSI_ASCQ_SANITIZE_COMMAND_FAILED; break; case NVME_SC_SANITIZE_IN_PROGRESS: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_NOT_READY; - cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; - cpl->ascq = - SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_SANITIZE_IN_PROGRESS; + cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; + cpl->ascq = SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_SANITIZE_IN_PROGRESS; break; case NVME_SC_NAMESPACE_IS_WRITE_PROTECTED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_DATA_PROTECT; - cpl->asc = SCSI_ASC_WRITE_PROTECTED; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_WRITE_PROTECTED; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_COMMAND_INTERRUPTED: case NVME_SC_TRANSIENT_TRANSPORT_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; default: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; } } -static void ps3_nvme_spec_error_to_scsi_status(unsigned char nvmeSc, - struct ps3_nvme_scsi_status *cpl) +static void ps3_nvme_spec_error_to_scsi_status(U8 nvmeSc, ps3_nvme_scsi_status *cpl) { switch (nvmeSc) { case NVME_CSC_COMPLETION_QUEUE_INVALID: case NVME_CSC_ABORT_COMMAND_LIMIT_EXCEEDED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_CSC_INVALID_FORMAT: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_FORMAT_COMMAND_FAILED; - cpl->ascq = SCSI_ASCQ_FORMAT_COMMAND_FAILED; + cpl->asc = SCSI_ASC_FORMAT_COMMAND_FAILED; + cpl->ascq = SCSI_ASCQ_FORMAT_COMMAND_FAILED; break; case NVME_CSC_CONFLICTING_ATTRIBUTES: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_CSC_ATTEMPTED_WRITE_TO_RO_RANGE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_DATA_PROTECT; - cpl->asc = SCSI_ASC_WRITE_PROTECTED; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_WRITE_PROTECTED; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_CSC_INVALID_QUEUE_IDENTIFIER: case NVME_CSC_MAXIMUM_QUEUE_SIZE_EXCEEDED: @@ -240,17 +235,16 @@ static void ps3_nvme_spec_error_to_scsi_status(unsigned char nvmeSc, case NVME_CSC_FIRMWARE_ACTIVATION_PROHIBITED: case NVME_CSC_BOOT_PARTITION_WRITE_PROHIBITED: case NVME_CSC_INVALID_FIRMWARE_SLOT: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_CSC_INVALID_FIRMWARE_IMAGE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_WARNING; - cpl->ascq = - SCSI_ASCQ_WARNING_MICROCODE_DIGITAL_SIGNATURE_VALIDATION_FAILURE; + cpl->asc = SCSI_ASC_WARNING; + cpl->ascq = SCSI_ASCQ_WARNING_MICROCODE_DIGITAL_SIGNATURE_VALIDATION_FAILURE; break; case NVME_CSC_INVALID_INTERRUPT_VECTOR: case NVME_CSC_INVALID_LOG_PAGE: @@ -261,10 +255,10 @@ static void ps3_nvme_spec_error_to_scsi_status(unsigned char nvmeSc, case NVME_CSC_FEATURE_NOT_NAMESPACE_SPECIFIC: case NVME_CSC_FIRMWARE_REQ_RESET: case NVME_CSC_OVERLAPPING_RANGE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_CSC_NAMESPACE_INSUFFICIENT_CAPACITY: case NVME_CSC_NAMESPACE_ID_UNAVAILABLE: @@ -275,81 +269,78 @@ static void ps3_nvme_spec_error_to_scsi_status(unsigned char nvmeSc, case NVME_CSC_CONTROLLER_LIST_INVALID: default: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; } } -static void -ps3_nvme_media_error_to_scsi_status(unsigned char nvmeSc, - struct ps3_nvme_scsi_status *cpl) +static void ps3_nvme_media_error_to_scsi_status(U8 nvmeSc, ps3_nvme_scsi_status *cpl) { switch (nvmeSc) { case NVME_MSC_WRITE_FAULTS: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MEDIUM_ERROR; - cpl->asc = SCSI_ASC_PERIPHERAL_DEVICE_WRITE_FAULT; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_PERIPHERAL_DEVICE_WRITE_FAULT; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_MSC_UNRECOVERED_READ_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MEDIUM_ERROR; - cpl->asc = SCSI_ASC_UNRECOVERED_READ_ERROR; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_UNRECOVERED_READ_ERROR; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_MSC_GUARD_CHECK_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_LOGICAL_BLOCK_GUARD_CHECK_FAILED; - cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_GUARD_CHECK_FAILED; + cpl->asc = SCSI_ASC_LOGICAL_BLOCK_GUARD_CHECK_FAILED; + cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_GUARD_CHECK_FAILED; break; case NVME_MSC_APPLICATION_TAG_CHECK_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_LOGICAL_BLOCK_APPTAG_CHECK_FAILED; - cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_APPTAG_CHECK_FAILED; + cpl->asc = SCSI_ASC_LOGICAL_BLOCK_APPTAG_CHECK_FAILED; + cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_APPTAG_CHECK_FAILED; break; case NVME_MSC_REFERENCE_TAG_CHECK_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_LOGICAL_BLOCK_REFTAG_CHECK_FAILED; - cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_REFTAG_CHECK_FAILED; + cpl->asc = SCSI_ASC_LOGICAL_BLOCK_REFTAG_CHECK_FAILED; + cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_REFTAG_CHECK_FAILED; break; case NVME_MSC_COMPARE_FAILURE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MISCOMPARE; - cpl->asc = SCSI_ASC_MISCOMPARE_DURING_VERIFY_OPERATION; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_MISCOMPARE_DURING_VERIFY_OPERATION; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_MSC_ACCESS_DENIED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_DATA_PROTECT; - cpl->asc = SCSI_ASC_ACCESS_DENIED; - cpl->ascq = SCSI_ASCQ_NO_ACCESS_RIGHTS; + cpl->asc = SCSI_ASC_ACCESS_DENIED; + cpl->ascq = SCSI_ASCQ_NO_ACCESS_RIGHTS; break; case NVME_MSC_DEALLOCATED_OR_UNWRITTEN_BLOCK: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MEDIUM_ERROR; - cpl->asc = SCSI_ASC_UNRECOVERED_READ_ERROR; - cpl->ascq = SCSI_ASCQ_SDBP_INCOMING_BUFFER_OVERFLOW; + cpl->asc = SCSI_ASC_UNRECOVERED_READ_ERROR; + cpl->ascq = SCSI_ASCQ_SDBP_INCOMING_BUFFER_OVERFLOW; break; default: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; } } -void ps3_nvme_error_to_scsi_status(struct PS3NvmeCmdStatus status, - struct ps3_nvme_scsi_status *cpl) +void ps3_nvme_error_to_scsi_status(PS3NvmeCmdStatus_s status, ps3_nvme_scsi_status *cpl) { - unsigned char sct = status.sct; - unsigned char sc = status.sc; + U8 sct = status.sct; + U8 sc = status.sc; switch (sct) { case NVME_SCT_GENERIC: @@ -363,36 +354,36 @@ void ps3_nvme_error_to_scsi_status(struct PS3NvmeCmdStatus status, break; case NVME_SCT_VENDOR_SPECIFIC: default: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; } } void ps3_nvme_resp_to_scsi_status(struct ps3_cmd *cmd) { - struct PS3NvmeCmdStatus status; - struct ps3_nvme_scsi_status cpl; + PS3NvmeCmdStatus_s status; + ps3_nvme_scsi_status cpl; status.cmdStatus = cmd->reply_word.retStatus; - LOG_FILE_ERROR("trace_id:0x%llx host_no:%d tag:%d nvme status:\n" - "\tsc:%d sct:%d crd:%d more:%d dnr:%d p:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - status.sc, status.sct, status.crd, status.m, status.dnr, - status.p); + LOG_FILE_ERROR("trace_id:0x%llx host_no:%d tag:%d nvme status:" + "sc:%d sct:%d crd:%d more:%d dnr:%d p:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index, status.sc, status.sct, status.crd, + status.m, status.dnr, status.p); - memset(&cpl, 0, sizeof(struct ps3_nvme_scsi_status)); + memset(&cpl, 0, sizeof(ps3_nvme_scsi_status)); ps3_nvme_error_to_scsi_status(status, &cpl); memset(cmd->resp_frame->sasRespFrame.data, 0, PS3_SENSE_BUFFER_SIZE); scsi_build_sense_buffer(0, cmd->resp_frame->sasRespFrame.data, - cpl.senseKey, cpl.asc, cpl.ascq); + cpl.senseKey, cpl.asc, cpl.ascq); if (cmd->reply_word.mode == PS3_REPLY_WORD_MODE_DIRECT_OK && - cpl.senseKey == SENSE_KEY_MEDIUM_ERROR) { - memset(&cmd->resp_frame->sasRespFrame.data[3], 0xff, - PS3_MEDIUM_ERROR_LEN); + cpl.senseKey == SENSE_KEY_MEDIUM_ERROR) { + memset(&cmd->resp_frame->sasRespFrame.data[3], 0xff, PS3_MEDIUM_ERROR_LEN); } cmd->resp_frame->sasRespFrame.status = cpl.status; + } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.h b/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.h index 14be9e95f344..35206918ee8a 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.h @@ -1,14 +1,13 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #include "ps3_cmd_channel.h" -struct ps3_nvme_scsi_status { - unsigned char status; - unsigned char senseKey; - unsigned char asc; - unsigned char ascq; -}; +typedef struct ps3_nvme_scsi_status { + U8 status; + U8 senseKey; + U8 asc; + U8 ascq; +} ps3_nvme_scsi_status; + +void ps3_nvme_error_to_scsi_status(PS3NvmeCmdStatus_s status, ps3_nvme_scsi_status *cpl); -void ps3_nvme_error_to_scsi_status(struct PS3NvmeCmdStatus status, - struct ps3_nvme_scsi_status *cpl); -void ps3_nvme_resp_to_scsi_status(struct ps3_cmd *cmd); +void ps3_nvme_resp_to_scsi_status(struct ps3_cmd *cmd); \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/ps3_pci.c b/drivers/scsi/linkdata/ps3stor/ps3_pci.c index be7f1f3449d7..689527f62f8c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_pci.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_pci.c @@ -1,476 +1,461 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include "ps3_instance_manager.h" #include "ps3_pci.h" #define PS3_VALID_MEMORY_BAR_INDEX 2 #ifdef _WINDOWS -#define PS3_CHECK_BAR_64BIT(bar) ((bar) & 0x4) -#define PS3_CHECK_BAR_MEMORYSPACE(bar) (!((bar) & 0x1)) -#define PS3_BAR_BASE_ADDR_MARSK (0xFFFFFFF0) -#define PS3_GET_BAR_BASE_ADDR(addr) \ - ((unsigned long long)((addr) & PS3_BAR_BASE_ADDR_MARSK)) - -static int ps3_pci_map_reg(struct ps3_instance *instance, - PPORT_CONFIGURATION_INFORMATION config); -static int ps3_pci_info_get(struct ps3_instance *instance, - PPORT_CONFIGURATION_INFORMATION config); +#define PS3_CHECK_BAR_64BIT(bar) ((bar)&0x4) +#define PS3_CHECK_BAR_MEMORYSPACE(bar) (!((bar)&0x1)) +#define PS3_BAR_BASE_ADDR_MARSK (0xFFFFFFF0) +#define PS3_GET_BAR_BASE_ADDR(addr) (U64)((addr) & PS3_BAR_BASE_ADDR_MARSK) + +static S32 ps3_pci_map_reg(struct ps3_instance *instance, PPORT_CONFIGURATION_INFORMATION config); +static S32 ps3_pci_info_get(struct ps3_instance *instance, PPORT_CONFIGURATION_INFORMATION config); static void ps3_pci_unmap_reg(struct ps3_instance *instance); -static void ps3_pci_irq_type_get(struct ps3_instance *instance, - PPCI_COMMON_CONFIG pci_config); -static unsigned short ps3_pci_msix_vec_count(struct ps3_instance *instance, - PPCI_COMMON_CONFIG pci_config); -static unsigned short ps3_pci_msi_vec_count(struct ps3_instance *instance, - PPCI_COMMON_CONFIG pci_config); -int ps3_pci_init(struct ps3_instance *instance, void *config) +static void ps3_pci_irq_type_get(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config); +static U16 ps3_pci_msix_vec_count(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config); +static U16 ps3_pci_msi_vec_count(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config); + +S32 ps3_pci_init(struct ps3_instance *instance, void *config) { - int ret = PS3_SUCCESS; - PPORT_CONFIGURATION_INFORMATION config_info = - (PPORT_CONFIGURATION_INFORMATION)config; + S32 ret = PS3_SUCCESS; + PPORT_CONFIGURATION_INFORMATION config_info = (PPORT_CONFIGURATION_INFORMATION)config; - ret = ps3_pci_info_get(instance, config_info); - if (ret != PS3_SUCCESS) - goto l_out; + ret = ps3_pci_info_get(instance, config_info); + if (ret != PS3_SUCCESS) { + goto l_out; + } - ret = ps3_pci_map_reg(instance, config_info); - if (ret != PS3_SUCCESS) - goto l_out; + ret = ps3_pci_map_reg(instance, config_info); + if (ret != PS3_SUCCESS) { + goto l_out; + } l_out: - return ret; + return ret; } void ps3_pci_exit(struct ps3_instance *instance) { - ps3_pci_unmap_reg(instance); + ps3_pci_unmap_reg(instance); } -static int ps3_pci_info_get(struct ps3_instance *instance, - PPORT_CONFIGURATION_INFORMATION config) +static S32 ps3_pci_info_get( + struct ps3_instance *instance, + PPORT_CONFIGURATION_INFORMATION config +) { - PCI_COMMON_CONFIG pci_config = { 0 }; - unsigned long len = 0; - unsigned long base_addr = 0; + PCI_COMMON_CONFIG pci_config = { 0 }; + ULong len = 0; + ULong base_addr = 0; #ifdef PS3_HARDWARE_ASIC - unsigned int check_count = ps3_hba_check_time_query() * 10; + U32 check_count = ps3_hba_check_time_query() * 10; #endif - if (config->AdapterInterfaceType != PCIBus) { - LOG_ERROR("there is not pcibus, type:%d\n", - config->AdapterInterfaceType); - return -PS3_FAILED; - } - - len = StorPortGetBusData(instance, PCIConfiguration, - config->SystemIoBusNumber, - (unsigned long)config->SlotNumber, - (void *)&pci_config, sizeof(pci_config)); - - if (len == 0 || len == 2) { - LOG_ERROR("get bus data failed,cfg length:%d\n", len); - return -PS3_FAILED; - } + + if (config->AdapterInterfaceType != PCIBus) { + LOG_ERROR("there is not pcibus, type:%d\n", config->AdapterInterfaceType); + return -PS3_FAILED; + } + + len = StorPortGetBusData(instance, + PCIConfiguration, + config->SystemIoBusNumber, + (ULong)config->SlotNumber, + (void*)&pci_config, + sizeof(pci_config)); + + if (len == 0 || len == 2) { + LOG_ERROR("get bus data failed,cfg length:%d\n", len); + return -PS3_FAILED; + } #ifdef PS3_HARDWARE_ASIC - while (pci_config.DeviceID == PCI_DEVICE_ID_PS3_RAID_FPGA && - check_count > 0) { + while(pci_config.DeviceID == PCI_DEVICE_ID_PS3_RAID_FPGA && + check_count > 0) { + check_count--; ps3_msleep(100); - len = StorPortGetBusData(instance, PCIConfiguration, - config->SystemIoBusNumber, - (unsigned long)config->SlotNumber, - (void *)&pci_config, - sizeof(pci_config)); + len = StorPortGetBusData(instance, + PCIConfiguration, + config->SystemIoBusNumber, + (ULong)config->SlotNumber, + (void*)&pci_config, + sizeof(pci_config)); if (len == 0 || len == 2) { LOG_ERROR("get bus data failed,cfg length:%d\n", len); return -PS3_FAILED; } - LOG_INFO("get real device id is[0x%x]\n", pci_config.DeviceID); + LOG_INFO("get real device id is[0x%x] \n", pci_config.DeviceID); }; #endif - instance->pci_dev_context.slot_number = - (unsigned long long)config->SlotNumber; - instance->pci_dev_context.device_id = pci_config.DeviceID; - instance->pci_dev_context.vendor_id = pci_config.VendorID; - instance->pci_dev_context.sub_vendor_id = - pci_config.u.type0.SubVendorID; - instance->pci_dev_context.sub_device_id = - pci_config.u.type0.SubSystemID; - base_addr = - pci_config.u.type0.BaseAddresses[PS3_VALID_MEMORY_BAR_INDEX]; - if (!PS3_CHECK_BAR_MEMORYSPACE(base_addr)) { - LOG_ERROR("Bar%d is not memory space\n", - PS3_VALID_MEMORY_BAR_INDEX); - return -PS3_FAILED; - } - - if (PS3_CHECK_BAR_64BIT(base_addr)) { - instance->pci_dev_context.bar_base_addr = - PS3_GET_BAR_BASE_ADDR(base_addr); - base_addr = - pci_config.u.type0 - .BaseAddresses[PS3_VALID_MEMORY_BAR_INDEX + 1]; - instance->pci_dev_context.bar_base_addr |= - ((unsigned long long)base_addr) << 32; - } else { - instance->pci_dev_context.bar_base_addr = - PS3_GET_BAR_BASE_ADDR(base_addr); - } - - ps3_pci_irq_type_get(instance, &pci_config); - - if (instance->pci_dev_context.pci_irq_type == PS3_PCI_IRQ_MSIX) { - instance->pci_dev_context.irq_vec_count = - ps3_pci_msix_vec_count(instance, &pci_config); - } else if (instance->pci_dev_context.pci_irq_type == PS3_PCI_IRQ_MSI) { - instance->pci_dev_context.irq_vec_count = - ps3_pci_msi_vec_count(instance, &pci_config); - } else { - instance->pci_dev_context.irq_vec_count = 1; - } - - LOG_INFO( - "vid:%x, devid:%x, sub_vid:%x, sub_devid:%x, bar_base:0x%llx, irq_type:%d, vec_count:%d\n", - instance->pci_dev_context.vendor_id, - instance->pci_dev_context.device_id, - instance->pci_dev_context.sub_vendor_id, - instance->pci_dev_context.sub_device_id, - instance->pci_dev_context.bar_base_addr, - instance->pci_dev_context.pci_irq_type, - instance->pci_dev_context.irq_vec_count); - - return PS3_SUCCESS; + instance->pci_dev_context.slot_number = (U64)config->SlotNumber; + instance->pci_dev_context.device_id = pci_config.DeviceID; + instance->pci_dev_context.vendor_id = pci_config.VendorID; + instance->pci_dev_context.sub_vendor_id = pci_config.u.type0.SubVendorID; + instance->pci_dev_context.sub_device_id = pci_config.u.type0.SubSystemID; + + base_addr = pci_config.u.type0.BaseAddresses[PS3_VALID_MEMORY_BAR_INDEX]; + if (!PS3_CHECK_BAR_MEMORYSPACE(base_addr)) { + LOG_ERROR("Bar%d is not memory space\n", PS3_VALID_MEMORY_BAR_INDEX); + return -PS3_FAILED; + } + + if (PS3_CHECK_BAR_64BIT(base_addr)) { + instance->pci_dev_context.bar_base_addr = + PS3_GET_BAR_BASE_ADDR(base_addr); + base_addr = pci_config.u.type0.BaseAddresses[PS3_VALID_MEMORY_BAR_INDEX + 1]; + instance->pci_dev_context.bar_base_addr |= ((U64)base_addr) << 32; + } + else { + instance->pci_dev_context.bar_base_addr = + PS3_GET_BAR_BASE_ADDR(base_addr); + } + + ps3_pci_irq_type_get(instance, &pci_config); + + if (instance->pci_dev_context.pci_irq_type == PS3_PCI_IRQ_MSIX) { + instance->pci_dev_context.irq_vec_count = ps3_pci_msix_vec_count(instance, &pci_config); + } + else if (instance->pci_dev_context.pci_irq_type == PS3_PCI_IRQ_MSI) { + instance->pci_dev_context.irq_vec_count = ps3_pci_msi_vec_count(instance, &pci_config); + } + else { + instance->pci_dev_context.irq_vec_count = 1; + } + + LOG_INFO("vid:%x, devid:%x, sub_vid:%x, sub_devid:%x, bar_base:0x%llx, irq_type:%d, vec_count:%d\n", + instance->pci_dev_context.vendor_id, + instance->pci_dev_context.device_id, + instance->pci_dev_context.sub_vendor_id, + instance->pci_dev_context.sub_device_id, + instance->pci_dev_context.bar_base_addr, + instance->pci_dev_context.pci_irq_type, + instance->pci_dev_context.irq_vec_count); + + return PS3_SUCCESS; }; -static int ps3_pci_map_reg(struct ps3_instance *instance, - PPORT_CONFIGURATION_INFORMATION config) +static S32 ps3_pci_map_reg(struct ps3_instance *instance, PPORT_CONFIGURATION_INFORMATION config) { - int ret = -PS3_FAILED; - unsigned long i = 0; - - if (config->NumberOfAccessRanges <= 0) { - LOG_ERROR("valid access range is 0\n"); - goto l_out; - } - - if (config->AdapterInterfaceType != PCIBus) { - LOG_ERROR("adapter interface type is not PCIBus\n"); - goto l_out; - } - - for (i = 0; i < config->NumberOfAccessRanges; i++) { - LOG_DEBUG("Bar%llu:0x%llx, memory:%d, len:0x%x, ex:0x%llx\n", i, - (*(config->AccessRanges))[i].RangeStart.QuadPart, - (*(config->AccessRanges))[i].RangeInMemory, - (*(config->AccessRanges))[i].RangeLength, - instance->pci_dev_context.bar_base_addr); - if ((unsigned long long)(*(config->AccessRanges))[i] - .RangeStart.QuadPart != - instance->pci_dev_context.bar_base_addr) { - continue; - } - - if (!(*(config->AccessRanges))[i].RangeInMemory) { - LOG_INFO( - "access range number continue:%d, is not memery\n", - i); - continue; - } - - instance->reg_set = (struct Ps3Fifo *)StorPortGetDeviceBase( - instance, config->AdapterInterfaceType, - config->SystemIoBusNumber, - (*(config->AccessRanges))[i].RangeStart, - (*(config->AccessRanges))[i].RangeLength, 0); - - if (instance->reg_set != NULL) - ret = PS3_SUCCESS; - - break; - } + S32 ret = -PS3_FAILED; + ULong i = 0; + + if (config->NumberOfAccessRanges <= 0) { + LOG_ERROR("valid access range is 0\n"); + goto l_out; + } + + if (config->AdapterInterfaceType != PCIBus) { + LOG_ERROR("adapter interface type is not PCIBus\n"); + goto l_out; + } + + for (i = 0; i < config->NumberOfAccessRanges; i++) { + + LOG_DEBUG("Bar%llu:0x%llx, memory:%d, len:0x%x, ex:0x%llx\n", i, + (*(config->AccessRanges))[i].RangeStart.QuadPart, (*(config->AccessRanges))[i].RangeInMemory, + (*(config->AccessRanges))[i].RangeLength, + instance->pci_dev_context.bar_base_addr); + if ((U64)(*(config->AccessRanges))[i].RangeStart.QuadPart != instance->pci_dev_context.bar_base_addr) { + continue; + } + + if (!(*(config->AccessRanges))[i].RangeInMemory) { + LOG_INFO("access range number continue:%d, is not memery\n", i); + continue; + } + + instance->reg_set = (Ps3Fifo_s*)StorPortGetDeviceBase(instance, + config->AdapterInterfaceType, + config->SystemIoBusNumber, + (*(config->AccessRanges))[i].RangeStart, + (*(config->AccessRanges))[i].RangeLength, + 0); + + if (instance->reg_set != NULL) { + ret = PS3_SUCCESS; + } + + break; + } l_out: - LOG_INFO("map reg:%d,reg:%p\n", ret, instance->reg_set); - return ret; + LOG_INFO("map reg:%d,reg:%p\n", ret, instance->reg_set); + return ret; } static void ps3_pci_unmap_reg(struct ps3_instance *instance) { - if (instance->reg_set != NULL) { - StorPortFreeDeviceBase(instance, instance->reg_set); - instance->reg_set = NULL; - } + if (instance->reg_set != NULL) { + StorPortFreeDeviceBase(instance, instance->reg_set); + instance->reg_set = NULL; + } } -static int __ps3_pci_find_capability(PPCI_COMMON_CONFIG pci_config, int cap_id) +static S32 __ps3_pci_find_capability(PPCI_COMMON_CONFIG pci_config, S32 cap_id) { - int pos = 0; - unsigned char *config_base_addr = (unsigned char *)pci_config; - unsigned char cap_offset = 0; - PPCI_CAPABILITIES_HEADER cap_header = NULL; - - if (PCI_CONFIGURATION_TYPE(pci_config)) { - LOG_ERROR("there is not agent device\n"); - goto l_out; - } - - if ((pci_config->Status & PCI_STATUS_CAPABILITIES_LIST) == 0) { - LOG_ERROR("capability pointer invalid\n"); - goto l_out; - } - - cap_offset = pci_config->u.type0.CapabilitiesPtr; - while (cap_offset != 0) { - cap_header = (PPCI_CAPABILITIES_HEADER)(config_base_addr + - cap_offset); - if (cap_header->CapabilityID == 0) { - cap_offset = cap_header->Next; - continue; - } - - if (cap_header->CapabilityID == (unsigned char)cap_id) { - pos = cap_offset; - break; - } - cap_offset = cap_header->Next; - }; + S32 pos = 0; + U8 *config_base_addr = (U8*)pci_config; + U8 cap_offset = 0; + PPCI_CAPABILITIES_HEADER cap_header = NULL; + + if (PCI_CONFIGURATION_TYPE(pci_config)) { + LOG_ERROR("there is not agent device\n"); + goto l_out; + } + + if ((pci_config->Status & PCI_STATUS_CAPABILITIES_LIST) == 0) { + LOG_ERROR("capability pointer invalid\n"); + goto l_out; + } + + cap_offset = pci_config->u.type0.CapabilitiesPtr; + while (cap_offset != 0) { + cap_header = (PPCI_CAPABILITIES_HEADER)(config_base_addr + cap_offset); + if (cap_header->CapabilityID == 0) { + cap_offset = cap_header->Next; + continue; + } + + if (cap_header->CapabilityID == (U8)cap_id) { + pos = cap_offset; + break; + + } + cap_offset = cap_header->Next; + }; l_out: - return pos; + return pos; } -static void ps3_pci_irq_type_get(struct ps3_instance *instance, - PPCI_COMMON_CONFIG pci_config) +static void ps3_pci_irq_type_get(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config) { - unsigned char *config_base_addr = (unsigned char *)pci_config; - unsigned short data_u16 = 0; - int pos = 0; - - instance->pci_dev_context.pci_irq_type = PS3_PCI_IRQ_LEGACY; - pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSIX); - if (pos != 0) { - data_u16 = *((unsigned short *)(config_base_addr + pos + - PCI_MSIX_FLAGS)); - - for (size_t i = 0; i < 4; i++) { - unsigned char tmp = *( - (unsigned char *)(config_base_addr + pos + i)); - - LOG_DEBUG("%d:%d:%x\n", pos, i, tmp); - } - - if ((data_u16 & PCI_MSIX_FLAGS_ENABLE) == - PCI_MSIX_FLAGS_ENABLE) { - instance->pci_dev_context.pci_irq_type = - PS3_PCI_IRQ_MSIX; - goto l_out; - } - } - - pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSI); - if (pos != 0) { - data_u16 = *((unsigned short *)(config_base_addr + pos + - PCI_MSI_FLAGS)); - if ((data_u16 & PCI_MSI_FLAGS_ENABLE) == PCI_MSI_FLAGS_ENABLE) { - instance->pci_dev_context.pci_irq_type = - PS3_PCI_IRQ_MSI; - goto l_out; - } - } + U8 *config_base_addr = (U8*)pci_config; + U16 data_u16 = 0; + S32 pos = 0; + + instance->pci_dev_context.pci_irq_type = PS3_PCI_IRQ_LEGACY; + pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSIX); + if ( pos != 0) { + data_u16 = *( (U16*)(config_base_addr + pos + PCI_MSIX_FLAGS) ); + + for (size_t i = 0; i < 4; i++) + { + U8 tmp = *((U8*)(config_base_addr + pos + i)); + LOG_DEBUG("%d:%d:%x\n", pos, i, tmp); + } + + if ((data_u16 & PCI_MSIX_FLAGS_ENABLE) == PCI_MSIX_FLAGS_ENABLE) { + instance->pci_dev_context.pci_irq_type = PS3_PCI_IRQ_MSIX; + goto l_out; + } + } + + pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSI); + if (pos != 0) { + data_u16 = *((U16*)(config_base_addr + pos + PCI_MSI_FLAGS)); + if ( (data_u16 & PCI_MSI_FLAGS_ENABLE) == PCI_MSI_FLAGS_ENABLE) { + instance->pci_dev_context.pci_irq_type = PS3_PCI_IRQ_MSI; + goto l_out; + } + } l_out: - return; + return; } -void ps3_pci_intx(struct ps3_instance *instance, unsigned char enable) +void ps3_pci_intx(struct ps3_instance *instance, U8 enable) { - unsigned short pci_command = 0; - unsigned short pci_command_new = 0; - - if (ps3_pci_read_config_word(instance, PCI_COMMAND, &pci_command) != - PS3_SUCCESS) { - goto l_out; - } - - if (enable) - pci_command_new = pci_command & ~PCI_COMMAND_INTX_DISABLE; - else - pci_command_new = pci_command | PCI_COMMAND_INTX_DISABLE; - - if (pci_command_new != pci_command) { - ps3_pci_write_config_word(instance, PCI_COMMAND, - pci_command_new); - } + U16 pci_command = 0; + U16 pci_command_new = 0; + if (ps3_pci_read_config_word(instance, PCI_COMMAND, &pci_command) != PS3_SUCCESS) { + goto l_out; + } + + if (enable) { + pci_command_new = pci_command & ~PCI_COMMAND_INTX_DISABLE; + } + else { + pci_command_new = pci_command | PCI_COMMAND_INTX_DISABLE; + } + + if (pci_command_new != pci_command) { + ps3_pci_write_config_word(instance, PCI_COMMAND, pci_command_new); + } l_out: - return; + return; } -static unsigned short ps3_pci_msix_vec_count(struct ps3_instance *instance, - PPCI_COMMON_CONFIG pci_config) +static U16 ps3_pci_msix_vec_count(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config) { - unsigned char *config_base_addr = (unsigned char *)pci_config; - int pos = 0; - unsigned short msix_vec_count = 0; - unsigned short data_u16 = 0; + U8 *config_base_addr = (U8*)pci_config; + S32 pos = 0; + U16 msix_vec_count = 0; + U16 data_u16 = 0; - (void)instance; - pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSIX); - if (pos != 0) - data_u16 = *((unsigned short *)(config_base_addr + pos + - PCI_MSIX_FLAGS)); + (void)instance; + pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSIX); + if (pos != 0) { + data_u16 = *((U16*)(config_base_addr + pos + PCI_MSIX_FLAGS)); + } - msix_vec_count = ((data_u16 & PCI_MSIX_FLAGS_QSIZE) + 1); + msix_vec_count = ((data_u16 & PCI_MSIX_FLAGS_QSIZE) + 1); - return msix_vec_count; + return msix_vec_count; } -static unsigned short ps3_pci_msi_vec_count(struct ps3_instance *instance, - PPCI_COMMON_CONFIG pci_config) +static U16 ps3_pci_msi_vec_count(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config) { - unsigned char *config_base_addr = (unsigned char *)pci_config; - int pos = 0; - unsigned short msi_vec_count = 0; - unsigned short data_u16 = 0; + U8 *config_base_addr = (U8*)pci_config; + S32 pos = 0; + U16 msi_vec_count = 0; + U16 data_u16 = 0; - (void)instance; - pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSI); - if (pos != 0) - data_u16 = *((unsigned short *)(config_base_addr + pos + - PCI_MSI_FLAGS)); + (void)instance; + pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSI); + if (pos != 0) { + data_u16 = *((U16*)(config_base_addr + pos + PCI_MSI_FLAGS)); + } - msi_vec_count = 1 << ((data_u16 & PCI_MSI_FLAGS_QMASK) >> 1); + msi_vec_count = 1 << ((data_u16 & PCI_MSI_FLAGS_QMASK) >> 1); - return data_u16; + return data_u16; } #endif -int ps3_pci_find_capability(struct ps3_instance *instance, int cap_id) +S32 ps3_pci_find_capability(struct ps3_instance *instance, S32 cap_id) { - int pos = 0; + S32 pos = 0; #ifdef _WINDOWS - PCI_COMMON_CONFIG pci_config = { 0 }; - unsigned int len = 0; + PCI_COMMON_CONFIG pci_config = { 0 }; + U32 len = 0; - len = (unsigned int)StorPortGetBusData( - instance, PCIConfiguration, (unsigned long)instance->bus_number, - (unsigned long)instance->pci_dev_context.slot_number, - (void *)&pci_config, (unsigned long)sizeof(pci_config)); + len = (U32)StorPortGetBusData(instance, + PCIConfiguration, + (ULong)instance->bus_number, + (ULong)instance->pci_dev_context.slot_number, + (void*)&pci_config, + (ULong)sizeof(pci_config)); - if (len == 0 || len == 2) { - LOG_ERROR("get bus data failed,cfg length:%d\n", len); - goto l_out; - } + if (len == 0 || len == 2) { + LOG_ERROR("get bus data failed,cfg length:%d\n", len); + goto l_out; + } - pos = __ps3_pci_find_capability(&pci_config, cap_id); + pos = __ps3_pci_find_capability(&pci_config, cap_id); l_out: #else pos = pci_find_capability(instance->pdev, cap_id); #endif - return pos; + return pos; } -int ps3_pci_read_config_word(struct ps3_instance *instance, unsigned int offset, - unsigned short *val) +S32 ps3_pci_read_config_word(struct ps3_instance *instance, U32 offset, U16 *val) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; #ifdef _WINDOWS - PCI_COMMON_CONFIG pci_config = { 0 }; - unsigned int len = 0; - unsigned char *config_base_addr = (unsigned char *)&pci_config; + PCI_COMMON_CONFIG pci_config = { 0 }; + U32 len = 0; + U8 *config_base_addr = (U8*)&pci_config; - len = (unsigned int)StorPortGetBusData( - instance, PCIConfiguration, (unsigned long)instance->bus_number, - (unsigned long)instance->pci_dev_context.slot_number, - (void *)&pci_config, (unsigned long)sizeof(pci_config)); + len = (U32)StorPortGetBusData(instance, + PCIConfiguration, + (ULong)instance->bus_number, + (ULong)instance->pci_dev_context.slot_number, + (void*)&pci_config, + (ULong)sizeof(pci_config)); - if (len == 0 || len == 2) { - LOG_ERROR("get bus data failed,cfg length:%d\n", len); - goto l_out; - } + if (len == 0 || len == 2) { + LOG_ERROR("get bus data failed,cfg length:%d\n", len); + goto l_out; + } - *val = *((unsigned short *)(config_base_addr + offset)); - ret = PS3_SUCCESS; + *val = *( (U16*)(config_base_addr + offset) ); + ret = PS3_SUCCESS; l_out: #else ret = pci_read_config_word(instance->pdev, offset, val); #endif - LOG_INFO("read config word :%d\n", ret); - return ret; + LOG_INFO("read config word :%d\n", ret); + return ret; } -int ps3_pci_write_config_word(struct ps3_instance *instance, - unsigned int offset, unsigned short val) +S32 ps3_pci_write_config_word(struct ps3_instance *instance, U32 offset, U16 val) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; #ifdef _WINDOWS - unsigned int len = 0; - - len = (unsigned int)StorPortSetBusDataByOffset( - instance, PCIConfiguration, (unsigned long)instance->bus_number, - (unsigned long)instance->pci_dev_context.slot_number, - (void *)&val, (unsigned long)offset, - (unsigned long)sizeof(unsigned short)); - - if (len == sizeof(unsigned short)) - ret = PS3_SUCCESS; + U32 len = 0; + len = (U32)StorPortSetBusDataByOffset(instance, + PCIConfiguration, + (ULong)instance->bus_number, + (ULong)instance->pci_dev_context.slot_number, + (void*)&val, + (ULong)offset, + (ULong)sizeof(U16) + ); + + if (len == sizeof(U16)) { + ret = PS3_SUCCESS; + } #else - ret = pci_write_config_word(instance->pdev, offset, val); + ret = pci_write_config_word(instance->pdev, offset, + val); #endif - LOG_INFO("write config word :%d\n", ret); - return ret; + LOG_INFO("write config word :%d\n", ret); + return ret; } -void ps3_reg_write_u64(struct ps3_instance *instance, unsigned long long val, - void *reg) +void ps3_reg_write_u64(struct ps3_instance *instance, U64 val, void *reg) { + (void)instance; #ifndef _WINDOWS #if defined(writeq) && defined(CONFIG_64BIT) - (void)instance; - writeq(val, reg); + writeq(val, reg); #else - unsigned long flags; - - ps3_spin_lock_irqsave(&instance->req_queue_lock, &flags); - writel((unsigned int)(val & 0xffffffff), reg); - writel((unsigned int)(val >> 32), reg + 0x4UL); - ps3_spin_unlock_irqrestore(&instance->req_queue_lock, flags); + ULong flags; + ps3_spin_lock_irqsave(&instance->req_queue_lock, &flags); + writel((U32)(val & 0xffffffff), reg); + writel((U32)(val >> 32), reg + 0x4UL); + ps3_spin_unlock_irqrestore(&instance->req_queue_lock, flags); #endif #else - StorPortWriteRegisterUlong64(instance, reg, val); + StorPortWriteRegisterUlong64(instance, reg, val); #endif + } -unsigned long long ps3_reg_read_u64(struct ps3_instance *instance, void *reg) +U64 ps3_reg_read_u64(struct ps3_instance *instance, void *reg) { - unsigned long long value = 0; - (void)instance; + U64 value = 0; + (void)instance; #ifndef _WINDOWS #if defined(readq) && defined(CONFIG_64BIT) - value = readq(reg); + value = readq(reg); #else - value = (((unsigned long long)readl(reg + 0x4UL) << 32) | - (unsigned long long)readl(reg)); + value = (((U64)readl(reg + 0x4UL) << 32) | + (U64)readl(reg)); #endif #else - value = StorPortReadRegisterUlong64(instance, reg); + value = StorPortReadRegisterUlong64(instance, reg); #endif - return value; + return value; } -void __iomem *ps3_reg_set_ioremap(struct pci_dev *pdev, unsigned long reg_bar) +void __iomem *ps3_reg_set_ioremap(struct pci_dev *pdev, ULong reg_bar) { resource_size_t base_addr = 0; base_addr = pci_resource_start(pdev, reg_bar); - return ioremap(base_addr, PS3_REGISTER_SET_SIZE); -} + return ioremap(base_addr,PS3_REGISTER_SET_SIZE); +} \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/ps3_pci.h b/drivers/scsi/linkdata/ps3stor/ps3_pci.h index 171f63be43c7..e8da2f2a72bc 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_pci.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_pci.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_PCI_H_ #define _PS3_PCI_H_ @@ -9,16 +8,19 @@ #define PCI_CAP_ID_MSIX PCI_CAPABILITY_ID_MSIX #define PCI_CAP_ID_MSI PCI_CAPABILITY_ID_MSI -#define PCI_MSIX_FLAGS_ENABLE 0x8000 -#define PCI_MSIX_FLAGS 2 -#define PCI_MSI_FLAGS 2 -#define PCI_MSI_FLAGS_ENABLE 0x0001 +#define PCI_MSIX_FLAGS_ENABLE 0x8000 +#define PCI_MSIX_FLAGS 2 +#define PCI_MSI_FLAGS 2 +#define PCI_MSI_FLAGS_ENABLE 0x0001 #define PCI_COMMAND_INTX_DISABLE 0x400 -#define PCI_COMMAND 0x04 -#define PCI_STATUS 0x06 -#define PCI_STATUS_INTERRUPT 0x08 -#define PCI_MSIX_FLAGS_QSIZE 0x07FF -#define PCI_MSI_FLAGS_QMASK 0x000e +#define PCI_COMMAND 0x04 +#define PCI_STATUS 0x06 +#define PCI_STATUS_INTERRUPT 0x08 +#define PCI_MSIX_FLAGS_QSIZE 0x07FF +#define PCI_MSI_FLAGS_QMASK 0x000e + +#else +#include "ps3_types.h" #endif #ifndef _WINDOWS @@ -31,37 +33,36 @@ struct ps3_instance; #ifdef _WINDOWS struct ps3_pci_context { - unsigned long long slot_number; - unsigned short vendor_id; - unsigned short device_id; - unsigned short sub_vendor_id; - unsigned short sub_device_id; - unsigned long long bar_base_addr; - unsigned short irq_vec_count; - unsigned short valid_irq_count; - unsigned char pci_irq_type; + U64 slot_number; + U16 vendor_id; + U16 device_id; + U16 sub_vendor_id; + U16 sub_device_id; + + U64 bar_base_addr; + U16 irq_vec_count; + U16 valid_irq_count; + U8 pci_irq_type; }; -int ps3_pci_init(struct ps3_instance *instance, void *config); +S32 ps3_pci_init(struct ps3_instance *instance, void *config); void ps3_pci_exit(struct ps3_instance *instance); -void ps3_pci_intx(struct ps3_instance *instance, unsigned char enable); +void ps3_pci_intx(struct ps3_instance *instance, U8 enable); #endif -int ps3_pci_find_capability(struct ps3_instance *instance, int cap_id); -int ps3_pci_read_config_word(struct ps3_instance *instance, unsigned int offset, - unsigned short *val); +S32 ps3_pci_find_capability(struct ps3_instance *instance, S32 cap_id); + +S32 ps3_pci_read_config_word(struct ps3_instance *instance, U32 offset, U16 *val); -int ps3_pci_write_config_word(struct ps3_instance *instance, - unsigned int offset, unsigned short val); +S32 ps3_pci_write_config_word(struct ps3_instance *instance, U32 offset, U16 val); -void ps3_reg_write_u64(struct ps3_instance *instance, unsigned long long val, - void *reg); +void ps3_reg_write_u64(struct ps3_instance *instance, U64 val, void *reg); -unsigned long long ps3_reg_read_u64(struct ps3_instance *instance, void *reg); +U64 ps3_reg_read_u64(struct ps3_instance *instance, void *reg); -void __iomem *ps3_reg_set_ioremap(struct pci_dev *pdev, unsigned long reg_bar); +void __iomem *ps3_reg_set_ioremap(struct pci_dev *pdev, ULong reg_bar); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.c b/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.c index 1a7fcb14a0a7..bb3a4e9f7c18 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.c @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + + #include "ps3_platform_utils.h" #include "ps3_instance_manager.h" #include "ps3_mgr_channel.h" @@ -7,84 +7,94 @@ #ifndef _WINDOWS #include #endif -#include "ps3_kernel_version.h" - #ifdef _WINDOWS -int ps3_dma_free(struct ps3_instance *instance, size_t length, void *buffer) +S32 ps3_dma_free( + struct ps3_instance *instance, + size_t length, + void *buffer +) { - int ret = PS3_SUCCESS; - unsigned long status; - - if (buffer == NULL || length == 0) { - ret = -PS3_FAILED; - goto l_out; - } - - status = StorPortFreeContiguousMemorySpecifyCache(instance, buffer, - length, MmCached); - - if (status != STOR_STATUS_SUCCESS) - ret = -PS3_FAILED; + S32 ret = PS3_SUCCESS; + ULong status; + + if (buffer == NULL || length == 0) { + ret = -PS3_FAILED; + goto l_out; + } + + status = StorPortFreeContiguousMemorySpecifyCache(instance, + buffer, + length, + MmCached); + + if (status != STOR_STATUS_SUCCESS) { + ret = -PS3_FAILED; + } l_out: - return ret; + return ret; } -int ps3_dma_alloc(struct ps3_instance *instance, size_t length, void **buffer, - unsigned long long *phy_addr) +S32 ps3_dma_alloc( + struct ps3_instance *instance, + size_t length, + void **buffer, + U64 *phy_addr +) { - int ret = PS3_SUCCESS; - unsigned long len; - unsigned long status; - PHYSICAL_ADDRESS minPhysicalAddress; - PHYSICAL_ADDRESS maxPhysicalAddress; - PHYSICAL_ADDRESS boundaryPhysicalAddress; - STOR_PHYSICAL_ADDRESS PhysicalAddress; - - minPhysicalAddress.QuadPart = 0; - maxPhysicalAddress.QuadPart = 0xFFFFFFFFFFFF; - boundaryPhysicalAddress.QuadPart = 0; - - status = StorPortAllocateContiguousMemorySpecifyCacheNode( - instance, length, minPhysicalAddress, maxPhysicalAddress, - boundaryPhysicalAddress, MmCached, MM_ANY_NODE_OK, buffer); - - if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("alloc dma buffer failed, length:%d, status:0x%x\n", - length, status); - ret = -PS3_FAILED; - goto l_out; - } - - PhysicalAddress = - StorPortGetPhysicalAddress(instance, NULL, *buffer, &len); - *phy_addr = (unsigned long long)PhysicalAddress.QuadPart; - if (PhysicalAddress.QuadPart == 0) { - LOG_ERROR("dma buffer remap fail\n"); - ps3_dma_free(instance, length, *buffer); - *buffer = NULL; - ret = -PS3_FAILED; - } + S32 ret = PS3_SUCCESS; + ULong len; + ULong status; + PHYSICAL_ADDRESS minPhysicalAddress; + PHYSICAL_ADDRESS maxPhysicalAddress; + PHYSICAL_ADDRESS boundaryPhysicalAddress; + STOR_PHYSICAL_ADDRESS PhysicalAddress; + + minPhysicalAddress.QuadPart = 0; + maxPhysicalAddress.QuadPart = 0xFFFFFFFFFFFF; + boundaryPhysicalAddress.QuadPart = 0; + + status = StorPortAllocateContiguousMemorySpecifyCacheNode(instance, + length, + minPhysicalAddress, + maxPhysicalAddress, + boundaryPhysicalAddress, + MmCached, + MM_ANY_NODE_OK, + buffer); + + if (status != STOR_STATUS_SUCCESS) { + LOG_ERROR("alloc dma buffer failed, length:%d, status:0x%x\n", length, status); + ret = -PS3_FAILED; + goto l_out; + } + + PhysicalAddress = StorPortGetPhysicalAddress(instance, NULL, *buffer, &len); + *phy_addr = (U64)PhysicalAddress.QuadPart; + if (PhysicalAddress.QuadPart == 0) { + LOG_ERROR("dma buffer remap fail\n"); + ps3_dma_free(instance, length, *buffer); + *buffer = NULL; + ret = -PS3_FAILED; + } l_out: - return ret; + return ret; } #endif -void *ps3_kcalloc(struct ps3_instance *instance, unsigned int blocks, - unsigned int block_size) +void *ps3_kcalloc(struct ps3_instance *instance, U32 blocks, U32 block_size) { - void *ret = NULL; + void *ret = NULL; #ifndef _WINDOWS (void)instance; - ret = kcalloc(blocks, block_size, GFP_KERNEL); + ret = kcalloc(blocks, block_size, GFP_KERNEL); #else - unsigned long status = StorPortAllocatePool( - instance, blocks * block_size, 'd3sp', &ret); + ULong status = StorPortAllocatePool(instance, + blocks * block_size, 'd3sp', &ret); if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("host_no:%d, memory alloc failed, status0x%x\n", - PS3_HOST(instance), status); + LOG_ERROR("host_no:%d, memory alloc failed, status0x%x\n", PS3_HOST(instance), status); ret = NULL; } else { memset(ret, 0, blocks * block_size); @@ -93,32 +103,31 @@ void *ps3_kcalloc(struct ps3_instance *instance, unsigned int blocks, #endif if (ret == NULL) { - LOG_ERROR("host_no:%u, memory:%u %u alloc failed\n", - PS3_HOST(instance), blocks, block_size); + LOG_ERROR("host_no:%u, memory:%u %u alloc failed\n", PS3_HOST(instance), blocks, block_size); } - return ret; + return ret; } void ps3_kfree(struct ps3_instance *instance, void *buffer) { #ifndef _WINDOWS (void)instance; - if (buffer != NULL) - kfree(buffer); -#else - unsigned long status = StorPortFreePool(instance, buffer); - - if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("host_no:%u, memory free failed, status0x%x\n", - PS3_HOST(instance), status); + if(buffer != NULL){ + kfree(buffer); } +#else + ULong status = StorPortFreePool(instance, buffer); + if (status != STOR_STATUS_SUCCESS) { + LOG_ERROR("host_no:%u, memory free failed, status0x%x\n", PS3_HOST(instance), status); + } #endif + + return; } -void *ps3_kzalloc(struct ps3_instance *instance, unsigned int size) -{ +void *ps3_kzalloc(struct ps3_instance *instance, U32 size) { return ps3_kcalloc(instance, 1, size); } @@ -128,29 +137,28 @@ void ps3_vfree(struct ps3_instance *instance, void *buffer) (void)instance; vfree(buffer); #else - unsigned long status = StorPortFreePool(instance, buffer); - + ULong status = StorPortFreePool(instance, buffer); if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("host_no:%u, memory free failed, status0x%x\n", - PS3_HOST(instance), status); + LOG_ERROR("host_no:%u, memory free failed, status0x%x\n", PS3_HOST(instance), status); } #endif + + return; } -void *ps3_vzalloc(struct ps3_instance *instance, unsigned int size) +void *ps3_vzalloc(struct ps3_instance *instance, U32 size) { void *ret = NULL; #ifndef _WINDOWS (void)instance; ret = vzalloc(size); #else - unsigned long status = - StorPortAllocatePool(instance, size, 'd3sp', &ret); + ULong status = StorPortAllocatePool(instance, + size, 'd3sp', &ret); if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("host_no:%d, memory alloc failed, status0x%x\n", - PS3_HOST(instance), status); + LOG_ERROR("host_no:%d, memory alloc failed, status0x%x\n", PS3_HOST(instance), status); ret = NULL; } else { memset(ret, 0, size); @@ -159,39 +167,38 @@ void *ps3_vzalloc(struct ps3_instance *instance, unsigned int size) #endif if (ret == NULL) { - LOG_ERROR("host_no:%u, memory:%u alloc failed\n", - PS3_HOST(instance), size); + LOG_ERROR("host_no:%u, memory:%u alloc failed\n", PS3_HOST(instance), size); } return ret; } -int ps3_wait_for_completion_timeout(void *sync_done, unsigned long time_out) +S32 ps3_wait_for_completion_timeout(void *sync_done, ULong time_out) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; #ifdef _WINDOWS NTSTATUS wait_ret = STATUS_SUCCESS; LARGE_INTEGER win_timeout = { 0 }; - if (time_out > 0) { - win_timeout.QuadPart = (long long)(time_out * (-10000000LL)); - wait_ret = KeWaitForSingleObject( - sync_done, Executive, KernelMode, FALSE, &win_timeout); - } else { + win_timeout.QuadPart = (S64)(time_out * (-10000000LL)); + wait_ret = KeWaitForSingleObject(sync_done, Executive, + KernelMode, FALSE, &win_timeout); + } + else { wait_ret = KeWaitForSingleObject(sync_done, Executive, - KernelMode, FALSE, NULL); + KernelMode, FALSE, NULL); } - if (wait_ret == STATUS_TIMEOUT) + if (wait_ret == STATUS_TIMEOUT) { ret = -PS3_TIMEOUT; + } #else - unsigned short timeout = 0; - + U16 timeout = 0; if (time_out > 0) { - timeout = wait_for_completion_timeout( - (struct completion *)sync_done, time_out * HZ); - if (timeout == 0) + timeout = wait_for_completion_timeout((struct completion *)sync_done, time_out * HZ); + if (timeout == 0) { ret = -PS3_TIMEOUT; + } } else { wait_for_completion((struct completion *)sync_done); } @@ -199,56 +206,49 @@ int ps3_wait_for_completion_timeout(void *sync_done, unsigned long time_out) return ret; } -int ps3_wait_cmd_for_completion_timeout(struct ps3_instance *instance, - struct ps3_cmd *cmd, - unsigned long timeout) -{ - int ret = PS3_SUCCESS; - unsigned long time_out; +S32 ps3_wait_cmd_for_completion_timeout(struct ps3_instance *instance, struct ps3_cmd *cmd, ULong timeout) { + S32 ret = PS3_SUCCESS; + ULong time_out; #ifdef _WINDOWS (void)instance; - time_out = max_t(unsigned long, cmd->time_out, timeout); + time_out = max((ULong)cmd->time_out, timeout); ret = ps3_wait_for_completion_timeout(&cmd->sync_done, time_out); #else if (cmd->time_out == 0 && cmd->is_interrupt) { ps3_wait_cmd_for_completion_interrupt(instance, cmd); } else { - time_out = max_t(unsigned long, cmd->time_out, timeout); - ret = ps3_wait_for_completion_timeout(&cmd->sync_done, - time_out); + time_out = max((ULong)cmd->time_out, timeout); + ret = ps3_wait_for_completion_timeout(&cmd->sync_done, time_out); } #endif - return ret; + return ret; } -int ps3_scsi_device_get(struct ps3_instance *instance, struct scsi_device *sdev) +S32 ps3_scsi_device_get(struct ps3_instance *instance, struct scsi_device *sdev) { #ifdef _WINDOWS - return ps3_scsi_device_get_win(instance, sdev); + return ps3_scsi_device_get_win(instance, sdev); #else (void)instance; - return scsi_device_get(sdev); + return scsi_device_get(sdev); #endif } -void ps3_scsi_device_put(struct ps3_instance *instance, - struct scsi_device *sdev) +void ps3_scsi_device_put(struct ps3_instance *instance, struct scsi_device *sdev) { #ifdef _WINDOWS - ps3_scsi_device_put_win(instance, sdev); + ps3_scsi_device_put_win(instance, sdev); #else (void)instance; - scsi_device_put(sdev); + scsi_device_put(sdev); #endif } #ifndef _WINDOWS -#if defined(PS3_SCSI_DEVICE_LOOKUP) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) struct scsi_device *__ps3_scsi_device_lookup_check(struct Scsi_Host *shost, - unsigned int channel, - unsigned int id, - unsigned int lun) + U32 channel, U32 id, U32 lun) { struct scsi_device *sdev = NULL; @@ -256,7 +256,7 @@ struct scsi_device *__ps3_scsi_device_lookup_check(struct Scsi_Host *shost, if (sdev->sdev_state == SDEV_DEL) continue; if (sdev->channel == channel && sdev->id == id && - sdev->lun == lun) + sdev->lun == lun) return sdev; } @@ -264,9 +264,7 @@ struct scsi_device *__ps3_scsi_device_lookup_check(struct Scsi_Host *shost, } struct scsi_device *ps3_scsi_device_lookup_check(struct Scsi_Host *shost, - unsigned int channel, - unsigned int id, - unsigned int lun) + U32 channel, U32 id, U32 lun) { struct scsi_device *sdev = NULL; unsigned long flags = 0; @@ -284,125 +282,115 @@ struct scsi_device *ps3_scsi_device_lookup_check(struct Scsi_Host *shost, #endif -struct scsi_device *ps3_scsi_device_lookup(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id, - unsigned char lun) +struct scsi_device *ps3_scsi_device_lookup(struct ps3_instance *instance, U8 channel, U16 target_id, U8 lun) { #ifdef _WINDOWS - (void)lun; - struct scsi_device *sdev = ps3_scsi_device_lookup_win( - instance, channel, (unsigned char)target_id); - if (sdev != NULL && sdev->unit_start == 1) - return sdev; - return NULL; + (void)lun; + struct scsi_device *sdev = ps3_scsi_device_lookup_win(instance, channel, (U8)target_id); + if (sdev != NULL && sdev->unit_start == 1) { + return sdev; + } + return NULL; #else -#if defined(PS3_SCSI_DEVICE_LOOKUP) - return ps3_scsi_device_lookup_check(instance->host, channel, target_id, - lun); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) + return ps3_scsi_device_lookup_check(instance->host, channel, target_id, lun); #else return scsi_device_lookup(instance->host, channel, target_id, lun); #endif #endif } -void ps3_scsi_remove_device(struct ps3_instance *instance, - struct scsi_device *sdev) +void ps3_scsi_remove_device(struct ps3_instance *instance, struct scsi_device *sdev) { #ifdef _WINDOWS - ps3_scsi_remove_device_win(instance, sdev); + ps3_scsi_remove_device_win(instance, sdev); #else (void)instance; - scsi_remove_device(sdev); + scsi_remove_device(sdev); #endif } -int ps3_scsi_add_device(struct ps3_instance *instance, unsigned char channel, - unsigned short target_id, unsigned char lun) +S32 ps3_scsi_add_device(struct ps3_instance *instance, U8 channel, U16 target_id, U8 lun) { #ifdef _WINDOWS - (void)lun; - return ps3_scsi_add_device_win(instance, channel, - (unsigned char)target_id); + (void)lun; + return ps3_scsi_add_device_win(instance, channel, (U8)target_id); #else - return scsi_add_device(instance->host, channel, target_id, lun); + return scsi_add_device(instance->host, channel, target_id, lun); #endif } -unsigned long long ps3_now_ms_get(void) +U64 ps3_now_ms_get(void) { #ifdef _WINDOWS - LARGE_INTEGER timestamp; - - KeQuerySystemTime(×tamp); - return timestamp.QuadPart / 10000; + LARGE_INTEGER timestamp; + KeQuerySystemTime(×tamp); + return timestamp.QuadPart / 10000; #else return ktime_to_ms(ktime_get_real()); #endif } -unsigned long long ps3_1970_now_ms_get(void) +U64 ps3_1970_now_ms_get(void) { #ifdef _WINDOWS - unsigned long long timestamp; - LARGE_INTEGER timestamp1970; - TIME_FIELDS timefiled; - - timefiled.Year = 1970; - timefiled.Month = 1; - timefiled.Day = 1; - timefiled.Hour = 0; - timefiled.Minute = 0; - timefiled.Second = 0; - timefiled.Milliseconds = 0; - - RtlTimeFieldsToTime(&timefiled, ×tamp1970); - timestamp = ps3_now_ms_get(); - return timestamp - (timestamp1970.QuadPart / 10000); + U64 timestamp; + LARGE_INTEGER timestamp1970; + TIME_FIELDS timefiled; + + timefiled.Year = 1970; + timefiled.Month = 1; + timefiled.Day = 1; + timefiled.Hour = 0; + timefiled.Minute = 0; + timefiled.Second = 0; + timefiled.Milliseconds = 0; + + RtlTimeFieldsToTime(&timefiled, ×tamp1970); + timestamp = ps3_now_ms_get(); + return timestamp - (timestamp1970.QuadPart / 10000); #else - return ps3_now_ms_get(); + return ps3_now_ms_get(); #endif } #ifdef _WINDOWS -int ps3_now_format_get(char *buff, int buf_len) +S32 ps3_now_format_get(char *buff, S32 buf_len) { #ifdef _WINDOWS - LARGE_INTEGER timestamp; - - KeQuerySystemTime(×tamp); - LARGE_INTEGER localtime; - TIME_FIELDS timefiled; - - ExSystemTimeToLocalTime(×tamp, &localtime); - RtlTimeToTimeFields(&localtime, &timefiled); - - return snprintf(buff, buf_len, "%04ld-%02d-%02d_%02d:%02d:%02d.%03d", - timefiled.Year, timefiled.Month, timefiled.Day, - timefiled.Hour, timefiled.Minute, timefiled.Second, - timefiled.Milliseconds); + LARGE_INTEGER timestamp; + KeQuerySystemTime(×tamp); + LARGE_INTEGER localtime; + TIME_FIELDS timefiled; + + ExSystemTimeToLocalTime(×tamp, &localtime); + RtlTimeToTimeFields(&localtime, &timefiled); + + return snprintf(buff, buf_len, "%04ld-%02d-%02d_%02d:%02d:%02d.%03d", + timefiled.Year, timefiled.Month, timefiled.Day, + timefiled.Hour, timefiled.Minute, timefiled.Second, + timefiled.Milliseconds); #else - struct timeval tv; - struct tm td; + struct timeval tv; + struct tm td; - do_gettimeofday(&tv); - time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); + do_gettimeofday(&tv); + time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); - return snprintf(buff, buf_len, "%04ld-%02d-%02d_%02d:%02d:%02d", - td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, - td.tm_hour, td.tm_min, td.tm_sec); + return snprintf(buff, buf_len, "%04ld-%02d-%02d_%02d:%02d:%02d", + td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, + td.tm_hour, td.tm_min, td.tm_sec); #endif } #endif -unsigned long long ps3_tick_count_get(void) +U64 ps3_tick_count_get(void) { #ifdef _WINDOWS - LARGE_INTEGER tick_count; - LARGE_INTEGER tick_frequency; + LARGE_INTEGER tick_count; + LARGE_INTEGER tick_frequency; - tick_count = KeQueryPerformanceCounter(&tick_frequency); - return (unsigned long long)(tick_count.QuadPart * 1000000 / - tick_frequency.QuadPart); + tick_count = KeQueryPerformanceCounter(&tick_frequency); + return (U64)(tick_count.QuadPart * 1000000 / tick_frequency.QuadPart); #else - return (unsigned long long)ktime_to_us(ktime_get_real()); + return (U64)ktime_to_us(ktime_get_real()); #endif } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.h b/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.h index 36c942705bb9..3004062603d6 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_PLATFORM_UTILS_H_ #define _PS3_PLATFORM_UTILS_H_ @@ -10,7 +9,7 @@ #include #include #include -#include "linux/kernel.h" + #endif #include "ps3_err_def.h" @@ -22,97 +21,93 @@ struct ps3_cmd; #define scsi_cmnd_cdb(scmnd) ((scmnd)->cmnd) #define scsi_device_private_data(scmnd) (PS3_SDEV_PRI_DATA((scmnd)->device)) #ifdef _WINDOWS -#define scsi_host_data(scmnd) ((struct ps3_instance *)((scmnd)->instance)) +#define scsi_host_data(scmnd) (struct ps3_instance*)((scmnd)->instance) #else -#define scsi_host_data(scmnd) \ - ((struct ps3_instance *)((scmnd)->device->host->hostdata)) +#define scsi_host_data(scmnd) (struct ps3_instance*)((scmnd)->device->host->hostdata) #endif #ifdef _WINDOWS -#define ps3_container_of(ptr, type, member) \ - ((type *)((char *)ptr - offsetof(type, member))) +#define ps3_container_of(ptr, type, member) \ + ((type*)((char*)ptr - offsetof(type,member))) #else #define ps3_container_of container_of #endif #define MAX_MDELAY (1) -#ifndef PS3_FALSE -#define PS3_FALSE (0) -#endif -#ifndef PS3_TRUE -#define PS3_TRUE (1) -#endif -#ifndef PS3_MAX -#define PS3_MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif -#ifndef PS3_MIN -#define PS3_MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef PS3_DESC -#define PS3_DESC(a) 1 + +#ifdef _WINDOWS +typedef struct { + FAST_MUTEX mutex; +}ps3_mutex, *pps3_mutex; +#else + +typedef struct mutex ps3_mutex; + #endif -static inline void ps3_mutex_init(struct mutex *mutex_lock) +static inline void ps3_mutex_init(ps3_mutex *mutex_lock) { #ifdef _WINDOWS - ExInitializeFastMutex(&mutex_lock->mutex); + ExInitializeFastMutex(&mutex_lock->mutex); #else mutex_init(mutex_lock); #endif } -static inline void ps3_mutex_destroy(struct mutex *mutex_lock) +static inline void ps3_mutex_destroy(ps3_mutex *mutex_lock) { #ifdef _WINDOWS - (void)mutex_lock; + (void)mutex_lock; #else mutex_destroy(mutex_lock); #endif + return; } -static inline int ps3_mutex_lock(struct mutex *mtx_lock) +static inline S32 ps3_mutex_lock(ps3_mutex *mtx_lock) { + #ifdef _WINDOWS - if (KeGetCurrentIrql() <= APC_LEVEL) { - ExAcquireFastMutex(&mtx_lock->mutex); + if (KeGetCurrentIrql() <= APC_LEVEL) { + ExAcquireFastMutex(&mtx_lock->mutex); - return PS3_SUCCESS; - } - return -PS3_FAILED; + return PS3_SUCCESS; + } + return -PS3_FAILED; #else mutex_lock(mtx_lock); return PS3_SUCCESS; #endif } -static inline int ps3_mutex_trylock(struct mutex *mutex_lock) +static inline S32 ps3_mutex_trylock(ps3_mutex *mutex_lock) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; #ifdef _WINDOWS - if (KeGetCurrentIrql() > APC_LEVEL) { - ret = -PS3_FAILED; - goto l_out; - } + if (KeGetCurrentIrql() > APC_LEVEL) { + ret = -PS3_FAILED; + goto l_out; + } - if (!ExTryToAcquireFastMutex(&mutex_lock->mutex)) { - ret = -PS3_FAILED; - goto l_out; - } + if (!ExTryToAcquireFastMutex(&mutex_lock->mutex)) { + ret = -PS3_FAILED; + goto l_out; + } l_out: #else ret = mutex_trylock(mutex_lock); #endif - return ret; + return ret; } -static inline int ps3_mutex_unlock(struct mutex *mutex_lock) +static inline S32 ps3_mutex_unlock(ps3_mutex *mutex_lock) { #ifdef _WINDOWS - if (KeGetCurrentIrql() <= APC_LEVEL) { - ExReleaseFastMutex(&mutex_lock->mutex); + if (KeGetCurrentIrql() <= APC_LEVEL) { + ExReleaseFastMutex(&mutex_lock->mutex); - return PS3_SUCCESS; - } + return PS3_SUCCESS; + } - return -PS3_FAILED; + return -PS3_FAILED; #else mutex_unlock(mutex_lock); return PS3_SUCCESS; @@ -120,121 +115,123 @@ static inline int ps3_mutex_unlock(struct mutex *mutex_lock) #endif } -static inline int ps3_atomic_read(atomic_t *value) -{ #ifdef _WINDOWS - return value->value; +typedef struct { + volatile S32 value; +}ps3_atomic32, *pps3_atomic32; + +typedef struct { + volatile S64 value; +}ps3_atomic64, *pps3_atomic64; +#else +typedef atomic_t ps3_atomic32; +typedef atomic64_t ps3_atomic64; +#endif + +static inline S32 ps3_atomic_read(ps3_atomic32 *value) { +#ifdef _WINDOWS + return value->value; #else return atomic_read(value); #endif } -static inline int ps3_atomic_dec(atomic_t *value) -{ +static inline S32 ps3_atomic_dec(ps3_atomic32 *value) { #ifdef _WINDOWS - return (int)InterlockedDecrement((LONG *)(&value->value)); + return (S32)InterlockedDecrement((LONG*)(&value->value)); #else atomic_dec(value); return PS3_SUCCESS; #endif } -static inline int ps3_atomic_add(int i, atomic_t *value) -{ +static inline S32 ps3_atomic_add(S32 i, ps3_atomic32 *value) { #ifdef _WINDOWS - return (int)_InlineInterlockedAdd((LONG *)&value->value, (LONG)i); + return (S32)_InlineInterlockedAdd((LONG*)&value->value, (LONG)i); #else atomic_add(i, value); return PS3_SUCCESS; #endif } -static inline int ps3_atomic_sub(int i, atomic_t *value) -{ +static inline S32 ps3_atomic_sub(S32 i, ps3_atomic32 *value) { #ifdef _WINDOWS - return (int)_InlineInterlockedAdd((LONG *)&value->value, (LONG)-i); + return (S32)_InlineInterlockedAdd((LONG*)&value->value, (LONG)-i); #else atomic_sub(i, value); return PS3_SUCCESS; #endif } -static inline int ps3_atomic_cmpxchg(atomic_t *value, int old, int cur) +static inline S32 ps3_atomic_cmpxchg(ps3_atomic32 *value, S32 old, S32 cur) { #ifdef _WINDOWS - return (int)InterlockedCompareExchange((LONG *)&value->value, (LONG)cur, - (LONG)old); + return (S32)InterlockedCompareExchange((LONG*)&value->value, (LONG)cur, (LONG)old); #else return atomic_cmpxchg(value, cur, old); #endif } -static inline unsigned char ps3_atomic_add_unless(atomic_t *value, int a, int u) -{ +static inline Bool ps3_atomic_add_unless(ps3_atomic32 *value, S32 a, S32 u) { #ifdef _WINDOWS - int c = 0; - int old = 0; - - c = value->value; - while (c != u && (old = ps3_atomic_cmpxchg(value, c, c + a)) != c) - c = old; + S32 c = 0; + S32 old = 0; + c = value->value; + while (c != u && + (old = ps3_atomic_cmpxchg(value, c, c + a)) != c) { + c = old; + } - return c != u; + return c != u; #else return atomic_add_unless(value, a, u); #endif } -static inline int ps3_atomic_inc(atomic_t *value) -{ +static inline S32 ps3_atomic_inc(ps3_atomic32 *value) { #ifdef _WINDOWS - return (int)InterlockedIncrement((LONG *)(&value->value)); + return (S32)InterlockedIncrement((LONG*)(&value->value)); #else atomic_inc(value); return PS3_SUCCESS; #endif } -static inline int ps3_atomic_inc_return(atomic_t *value) -{ +static inline S32 ps3_atomic_inc_return(ps3_atomic32 *value) { #ifdef _WINDOWS - return (int)InterlockedIncrement((LONG *)(&value->value)); + return (S32)InterlockedIncrement((LONG*)(&value->value)); #else return atomic_inc_return(value); #endif } -static inline int ps3_atomic_dec_return(atomic_t *value) -{ +static inline S32 ps3_atomic_dec_return(ps3_atomic32 *value) { #ifdef _WINDOWS - return (int)InterlockedDecrement((LONG *)(&value->value)); + return (S32)InterlockedDecrement((LONG*)(&value->value)); #else return atomic_dec_return(value); #endif } -static inline long long ps3_atomic64_inc(atomic64_t *value) -{ +static inline S64 ps3_atomic64_inc(ps3_atomic64 *value) { #ifdef _WINDOWS - return (long long)InterlockedIncrement64((LONG64 *)(&value->value)); + return (S64)InterlockedIncrement64((LONG64*)(&value->value)); #else atomic64_inc(value); return PS3_SUCCESS; #endif } -static inline long long ps3_atomic64_inc_return(atomic64_t *value) -{ +static inline S64 ps3_atomic64_inc_return(ps3_atomic64 *value) { #ifdef _WINDOWS - return (long long)InterlockedIncrement64((LONG64 *)(&value->value)); + return (S64)InterlockedIncrement64((LONG64*)(&value->value)); #else return atomic64_inc_return(value); #endif } -static inline long long ps3_atomic64_read(atomic64_t *value) -{ +static inline S64 ps3_atomic64_read(ps3_atomic64 *value) { #ifdef _WINDOWS return value->value; #else @@ -242,8 +239,7 @@ static inline long long ps3_atomic64_read(atomic64_t *value) #endif } -static inline void ps3_atomic64_set(atomic64_t *value, long long i) -{ +static inline void ps3_atomic64_set(ps3_atomic64 *value, S64 i) { #ifdef _WINDOWS value->value = i; #else @@ -251,8 +247,7 @@ static inline void ps3_atomic64_set(atomic64_t *value, long long i) #endif } -static inline void ps3_atomic_set(atomic_t *value, int i) -{ +static inline void ps3_atomic_set(ps3_atomic32 *value, S32 i) { #ifdef _WINDOWS value->value = i; #else @@ -260,267 +255,279 @@ static inline void ps3_atomic_set(atomic_t *value, int i) #endif } -static inline long long ps3_atomic64_add(long long i, atomic64_t *value) -{ +static inline S64 ps3_atomic64_add(S64 i, ps3_atomic64 *value) { #ifdef _WINDOWS - return (long long)_InlineInterlockedAdd64((LONG64 *)&value->value, - (LONG64)i); + return (S64)_InlineInterlockedAdd64((LONG64*)&value->value, (LONG64)i); #else atomic64_add(i, value); return PS3_SUCCESS; #endif } -static inline long long ps3_atomic64_dec(atomic64_t *value) -{ +static inline S64 ps3_atomic64_dec(ps3_atomic64 *value) { #ifdef _WINDOWS - return (long long)InterlockedDecrement64((LONG64 *)&value->value); + return (S64)InterlockedDecrement64((LONG64*)&value->value); #else atomic64_dec(value); return PS3_SUCCESS; #endif } -static inline void ps3_spin_lock_init(spinlock_t *lock) +#ifdef _WINDOWS +typedef struct { + KSPIN_LOCK lock; +}ps3_spinlock, *pps3_spinlock; +#else +typedef spinlock_t ps3_spinlock; +#endif + +static inline void ps3_spin_lock_init(ps3_spinlock *lock) { #ifdef _WINDOWS - KeInitializeSpinLock(&lock->lock); + KeInitializeSpinLock(&lock->lock); #else spin_lock_init(lock); #endif } -static inline void ps3_spin_lock(spinlock_t *lock, unsigned long *flag) +static inline void ps3_spin_lock(ps3_spinlock *lock, ULong*flag) { #ifdef _WINDOWS - KeAcquireSpinLock(&lock->lock, (PKIRQL)flag); + KeAcquireSpinLock(&lock->lock, (PKIRQL)flag); #else (void)flag; - spin_lock(lock); + spin_lock(lock); #endif } -static inline void ps3_spin_lock_irqsave(spinlock_t *lock, unsigned long *flag) +static inline void ps3_spin_lock_irqsave(ps3_spinlock *lock, ULong *flag) { #ifdef _WINDOWS - KeAcquireSpinLock(&lock->lock, (PKIRQL)flag); + KeAcquireSpinLock(&lock->lock, (PKIRQL)flag); #else - spin_lock_irqsave(lock, *flag); + spin_lock_irqsave(lock, *flag); #endif } -static inline void ps3_spin_unlock(spinlock_t *lock, unsigned long flag) +static inline void ps3_spin_unlock(ps3_spinlock *lock, ULong flag) { #ifdef _WINDOWS - KeReleaseSpinLock(&lock->lock, (KIRQL)flag); + KeReleaseSpinLock(&lock->lock, (KIRQL)flag); #else (void)flag; - spin_unlock(lock); + spin_unlock(lock); #endif } -static inline void ps3_spin_unlock_irqrestore(spinlock_t *lock, - unsigned long flag) +static inline void ps3_spin_unlock_irqrestore(ps3_spinlock *lock, ULong flag) { #ifdef _WINDOWS - KeReleaseSpinLock(&lock->lock, (KIRQL)flag); + KeReleaseSpinLock(&lock->lock, (KIRQL)flag); #else - spin_unlock_irqrestore(lock, flag); + spin_unlock_irqrestore(lock, flag); #endif } -int ps3_wait_for_completion_timeout(void *sync_done, unsigned long Timeout); -int ps3_wait_cmd_for_completion_timeout(struct ps3_instance *instance, - struct ps3_cmd *cmd, - unsigned long timeout); +S32 ps3_wait_for_completion_timeout(void *sync_done, ULong Timeout); +S32 ps3_wait_cmd_for_completion_timeout(struct ps3_instance *instance, + struct ps3_cmd *cmd, ULong timeout); + +#ifdef _WINDOWS +typedef LIST_ENTRY ps3_list_head; +#else +typedef struct list_head ps3_list_head; +#endif #ifdef _WINDOWS -#define complete(x) KeSetEvent(x, IO_NO_INCREMENT, FALSE) -#define init_completion(x) KeInitializeEvent(x, SynchronizationEvent, FALSE) +#define complete(x) KeSetEvent(x, IO_NO_INCREMENT, FALSE); +#define init_completion(x) KeInitializeEvent(x, SynchronizationEvent, FALSE); -static inline int list_empty(const struct list_head *head) +static inline int list_empty(const ps3_list_head* head) { - return head->Blink == head; + return head->Blink == head; } -#define list_entry(ptr, type, member) CONTAINING_RECORD(ptr, type, member) +#define list_entry(ptr, type, member) \ + CONTAINING_RECORD(ptr, type, member) -#define list_for_each(pos, head) \ +#define list_for_each(pos, head) \ for (pos = (head)->Blink; pos != (head); pos = pos->Blink) -#define list_first_entry(ptr, type, member) \ - list_entry((ptr)->Blink, type, member) -#define list_next_entry(pos, type, member) \ - list_entry((pos)->member.Blink, type, member) -#define list_for_each_entry(pos, type, head, member) \ - for (pos = list_first_entry(head, type, member); \ - &pos->member != (head); pos = list_next_entry(pos, type, member)) -#define list_for_each_entry_safe(pos, type, tmp, head, member) \ - for (pos = list_first_entry(head, type, member), \ - tmp = list_next_entry(pos, type, member); \ - &pos->member != (head); \ - pos = tmp, tmp = list_next_entry(tmp, type, member)) - -static inline void INIT_LIST_HEAD(struct list_head *list) +#define list_first_entry(ptr, type, member) \ + list_entry((ptr)->Blink, type, member) + +#define list_next_entry(pos, type, member) \ + list_entry((pos)->member.Blink, type, member) + +#define list_for_each_entry(pos, type, head, member) \ + for (pos = list_first_entry(head, type, member); \ + &pos->member != (head); \ + pos = list_next_entry(pos, type, member)) + +#define list_for_each_entry_safe(pos, type, tmp, head, member) \ + for (pos = list_first_entry(head, type, member), \ + tmp = list_next_entry(pos, type, member); \ + &pos->member != (head); \ + pos = tmp, tmp = list_next_entry(tmp, type, member)) + +static inline void INIT_LIST_HEAD(ps3_list_head* list) { - InitializeListHead((PLIST_ENTRY)list); + InitializeListHead((PLIST_ENTRY)list); } -static inline void list_del(struct list_head *entry) +static inline void list_del(ps3_list_head* entry) { - RemoveEntryList((PLIST_ENTRY)entry); + RemoveEntryList((PLIST_ENTRY)entry); } -static inline void list_del_init(struct list_head *entry) +static inline void list_del_init(ps3_list_head* entry) { - list_del(entry); - INIT_LIST_HEAD(entry); + list_del(entry); + INIT_LIST_HEAD(entry); } -static inline void list_add_tail(struct list_head *entry, - struct list_head *head) +static inline void list_add_tail(ps3_list_head* entry, ps3_list_head* head) { - InsertTailList((PLIST_ENTRY)head, (PLIST_ENTRY)entry); + InsertTailList((PLIST_ENTRY)head, (PLIST_ENTRY)entry); } -static inline struct list_head *list_remove_head(struct list_head *head) +static inline ps3_list_head* list_remove_head(ps3_list_head* head) { - return (struct list_head *)RemoveHeadList((PLIST_ENTRY)head); + return (ps3_list_head*)RemoveHeadList((PLIST_ENTRY)head); } -inline int kstrtou16(const char *s, unsigned int base, unsigned short *res) +inline S32 kstrtou16(const S8 *s, U32 base, U16 *res) { - unsigned long tmp = 0; - int ret = RtlCharToInteger(s, base, &tmp); + ULong tmp = 0; + int ret = RtlCharToInteger(s, base, &tmp); + if (ret != STATUS_SUCCESS) { + goto l_out; + } - if (ret != STATUS_SUCCESS) - goto l_out; - - if (tmp != (unsigned long long)(unsigned short)tmp) { - ret = -34; - goto l_out; - } + if (tmp != (U64)(U16)tmp) { + ret = -34; + goto l_out; + } - *res = (unsigned short)tmp; + *res = (U16)tmp; l_out: - return ret; + return ret; } -inline int kstrtoint(const char *s, unsigned int base, int *res) +inline S32 kstrtoint(const S8 *s, U32 base, S32* res) { - unsigned long tmp = 0; - int ret = RtlCharToInteger(s, base, &tmp); + ULong tmp = 0; + int ret = RtlCharToInteger(s, base, &tmp); + if (ret != STATUS_SUCCESS) { - if (ret != STATUS_SUCCESS) - goto l_out; + } - if (tmp != (unsigned long long)(int)tmp) { - ret = -34; - goto l_out; - } + if (tmp != (U64)(int)tmp) { + ret = -34; + goto l_out; + } - *res = (int)tmp; + *res = (int)tmp; l_out: - return ret; + return ret; } -inline int kstrtouint(const char *s, unsigned int base, unsigned int *res) +inline S32 kstrtouint(const S8 *s, U32 base, U32* res) { - unsigned long tmp = 0; - int ret = RtlCharToInteger(s, base, &tmp); - - if (ret != STATUS_SUCCESS) - goto l_out; + ULong tmp = 0; + int ret = RtlCharToInteger(s, base, &tmp); + if (ret != STATUS_SUCCESS) { + goto l_out; + } - if (tmp != (unsigned long long)(unsigned int)tmp) { - ret = -34; - goto l_out; - } + if (tmp != (U64)(U32)tmp) { + ret = -34; + goto l_out; + } - *res = (unsigned int)tmp; + *res = (unsigned int)tmp; l_out: - return ret; + return ret; } -inline int kstrtou64(const char *s, unsigned long long base, - unsigned long long *res) +inline S32 kstrtou64(const S8 *s, U64 base, U64* res) { - unsigned long tmp = 0; - int ret = RtlCharToInteger(s, base, &tmp); + ULong tmp = 0; + int ret = RtlCharToInteger(s, base, &tmp); + if (ret != STATUS_SUCCESS) { + goto l_out; + } - if (ret != STATUS_SUCCESS) - goto l_out; + if (tmp != (U64)tmp) { + ret = -34; + goto l_out; + } - if (tmp != (unsigned long long)tmp) { - ret = -34; - goto l_out; - } - - *res = (unsigned long)tmp; + *res = (ULong)tmp; l_out: - return ret; + return ret; } -int ps3_dma_free(struct ps3_instance *instance, size_t length, void *buffer); +S32 ps3_dma_free( + struct ps3_instance *instance, + size_t length, + void *buffer +); -int ps3_dma_alloc(struct ps3_instance *instance, size_t length, void **buffer, - unsigned long long *phy_addr); +S32 ps3_dma_alloc( + struct ps3_instance *instance, + size_t length, + void **buffer, + U64 *phy_addr +); #endif -static inline void ps3_msleep(unsigned int ms) +static inline void ps3_msleep(U32 ms) { #ifdef _WINDOWS - StorPortStallExecution((unsigned long)ms * 1000); + StorPortStallExecution((ULong)ms*1000); #else msleep(ms); #endif } -static inline void ps3_mdelay(unsigned int ms) +static inline void ps3_mdelay(U32 ms) { #ifndef _WINDOWS - unsigned int count = (ms / MAX_MDELAY); - unsigned int remain = (ms % MAX_MDELAY); - + U32 count = (ms/MAX_MDELAY); + U32 remain = (ms%MAX_MDELAY); do { - udelay(1000 * MAX_MDELAY); + udelay(1000*MAX_MDELAY); count--; - } while (count); + } while(count); - if (remain != 0) + if(remain != 0){ udelay(remain * 1000); + } #else - StorPortStallExecution((unsigned long)ms * 1000); + StorPortStallExecution((ULong)ms*1000); #endif } -void *ps3_kcalloc(struct ps3_instance *instance, unsigned int blocks, - unsigned int block_size); +void *ps3_kcalloc(struct ps3_instance *instance, U32 blocks, U32 block_size); void ps3_kfree(struct ps3_instance *instance, void *buffer); -void *ps3_kzalloc(struct ps3_instance *instance, unsigned int size); +void *ps3_kzalloc(struct ps3_instance *instance, U32 size); void ps3_vfree(struct ps3_instance *instance, void *buffer); -void *ps3_vzalloc(struct ps3_instance *instance, unsigned int size); - -int ps3_scsi_device_get(struct ps3_instance *instance, - struct scsi_device *sdev); -void ps3_scsi_device_put(struct ps3_instance *instance, - struct scsi_device *sdev); -struct scsi_device *ps3_scsi_device_lookup(struct ps3_instance *instance, - unsigned char channel, - unsigned short target_id, - unsigned char lun); -void ps3_scsi_remove_device(struct ps3_instance *instance, - struct scsi_device *sdev); -int ps3_scsi_add_device(struct ps3_instance *instance, unsigned char channel, - unsigned short target_id, unsigned char lun); - -unsigned long long ps3_now_ms_get(void); -#ifdef _WINDOWS -int ps3_now_format_get(char *buff, int buf_len); -#endif -unsigned long long ps3_1970_now_ms_get(void); -unsigned long long ps3_tick_count_get(void); +void *ps3_vzalloc(struct ps3_instance *instance, U32 size); + +int ps3_scsi_device_get(struct ps3_instance *instance, struct scsi_device *sdev); +void ps3_scsi_device_put(struct ps3_instance *instance, struct scsi_device *sdev); +struct scsi_device *ps3_scsi_device_lookup(struct ps3_instance *instance, U8 channel, U16 target_id, U8 lun); +void ps3_scsi_remove_device(struct ps3_instance *instance, struct scsi_device *sdev); +S32 ps3_scsi_add_device(struct ps3_instance *instance, U8 channel, U16 target_id, U8 lun); + +U64 ps3_now_ms_get(void); +#ifdef _WINDOWS +S32 ps3_now_format_get(char *buff, S32 buf_len); +#endif +U64 ps3_1970_now_ms_get(void); +U64 ps3_tick_count_get(void); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_qos.c b/drivers/scsi/linkdata/ps3stor/ps3_qos.c index 096b22fca478..ac20e01c2661 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_qos.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_qos.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include #include #include @@ -8,6 +6,7 @@ #include #include "ps3_ioc_manager.h" #include "ps3_util.h" +#include "ps3_types.h" #include "ps3_instance_manager.h" #include "ps3_htp_def.h" #include "ps3_scsih.h" @@ -20,7 +19,6 @@ #include "ps3_cmd_statistics.h" #include "ps3_scsih_raid_engine.h" #include "ps3_ioc_state.h" -#include "ps3_kernel_version.h" #define PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr) ((qos_pd_mgr)->vd_id > 0) @@ -30,16 +28,14 @@ #define PS3_QOS_VD_SDD_DELAY_THD_MS 1 -static inline unsigned char ps3_tfifo_depth_get(struct ps3_instance *instance, - unsigned long long *depth) +static inline Bool ps3_tfifo_depth_get(struct ps3_instance *instance, + U64 *depth) { - unsigned char ret = PS3_TRUE; - - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3TfifoDepth, *depth); + Bool ret = PS3_TRUE; + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3TfifoDepth, *depth); if (*depth == U64_MAX) { LOG_INFO("host_no:%u read reg ps3TfifoDepth failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *depth = 0; ret = PS3_FALSE; goto l_out; @@ -51,17 +47,15 @@ static inline unsigned char ps3_tfifo_depth_get(struct ps3_instance *instance, return ret; } -static inline unsigned char ps3_cmdq_depth_get(struct ps3_instance *instance, - unsigned long long *depth) +static inline Bool ps3_cmdq_depth_get(struct ps3_instance *instance, + U64 *depth) { - unsigned char ret = PS3_TRUE; - - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3CmdQueueDepth, *depth); + Bool ret = PS3_TRUE; + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3CmdQueueDepth, *depth); if (*depth == U64_MAX) { LOG_INFO("host_no:%u read reg ps3CmdQueueDepth failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *depth = 0; ret = PS3_FALSE; goto l_out; @@ -73,17 +67,15 @@ static inline unsigned char ps3_cmdq_depth_get(struct ps3_instance *instance, return ret; } -static inline unsigned char ps3_mgrq_depth_get(struct ps3_instance *instance, - unsigned long long *depth) +static inline Bool ps3_mgrq_depth_get(struct ps3_instance *instance, + U64 *depth) { - unsigned char ret = PS3_TRUE; - - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, - ps3MgrQueueDepth, *depth); + Bool ret = PS3_TRUE; + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MgrQueueDepth, *depth); if (*depth == U64_MAX) { LOG_INFO("host_no:%u read reg ps3MgrQueueDepth failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *depth = 0; ret = PS3_FALSE; goto l_out; @@ -95,41 +87,38 @@ static inline unsigned char ps3_mgrq_depth_get(struct ps3_instance *instance, return ret; } -static inline struct ps3_qos_pd_mgr * -ps3_qos_pd_mgr_get(struct ps3_instance *instance, unsigned short disk_id) +static inline struct ps3_qos_pd_mgr *ps3_qos_pd_mgr_get(struct ps3_instance *instance, U16 disk_id) { - return &instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; + return &instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; } -static inline bool ps3_is_nvme_direct_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_cmd *cmd) +static inline bool ps3_is_nvme_direct_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_cmd *cmd) { return (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD && - cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK); + cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK); } static void ps3_qos_update_pd_quota(struct ps3_cmd *cmd) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - unsigned short i = 0; - unsigned short disk_id = 0; - int pd_used_quota = 0; - atomic_t *pd_rsc = NULL; + U16 i = 0; + U16 disk_id = 0; + S32 pd_used_quota = 0; + ps3_atomic32 *pd_rsc = NULL; for (i = 0; i < cmd->target_pd_count; i++) { if (cmd->target_pd[i].get_quota) { disk_id = cmd->target_pd[i].flat_disk_id; qos_pd_mgr = ps3_qos_pd_mgr_get(cmd->instance, disk_id); - if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) + if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) { pd_rsc = &qos_pd_mgr->direct_used_quota; - else + } else { pd_rsc = &qos_pd_mgr->pd_used_quota; + } pd_used_quota = ps3_atomic_dec_return(pd_rsc); - LOG_DEBUG( - "update pd quota. host_no:%u t_id:0x%llx CFID:%u direct:%u pid:%u used_quota:%d\n", - PS3_HOST(cmd->instance), cmd->trace_id, - cmd->index, cmd->cmd_word.direct, disk_id, - pd_used_quota); + LOG_DEBUG("update pd quota. host_no:%u t_id:0x%llx CFID:%u direct:%u pid:%u used_quota:%d\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, cmd->cmd_word.direct, + disk_id, pd_used_quota); break; } } @@ -137,26 +126,24 @@ static void ps3_qos_update_pd_quota(struct ps3_cmd *cmd) static inline struct ps3_qos_vd_mgr *ps3_qos_vd_mgr_get(struct ps3_cmd *cmd) { - unsigned short disk_id = 0; - unsigned short flat_disk_id = 0; + U16 disk_id = 0; + U16 flat_disk_id = 0; struct ps3_instance *instance = cmd->instance; if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { disk_id = PS3_VDID(&cmd->io_attr.vd_entry->diskPos); - flat_disk_id = - get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_id); + flat_disk_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_id); return &instance->qos_context.vd_ctx.qos_vd_mgrs[flat_disk_id]; } else { - return &instance->qos_context.vd_ctx - .qos_vd_mgrs[instance->qos_context.max_vd_count]; + return &instance->qos_context.vd_ctx.qos_vd_mgrs[instance->qos_context.max_vd_count]; } } -static inline struct ps3_qos_vd_mgr * -ps3_qos_vd_mgr_get_by_id(struct ps3_instance *instance, unsigned short disk_id) +static inline struct ps3_qos_vd_mgr *ps3_qos_vd_mgr_get_by_id(struct ps3_instance *instance, + U16 disk_id) { struct ps3_qos_vd_context *qos_vd_ctx = NULL; - unsigned short flat_disk_id = 0; + U16 flat_disk_id = 0; qos_vd_ctx = &instance->qos_context.vd_ctx; flat_disk_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_id); @@ -168,35 +155,35 @@ static void ps3_qos_update_vd_quota(struct ps3_cmd *cmd) struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) { - qos_vd_mgr = ps3_qos_vd_mgr_get(cmd); + qos_vd_mgr = ps3_qos_vd_mgr_get(cmd); ps3_atomic_inc(&qos_vd_mgr->vd_quota); } } -static inline unsigned char ps3_qos_enable(struct ps3_instance *instance) +Bool ps3_qos_enable(struct ps3_instance *instance) { return instance->qos_context.qos_switch; } -static void ps3_qos_cmd_resend_fail(struct ps3_cmd *cmd, int ret) +static void ps3_qos_cmd_resend_fail(struct ps3_cmd *cmd, S32 ret) { struct ps3_scsi_priv_data *pri_data = NULL; struct ps3_instance *instance = cmd->instance; struct scsi_cmnd *s_cmd = cmd->scmd; - if (ret == -PS3_RECOVERED || ret == -PS3_RETRY) + if (ret == -PS3_RECOVERED || ret == -PS3_RETRY) { s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_RESET); - else + } else { s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + } if (cmd->is_got_r1x == 1) { pri_data = (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; ps3_r1x_write_unlock(&pri_data->lock_mgr, cmd); } - LOG_INFO_IN_IRQ(instance, - "t_id:0x%llx hno:%u tag:%d cmd send err ret:%d\n", - cmd->trace_id, PS3_HOST(instance), cmd->index, ret); + LOG_INFO_IN_IRQ(instance, "t_id:0x%llx hno:%u tag:%d cmd send err ret:%d\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, ret); ps3_scsi_dma_unmap(cmd); s_cmd = cmd->scmd; PS3_DEV_IO_START_ERR_INC(instance, cmd); @@ -208,27 +195,22 @@ static void ps3_qos_cmd_resend_fail(struct ps3_cmd *cmd, int ret) SCMD_IO_DONE(s_cmd); } -struct qos_wait_queue * -ps3_qos_cmd_waitq_get(struct ps3_qos_tg_context *qos_tg_ctx, - struct ps3_cmd *cmd) +struct qos_wait_queue *ps3_qos_cmd_waitq_get(struct ps3_qos_tg_context *qos_tg_ctx, struct ps3_cmd *cmd) { struct qos_wait_queue *wait_q = NULL; - unsigned short disk_id = 0; + U16 disk_id = 0; struct ps3_qos_context *qos_ctx = NULL; if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { wait_q = &qos_tg_ctx->mgr_cmd_wait_q; } else { if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - disk_id = get_offset_of_vdid( - PS3_VDID_OFFSET(cmd->instance), - PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); + disk_id = get_offset_of_vdid(PS3_VDID_OFFSET(cmd->instance), + PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); wait_q = &qos_tg_ctx->vd_cmd_waitqs[disk_id]; } else { qos_ctx = &cmd->instance->qos_context; - wait_q = - &qos_tg_ctx - ->vd_cmd_waitqs[qos_ctx->max_vd_count]; + wait_q = &qos_tg_ctx->vd_cmd_waitqs[qos_ctx->max_vd_count]; } } @@ -237,10 +219,8 @@ ps3_qos_cmd_waitq_get(struct ps3_qos_tg_context *qos_tg_ctx, static void ps3_hba_qos_cmd_update(struct ps3_cmd *cmd) { - struct ps3_qos_tg_context *qos_tg_ctx = - &cmd->instance->qos_context.tg_ctx; + struct ps3_qos_tg_context *qos_tg_ctx = &cmd->instance->qos_context.tg_ctx; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { if (ps3_atomic_dec_return(&qos_tg_ctx->mgr_share_used) >= 0) { ps3_atomic_inc(&qos_tg_ctx->share_free_cnt); @@ -252,11 +232,11 @@ static void ps3_hba_qos_cmd_update(struct ps3_cmd *cmd) ps3_qos_update_pd_quota(cmd); if (cmd->cmd_word.direct != PS3_CMDWORD_DIRECT_OK) { qos_vd_mgr = ps3_qos_vd_mgr_get(cmd); - if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) + if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) { ps3_atomic_inc(&qos_vd_mgr->vd_quota); + } - if (ps3_atomic_dec_return( - &qos_vd_mgr->share_cmd_used) >= 0) { + if (ps3_atomic_dec_return(&qos_vd_mgr->share_cmd_used) >= 0) { ps3_atomic_inc(&qos_tg_ctx->share_free_cnt); } else { ps3_atomic_inc(&qos_vd_mgr->share_cmd_used); @@ -265,15 +245,13 @@ static void ps3_hba_qos_cmd_update(struct ps3_cmd *cmd) } } LOG_DEBUG("qos cmd update. host_no:%u dev_t:%u share:%u\n", - PS3_HOST(cmd->instance), cmd->io_attr.dev_type, - ps3_atomic_read(&qos_tg_ctx->share_free_cnt)); + PS3_HOST(cmd->instance), cmd->io_attr.dev_type, + ps3_atomic_read(&qos_tg_ctx->share_free_cnt)); } -static inline unsigned char -ps3_qos_share_cmdword_dec(struct ps3_qos_tg_context *qos_tg_ctx) +static inline Bool ps3_qos_share_cmdword_dec(struct ps3_qos_tg_context *qos_tg_ctx) { - unsigned char can_get = PS3_FALSE; - + Bool can_get = PS3_FALSE; if (ps3_atomic_dec_return(&qos_tg_ctx->share_free_cnt) >= 0) { can_get = PS3_TRUE; } else { @@ -284,12 +262,11 @@ ps3_qos_share_cmdword_dec(struct ps3_qos_tg_context *qos_tg_ctx) return can_get; } -static unsigned char -ps3_qos_share_cmdword_get(struct ps3_qos_tg_context *qos_tg_ctx, - struct ps3_cmd *cmd, struct qos_wait_queue *wait_q) +static Bool ps3_qos_share_cmdword_get(struct ps3_qos_tg_context *qos_tg_ctx, + struct ps3_cmd *cmd, struct qos_wait_queue *wait_q) { - unsigned char can_get = PS3_FALSE; - unsigned long flag = 0; + Bool can_get = PS3_FALSE; + ULong flag = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; can_get = ps3_qos_share_cmdword_dec(qos_tg_ctx); @@ -300,8 +277,7 @@ ps3_qos_share_cmdword_get(struct ps3_qos_tg_context *qos_tg_ctx, qos_tg_ctx->total_wait_cmd_cnt++; cmd->qos_waitq_flag = PS3_QOS_CMD_IN_FRAME; ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); - LOG_DEBUG( - "insert qos tag waitq.host_no:%u:t_id:0x%llx CFID:%u diskid:%u waitq:%u\n", + LOG_DEBUG("insert qos tag waitq.host_no:%u:t_id:0x%llx CFID:%u diskid:%u waitq:%u\n", PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, cmd->io_attr.disk_id, wait_q->count); PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_TAG_QUEUE); @@ -333,9 +309,9 @@ static bool ps3_qos_mgr_cmdword_get(struct ps3_cmd *cmd) return can_get; } -unsigned char ps3_qos_vd_cmdword_get(struct ps3_cmd *cmd) +Bool ps3_qos_vd_cmdword_get(struct ps3_cmd *cmd) { - unsigned char can_get = PS3_FALSE; + Bool can_get = PS3_FALSE; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; qos_vd_mgr = ps3_qos_vd_mgr_get(cmd); @@ -349,23 +325,24 @@ unsigned char ps3_qos_vd_cmdword_get(struct ps3_cmd *cmd) return can_get; } -unsigned char ps3_qos_exclusive_cmdword_get(struct ps3_cmd *cmd) +Bool ps3_qos_exclusive_cmdword_get(struct ps3_cmd *cmd) { - unsigned char can_get = PS3_FALSE; + Bool can_get = PS3_FALSE; - if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) + if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { can_get = ps3_qos_mgr_cmdword_get(cmd); - else + } else { can_get = ps3_qos_vd_cmdword_get(cmd); + } return can_get; } -unsigned char ps3_qos_tg_decision(struct ps3_cmd *cmd) +Bool ps3_qos_tg_decision(struct ps3_cmd *cmd) { - unsigned char can_get = PS3_FALSE; + Bool can_get = PS3_FALSE; struct ps3_instance *instance = cmd->instance; - unsigned long flag = 0; + ULong flag = 0; struct qos_wait_queue *cmd_wait_q = NULL; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; @@ -373,31 +350,30 @@ unsigned char ps3_qos_tg_decision(struct ps3_cmd *cmd) cmd_wait_q = ps3_qos_cmd_waitq_get(qos_tg_ctx, cmd); if (cmd_wait_q->count == 0) { can_get = ps3_qos_exclusive_cmdword_get(cmd); - if (can_get) + if (can_get){ goto out; + } } if (likely(qos_tg_ctx->total_wait_cmd_cnt == 0)) { - can_get = - ps3_qos_share_cmdword_get(qos_tg_ctx, cmd, cmd_wait_q); + can_get = ps3_qos_share_cmdword_get(qos_tg_ctx, cmd, cmd_wait_q); } else { + INJECT_START(PS3_ERR_IJ_QOS_WAIT_TAG_WAITQ_CLEAR, cmd->instance) ps3_spin_lock_irqsave(&qos_tg_ctx->lock, &flag); - if (qos_tg_ctx->total_wait_cmd_cnt > 0) { + if (qos_tg_ctx->total_wait_cmd_cnt > 0){ list_add_tail(&cmd->qos_list, &cmd_wait_q->wait_list); cmd_wait_q->count++; qos_tg_ctx->total_wait_cmd_cnt++; cmd->qos_waitq_flag = PS3_QOS_CMD_IN_FRAME; ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); can_get = PS3_FALSE; - LOG_DEBUG( - "insert qos tag waitq.host_no:%u:t_id:0x%llx CFID:%u diskid:%u waitq:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - cmd->io_attr.disk_id, cmd_wait_q->count); + LOG_DEBUG("insert qos tag waitq.host_no:%u:t_id:0x%llx CFID:%u diskid:%u waitq:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, + cmd->io_attr.disk_id, cmd_wait_q->count); PS3_QOS_STAT_START(instance, cmd, PS3_QOS_TAG_QUEUE); } else { ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); - can_get = ps3_qos_share_cmdword_get(qos_tg_ctx, cmd, - cmd_wait_q); + can_get = ps3_qos_share_cmdword_get(qos_tg_ctx, cmd, cmd_wait_q); } } out: @@ -407,7 +383,7 @@ unsigned char ps3_qos_tg_decision(struct ps3_cmd *cmd) static inline bool ps3_qos_pd_quota_add(struct qos_wait_queue *waitq) { - unsigned char can_get = PS3_TRUE; + Bool can_get = PS3_TRUE; if (ps3_atomic_inc_return(waitq->used_rsc) > *waitq->free_rsc) { ps3_atomic_dec(waitq->used_rsc); @@ -418,10 +394,8 @@ static inline bool ps3_qos_pd_quota_add(struct qos_wait_queue *waitq) } static void ps3_qos_pd_in_q(struct ps3_cmd *cmd, struct qos_wait_queue *waitq, - unsigned short pd_idx) -{ - unsigned long flag = 0; - + U16 pd_idx) { + ULong flag = 0; ps3_spin_lock_irqsave(waitq->rsc_lock, &flag); list_add_tail(&cmd->qos_list, &waitq->wait_list); waitq->count++; @@ -432,59 +406,57 @@ static void ps3_qos_pd_in_q(struct ps3_cmd *cmd, struct qos_wait_queue *waitq, PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_PD_QUEUE); } -static struct qos_wait_queue * -ps3_qos_pd_waitq_get(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_cmd *cmd) +static struct qos_wait_queue* ps3_qos_pd_waitq_get(struct ps3_qos_pd_mgr *qos_pd_mgr, + struct ps3_cmd *cmd) { - unsigned short que_id = 0; + U16 que_id = 0; struct ps3_instance *instance = NULL; instance = cmd->instance; if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - que_id = get_offset_of_vdid( - PS3_VDID_OFFSET(instance), - PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); + que_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), + PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); } else { - if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) + if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) { que_id = 0; - else + } else { que_id = instance->qos_context.max_vd_count; + } } return &qos_pd_mgr->waitqs[que_id]; } -static unsigned char ps3_qos_pd_quota_get(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_cmd *cmd, - unsigned short pd_idx, - struct qos_wait_queue *waitq) +static Bool ps3_qos_pd_quota_get(struct ps3_qos_pd_mgr *qos_pd_mgr, + struct ps3_cmd *cmd, U16 pd_idx, struct qos_wait_queue *waitq) { - unsigned char can_get = PS3_FALSE; + Bool can_get = PS3_FALSE; can_get = ps3_qos_pd_quota_add(waitq); if (!can_get) { ps3_qos_pd_in_q(cmd, waitq, pd_idx); - LOG_DEBUG( - "insert qos pd quota waitq.host_no:%u:t_id:0x%llx CFID:%u waitq[%u,%u] did[%u,%u]\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - waitq->id, waitq->count, qos_pd_mgr->disk_id, pd_idx); + LOG_DEBUG("insert qos pd quota waitq.host_no:%u:t_id:0x%llx CFID:%u waitq[%u,%u] did[%u,%u]\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + waitq->id, waitq->count, qos_pd_mgr->disk_id, pd_idx); } else { cmd->target_pd[pd_idx].get_quota = PS3_TRUE; } - return can_get; + return can_get; } static bool ps3_qos_pd_quota_req(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_cmd *cmd, unsigned short pd_idx) + struct ps3_cmd *cmd, U16 pd_idx) { bool can_get = PS3_FALSE; - unsigned long flag = 0; + ULong flag = 0; struct qos_wait_queue *waitq = NULL; waitq = ps3_qos_pd_waitq_get(qos_pd_mgr, cmd); if (likely((*waitq->total_waited_cnt) == 0)) { can_get = ps3_qos_pd_quota_get(qos_pd_mgr, cmd, pd_idx, waitq); } else { + INJECT_START(PS3_ERR_IJ_QOS_WAIT_PD_WAITQ_CLEAR, cmd->instance) ps3_spin_lock_irqsave(waitq->rsc_lock, &flag); if ((*waitq->total_waited_cnt) > 0) { list_add_tail(&cmd->qos_list, &waitq->wait_list); @@ -494,17 +466,13 @@ static bool ps3_qos_pd_quota_req(struct ps3_qos_pd_mgr *qos_pd_mgr, cmd->first_over_quota_pd_idx = pd_idx; ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); can_get = PS3_FALSE; - LOG_DEBUG( - "insert qos pd quota waitq.host_no:%u:t_id:0x%llx CFID:%u waitq[%u,%u] did[%u,%u]\n", - PS3_HOST(cmd->instance), cmd->trace_id, - cmd->index, waitq->id, waitq->count, - qos_pd_mgr->disk_id, pd_idx); - PS3_QOS_STAT_START(cmd->instance, cmd, - PS3_QOS_PD_QUEUE); + LOG_DEBUG("insert qos pd quota waitq.host_no:%u:t_id:0x%llx CFID:%u waitq[%u,%u] did[%u,%u]\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + waitq->id, waitq->count, qos_pd_mgr->disk_id, pd_idx); + PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_PD_QUEUE); } else { ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); - can_get = ps3_qos_pd_quota_get(qos_pd_mgr, cmd, pd_idx, - waitq); + can_get = ps3_qos_pd_quota_get(qos_pd_mgr, cmd, pd_idx, waitq); } } @@ -512,16 +480,17 @@ static bool ps3_qos_pd_quota_req(struct ps3_qos_pd_mgr *qos_pd_mgr, } static bool ps3_qos_pd_quota_check(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_cmd *cmd) + struct ps3_cmd *cmd) { bool can_get = PS3_FALSE; - unsigned long flag = 0; + ULong flag = 0; struct qos_wait_queue *waitq = NULL; waitq = ps3_qos_pd_waitq_get(qos_pd_mgr, cmd); if (likely((*waitq->total_waited_cnt) == 0)) { can_get = ps3_qos_pd_quota_add(waitq); } else { + INJECT_START(PS3_ERR_IJ_QOS_WAIT_PD_WAITQ_CLEAR_2, cmd->instance) ps3_spin_lock_irqsave(waitq->rsc_lock, &flag); if ((*waitq->total_waited_cnt) > 0) { ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); @@ -537,22 +506,20 @@ static bool ps3_qos_pd_quota_check(struct ps3_qos_pd_mgr *qos_pd_mgr, static inline bool ps3_qos_vd_quota_dec(struct ps3_qos_vd_mgr *qos_vd_mgr) { - unsigned char can_get = PS3_FALSE; - + Bool can_get = PS3_FALSE; if (ps3_atomic_dec_return(&qos_vd_mgr->vd_quota) >= 0) { - can_get = PS3_TRUE; + can_get = PS3_TRUE; } else { ps3_atomic_inc(&qos_vd_mgr->vd_quota); - can_get = PS3_FALSE; + can_get = PS3_FALSE; } - return can_get; + return can_get; } -static void ps3_qos_insert_vd_quota_waitq(struct ps3_qos_vd_mgr *qos_vd_mgr, - struct ps3_cmd *cmd) +static void ps3_qos_insert_vd_quota_waitq(struct ps3_qos_vd_mgr *qos_vd_mgr, struct ps3_cmd *cmd) { - unsigned long flag = 0; + ULong flag = 0; struct qos_wait_queue *wait_q = NULL; wait_q = &qos_vd_mgr->vd_quota_wait_q; @@ -562,36 +529,35 @@ static void ps3_qos_insert_vd_quota_waitq(struct ps3_qos_vd_mgr *qos_vd_mgr, cmd->qos_waitq_flag = PS3_QOS_CMD_IN_VD; ps3_spin_unlock_irqrestore(wait_q->rsc_lock, flag); PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_VD_QUEUE); - LOG_DEBUG( - "insert qos vd quota waitq.host_no:%u:tid:0x%llx CFID:%u diskid:%u waitq:%u\n", + LOG_DEBUG("insert qos vd quota waitq.host_no:%u:tid:0x%llx CFID:%u diskid:%u waitq:%u\n", PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, cmd->io_attr.disk_id, wait_q->count); } -static bool ps3_qos_vd_quota_get_waitq(struct ps3_qos_vd_mgr *qos_vd_mgr, - struct ps3_cmd *cmd) +static bool ps3_qos_vd_quota_get_waitq(struct ps3_qos_vd_mgr *qos_vd_mgr, struct ps3_cmd *cmd) { - unsigned char can_get = PS3_FALSE; - + Bool can_get = PS3_FALSE; can_get = ps3_qos_vd_quota_dec(qos_vd_mgr); - if (!can_get) + if (!can_get) { ps3_qos_insert_vd_quota_waitq(qos_vd_mgr, cmd); + } - return can_get; + return can_get; } static bool ps3_qos_vd_quota_check(struct ps3_cmd *cmd) { bool can_get = PS3_FALSE; - unsigned long flag = 0; + ULong flag = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct qos_wait_queue *wait_q = NULL; qos_vd_mgr = ps3_qos_vd_mgr_get(cmd); wait_q = &qos_vd_mgr->vd_quota_wait_q; - if (likely(wait_q->count == 0)) { + if (likely(wait_q->count == 0)){ can_get = ps3_qos_vd_quota_get_waitq(qos_vd_mgr, cmd); } else { + INJECT_START(PS3_ERR_IJ_QOS_WAIT_VD_WAITQ_CLEAR, cmd->instance) ps3_spin_lock_irqsave(wait_q->rsc_lock, &flag); if (wait_q->count > 0) { list_add_tail(&cmd->qos_list, &wait_q->wait_list); @@ -599,14 +565,11 @@ static bool ps3_qos_vd_quota_check(struct ps3_cmd *cmd) cmd->qos_waitq_flag = PS3_QOS_CMD_IN_VD; ps3_spin_unlock_irqrestore(wait_q->rsc_lock, flag); can_get = PS3_FALSE; - LOG_DEBUG( - "insert qos vd quota waitq.host_no:%u:tid:0x%llx CFID:%u\n" - "\tdiskid:%u waitq:%u\n", - PS3_HOST(cmd->instance), cmd->trace_id, - cmd->index, cmd->io_attr.disk_id, - wait_q->count); - PS3_QOS_STAT_START(cmd->instance, cmd, - PS3_QOS_VD_QUEUE); + LOG_DEBUG("insert qos vd quota waitq.host_no:%u:tid:0x%llx CFID:%u " + "diskid:%u waitq:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + cmd->io_attr.disk_id, wait_q->count); + PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_VD_QUEUE); } else { ps3_spin_unlock_irqrestore(wait_q->rsc_lock, flag); can_get = ps3_qos_vd_quota_get_waitq(qos_vd_mgr, cmd); @@ -616,31 +579,28 @@ static bool ps3_qos_vd_quota_check(struct ps3_cmd *cmd) return can_get; } -static inline unsigned char -ps3_qos_pd_notify_judge(struct ps3_qos_pd_mgr *qos_pd_mgr) +static inline Bool ps3_qos_pd_notify_judge(struct ps3_qos_pd_mgr *qos_pd_mgr) { - unsigned char can_notify = PS3_FALSE; + Bool can_notify = PS3_FALSE; can_notify = qos_pd_mgr->total_wait_cmd_cnt && - (ps3_atomic_read(&qos_pd_mgr->pd_used_quota) < - qos_pd_mgr->pd_quota); + (ps3_atomic_read(&qos_pd_mgr->pd_used_quota) < qos_pd_mgr->pd_quota); if (PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr) || can_notify) { goto _out; } else { can_notify = qos_pd_mgr->total_waited_direct_cmd && - (ps3_atomic_read(&qos_pd_mgr->direct_used_quota) < - qos_pd_mgr->direct_quota); + (ps3_atomic_read(&qos_pd_mgr->direct_used_quota) < qos_pd_mgr->direct_quota); } _out: + INJECT_START(PS3_ERR_IJ_QOS_NOT_AWAKE_PD, &can_notify) return can_notify; } -static unsigned char -ps3_qos_single_pd_notify(struct ps3_qos_pd_context *qos_pd_ctx, +static Bool ps3_qos_single_pd_notify(struct ps3_qos_pd_context *qos_pd_ctx, struct ps3_qos_pd_mgr *qos_pd_mgr) { struct workqueue_struct *workq = NULL; - unsigned char notified = PS3_FALSE; + Bool notified = PS3_FALSE; if (ps3_atomic_read(&qos_pd_mgr->valid) == 1) { if (ps3_qos_pd_notify_judge(qos_pd_mgr)) { @@ -655,7 +615,7 @@ ps3_qos_single_pd_notify(struct ps3_qos_pd_context *qos_pd_ctx, static void ps3_qos_pd_notify(struct ps3_instance *instance) { - unsigned short id = 0; + U16 id = 0; struct ps3_qos_pd_context *qos_pd_ctx = NULL; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; @@ -666,16 +626,15 @@ static void ps3_qos_pd_notify(struct ps3_instance *instance) } } -static unsigned char -ps3_qos_single_vd_notify(struct ps3_qos_vd_context *qos_vd_ctx, +static Bool ps3_qos_single_vd_notify(struct ps3_qos_vd_context *qos_vd_ctx, struct ps3_qos_vd_mgr *qos_vd_mgr) { struct workqueue_struct *workq = NULL; - unsigned char notify = PS3_FALSE; + Bool notify = PS3_FALSE; if (qos_vd_mgr->valid) { if (qos_vd_mgr->vd_quota_wait_q.count > 0 && - ps3_atomic_read(&qos_vd_mgr->vd_quota) > 0) { + ps3_atomic_read(&qos_vd_mgr->vd_quota) > 0) { workq = qos_vd_ctx->work_queues[qos_vd_mgr->workq_id]; queue_work(workq, &qos_vd_mgr->resend_work); notify = PS3_TRUE; @@ -685,37 +644,37 @@ ps3_qos_single_vd_notify(struct ps3_qos_vd_context *qos_vd_ctx, return notify; } -static unsigned char ps3_qos_vd_notify(struct ps3_instance *instance) +static U8 ps3_qos_vd_notify(struct ps3_instance *instance) { - unsigned char notify = PS3_FALSE; - unsigned short id = 0; + U8 notify = PS3_FALSE; + U16 id = 0; struct ps3_qos_vd_context *qos_vd_ctx = NULL; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; qos_vd_ctx = &instance->qos_context.vd_ctx; for (id = 1; id <= instance->qos_context.max_vd_count; id++) { qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[id]; - if (ps3_qos_single_vd_notify(qos_vd_ctx, qos_vd_mgr)) + if (ps3_qos_single_vd_notify(qos_vd_ctx, qos_vd_mgr)) { notify = PS3_TRUE; + } } return notify; } -static unsigned char ps3_qos_tag_rsc_available(struct ps3_instance *instance) +static Bool ps3_qos_tag_rsc_available(struct ps3_instance *instance) { - unsigned char rsc_avail = PS3_FALSE; - unsigned short i = 0; + Bool rsc_avail = PS3_FALSE; + U16 i = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; - if (ps3_atomic_read(&qos_tg_ctx->share_free_cnt) > 0) { rsc_avail = PS3_TRUE; goto _lout; } if (qos_tg_ctx->mgr_cmd_wait_q.count > 0 && - ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt) > 0) { + ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt) > 0) { rsc_avail = PS3_TRUE; goto _lout; } @@ -723,23 +682,24 @@ static unsigned char ps3_qos_tag_rsc_available(struct ps3_instance *instance) for (i = 1; i <= instance->qos_context.max_vd_count; i++) { qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[i]; if (ps3_atomic_read(&qos_vd_mgr->exclusive_cmd_cnt) > 0 && - qos_tg_ctx->vd_cmd_waitqs[i].count > 0) { + qos_tg_ctx->vd_cmd_waitqs[i].count > 0) { rsc_avail = PS3_TRUE; break; } } _lout: + INJECT_START(PS3_ERR_IJ_QOS_NOT_AWAKE_TAG, &rsc_avail); return rsc_avail; } -static unsigned char ps3_qos_tg_notify(struct ps3_instance *instance) +static Bool ps3_qos_tg_notify(struct ps3_instance *instance) { - unsigned char notified = PS3_FALSE; + Bool notified = PS3_FALSE; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; if (qos_tg_ctx->total_wait_cmd_cnt > 0 && - ps3_qos_tag_rsc_available(instance)) { + ps3_qos_tag_rsc_available(instance)) { queue_work(qos_tg_ctx->work_queue, &qos_tg_ctx->resend_work); notified = PS3_TRUE; } @@ -747,66 +707,55 @@ static unsigned char ps3_qos_tg_notify(struct ps3_instance *instance) return notified; } -unsigned char ps3_qos_all_pd_rc_get(struct ps3_cmd *cmd) +Bool ps3_qos_all_pd_rc_get(struct ps3_cmd *cmd) { cmd->target_pd[cmd->first_over_quota_pd_idx].get_quota = PS3_TRUE; PS3_QOS_STAT_END(cmd->instance, cmd, PS3_QOS_PD_QUEUE); - LOG_DEBUG( - "resend cmd judge:host_no:%u t_id:0x%llx cmd:%u cmd_t:%u dev_t:%u ret[%u,%u]\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - cmd->cmd_word.type, cmd->io_attr.dev_type, - cmd->first_over_quota_pd_idx, 1); + LOG_DEBUG("resend cmd judge:host_no:%u t_id:0x%llx cmd:%u cmd_t:%u dev_t:%u ret[%u,%u]\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, cmd->cmd_word.type, cmd->io_attr.dev_type, + cmd->first_over_quota_pd_idx, 1); return PS3_TRUE; } -static void ps3_vd_quota_waitq_clean(struct ps3_qos_vd_mgr *qos_vd_mgr, - struct ps3_scsi_priv_data *priv_data, - int resp_status) +static void ps3_vd_quota_waitq_clean( struct ps3_qos_vd_mgr *qos_vd_mgr, + struct ps3_scsi_priv_data *priv_data, S32 resp_status) { - unsigned long flag = 0; + ULong flag = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; ps3_spin_lock_irqsave(qos_vd_mgr->vd_quota_wait_q.rsc_lock, &flag); if (qos_vd_mgr->vd_quota_wait_q.count > 0) { - list_for_each_entry_safe( - cmd, cmd_next, &qos_vd_mgr->vd_quota_wait_q.wait_list, - qos_list) { + list_for_each_entry_safe(cmd, cmd_next, &qos_vd_mgr->vd_quota_wait_q.wait_list, qos_list) { if (priv_data == NULL || - priv_data == scsi_device_private_data(cmd->scmd)) { + priv_data == scsi_device_private_data(cmd->scmd)) { list_del(&cmd->qos_list); qos_vd_mgr->vd_quota_wait_q.count--; - LOG_DEBUG( - "qos clean vd quota waitq. hno:%u t_id:0x%llx cmd:%d vd_id:%u\n", - PS3_HOST(qos_vd_mgr->instance), - cmd->trace_id, cmd->index, - qos_vd_mgr->id); + LOG_DEBUG("qos clean vd quota waitq. hno:%u t_id:0x%llx cmd:%d vd_id:%u\n", + PS3_HOST(qos_vd_mgr->instance), cmd->trace_id, cmd->index, qos_vd_mgr->id); ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi( - cmd->scmd, cmd, resp_status, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); } } } ps3_spin_unlock_irqrestore(qos_vd_mgr->vd_quota_wait_q.rsc_lock, flag); LOG_FILE_INFO("clean qos device vd quota waitq host_no:%u diskid:%u\n", - PS3_HOST(qos_vd_mgr->instance), qos_vd_mgr->id); + PS3_HOST(qos_vd_mgr->instance), qos_vd_mgr->id); } static void ps3_qos_vd_quota_waitq_resend(struct ps3_qos_vd_mgr *qos_vd_mgr) { struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; - unsigned long flag = 0; - int ret = PS3_SUCCESS; - unsigned char waitq_cleared = PS3_FALSE; + ULong flag = 0; + S32 ret = PS3_SUCCESS; + Bool waitq_cleared = PS3_FALSE; struct ps3_instance *instance = qos_vd_mgr->instance; ps3_spin_lock_irqsave(qos_vd_mgr->vd_quota_wait_q.rsc_lock, &flag); - if (qos_vd_mgr->vd_quota_wait_q.count > 0 && - ps3_atomic_read(&qos_vd_mgr->vd_quota) > 0) { - list_for_each_entry_safe( - cmd, cmd_next, &qos_vd_mgr->vd_quota_wait_q.wait_list, - qos_list) { + if (qos_vd_mgr->vd_quota_wait_q.count > 0 + && ps3_atomic_read(&qos_vd_mgr->vd_quota) > 0) { + list_for_each_entry_safe(cmd, cmd_next, &qos_vd_mgr->vd_quota_wait_q.wait_list, qos_list) { if (ps3_atomic_dec_return(&qos_vd_mgr->vd_quota) < 0) { ps3_atomic_inc(&qos_vd_mgr->vd_quota); break; @@ -815,29 +764,26 @@ static void ps3_qos_vd_quota_waitq_resend(struct ps3_qos_vd_mgr *qos_vd_mgr) qos_vd_mgr->vd_quota_wait_q.count--; PS3_QOS_STAT_END(instance, cmd, PS3_QOS_VD_QUEUE); if (ps3_qos_tg_decision(cmd)) { - ret = ps3_scsi_cmd_send(instance, cmd, - PS3_FALSE); + ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); if (unlikely(ret != PS3_SUCCESS)) { ps3_qos_cmd_update(instance, cmd); ps3_qos_cmd_resend_fail(cmd, ret); } else { cmd->qos_waitq_flag = 0; - LOG_DEBUG( - "qos vd quota waitq resend:host_no:%u vid:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), - qos_vd_mgr->id, cmd->trace_id, - cmd->index, cmd->cmd_word.type); + LOG_DEBUG("qos vd quota waitq resend:host_no:%u vid:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), qos_vd_mgr->id, cmd->trace_id, cmd->index, cmd->cmd_word.type); } } } - if (qos_vd_mgr->vd_quota_wait_q.count == 0) + if (qos_vd_mgr->vd_quota_wait_q.count == 0) { waitq_cleared = PS3_TRUE; + } } ps3_spin_unlock_irqrestore(qos_vd_mgr->vd_quota_wait_q.rsc_lock, flag); if (waitq_cleared) { LOG_DEBUG("qos vd quota waitq cleared.host_no:%u vd:%u\n", - PS3_HOST(instance), qos_vd_mgr->id); + PS3_HOST(instance), qos_vd_mgr->id); } qos_vd_mgr->last_sched_jiffies = jiffies; @@ -847,37 +793,33 @@ static void ps3_qos_vd_quota_waitq_resend(struct ps3_qos_vd_mgr *qos_vd_mgr) static void ps3_qos_vd_resend_work(struct work_struct *work) { struct ps3_qos_vd_mgr *qos_vd_mgr = - ps3_container_of(work, struct ps3_qos_vd_mgr, resend_work); + ps3_container_of(work, struct ps3_qos_vd_mgr, resend_work); ps3_qos_vd_quota_waitq_resend(qos_vd_mgr); } static void ps3_qos_waitq_clean(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct qos_wait_queue *waitq, int resp_status) + struct qos_wait_queue *waitq, S32 resp_status) { - unsigned long flag = 0; + ULong flag = 0; struct ps3_cmd *cmd = NULL; - ps3_spin_lock_irqsave(waitq->rsc_lock, &flag); while (waitq->count > 0) { - cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, - qos_list); - LOG_DEBUG( - "qos clean pd waitq. hno:%u t_id:0x%llx CFID:%d pid:%u que_id:%u\n", - PS3_HOST(qos_pd_mgr->instance), cmd->trace_id, - cmd->index, qos_pd_mgr->disk_id, waitq->id); + cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); + LOG_DEBUG("qos clean pd waitq. hno:%u t_id:0x%llx CFID:%d pid:%u que_id:%u\n", + PS3_HOST(qos_pd_mgr->instance), cmd->trace_id, cmd->index, + qos_pd_mgr->disk_id, waitq->id); list_del(&cmd->qos_list); waitq->count--; (*waitq->total_waited_cnt)--; - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, - PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); } ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); } void ps3_pd_quota_waitq_clear_all(struct ps3_qos_pd_mgr *qos_pd_mgr, - int resp_status) + S32 resp_status) { - unsigned short i = 0; + U16 i = 0; struct qos_wait_queue *waitq = NULL; for (i = 0; i < qos_pd_mgr->waitq_cnt; i++) { @@ -886,15 +828,13 @@ void ps3_pd_quota_waitq_clear_all(struct ps3_qos_pd_mgr *qos_pd_mgr, } LOG_DEBUG("clear all qos pd quota waitq host_no:%u did:%u vid:%u\n", - PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, - qos_pd_mgr->vd_id); + PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, qos_pd_mgr->vd_id); } void ps3_pd_quota_waitq_clean(struct ps3_qos_pd_mgr *qos_pd_mgr, - unsigned short que_id, int resp_status) + U16 que_id, S32 resp_status) { struct qos_wait_queue *waitq = NULL; - if (que_id == 0) { ps3_pd_quota_waitq_clear_all(qos_pd_mgr, resp_status); } else { @@ -903,96 +843,92 @@ void ps3_pd_quota_waitq_clean(struct ps3_qos_pd_mgr *qos_pd_mgr, } LOG_DEBUG("clean qos pd quota waitq host_no:%u did:%u vid:%u\n", - PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, - qos_pd_mgr->vd_id); + PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, qos_pd_mgr->vd_id); } -static unsigned char ps3_hba_qos_pd_resend_check(struct ps3_cmd *cmd) +static Bool ps3_hba_qos_pd_resend_check(struct ps3_cmd *cmd) { - unsigned char can_get = PS3_FALSE; + Bool can_get = PS3_FALSE; if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) { - if (!ps3_qos_vd_quota_check(cmd)) + if (!ps3_qos_vd_quota_check(cmd)) { goto _out; + } } can_get = ps3_qos_tg_decision(cmd); _out: return can_get; } -static unsigned char ps3_qos_pd_resend_check(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static Bool ps3_qos_pd_resend_check(struct ps3_instance *instance, struct ps3_cmd *cmd) { - unsigned char can_get = PS3_FALSE; + Bool can_get = PS3_FALSE; if (cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) { - cmd->target_pd[cmd->first_over_quota_pd_idx].get_quota = - PS3_TRUE; + cmd->target_pd[cmd->first_over_quota_pd_idx].get_quota = PS3_TRUE; PS3_QOS_STAT_END(cmd->instance, cmd, PS3_QOS_PD_QUEUE); can_get = PS3_TRUE; } else { - if (!ps3_qos_all_pd_rc_get(cmd)) + if (!ps3_qos_all_pd_rc_get(cmd)) { goto _out; + } can_get = instance->qos_context.opts.qos_pd_resend_check(cmd); } _out: return can_get; } -static unsigned char ps3_qos_vd_seq_check(struct ps3_cmd *cmd) +static Bool ps3_qos_vd_seq_check(struct ps3_cmd *cmd) { struct PS3VDEntry *vd_entry = NULL; - unsigned short vd_id = 0; - unsigned char seq_changed = PS3_FALSE; + U16 vd_id = 0; + Bool seq_changed = PS3_FALSE; + INJECT_START(PS3_ERR_IJ_QOS_FORCE_VD_SEQ_CHANGE, cmd); if (cmd->cmd_word.direct == PS3_CMDWORD_DIRECT_ADVICE) { vd_id = PS3_VDID(&cmd->io_attr.vd_entry->diskPos); - vd_entry = - ps3_dev_mgr_lookup_vd_info_by_id(cmd->instance, vd_id); - if (!vd_entry || - vd_entry->virtDiskSeq != - cmd->req_frame->hwReq.reqHead.virtDiskSeq) { + vd_entry = ps3_dev_mgr_lookup_vd_info_by_id(cmd->instance, vd_id); + if (!vd_entry || vd_entry->virtDiskSeq != + cmd->req_frame->hwReq.reqHead.virtDiskSeq) { seq_changed = PS3_TRUE; - LOG_DEBUG("qos pd waitq vd seq check:host_no:%u\n" - "\tt_id:0x%llx CFID:%u seq[%u %u]\n", - PS3_HOST(cmd->instance), cmd->trace_id, - cmd->index, - cmd->req_frame->hwReq.reqHead.virtDiskSeq, - (!vd_entry) ? 0 : vd_entry->virtDiskSeq); + LOG_DEBUG("qos pd waitq vd seq check:host_no:%u" + "t_id:0x%llx CFID:%u seq[%u %u]\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + cmd->req_frame->hwReq.reqHead.virtDiskSeq, + (!vd_entry) ? 0 : vd_entry->virtDiskSeq); ps3_qos_update_pd_quota(cmd); ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, - SCSI_STATUS_TASK_ABORTED, - PS3_FALSE); + SCSI_STATUS_TASK_ABORTED, PS3_FALSE); } } return seq_changed; } -static unsigned int ps3_qos_pd_resend_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct qos_wait_queue *waitq, - int count) +static U32 ps3_qos_pd_resend_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, + struct qos_wait_queue *waitq, S32 count) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_instance *instance = qos_pd_mgr->instance; - unsigned int can_send = 0; - unsigned int que_cnt = 0; - int avail_rsc = 0; - int used_rsc = ps3_atomic_read(waitq->used_rsc); + U32 can_send = 0; + U32 que_cnt = 0; + S32 avail_rsc = 0; + S32 used_rsc = ps3_atomic_read(waitq->used_rsc); - if (used_rsc < *waitq->free_rsc) + if (used_rsc < *waitq->free_rsc) { avail_rsc = *waitq->free_rsc - used_rsc; + } can_send = PS3_MIN(avail_rsc, count); que_cnt = waitq->count; - while (can_send > 0 && waitq->count > 0) { - cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, - qos_list); + while(can_send > 0 && waitq->count > 0) { + cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); list_del(&cmd->qos_list); waitq->count--; (*waitq->total_waited_cnt)--; - if (ps3_qos_vd_seq_check(cmd)) + if (ps3_qos_vd_seq_check(cmd)) { continue; + } can_send--; ps3_atomic_inc(waitq->used_rsc); if (ps3_qos_pd_resend_check(instance, cmd)) { @@ -1002,13 +938,10 @@ static unsigned int ps3_qos_pd_resend_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, ps3_qos_cmd_resend_fail(cmd, ret); } else { cmd->qos_waitq_flag = 0; - LOG_DEBUG( - "qos pd quota waitq resend:host_no:%u qid:%u pid:%u\n" - "\tt_id:0x%llx CFID:%u resend[%u %u]\n", - PS3_HOST(instance), waitq->id, - qos_pd_mgr->disk_id, cmd->trace_id, - cmd->index, waitq->has_resend, - waitq->can_resend); + LOG_DEBUG("qos pd quota waitq resend:host_no:%u qid:%u pid:%u" + "t_id:0x%llx CFID:%u resend[%u %u]\n", + PS3_HOST(instance), waitq->id, qos_pd_mgr->disk_id, + cmd->trace_id, cmd->index, waitq->has_resend, waitq->can_resend); } } } @@ -1017,25 +950,24 @@ static unsigned int ps3_qos_pd_resend_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, } static void ps3_qos_pd_waitq_resend(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct qos_wait_queue *waitq) + struct qos_wait_queue *waitq ) { - unsigned long flag = 0; - unsigned char waitq_cleared = PS3_FALSE; - + ULong flag = 0; + Bool waitq_cleared = PS3_FALSE; if (waitq->count > 0) { ps3_spin_lock_irqsave(waitq->rsc_lock, &flag); - if (ps3_atomic_read(waitq->used_rsc) < *waitq->free_rsc) + if (ps3_atomic_read(waitq->used_rsc) < *waitq->free_rsc) { ps3_qos_pd_resend_cmd(qos_pd_mgr, waitq, waitq->count); + } - if (*waitq->total_waited_cnt == 0) + if (*waitq->total_waited_cnt == 0) { waitq_cleared = PS3_TRUE; + } ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); if (waitq_cleared) { - LOG_DEBUG( - "qos pd quota waitq is cleard. host_no:%u did:%u qid:%u\n", - PS3_HOST(qos_pd_mgr->instance), - qos_pd_mgr->disk_id, waitq->id); + LOG_DEBUG("qos pd quota waitq is cleard. host_no:%u did:%u qid:%u\n", + PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, waitq->id); } } } @@ -1044,7 +976,7 @@ static void ps3_qos_pd_jbod_resend(struct ps3_qos_pd_mgr *qos_pd_mgr) { struct ps3_instance *instance = qos_pd_mgr->instance; struct qos_wait_queue *waitq = NULL; - unsigned short que_id = 0; + U16 que_id = 0; if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { waitq = &qos_pd_mgr->waitqs[0]; @@ -1058,36 +990,36 @@ static void ps3_qos_pd_jbod_resend(struct ps3_qos_pd_mgr *qos_pd_mgr) void ps3_qos_pd_waitq_ratio_update(struct ps3_qos_pd_mgr *qos_pd_mgr) { - unsigned short min_waitq_cnt = 0; - unsigned short i = 0; + U16 min_waitq_cnt = 0; + U16 i = 0; struct qos_wait_queue *waitq = NULL; - unsigned long min_cmd_jiffies = 0; + ULong min_cmd_jiffies = 0; struct ps3_cmd *cmd = NULL; - unsigned short poll_que_id = 1; + U16 poll_que_id = 1; - if (qos_pd_mgr->poll_que_id != qos_pd_mgr->poll_start_que_id) + if (qos_pd_mgr->poll_que_id != qos_pd_mgr->poll_start_que_id) { return; + } waitq = &qos_pd_mgr->waitqs[qos_pd_mgr->poll_que_id]; - if (waitq->has_resend > 0) + if (waitq->has_resend > 0) { return; + } for (i = 1; i < qos_pd_mgr->waitq_cnt - 1; i++) { waitq = &qos_pd_mgr->waitqs[i]; if (waitq->count > 0) { - cmd = list_first_entry(&waitq->wait_list, - struct ps3_cmd, qos_list); + cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); if (min_waitq_cnt == 0) { min_waitq_cnt = waitq->count; min_cmd_jiffies = cmd->scmd->jiffies_at_alloc; } else { - if (min_waitq_cnt > waitq->count) + if (min_waitq_cnt > waitq->count) { min_waitq_cnt = waitq->count; + } - if (min_cmd_jiffies > - cmd->scmd->jiffies_at_alloc) { - min_cmd_jiffies = - cmd->scmd->jiffies_at_alloc; + if (min_cmd_jiffies > cmd->scmd->jiffies_at_alloc) { + min_cmd_jiffies = cmd->scmd->jiffies_at_alloc; poll_que_id = i; } } @@ -1097,10 +1029,8 @@ void ps3_qos_pd_waitq_ratio_update(struct ps3_qos_pd_mgr *qos_pd_mgr) for (i = 1; i < qos_pd_mgr->waitq_cnt - 1; i++) { waitq = &qos_pd_mgr->waitqs[i]; if (waitq->count > 0) { - waitq->can_resend = - waitq->count / min_waitq_cnt > 0 ? - waitq->count / min_waitq_cnt : - 1; + waitq->can_resend = waitq->count/min_waitq_cnt > 0 ? + waitq->count/min_waitq_cnt : 1; waitq->has_resend = 0; } } @@ -1109,78 +1039,69 @@ void ps3_qos_pd_waitq_ratio_update(struct ps3_qos_pd_mgr *qos_pd_mgr) qos_pd_mgr->poll_start_que_id = poll_que_id; LOG_DEBUG("qos pd ratio update:host_no:%u pid:%u first:%u\n", - PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, - poll_que_id); + PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, poll_que_id); } static void ps3_qos_pd_vd_member_resend(struct ps3_qos_pd_mgr *qos_pd_mgr) { - unsigned long flag = 0; + ULong flag = 0; struct ps3_instance *instance = qos_pd_mgr->instance; struct qos_wait_queue *waitq = NULL; - unsigned long timeout_jiffies = 0; - unsigned char waitq_cleared = PS3_FALSE; - unsigned char vd_expired = PS3_FALSE; - unsigned int pd_wait_count = 0; + ULong timeout_jiffies = 0; + Bool waitq_cleared = PS3_FALSE; + Bool vd_expired = PS3_FALSE; + U32 pd_wait_count = 0; ps3_spin_lock_irqsave(&qos_pd_mgr->rc_lock, &flag); - pd_wait_count = - qos_pd_mgr->waitqs[instance->qos_context.max_vd_count].count; + pd_wait_count = qos_pd_mgr->waitqs[instance->qos_context.max_vd_count].count; while ((ps3_atomic_read(&qos_pd_mgr->pd_used_quota) < - qos_pd_mgr->pd_quota) && - qos_pd_mgr->total_wait_cmd_cnt > pd_wait_count) { + qos_pd_mgr->pd_quota) && qos_pd_mgr->total_wait_cmd_cnt > pd_wait_count) { ps3_qos_pd_waitq_ratio_update(qos_pd_mgr); waitq = &qos_pd_mgr->waitqs[qos_pd_mgr->poll_que_id]; - if (waitq->count == 0) + if (waitq->count == 0) { goto _next_waitq; + } if (waitq->has_resend > 0) { if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_SAS_HDD || - qos_pd_mgr->dev_type == PS3_DEV_TYPE_SATA_HDD) { - timeout_jiffies = - waitq->last_sched_jiffies + - msecs_to_jiffies( - PS3_QOS_VD_HDD_DELAY_THD_MS); + qos_pd_mgr->dev_type == PS3_DEV_TYPE_SATA_HDD) { + timeout_jiffies = waitq->last_sched_jiffies + + msecs_to_jiffies(PS3_QOS_VD_HDD_DELAY_THD_MS); } else { - timeout_jiffies = - waitq->last_sched_jiffies + - msecs_to_jiffies( - PS3_QOS_VD_SDD_DELAY_THD_MS); + timeout_jiffies = waitq->last_sched_jiffies + + msecs_to_jiffies(PS3_QOS_VD_SDD_DELAY_THD_MS); } vd_expired = time_after(jiffies, timeout_jiffies); + INJECT_START(PS3_ERR_IJ_QOS_PD_RESEND_NOT_EXPIRED, &vd_expired) if (vd_expired) { - LOG_DEBUG( - "go to next vd waitq for delay:host_no:%u qid:%u pid:%u", - PS3_HOST(instance), waitq->id, - qos_pd_mgr->disk_id); + LOG_DEBUG("go to next vd waitq for delay:host_no:%u qid:%u pid:%u", + PS3_HOST(instance), waitq->id, qos_pd_mgr->disk_id); goto _next_waitq; } } waitq->last_sched_jiffies = jiffies; - waitq->has_resend += ps3_qos_pd_resend_cmd( - qos_pd_mgr, waitq, - waitq->can_resend - waitq->has_resend); - if (waitq->has_resend >= waitq->can_resend) + waitq->has_resend += ps3_qos_pd_resend_cmd(qos_pd_mgr, waitq, waitq->can_resend - waitq->has_resend); + if (waitq->has_resend >= waitq->can_resend) { goto _next_waitq; + } continue; _next_waitq: waitq->has_resend = 0; - if (++qos_pd_mgr->poll_que_id == - instance->qos_context.max_vd_count) { + if (++qos_pd_mgr->poll_que_id == instance->qos_context.max_vd_count) { qos_pd_mgr->poll_que_id = 1; } } - if (qos_pd_mgr->total_wait_cmd_cnt == 0) + if (qos_pd_mgr->total_wait_cmd_cnt == 0) { waitq_cleared = PS3_TRUE; + } ps3_spin_unlock_irqrestore(&qos_pd_mgr->rc_lock, flag); if (waitq_cleared) { - LOG_DEBUG( - "qos pd quota waitq is cleard. host_no:%u diskid:%u\n", - PS3_HOST(instance), qos_pd_mgr->disk_id); + LOG_DEBUG("qos pd quota waitq is cleard. host_no:%u diskid:%u\n", + PS3_HOST(instance), qos_pd_mgr->disk_id); } } @@ -1190,39 +1111,41 @@ static void ps3_qos_pd_resend_work(struct work_struct *work) ps3_container_of(work, struct ps3_qos_pd_mgr, resend_work); ps3_qos_pd_jbod_resend(qos_pd_mgr); + INJECT_START(PS3_ERR_IJ_QOS_WAIT_VD_SEND, qos_pd_mgr) ps3_qos_pd_vd_member_resend(qos_pd_mgr); qos_pd_mgr->last_sched_jiffies = jiffies; + + return; } static void ps3_poll_vd_cmd_waitq(struct ps3_qos_tg_context *qos_tg_ctx) { struct qos_wait_queue *waitq = NULL; - unsigned int free_cnt = 0; - unsigned char vd_id = 0; - int ret = PS3_SUCCESS; + U32 free_cnt = 0; + U8 vd_id = 0; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - unsigned int sent_count = 0; + U32 sent_count = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_instance *instance = qos_tg_ctx->instance; - unsigned int mgrq_cnt = qos_tg_ctx->mgr_cmd_wait_q.count; + U32 mgrq_cnt = qos_tg_ctx->mgr_cmd_wait_q.count; + INJECT_START(PS3_ERR_IJ_QOS_SET_SHARE_COUNT, instance) free_cnt = ps3_atomic_read(&qos_tg_ctx->share_free_cnt); vd_id = qos_tg_ctx->poll_vd_id; - while (free_cnt > sent_count && - qos_tg_ctx->total_wait_cmd_cnt > mgrq_cnt) { + while (free_cnt > sent_count && qos_tg_ctx->total_wait_cmd_cnt > mgrq_cnt) { waitq = &qos_tg_ctx->vd_cmd_waitqs[vd_id]; if (waitq->count > 0) { - qos_vd_mgr = - &instance->qos_context.vd_ctx.qos_vd_mgrs[vd_id]; - cmd = list_first_entry(&waitq->wait_list, - struct ps3_cmd, qos_list); + qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[vd_id]; + cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); list_del(&cmd->qos_list); cmd->qos_waitq_flag = 0; waitq->count--; qos_tg_ctx->total_wait_cmd_cnt--; PS3_QOS_STAT_END(instance, cmd, PS3_QOS_TAG_QUEUE); - if (ps3_qos_vd_seq_check(cmd)) + if (ps3_qos_vd_seq_check(cmd)) { continue; + } ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); if (unlikely(ret != PS3_SUCCESS)) { ps3_qos_update_vd_quota(cmd); @@ -1231,19 +1154,18 @@ static void ps3_poll_vd_cmd_waitq(struct ps3_qos_tg_context *qos_tg_ctx) } else { ps3_atomic_inc(&qos_vd_mgr->share_cmd_used); ++sent_count; - LOG_DEBUG( - "qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), cmd->trace_id, - cmd->index, cmd->cmd_word.type); + LOG_DEBUG("qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, cmd->cmd_word.type); } } - if (++vd_id > instance->qos_context.max_vd_count) + if (++vd_id > instance->qos_context.max_vd_count) { vd_id = 1; + } } ps3_atomic_sub(sent_count, &qos_tg_ctx->share_free_cnt); LOG_DEBUG("resend vd cmd waitq. host_no:%u poll_vd_id:%u sent:%u\n", - PS3_HOST(instance), vd_id, sent_count); + PS3_HOST(instance), vd_id, sent_count); qos_tg_ctx->poll_vd_id = vd_id; } @@ -1254,14 +1176,13 @@ static void ps3_mgr_cmd_waitq_resend(struct ps3_qos_tg_context *qos_tg_ctx) struct ps3_cmd *cmd_next = NULL; struct qos_wait_queue *wait_q = NULL; struct ps3_instance *instance = qos_tg_ctx->instance; - int ret = PS3_SUCCESS; - unsigned int free_cnt = ps3_atomic_read(&qos_tg_ctx->share_free_cnt); - unsigned int sent_count = 0; + S32 ret = PS3_SUCCESS; + U32 free_cnt = ps3_atomic_read(&qos_tg_ctx->share_free_cnt); + U32 sent_count = 0; wait_q = &qos_tg_ctx->mgr_cmd_wait_q; if (wait_q->count > 0 && free_cnt > 0) { - list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, - qos_list) { + list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, qos_list) { list_del(&cmd->qos_list); cmd->qos_waitq_flag = 0; wait_q->count--; @@ -1271,13 +1192,12 @@ static void ps3_mgr_cmd_waitq_resend(struct ps3_qos_tg_context *qos_tg_ctx) if (unlikely(ret != PS3_SUCCESS)) { ps3_qos_cmd_resend_fail(cmd, ret); } else { - LOG_DEBUG( - "qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), cmd->trace_id, - cmd->index, cmd->cmd_word.type); + LOG_DEBUG("qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, cmd->cmd_word.type); ps3_atomic_inc(&qos_tg_ctx->mgr_share_used); - if (++sent_count == free_cnt) + if(++sent_count == free_cnt) { break; + } } } @@ -1293,21 +1213,19 @@ static void ps3_qos_tg_share_resend(struct ps3_qos_tg_context *qos_tg_ctx) static void ps3_qos_tg_exclusive_resend(struct ps3_qos_tg_context *qos_tg_ctx) { - struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - struct qos_wait_queue *waitq = NULL; - struct ps3_cmd *cmd = NULL; - struct ps3_cmd *cmd_next = NULL; - int ret = PS3_SUCCESS; - unsigned char id = 0; - struct ps3_instance *instance = qos_tg_ctx->instance; - - waitq = &qos_tg_ctx->mgr_cmd_wait_q; - if (waitq->count > 0 && - ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt) > 0) { - list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, - qos_list) { - if (ps3_atomic_dec_return(&qos_tg_ctx->mgr_free_cnt) < - 0) { + struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; + struct qos_wait_queue *waitq = NULL; + struct ps3_cmd *cmd = NULL; + struct ps3_cmd *cmd_next = NULL; + S32 ret = PS3_SUCCESS; + U8 id = 0; + struct ps3_instance *instance = qos_tg_ctx->instance; + + waitq = &qos_tg_ctx->mgr_cmd_wait_q; + if (waitq->count > 0 && + ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt) > 0) { + list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, qos_list) { + if (ps3_atomic_dec_return(&qos_tg_ctx->mgr_free_cnt) < 0) { ps3_atomic_inc(&qos_tg_ctx->mgr_free_cnt); break; } @@ -1321,10 +1239,8 @@ static void ps3_qos_tg_exclusive_resend(struct ps3_qos_tg_context *qos_tg_ctx) ps3_qos_cmd_resend_fail(cmd, ret); ps3_atomic_inc(&qos_tg_ctx->mgr_free_cnt); } else { - LOG_DEBUG( - "qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), cmd->trace_id, - cmd->index, cmd->cmd_word.type); + LOG_DEBUG("qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, cmd->cmd_word.type); } } } @@ -1333,41 +1249,30 @@ static void ps3_qos_tg_exclusive_resend(struct ps3_qos_tg_context *qos_tg_ctx) waitq = &qos_tg_ctx->vd_cmd_waitqs[id]; qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[id]; if (waitq->count > 0 && - ps3_atomic_read(&qos_vd_mgr->exclusive_cmd_cnt) > 0) { - list_for_each_entry_safe(cmd, cmd_next, - &waitq->wait_list, qos_list) { - if (ps3_atomic_dec_return( - &qos_vd_mgr->exclusive_cmd_cnt) < - 0) { - ps3_atomic_inc( - &qos_vd_mgr->exclusive_cmd_cnt); + ps3_atomic_read(&qos_vd_mgr->exclusive_cmd_cnt) > 0) { + list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, qos_list) { + if (ps3_atomic_dec_return(&qos_vd_mgr->exclusive_cmd_cnt) < 0) { + ps3_atomic_inc(&qos_vd_mgr->exclusive_cmd_cnt); break; } list_del(&cmd->qos_list); cmd->qos_waitq_flag = 0; waitq->count--; qos_tg_ctx->total_wait_cmd_cnt--; - PS3_QOS_STAT_END(instance, cmd, - PS3_QOS_TAG_QUEUE); + PS3_QOS_STAT_END(instance, cmd, PS3_QOS_TAG_QUEUE); if (ps3_qos_vd_seq_check(cmd)) { - ps3_atomic_inc( - &qos_vd_mgr->exclusive_cmd_cnt); + ps3_atomic_inc(&qos_vd_mgr->exclusive_cmd_cnt); continue; } - ret = ps3_scsi_cmd_send(instance, cmd, - PS3_FALSE); + ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); if (unlikely(ret != PS3_SUCCESS)) { ps3_qos_update_vd_quota(cmd); ps3_qos_update_pd_quota(cmd); ps3_qos_cmd_resend_fail(cmd, ret); - ps3_atomic_inc( - &qos_vd_mgr->exclusive_cmd_cnt); + ps3_atomic_inc(&qos_vd_mgr->exclusive_cmd_cnt); } else { - LOG_DEBUG( - "qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), - cmd->trace_id, cmd->index, - cmd->cmd_word.type); + LOG_DEBUG("qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, cmd->cmd_word.type); } } } @@ -1376,77 +1281,76 @@ static void ps3_qos_tg_exclusive_resend(struct ps3_qos_tg_context *qos_tg_ctx) static void ps3_qos_tg_waitq_resend(struct ps3_qos_tg_context *qos_tg_ctx) { - unsigned long flag = 0; - unsigned char waitq_cleard = PS3_FALSE; + ULong flag = 0; + Bool waitq_cleard = PS3_FALSE; struct ps3_instance *instance = qos_tg_ctx->instance; ps3_spin_lock_irqsave(&qos_tg_ctx->lock, &flag); ps3_qos_tg_share_resend(qos_tg_ctx); ps3_qos_tg_exclusive_resend(qos_tg_ctx); - if (qos_tg_ctx->total_wait_cmd_cnt == 0) + if (qos_tg_ctx->total_wait_cmd_cnt == 0) { waitq_cleard = PS3_TRUE; + } ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); if (waitq_cleard) { LOG_DEBUG("hno:%u resend all tag waited cmds\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } - if (!ps3_qos_vd_notify(instance)) + if (!ps3_qos_vd_notify(instance)) { ps3_qos_pd_notify(instance); + } qos_tg_ctx->last_sched_jiffies = jiffies; } static void ps3_qos_tg_resend_work(struct work_struct *work) { struct ps3_qos_tg_context *qos_tg_ctx = - ps3_container_of(work, struct ps3_qos_tg_context, resend_work); + ps3_container_of(work, struct ps3_qos_tg_context, resend_work); ps3_qos_tg_waitq_resend(qos_tg_ctx); } -unsigned int g_ps3_qos_cmdq_depth = PS3_QOS_CMDQ_DEPTH; -unsigned int g_ps3_qos_mgrq_depth = PS3_QOS_MGRQ_DEPTH; -unsigned int g_ps3_qos_hdd_pd_quota = PS3_QOS_DEFAULT_PD_QUOTA; -unsigned int g_ps3_qos_ssd_pd_quota = PS3_QOS_DEFAULT_PD_QUOTA; -unsigned int g_ps3_qos_sas_pd_quota = PS3_QOS_SAS_PD_QUOTA; -unsigned int g_ps3_qos_nvme_pd_quota = PS3_QOS_NVME_DIRECT_QUOTA; -unsigned int g_ps3_qos_nvme_member_quota = PS3_QOS_NVME_MEMBER_QUOTA; -unsigned int g_ps3_qos_hba_nvme_normal_quota = PS3_QOS_HBA_NVME_NORMAL_QUOTA; -unsigned int g_ps3_qos_raid_nvme_normal_quota = PS3_QOS_RAID_NVME_NORMAL_QUOTA; -unsigned int g_ps3_qos_vd_quota = PS3_QOS_FUNC1_JBOD_VD_QUOTA; -unsigned int g_ps3_qos_max_cmds = PS3_QOS_HBA_MAX_CMD; -unsigned int g_ps3_qos_jbod_exclusive = PS3_QOS_JBOD_EXCLUSIVE_CMD_COUNT; -unsigned int g_ps3_qos_vd_exclusive = PS3_QOS_VD_EXCLUSIVE_CMD_COUNT; -unsigned int g_ps3_qos_mgr_exclusive = QOS_MGR_EXCLUSIVE_CMD_COUNT; +U32 g_ps3_qos_cmdq_depth = PS3_QOS_CMDQ_DEPTH; +U32 g_ps3_qos_mgrq_depth = PS3_QOS_MGRQ_DEPTH; +U32 g_ps3_qos_hdd_pd_quota = PS3_QOS_DEFAULT_PD_QUOTA; +U32 g_ps3_qos_ssd_pd_quota = PS3_QOS_DEFAULT_PD_QUOTA; +U32 g_ps3_qos_sas_pd_quota = PS3_QOS_SAS_PD_QUOTA; +U32 g_ps3_qos_nvme_pd_quota = PS3_QOS_NVME_DIRECT_QUOTA; +U32 g_ps3_qos_nvme_member_quota = PS3_QOS_NVME_MEMBER_QUOTA; +U32 g_ps3_qos_hba_nvme_normal_quota = PS3_QOS_HBA_NVME_NORMAL_QUOTA; +U32 g_ps3_qos_raid_nvme_normal_quota = PS3_QOS_RAID_NVME_NORMAL_QUOTA; +U32 g_ps3_qos_vd_quota = PS3_QOS_FUNC1_JBOD_VD_QUOTA; +U32 g_ps3_qos_max_cmds = PS3_QOS_HBA_MAX_CMD; +U32 g_ps3_qos_jbod_exclusive = PS3_QOS_JBOD_EXCLUSIVE_CMD_COUNT; +U32 g_ps3_qos_vd_exclusive = PS3_QOS_VD_EXCLUSIVE_CMD_COUNT; +U32 g_ps3_qos_mgr_exclusive = QOS_MGR_EXCLUSIVE_CMD_COUNT; #define PS3_QOS_MAX_WORKQ_NAME_LENGTH 32 -static int ps3_qos_pd_context_init(struct ps3_instance *instance) +static S32 ps3_qos_pd_context_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned short i = 0; - unsigned short j = 0; - unsigned short k = 0; + S32 ret = PS3_SUCCESS; + U16 i = 0; + U16 j = 0; + U16 k = 0; struct ps3_qos_pd_context *qos_pd_ctx = NULL; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = { 0 }; - unsigned short max_pd_count = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; + U16 max_pd_count = 0; struct qos_wait_queue *waitq = NULL; - unsigned int cpu_num = 0; + U32 cpu_num = 0; qos_pd_ctx = &instance->qos_context.pd_ctx; if (ps3_is_last_func(instance)) { cpu_num = num_online_cpus(); if (instance->irq_context.is_balance_current_perf_mode) { - if (cpu_num > - instance->irq_context.high_iops_msix_vectors + - PS3_QOS_FUNC1_PD_WORKQ_COUNT) { + INJECT_START(PS3_ERR_IJ_SET_HIGH_IOPS_CHANNEL_IN_QOS, instance); + if (cpu_num > instance->irq_context.high_iops_msix_vectors + + PS3_QOS_FUNC1_PD_WORKQ_COUNT) { qos_pd_ctx->workq_count = - cpu_num - - instance->irq_context - .high_iops_msix_vectors; + cpu_num - instance->irq_context.high_iops_msix_vectors; } else { - qos_pd_ctx->workq_count = - PS3_QOS_FUNC1_PD_WORKQ_COUNT; + qos_pd_ctx->workq_count = PS3_QOS_FUNC1_PD_WORKQ_COUNT; } } else { qos_pd_ctx->workq_count = PS3_QOS_FUNC1_PD_WORKQ_COUNT; @@ -1456,16 +1360,16 @@ static int ps3_qos_pd_context_init(struct ps3_instance *instance) } max_pd_count = instance->qos_context.max_pd_count; - qos_pd_ctx->qos_pd_mgrs = (struct ps3_qos_pd_mgr *)ps3_vzalloc( - instance, (max_pd_count + 1) * sizeof(struct ps3_qos_pd_mgr)); - if (qos_pd_ctx->qos_pd_mgrs == NULL) { + qos_pd_ctx->qos_pd_mgrs = (struct ps3_qos_pd_mgr *)ps3_vzalloc(instance, + (max_pd_count + 1) * sizeof(struct ps3_qos_pd_mgr)); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_2, instance) + if (qos_pd_ctx->qos_pd_mgrs == NULL ) { LOG_ERROR("hno:%u:Failed to kcalloc memory for qos_pd_mgrs\n", PS3_HOST(instance)); - ret = -PS3_FAILED; + ret = -PS3_FAILED; goto _out; } - memset(qos_pd_ctx->qos_pd_mgrs, 0, - sizeof(struct ps3_qos_pd_mgr) * (max_pd_count + 1)); + memset(qos_pd_ctx->qos_pd_mgrs, 0, sizeof(struct ps3_qos_pd_mgr) * (max_pd_count + 1)); for (i = 1; i <= max_pd_count; i++) { qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[i]; INIT_WORK(&qos_pd_mgr->resend_work, ps3_qos_pd_resend_work); @@ -1483,15 +1387,14 @@ static int ps3_qos_pd_context_init(struct ps3_instance *instance) qos_pd_mgr->instance = instance; qos_pd_mgr->total_wait_cmd_cnt = 0; qos_pd_mgr->total_waited_direct_cmd = 0; - qos_pd_mgr->waitq_cnt = instance->qos_context.max_vd_count + 1; - qos_pd_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc( - instance, - qos_pd_mgr->waitq_cnt * sizeof(struct qos_wait_queue)); + qos_pd_mgr->waitq_cnt = instance->qos_context.max_vd_count + 1; + qos_pd_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc(instance, + qos_pd_mgr->waitq_cnt * sizeof(struct qos_wait_queue)); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_3, qos_pd_ctx) if (qos_pd_mgr->waitqs == NULL) { - LOG_ERROR( - "hno:%u:Failed to kcalloc memory for pd waitqs\n", - PS3_HOST(instance)); - ret = -PS3_FAILED; + LOG_ERROR("hno:%u:Failed to kcalloc memory for pd waitqs\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; goto _release_pd_waitq; } @@ -1504,42 +1407,37 @@ static int ps3_qos_pd_context_init(struct ps3_instance *instance) INIT_LIST_HEAD(&waitq->wait_list); if (j == 0) { waitq->free_rsc = &qos_pd_mgr->direct_quota; - waitq->used_rsc = - &qos_pd_mgr->direct_used_quota; + waitq->used_rsc = &qos_pd_mgr->direct_used_quota; waitq->rsc_lock = &qos_pd_mgr->direct_rsc_lock; - waitq->total_waited_cnt = - &qos_pd_mgr->total_waited_direct_cmd; + waitq->total_waited_cnt = &qos_pd_mgr->total_waited_direct_cmd; } else { waitq->free_rsc = &qos_pd_mgr->pd_quota; waitq->used_rsc = &qos_pd_mgr->pd_used_quota; waitq->rsc_lock = &qos_pd_mgr->rc_lock; - waitq->total_waited_cnt = - &qos_pd_mgr->total_wait_cmd_cnt; + waitq->total_waited_cnt = &qos_pd_mgr->total_wait_cmd_cnt; } } } - qos_pd_ctx->work_queues = (struct workqueue_struct **)ps3_vzalloc( - instance, - (qos_pd_ctx->workq_count) * sizeof(struct workqueue_struct *)); + qos_pd_ctx->work_queues = (struct workqueue_struct **)ps3_vzalloc(instance, + (qos_pd_ctx->workq_count) * sizeof(struct workqueue_struct *)); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_4, instance) if (qos_pd_ctx->work_queues == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for work_queues\n", PS3_HOST(instance)); - ret = -PS3_FAILED; + ret = -PS3_FAILED; goto _release_pd_mgr; } - memset(qos_pd_ctx->work_queues, 0, - (qos_pd_ctx->workq_count) * sizeof(struct workqueue_struct *)); + memset(qos_pd_ctx->work_queues, 0, (qos_pd_ctx->workq_count) * sizeof(struct workqueue_struct *)); for (j = 0; j < qos_pd_ctx->workq_count; j++) { - snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, - "pd_wq_f%u_%u", ps3_get_pci_function(instance->pdev), - j); - qos_pd_ctx->work_queues[j] = - create_singlethread_workqueue(workq_name); + snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "pd_wq_f%u_%u", + ps3_get_pci_function(instance->pdev), j); + qos_pd_ctx->work_queues[j] = create_singlethread_workqueue(workq_name); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_1, qos_pd_ctx) if (qos_pd_ctx->work_queues[j] == NULL) { LOG_ERROR("qos pd workq:%u create failed\n", j); ret = -PS3_FAILED; - goto _destroy_created_workqueue; + goto _destroy_created_workqueue; } } @@ -1553,7 +1451,7 @@ static int ps3_qos_pd_context_init(struct ps3_instance *instance) ps3_vfree(instance, qos_pd_ctx->work_queues); qos_pd_ctx->work_queues = NULL; _release_pd_waitq: - for (k = 1; k < i; k++) { + for (k = 1; k < i; k++) { qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[k]; if (qos_pd_mgr->waitqs) { ps3_vfree(instance, qos_pd_mgr->waitqs); @@ -1569,7 +1467,7 @@ static int ps3_qos_pd_context_init(struct ps3_instance *instance) static void ps3_qos_pd_context_exit(struct ps3_instance *instance) { - unsigned short i = 0; + U16 i = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_qos_pd_context *qos_pd_ctx = NULL; struct workqueue_struct *wq = NULL; @@ -1598,16 +1496,16 @@ static void ps3_qos_pd_context_exit(struct ps3_instance *instance) } } -static int ps3_qos_vd_context_init(struct ps3_instance *instance) +static S32 ps3_qos_vd_context_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned short i = 0; - unsigned short j = 0; + S32 ret = PS3_SUCCESS; + U16 i = 0; + U16 j = 0; struct ps3_qos_vd_context *qos_vd_ctx = NULL; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = { 0 }; - unsigned short max_vd_count = 0; - unsigned short jbod_vd_quota = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; + U16 max_vd_count = 0; + U16 jbod_vd_quota = 0; qos_vd_ctx = &instance->qos_context.vd_ctx; if (ps3_is_last_func(instance)) { @@ -1618,20 +1516,19 @@ static int ps3_qos_vd_context_init(struct ps3_instance *instance) qos_vd_ctx->jbod_exclusive_cnt = 0; } - jbod_vd_quota = instance->qos_context.tg_ctx.share + - qos_vd_ctx->jbod_exclusive_cnt; + jbod_vd_quota = instance->qos_context.tg_ctx.share + qos_vd_ctx->jbod_exclusive_cnt; max_vd_count = instance->qos_context.max_vd_count; - qos_vd_ctx->qos_vd_mgrs = (struct ps3_qos_vd_mgr *)ps3_vzalloc( - instance, (max_vd_count + 1) * sizeof(struct ps3_qos_vd_mgr)); - if (qos_vd_ctx->qos_vd_mgrs == NULL) { + qos_vd_ctx->qos_vd_mgrs = (struct ps3_qos_vd_mgr *)ps3_vzalloc(instance, + (max_vd_count + 1) * sizeof(struct ps3_qos_vd_mgr)); + INJECT_START(PS3_ERR_IJ_QOS_VD_INIT_FAIL_1, instance) + if (qos_vd_ctx->qos_vd_mgrs == NULL ) { LOG_ERROR("hno:%u:Failed to kcalloc memory for qos_vd_mgrs\n", PS3_HOST(instance)); - ret = -PS3_FAILED; + ret = -PS3_FAILED; goto _out; } - memset(qos_vd_ctx->qos_vd_mgrs, 0, - sizeof(struct ps3_qos_vd_mgr) * (max_vd_count + 1)); + memset(qos_vd_ctx->qos_vd_mgrs, 0, sizeof(struct ps3_qos_vd_mgr) * (max_vd_count + 1)); for (i = 1; i <= max_vd_count; i++) { qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[i]; qos_vd_mgr->instance = instance; @@ -1644,38 +1541,34 @@ static int ps3_qos_vd_context_init(struct ps3_instance *instance) qos_vd_mgr->id = i; if (i == max_vd_count) { ps3_atomic_set(&qos_vd_mgr->vd_quota, jbod_vd_quota); - ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, - qos_vd_ctx->jbod_exclusive_cnt); + ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, qos_vd_ctx->jbod_exclusive_cnt); qos_vd_mgr->valid = PS3_TRUE; } else { - ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, - qos_vd_ctx->vd_exclusive_cnt); + ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, qos_vd_ctx->vd_exclusive_cnt); } ps3_atomic_set(&qos_vd_mgr->share_cmd_used, 0); } qos_vd_ctx->workq_count = 1; - qos_vd_ctx->work_queues = (struct workqueue_struct **)ps3_vzalloc( - instance, - (qos_vd_ctx->workq_count) * sizeof(struct workqueue_struct *)); + qos_vd_ctx->work_queues = (struct workqueue_struct **)ps3_vzalloc(instance, + (qos_vd_ctx->workq_count) * sizeof(struct workqueue_struct *)); + INJECT_START(PS3_ERR_IJ_QOS_VD_INIT_FAIL_2, instance) if (qos_vd_ctx->work_queues == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for work_queues\n", PS3_HOST(instance)); - ret = -PS3_FAILED; + ret = -PS3_FAILED; goto _release_vd_mgr; } - memset(qos_vd_ctx->work_queues, 0, - (qos_vd_ctx->workq_count) * sizeof(struct workqueue_struct *)); + memset(qos_vd_ctx->work_queues, 0, (qos_vd_ctx->workq_count) * sizeof(struct workqueue_struct *)); for (i = 0; i < qos_vd_ctx->workq_count; i++) { - snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, - "qos_vd_wq_f%u_%u", + snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "qos_vd_wq_f%u_%u", ps3_get_pci_function(instance->pdev), i); - qos_vd_ctx->work_queues[i] = - create_singlethread_workqueue(workq_name); + qos_vd_ctx->work_queues[i] = create_singlethread_workqueue(workq_name); + INJECT_START(PS3_ERR_IJ_QOS_VD_INIT_FAIL_3, instance) if (qos_vd_ctx->work_queues[i] == NULL) { LOG_ERROR("qos vd workq:%u create failed\n", i); ret = -PS3_FAILED; - goto _destroy_created_workqueue; + goto _destroy_created_workqueue; } } @@ -1698,7 +1591,7 @@ static int ps3_qos_vd_context_init(struct ps3_instance *instance) static void ps3_qos_vd_context_exit(struct ps3_instance *instance) { - unsigned short i = 0; + U16 i = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_vd_context *qos_vd_ctx = NULL; struct workqueue_struct *wq = NULL; @@ -1724,22 +1617,23 @@ static void ps3_qos_vd_context_exit(struct ps3_instance *instance) } } -static int ps3_qos_tg_context_init(struct ps3_instance *instance) +static S32 ps3_qos_tg_context_init(struct ps3_instance *instance) { struct ps3_qos_tg_context *qos_tg_ctx = NULL; - int ret = PS3_SUCCESS; - unsigned long long tfifo_depth = 0; - unsigned short i = 0; + S32 ret = PS3_SUCCESS; + U64 tfifo_depth = 0; + U16 i = 0; struct qos_wait_queue *wait_q = NULL; - char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = { 0 }; - unsigned int tag_exclusive = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; + U32 tag_exclusive = 0; ps3_tfifo_depth_get(instance, &tfifo_depth); + INJECT_START(PS3_ERR_IJ_QOS_FORCE_TFIFO_ZERO_DEPTH, &tfifo_depth) if (tfifo_depth == 0) { ret = -PS3_FAILED; LOG_ERROR("hno:%u:tfifo_depth is invalid func:%u\n", - PS3_HOST(instance), - ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), + ps3_get_pci_function(instance->pdev)); goto out; } qos_tg_ctx = &instance->qos_context.tg_ctx; @@ -1748,22 +1642,15 @@ static int ps3_qos_tg_context_init(struct ps3_instance *instance) qos_tg_ctx->high_pri_exclusive_cnt = QOS_HIGH_PRI_EXCLUSIVE_CMD_COUNT; qos_tg_ctx->mgr_exclusive_cnt = g_ps3_qos_mgr_exclusive; if (!ps3_ioc_multi_func_support(instance)) { - tag_exclusive = - qos_tg_ctx->mgr_exclusive_cnt + - qos_tg_ctx->high_pri_exclusive_cnt + - g_ps3_qos_jbod_exclusive + - instance->ctrl_info.maxVdCount * g_ps3_qos_vd_exclusive; + tag_exclusive = qos_tg_ctx->mgr_exclusive_cnt + qos_tg_ctx->high_pri_exclusive_cnt + + g_ps3_qos_jbod_exclusive + instance->ctrl_info.maxVdCount * g_ps3_qos_vd_exclusive; } else { - qos_tg_ctx->high_pri_exclusive_cnt = - qos_tg_ctx->high_pri_exclusive_cnt >> 1; - qos_tg_ctx->mgr_exclusive_cnt = - qos_tg_ctx->mgr_exclusive_cnt >> 1; - tag_exclusive = qos_tg_ctx->high_pri_exclusive_cnt + - qos_tg_ctx->mgr_exclusive_cnt; + qos_tg_ctx->high_pri_exclusive_cnt = qos_tg_ctx->high_pri_exclusive_cnt >> 1; + qos_tg_ctx->mgr_exclusive_cnt = qos_tg_ctx->mgr_exclusive_cnt >> 1; + tag_exclusive = qos_tg_ctx->high_pri_exclusive_cnt + qos_tg_ctx->mgr_exclusive_cnt; if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1) { tag_exclusive += (g_ps3_qos_jbod_exclusive + - instance->ctrl_info.maxVdCount * - g_ps3_qos_vd_exclusive); + instance->ctrl_info.maxVdCount * g_ps3_qos_vd_exclusive); } } @@ -1772,8 +1659,7 @@ static int ps3_qos_tg_context_init(struct ps3_instance *instance) else qos_tg_ctx->share = tag_exclusive; - ps3_atomic_set(&qos_tg_ctx->mgr_free_cnt, - qos_tg_ctx->mgr_exclusive_cnt); + ps3_atomic_set(&qos_tg_ctx->mgr_free_cnt, qos_tg_ctx->mgr_exclusive_cnt); ps3_atomic_set(&qos_tg_ctx->share_free_cnt, qos_tg_ctx->share); ps3_atomic_set(&qos_tg_ctx->mgr_share_used, 0); ps3_spin_lock_init(&qos_tg_ctx->lock); @@ -1781,36 +1667,33 @@ static int ps3_qos_tg_context_init(struct ps3_instance *instance) wait_q = &qos_tg_ctx->mgr_cmd_wait_q; INIT_LIST_HEAD(&wait_q->wait_list); - qos_tg_ctx->vd_cmd_waitqs = (struct qos_wait_queue *)ps3_vzalloc( - instance, (instance->qos_context.max_vd_count + 1) * - sizeof(struct qos_wait_queue)); + qos_tg_ctx->vd_cmd_waitqs = (struct qos_wait_queue *)ps3_vzalloc(instance, + (instance->qos_context.max_vd_count + 1) * sizeof(struct qos_wait_queue)); + INJECT_START(PS3_ERR_IJ_QOS_TAG_INIT_FAIL_1, qos_tg_ctx) if (qos_tg_ctx->vd_cmd_waitqs == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for qos_context\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto out; } - memset(qos_tg_ctx->vd_cmd_waitqs, 0, - (instance->qos_context.max_vd_count + 1) * - sizeof(struct qos_wait_queue)); + memset(qos_tg_ctx->vd_cmd_waitqs, 0, (instance->qos_context.max_vd_count + 1) * sizeof(struct qos_wait_queue)); for (i = 1; i < instance->qos_context.max_vd_count + 1; i++) { - wait_q = &qos_tg_ctx->vd_cmd_waitqs[i]; + wait_q = &qos_tg_ctx->vd_cmd_waitqs[i]; INIT_LIST_HEAD(&wait_q->wait_list); } INIT_WORK(&qos_tg_ctx->resend_work, ps3_qos_tg_resend_work); - snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "qos_tag_wq_f%u", - ps3_get_pci_function(instance->pdev)); + snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "qos_tag_wq_f%u", ps3_get_pci_function(instance->pdev)); qos_tg_ctx->work_queue = create_singlethread_workqueue(workq_name); + INJECT_START(PS3_ERR_IJ_QOS_TAG_INIT_FAIL_2, qos_tg_ctx) if (qos_tg_ctx->work_queue == NULL) { LOG_ERROR("qos tag workq:%u create failed\n", i); ret = -PS3_FAILED; - goto release_vd_cmd_waitqs; + goto release_vd_cmd_waitqs; } LOG_INFO("hno:%u func:%u: qos tg context init success tfifo:%llu\n", - PS3_HOST(instance), ps3_get_pci_function(instance->pdev), - tfifo_depth); + PS3_HOST(instance), ps3_get_pci_function(instance->pdev), tfifo_depth); goto out; release_vd_cmd_waitqs: ps3_vfree(instance, qos_tg_ctx->vd_cmd_waitqs); @@ -1837,21 +1720,24 @@ static void ps3_qos_tg_context_exit(struct ps3_instance *instance) } } -int ps3_hba_qos_init(struct ps3_instance *instance) +S32 ps3_hba_qos_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; ret = ps3_qos_tg_context_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto _out; + } ret = ps3_qos_vd_context_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto _tg_ctx_exit; + } ret = ps3_qos_pd_context_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto _vd_ctx_exit; + } goto _out; _vd_ctx_exit: @@ -1871,24 +1757,23 @@ void ps3_hba_qos_exit(struct ps3_instance *instance) LOG_INFO("hba qos exit. host_no:%u\n", PS3_HOST(instance)); } -static unsigned char ps3_qos_vd_member_insert(struct ps3_cmd *cmd) +static Bool ps3_qos_vd_member_insert(struct ps3_cmd *cmd) { - unsigned char i = 0; - unsigned short disk_id = 0; + U8 i = 0; + U16 disk_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct qos_wait_queue *waitq = NULL; - unsigned char in_queue = PS3_FALSE; + Bool in_queue = PS3_FALSE; for (i = 0; i < cmd->target_pd_count; i++) { disk_id = cmd->target_pd[i].flat_disk_id; qos_pd_mgr = ps3_qos_pd_mgr_get(cmd->instance, disk_id); ps3_atomic_inc(&qos_pd_mgr->processing_cnt); + INJECT_START(PS3_ERR_IJ_QOS_VD_MEMBER_CLEARING, qos_pd_mgr); if (unlikely(qos_pd_mgr->clearing)) { - LOG_DEBUG( - "qos vd member is clearing .host_no:%u:t_id:0x%llx CFID:%u did[%u %u]\n", - PS3_HOST(qos_pd_mgr->instance), cmd->trace_id, - cmd->index, qos_pd_mgr->disk_id, - qos_pd_mgr->vd_id); + LOG_DEBUG("qos vd member is clearing .host_no:%u:t_id:0x%llx CFID:%u did[%u %u]\n", + PS3_HOST(qos_pd_mgr->instance), cmd->trace_id, cmd->index, + qos_pd_mgr->disk_id, qos_pd_mgr->vd_id); ps3_atomic_dec(&qos_pd_mgr->processing_cnt); } else { in_queue = PS3_TRUE; @@ -1900,23 +1785,23 @@ static unsigned char ps3_qos_vd_member_insert(struct ps3_cmd *cmd) waitq = ps3_qos_pd_waitq_get(qos_pd_mgr, cmd); ps3_qos_pd_in_q(cmd, waitq, i); ps3_atomic_dec(&qos_pd_mgr->processing_cnt); - LOG_DEBUG("insert qos pd quota waitq.host_no:%u:t_id:0x%llx\n" - "\tCFID:%u waitq[%u,%u] did[%u %u]\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - waitq->id, waitq->count, qos_pd_mgr->disk_id, i); + LOG_DEBUG("insert qos pd quota waitq.host_no:%u:t_id:0x%llx" + " CFID:%u waitq[%u,%u] did[%u %u]\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + waitq->id, waitq->count, qos_pd_mgr->disk_id, i); } return in_queue; } -static unsigned char ps3_qos_pd_quota_decision(struct ps3_cmd *cmd) +static Bool ps3_qos_pd_quota_decision(struct ps3_cmd *cmd) { - unsigned char can_get = PS3_FALSE; + Bool can_get = PS3_FALSE; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - unsigned short disk_id = 0; - unsigned short i = 0; + U16 disk_id = 0; + U16 i = 0; struct scsi_device *sdev = NULL; - int pd_quota = 0; + S32 pd_quota = 0; PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_PD_PRO); if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { @@ -1931,20 +1816,23 @@ static unsigned char ps3_qos_pd_quota_decision(struct ps3_cmd *cmd) } } - if (cmd->target_pd_count == 0) + if (cmd->target_pd_count == 0) { can_get = PS3_TRUE; + } if (!can_get) { - if (!ps3_qos_vd_member_insert(cmd)) + if (!ps3_qos_vd_member_insert(cmd)) { can_get = PS3_TRUE; + } } } else { disk_id = cmd->io_attr.disk_id; qos_pd_mgr = ps3_qos_pd_mgr_get(cmd->instance, disk_id); - if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) + if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) { pd_quota = qos_pd_mgr->direct_quota; - else + } else { pd_quota = qos_pd_mgr->pd_quota; + } sdev = cmd->scmd->device; if (pd_quota >= sdev->queue_depth) { can_get = PS3_TRUE; @@ -1957,59 +1845,62 @@ static unsigned char ps3_qos_pd_quota_decision(struct ps3_cmd *cmd) return can_get; } -static unsigned char ps3_qos_vd_quota_decision(struct ps3_cmd *cmd) +static Bool ps3_qos_vd_quota_decision(struct ps3_cmd *cmd) { - unsigned char can_get = PS3_TRUE; + Bool can_get = PS3_TRUE; PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_VD_PRO); - if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) + if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD){ can_get = ps3_qos_vd_quota_check(cmd); + } PS3_QOS_STAT_END(cmd->instance, cmd, PS3_QOS_VD_PRO); return can_get; } -static inline unsigned char ps3_qos_dev_valid(struct ps3_cmd *cmd) +static inline Bool ps3_qos_dev_valid(struct ps3_cmd *cmd) { - unsigned char valid = PS3_TRUE; - struct ps3_scsi_priv_data *priv_data = NULL; + Bool valid = PS3_TRUE; + struct ps3_scsi_priv_data* priv_data = NULL; priv_data = scsi_device_private_data(cmd->scmd); if (priv_data->dev_deling) { LOG_INFO_LIM("qos dev is deling. host_no:%u chanel:%u id:%u\n", - PS3_HOST(cmd->instance), - PS3_SDEV_CHANNEL(cmd->scmd->device), - PS3_SDEV_TARGET(cmd->scmd->device)); + PS3_HOST(cmd->instance), + PS3_SDEV_CHANNEL(cmd->scmd->device), + PS3_SDEV_TARGET(cmd->scmd->device)); valid = PS3_FALSE; } return valid; } -static int ps3_qos_pre_check(struct ps3_instance *instance, struct ps3_cmd *cmd) +static S32 ps3_qos_pre_check(struct ps3_instance *instance, struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + INJECT_START(PS3_ERR_IJ_FORCE_TASK_MGR_BUSY, instance) if (instance->task_manager_host_busy) { LOG_INFO_LIM("hno:%u task_manager_host_busy\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_RETRY; goto l_out; } + INJECT_START(PS3_ERR_IJ_FORCE_INS_UNLOAD, instance) if (instance->is_probe_finish && !instance->state_machine.is_load) { - LOG_INFO_LIM("hno:%u instance state not is_load\n", - PS3_HOST(instance)); + LOG_INFO_LIM("hno:%u instance state not is_load\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - if (!ps3_qos_dev_valid(cmd)) + if (!ps3_qos_dev_valid(cmd)){ ret = -PS3_FAILED; + } + INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, instance) if (!ps3_is_instance_state_normal(instance, PS3_TRUE)) { - LOG_INFO_LIM("hno:%u instance state is not normal\n", - PS3_HOST(instance)); + LOG_INFO_LIM("hno:%u instance state is not normal\n", PS3_HOST(instance)); ret = -PS3_RECOVERED; goto l_out; } @@ -2017,20 +1908,20 @@ static int ps3_qos_pre_check(struct ps3_instance *instance, struct ps3_cmd *cmd) return ret; } -unsigned char ps3_hba_qos_decision(struct ps3_cmd *cmd) +Bool ps3_hba_qos_decision(struct ps3_cmd *cmd) { - unsigned char can_get = PS3_FALSE; - + Bool can_get = PS3_FALSE; if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { can_get = ps3_qos_pd_quota_decision(cmd); if (!can_get || - cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) { + cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) { goto _out; } can_get = ps3_qos_vd_quota_decision(cmd); - if (!can_get) + if (!can_get) { goto _out; + } } can_get = ps3_qos_tg_decision(cmd); @@ -2041,39 +1932,38 @@ unsigned char ps3_hba_qos_decision(struct ps3_cmd *cmd) void ps3_hba_qos_waitq_notify(struct ps3_instance *instance) { if (!ps3_qos_tg_notify(instance)) { - if (!ps3_qos_vd_notify(instance)) + if (!ps3_qos_vd_notify(instance)) { ps3_qos_pd_notify(instance); + } } } -static unsigned char ps3_pd_quota_waiq_abort(struct ps3_cmd *cmd) +static Bool ps3_pd_quota_waiq_abort(struct ps3_cmd *cmd) { - unsigned long lock_flag_pd = 0; - unsigned short disk_id = 0; - unsigned char found = PS3_FALSE; + ULong lock_flag_pd = 0; + U16 disk_id = 0; + Bool found = PS3_FALSE; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct qos_wait_queue *waitq = NULL; - unsigned short index = 0; + U16 index = 0; - for (index = cmd->first_over_quota_pd_idx; index < cmd->target_pd_count; - index++) { + for (index = cmd->first_over_quota_pd_idx; + index < cmd->target_pd_count; index++) { disk_id = cmd->target_pd[index].flat_disk_id; qos_pd_mgr = ps3_qos_pd_mgr_get(cmd->instance, disk_id); waitq = ps3_qos_pd_waitq_get(qos_pd_mgr, cmd); ps3_spin_lock_irqsave(waitq->rsc_lock, &lock_flag_pd); if (cmd->qos_waitq_flag == PS3_QOS_CMD_IN_PD && - index == cmd->first_over_quota_pd_idx) { + index == cmd->first_over_quota_pd_idx) { list_del(&cmd->qos_list); waitq->count--; (*waitq->total_waited_cnt)--; - ps3_spin_unlock_irqrestore(waitq->rsc_lock, - lock_flag_pd); + ps3_spin_unlock_irqrestore(waitq->rsc_lock, lock_flag_pd); found = PS3_TRUE; break; } ps3_spin_unlock_irqrestore(waitq->rsc_lock, lock_flag_pd); - LOG_INFO( - "abort pd waitq. t_id:0x%llx did[%u,%u] qid:%u found:%u\n", + LOG_INFO("abort pd waitq. t_id:0x%llx did[%u,%u] qid:%u found:%u\n", cmd->trace_id, index, disk_id, waitq->id, found); } @@ -2082,8 +1972,8 @@ static unsigned char ps3_pd_quota_waiq_abort(struct ps3_cmd *cmd) static bool ps3_vd_quota_waiq_abort(struct ps3_cmd *aborted_cmd) { - unsigned long flag = 0; - unsigned char found = PS3_FALSE; + ULong flag = 0; + Bool found = PS3_FALSE; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; qos_vd_mgr = ps3_qos_vd_mgr_get(aborted_cmd); @@ -2100,9 +1990,9 @@ static bool ps3_vd_quota_waiq_abort(struct ps3_cmd *aborted_cmd) bool ps3_cmd_waitq_abort(struct ps3_cmd *aborted_cmd) { - unsigned long lock_flag_mgr = 0; + ULong lock_flag_mgr = 0; struct ps3_instance *instance = NULL; - unsigned char found = PS3_FALSE; + Bool found = PS3_FALSE; struct qos_wait_queue *cmd_wait_q = NULL; struct ps3_qos_tg_context *qos_tg_ctx = NULL; @@ -2121,18 +2011,19 @@ bool ps3_cmd_waitq_abort(struct ps3_cmd *aborted_cmd) return found; } -static unsigned char ps3_hba_qos_waitq_abort(struct ps3_cmd *cmd) +static Bool ps3_hba_qos_waitq_abort(struct ps3_cmd *cmd) { - unsigned char found = PS3_FALSE; - - if (cmd->qos_waitq_flag == 0) + Bool found = PS3_FALSE; + if (cmd->qos_waitq_flag == 0) { goto out; + } if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { if (cmd->qos_waitq_flag == PS3_QOS_CMD_IN_PD) { found = ps3_pd_quota_waiq_abort(cmd); - if (found) + if (found) { goto out; + } } if (cmd->qos_waitq_flag == PS3_QOS_CMD_IN_VD) { @@ -2155,10 +2046,9 @@ static unsigned char ps3_hba_qos_waitq_abort(struct ps3_cmd *cmd) return found; } -static void ps3_vd_cmd_waitq_clean(struct ps3_instance *instance, - unsigned short disk_id, int result) +static void ps3_vd_cmd_waitq_clean(struct ps3_instance *instance, U16 disk_id, int result) { - unsigned long flag = 0; + ULong flag = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; @@ -2166,86 +2056,70 @@ static void ps3_vd_cmd_waitq_clean(struct ps3_instance *instance, ps3_spin_lock_irqsave(&qos_tg_ctx->lock, &flag); if (wait_q->count > 0) { - list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, - qos_list) { - LOG_DEBUG( - "qos clean vd cmd waitq. hno:%u t_id:0x%llx cmd:%d vd_id:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - disk_id); + list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, qos_list) { + LOG_DEBUG("qos clean vd cmd waitq. hno:%u t_id:0x%llx cmd:%d vd_id:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, disk_id); list_del(&cmd->qos_list); wait_q->count--; qos_tg_ctx->total_wait_cmd_cnt--; ps3_qos_update_vd_quota(cmd); ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, result, - PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, result, PS3_FALSE); } } ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); } static void ps3_jbod_cmd_waitq_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, - int result) + struct ps3_scsi_priv_data *priv_data, int result) { - unsigned long flag = 0; + ULong flag = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; - struct qos_wait_queue *wait_q = - &qos_tg_ctx->vd_cmd_waitqs[instance->qos_context.max_vd_count]; - unsigned short disk_id = priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; + struct qos_wait_queue *wait_q = &qos_tg_ctx->vd_cmd_waitqs + [instance->qos_context.max_vd_count]; + U16 disk_id = priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; ps3_spin_lock_irqsave(&qos_tg_ctx->lock, &flag); if (wait_q->count > 0) { - list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, - qos_list) { + list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, qos_list) { if (scsi_device_private_data(cmd->scmd) == priv_data) { - LOG_DEBUG( - "qos clean jbod cmd waitq. hno:%u t_id:0x%llx cmd:%d dev_t:%u diskid:%u\n", - PS3_HOST(instance), cmd->trace_id, - cmd->index, priv_data->dev_type, - disk_id); + LOG_DEBUG("qos clean jbod cmd waitq. hno:%u t_id:0x%llx cmd:%d dev_t:%u diskid:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, + priv_data->dev_type, disk_id); list_del(&cmd->qos_list); wait_q->count--; qos_tg_ctx->total_wait_cmd_cnt--; ps3_qos_update_vd_quota(cmd); ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, - result, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, result, PS3_FALSE); } } } ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); } -static void ps3_mgr_cmd_waitq_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, - int result) +static void ps3_mgr_cmd_waitq_clean(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data, int result) { - unsigned long flag = 0; + ULong flag = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; struct qos_wait_queue *wait_q = &qos_tg_ctx->mgr_cmd_wait_q; - unsigned short disk_id = priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; + U16 disk_id = priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; ps3_spin_lock_irqsave(&qos_tg_ctx->lock, &flag); if (wait_q->count > 0) { - list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, - qos_list) { - if (cmd->scmd && - scsi_device_private_data(cmd->scmd) == priv_data) { - LOG_DEBUG( - "qos clean mgr cmd waitq. hno:%u t_id:0x%llx cmd:%d dev_t:%u diskid:%u\n", - PS3_HOST(instance), cmd->trace_id, - cmd->index, priv_data->dev_type, - disk_id); + list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, qos_list) { + if (cmd->scmd && scsi_device_private_data(cmd->scmd) == priv_data) { + LOG_DEBUG("qos clean mgr cmd waitq. hno:%u t_id:0x%llx cmd:%d dev_t:%u diskid:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, + priv_data->dev_type, disk_id); list_del(&cmd->qos_list); wait_q->count--; qos_tg_ctx->total_wait_cmd_cnt--; - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, - result, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, result, PS3_FALSE); } } } @@ -2253,24 +2127,20 @@ static void ps3_mgr_cmd_waitq_clean(struct ps3_instance *instance, } static void ps3_hba_qos_vd_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, - int resp_status) + struct ps3_scsi_priv_data *priv_data, S32 resp_status) { - unsigned short vd_id = 0; - unsigned short pd_id = 0; + U16 vd_id = 0; + U16 pd_id = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), - PS3_VDID(&priv_data->disk_pos)); - qos_vd_mgr = ps3_qos_vd_mgr_get_by_id(instance, - PS3_VDID(&priv_data->disk_pos)); + vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), PS3_VDID(&priv_data->disk_pos)); + qos_vd_mgr = ps3_qos_vd_mgr_get_by_id(instance, PS3_VDID(&priv_data->disk_pos)); for (pd_id = 1; pd_id <= instance->qos_context.max_pd_count; pd_id++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); if (ps3_atomic_read(&qos_pd_mgr->valid) == 1 && - qos_pd_mgr->vd_id == vd_id) { - ps3_pd_quota_waitq_clean(qos_pd_mgr, vd_id, - resp_status); + qos_pd_mgr->vd_id == vd_id) { + ps3_pd_quota_waitq_clean(qos_pd_mgr, vd_id, resp_status); cancel_work_sync(&qos_pd_mgr->resend_work); } } @@ -2282,18 +2152,16 @@ static void ps3_hba_qos_vd_clean(struct ps3_instance *instance, ps3_mgr_cmd_waitq_clean(instance, priv_data, resp_status); LOG_FILE_INFO("qos clean vd. host_no:%u type:%u disk_id:%u\n", - PS3_HOST(instance), priv_data->dev_type, vd_id); + PS3_HOST(instance), priv_data->dev_type, vd_id); } -#define PS3_QOS_JBOD_VD_MGR(instance) \ - (&instance->qos_context.vd_ctx \ - .qos_vd_mgrs[instance->qos_context.max_vd_count]) +#define PS3_QOS_JBOD_VD_MGR(instance) \ + (&instance->qos_context.vd_ctx.qos_vd_mgrs[instance->qos_context.max_vd_count]) -#if defined(PS3_SUPPORT_LINX80) -void ps3_linx80_vd_member_change(struct ps3_instance *instance, - struct ps3_pd_entry *pd_entry) +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 9, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) +void ps3_linx80_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry) { - unsigned short pd_id = 0; + U16 pd_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; if (!PS3_QOS_INITED(instance)) @@ -2303,20 +2171,20 @@ void ps3_linx80_vd_member_change(struct ps3_instance *instance, qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); if (ps3_atomic_read(&qos_pd_mgr->valid) != PS3_TRUE) goto _out; + ps3_pd_quota_waitq_clean(qos_pd_mgr, 0, PS3_STATUS_VD_MEMBER_OFFLINE); cancel_work_sync(&qos_pd_mgr->resend_work); LOG_INFO("linx80 update pd qos rsc. host_no:%u pd_id:%u dev_type:%u\n", - PS3_HOST(instance), pd_id, pd_entry->dev_type); + PS3_HOST(instance), pd_id, pd_entry->dev_type); _out: return; } #endif static void ps3_hba_qos_pd_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, - int resp_status) + struct ps3_scsi_priv_data *priv_data, S32 resp_status) { - unsigned short disk_id = 0; + U16 disk_id = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; @@ -2331,143 +2199,139 @@ static void ps3_hba_qos_pd_clean(struct ps3_instance *instance, ps3_mgr_cmd_waitq_clean(instance, priv_data, resp_status); LOG_FILE_INFO("qos clean pd. host_no:%u diskid:%u\n", - PS3_HOST(instance), disk_id); + PS3_HOST(instance), disk_id); } static void ps3_qos_wait_io_end(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd *cmd = NULL; - LOG_DEBUG("host_no:%u wait cmd in qos flighting start\n", - PS3_HOST(instance)); + PS3_HOST(instance)); for (i = 0; i < instance->cmd_context.max_scsi_cmd_count; i++) { cmd = instance->cmd_context.cmd_buf[i]; - while (cmd->qos_processing) + while (cmd->qos_processing) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); + } } LOG_DEBUG("host_no:%u wait cmd in qos flighting end\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } -void ps3_qos_device_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, int resp_status) +void ps3_qos_device_clean(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data, + S32 resp_status) { - if (!PS3_QOS_INITED(instance)) + if (!PS3_QOS_INITED(instance)) { return; + } ps3_qos_wait_io_end(instance); if (priv_data->dev_type == PS3_DEV_TYPE_VD) { - instance->qos_context.opts.qos_vd_clean(instance, priv_data, - resp_status); + instance->qos_context.opts.qos_vd_clean(instance, priv_data, resp_status); } else { - instance->qos_context.opts.qos_pd_clean(instance, priv_data, - resp_status); + instance->qos_context.opts.qos_pd_clean(instance, priv_data, resp_status); } } static inline void ps3_qos_dev_end(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data) + struct ps3_scsi_priv_data *priv_data) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd *cmd = NULL; struct scsi_cmnd *scmd = NULL; struct scsi_device *sdev = NULL; - unsigned int softChan = PS3_CHANNEL(&priv_data->disk_pos); - unsigned int devID = PS3_TARGET(&priv_data->disk_pos); + U32 softChan = PS3_CHANNEL(&priv_data->disk_pos); + U32 devID = PS3_TARGET(&priv_data->disk_pos); LOG_DEBUG("host_no:%u dev wait cmd in qos flighting start\n", - PS3_HOST(instance)); + PS3_HOST(instance)); for (i = 0; i < instance->cmd_context.max_scsi_cmd_count; i++) { cmd = instance->cmd_context.cmd_buf[i]; - if (likely(!cmd->qos_processing)) + if (likely(!cmd->qos_processing)) { continue; + } scmd = cmd->scmd; - if (scmd == NULL) + if (scmd == NULL) { continue; + } sdev = scmd->device; - if (sdev == NULL) + if (sdev == NULL) { continue; + } if (PS3_SDEV_CHANNEL(sdev) == softChan && - PS3_SDEV_TARGET(sdev) == devID) { + PS3_SDEV_TARGET(sdev) == devID) { LOG_DEBUG("cmd is flighting. host_no:%u CFID:%u\n", - PS3_HOST(instance), cmd->index); - while (cmd->qos_processing) + PS3_HOST(instance), cmd->index); + while (cmd->qos_processing) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); + } } } LOG_DEBUG("host_no:%u dev wait cmd in qos flighting end\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } -void ps3_qos_disk_del(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data) +void ps3_qos_disk_del(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - unsigned short disk_id = 0; - int resp_status = PS3_STATUS_DEVICE_NOT_FOUND; + U16 disk_id = 0; + S32 resp_status = PS3_STATUS_DEVICE_NOT_FOUND; - if (!PS3_QOS_INITED(instance)) + if (!PS3_QOS_INITED(instance)) { return; + } priv_data->dev_deling = PS3_TRUE; - wmb(); /* in order to force CPU ordering */ + wmb(); disk_id = PS3_PDID(&priv_data->disk_pos); LOG_FILE_INFO("qos disk del. host_no:%u dev_t:%u diskid:%u\n", - PS3_HOST(instance), priv_data->dev_type, disk_id); + PS3_HOST(instance), priv_data->dev_type, disk_id); if (priv_data->dev_type == PS3_DEV_TYPE_VD) { ps3_qos_dev_end(instance, priv_data); - instance->qos_context.opts.qos_vd_clean(instance, priv_data, - resp_status); + instance->qos_context.opts.qos_vd_clean(instance, priv_data, resp_status); } else { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, disk_id); ps3_qos_dev_end(instance, priv_data); if (PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr)) { resp_status = PS3_STATUS_VD_MEMBER_OFFLINE; qos_pd_mgr->clearing = PS3_TRUE; - wmb(); /* in order to force CPU ordering */ - LOG_INFO( - "host_no:%u wait cmd in qos vd member flighting count:%d did:%u\n", + wmb(); + LOG_INFO("host_no:%u wait cmd in qos vd member flighting count:%d did:%u\n", PS3_HOST(instance), - ps3_atomic_read(&qos_pd_mgr->processing_cnt), - disk_id); - while (ps3_atomic_read(&qos_pd_mgr->processing_cnt) > - 0) { + ps3_atomic_read(&qos_pd_mgr->processing_cnt), disk_id); + while (ps3_atomic_read(&qos_pd_mgr->processing_cnt) > 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); } } - instance->qos_context.opts.qos_pd_clean(instance, priv_data, - resp_status); + instance->qos_context.opts.qos_pd_clean(instance, priv_data, resp_status); } } -void ps3_qos_vd_member_del(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos) +void ps3_qos_vd_member_del(struct ps3_instance *instance, struct PS3DiskDevPos *dev_pos) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - unsigned short disk_id = 0; + U16 disk_id = 0; disk_id = PS3_PDID(dev_pos); qos_pd_mgr = ps3_qos_pd_mgr_get(instance, disk_id); - LOG_INFO("qos disk del. host_no:%u did:%u vid:%u\n", PS3_HOST(instance), - disk_id, qos_pd_mgr->vd_id); + LOG_INFO("qos disk del. host_no:%u did:%u vid:%u\n", + PS3_HOST(instance), disk_id, qos_pd_mgr->vd_id); if (PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr)) { - ps3_pd_quota_waitq_clean(qos_pd_mgr, 0, - PS3_STATUS_VD_MEMBER_OFFLINE); + ps3_pd_quota_waitq_clean(qos_pd_mgr, 0, PS3_STATUS_VD_MEMBER_OFFLINE); } } -void ps3_hba_qos_waitq_clear_all(struct ps3_instance *instance, int resp_status) +void ps3_hba_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status) { - unsigned long flag = 0; - unsigned short i = 0; + ULong flag = 0; + U16 i = 0; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; + struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct qos_wait_queue *wait_q = NULL; struct ps3_cmd *cmd = NULL; @@ -2491,33 +2355,27 @@ void ps3_hba_qos_waitq_clear_all(struct ps3_instance *instance, int resp_status) for (i = 1; i <= instance->qos_context.max_vd_count; i++) { wait_q = &qos_tg_ctx->vd_cmd_waitqs[i]; while (wait_q->count > 0) { - cmd = list_first_entry(&wait_q->wait_list, - struct ps3_cmd, qos_list); - LOG_DEBUG( - "qos clear tg vd waitq. hno:%u qid:%u t_id:0x%llx cmd:%d\n", - PS3_HOST(instance), i, cmd->trace_id, - cmd->index); + cmd = list_first_entry(&wait_q->wait_list, struct ps3_cmd, qos_list); + LOG_DEBUG("qos clear tg vd waitq. hno:%u qid:%u t_id:0x%llx cmd:%d\n", + PS3_HOST(instance), i, cmd->trace_id, cmd->index); list_del(&cmd->qos_list); wait_q->count--; qos_tg_ctx->total_wait_cmd_cnt--; ps3_qos_update_vd_quota(cmd); ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, - PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); } } wait_q = &qos_tg_ctx->mgr_cmd_wait_q; while (wait_q->count > 0) { - cmd = list_first_entry(&wait_q->wait_list, struct ps3_cmd, - qos_list); + cmd = list_first_entry(&wait_q->wait_list, struct ps3_cmd, qos_list); LOG_DEBUG("qos clear tg mgr waitq. hno:%u t_id:0x%llx cmd:%d\n", - PS3_HOST(instance), cmd->trace_id, cmd->index); + PS3_HOST(instance), cmd->trace_id, cmd->index); list_del(&cmd->qos_list); wait_q->count--; qos_tg_ctx->total_wait_cmd_cnt--; - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, - PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); } ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); cancel_work_sync(&qos_tg_ctx->resend_work); @@ -2525,15 +2383,12 @@ void ps3_hba_qos_waitq_clear_all(struct ps3_instance *instance, int resp_status) LOG_INFO("host_no:%u:clear all qos waitq\n", PS3_HOST(instance)); } -static inline unsigned short -ps3_qos_pd_workq_id_get(struct ps3_qos_pd_context *qos_pd_ctx) +static inline U16 ps3_qos_pd_workq_id_get(struct ps3_qos_pd_context *qos_pd_ctx) { - return ps3_atomic_inc_return(&qos_pd_ctx->workq_id_cnt) % - qos_pd_ctx->workq_count; + return ps3_atomic_inc_return(&qos_pd_ctx->workq_id_cnt) % qos_pd_ctx->workq_count; } -void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_pd_entry *pd_entry) +void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_pd_entry *pd_entry) { struct ps3_qos_pd_context *pd_ctx = NULL; struct PS3QosInfo *qos_cfg_info = NULL; @@ -2543,127 +2398,108 @@ void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, qos_pd_mgr->direct_quota = pd_entry->direct_quota; qos_pd_mgr->dev_type = pd_entry->dev_type; switch (pd_entry->dev_type) { - case PS3_DEV_TYPE_SAS_HDD: - if (qos_pd_mgr->pd_quota == 0) { - qos_pd_mgr->pd_quota = - qos_cfg_info->sasHddQuota > 0 ? - qos_cfg_info->sasHddQuota : - g_ps3_qos_sas_pd_quota; - } - qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_min_quota = - qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); - break; - case PS3_DEV_TYPE_SAS_SSD: - if (qos_pd_mgr->pd_quota == 0) { - qos_pd_mgr->pd_quota = - qos_cfg_info->sasSsdQuota > 0 ? - qos_cfg_info->sasSsdQuota : - g_ps3_qos_sas_pd_quota; - } - qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_min_quota = - qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); - break; - case PS3_DEV_TYPE_SATA_HDD: - if (qos_pd_mgr->pd_quota == 0) { - qos_pd_mgr->pd_quota = - qos_cfg_info->sataHddQuota > 0 ? - qos_cfg_info->sataHddQuota : - g_ps3_qos_hdd_pd_quota; - } - qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_min_quota = - qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); - break; - case PS3_DEV_TYPE_SATA_SSD: - if (qos_pd_mgr->pd_quota == 0) { - qos_pd_mgr->pd_quota = - qos_cfg_info->sataSsdQuota > 0 ? - qos_cfg_info->sataSsdQuota : - g_ps3_qos_ssd_pd_quota; - } - qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_min_quota = - qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); - break; - case PS3_DEV_TYPE_NVME_SSD: - pd_ctx = &qos_pd_mgr->instance->qos_context.pd_ctx; - if (qos_pd_mgr->pd_quota == 0) { - qos_pd_mgr->pd_quota = - qos_cfg_info->nvmeNormalQuota > 0 ? - qos_cfg_info->nvmeNormalQuota : - pd_ctx->nvme_normal_quota; - } - if (qos_pd_mgr->direct_quota == 0) { - qos_pd_mgr->direct_quota = - qos_cfg_info->nvmeDirectQuota > 0 ? - qos_cfg_info->nvmeDirectQuota : - g_ps3_qos_nvme_pd_quota; - } - qos_pd_mgr->pd_init_quota = qos_pd_mgr->direct_quota; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->direct_quota; - qos_pd_mgr->adjust_min_quota = qos_pd_mgr->direct_quota - - (qos_pd_mgr->direct_quota / 10); - break; + case PS3_DEV_TYPE_SAS_HDD: + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = qos_cfg_info->sasHddQuota > 0 ? + qos_cfg_info->sasHddQuota : g_ps3_qos_sas_pd_quota; + } + qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; + case PS3_DEV_TYPE_SAS_SSD: + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = qos_cfg_info->sasSsdQuota > 0 ? + qos_cfg_info->sasSsdQuota : g_ps3_qos_sas_pd_quota; + } + qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; + case PS3_DEV_TYPE_SATA_HDD: + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = qos_cfg_info->sataHddQuota > 0 ? + qos_cfg_info->sataHddQuota : g_ps3_qos_hdd_pd_quota; + } + qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; + case PS3_DEV_TYPE_SATA_SSD: + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = qos_cfg_info->sataSsdQuota > 0 ? + qos_cfg_info->sataSsdQuota : g_ps3_qos_ssd_pd_quota; + } + qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; + case PS3_DEV_TYPE_NVME_SSD: + pd_ctx = &qos_pd_mgr->instance->qos_context.pd_ctx; + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = qos_cfg_info->nvmeNormalQuota > 0 ? + qos_cfg_info->nvmeNormalQuota : pd_ctx->nvme_normal_quota; + } + if (qos_pd_mgr->direct_quota == 0) { + qos_pd_mgr->direct_quota = qos_cfg_info->nvmeDirectQuota > 0 ? + qos_cfg_info->nvmeDirectQuota : g_ps3_qos_nvme_pd_quota; + } + qos_pd_mgr->pd_init_quota = qos_pd_mgr->direct_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->direct_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->direct_quota - (qos_pd_mgr->direct_quota / 10); + break; } - LOG_DEBUG( - "qos pd rsc init. hno:%u type:%u normal_quota:%u direct_quota:%u\n", - PS3_HOST(qos_pd_mgr->instance), pd_entry->dev_type, - pd_entry->normal_quota, pd_entry->direct_quota); + LOG_DEBUG("qos pd rsc init. hno:%u type:%u normal_quota:%u direct_quota:%u\n", + PS3_HOST(qos_pd_mgr->instance), pd_entry->dev_type, + pd_entry->normal_quota, pd_entry->direct_quota); } void ps3_qos_adjust_pd_rsc(struct scsi_device *sdev, - struct ps3_instance *instance, int reason) + struct ps3_instance *instance, S32 reason) { - int *quota = NULL; - unsigned long flag = 0; + S32 *quota = NULL; + ULong flag = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - if (!PS3_QOS_INITED(instance) || (PS3_SDEV_PRI_DATA(sdev) == NULL) || - (PS3_SDEV_PRI_DATA(sdev)->dev_type == PS3_DEV_TYPE_VD)) { + if (!PS3_QOS_INITED(instance) || + (PS3_SDEV_PRI_DATA(sdev) == NULL) || + (PS3_SDEV_PRI_DATA(sdev)->dev_type == PS3_DEV_TYPE_VD)) { goto l_out; } - qos_pd_mgr = ps3_qos_pd_mgr_get( - instance, PS3_PDID(&PS3_SDEV_PRI_DATA(sdev)->disk_pos)); + qos_pd_mgr = ps3_qos_pd_mgr_get(instance, PS3_PDID(&PS3_SDEV_PRI_DATA(sdev)->disk_pos)); switch (PS3_SDEV_PRI_DATA(sdev)->dev_type) { - case PS3_DEV_TYPE_SAS_HDD: - case PS3_DEV_TYPE_SAS_SSD: - case PS3_DEV_TYPE_SATA_HDD: - case PS3_DEV_TYPE_SATA_SSD: - quota = &qos_pd_mgr->pd_quota; - break; - case PS3_DEV_TYPE_NVME_SSD: - quota = &qos_pd_mgr->direct_quota; - break; - default: - goto l_out; - } - if ((*quota > sdev->queue_depth && - reason == PS3_QOS_QUOTA_ADJUST_QFULL) || - ((*quota == qos_pd_mgr->adjust_max_quota || - time_after(sdev->last_queue_full_time + sdev->queue_ramp_up_period, - jiffies) || - time_after(sdev->last_queue_ramp_up + sdev->queue_ramp_up_period, - jiffies)) && - reason == PS3_QOS_QUOTA_ADJUST_UP)) { + case PS3_DEV_TYPE_SAS_HDD: + case PS3_DEV_TYPE_SAS_SSD: + case PS3_DEV_TYPE_SATA_HDD: + case PS3_DEV_TYPE_SATA_SSD: + quota = &qos_pd_mgr->pd_quota; + break; + case PS3_DEV_TYPE_NVME_SSD: + quota = &qos_pd_mgr->direct_quota; + break; + default: + goto l_out; + } + if ((*quota > sdev->queue_depth && reason == PS3_QOS_QUOTA_ADJUST_QFULL) || + ((*quota == qos_pd_mgr->adjust_max_quota || + time_after(sdev->last_queue_full_time + sdev->queue_ramp_up_period, jiffies) || + time_after(sdev->last_queue_ramp_up + sdev->queue_ramp_up_period, jiffies)) + && reason == PS3_QOS_QUOTA_ADJUST_UP)) { goto l_out; } if (reason == PS3_QOS_QUOTA_ADJUST_UP) { ps3_spin_lock_irqsave(&qos_pd_mgr->adjust_quota_lock, &flag); - if (*quota < qos_pd_mgr->adjust_max_quota) + if (*quota < qos_pd_mgr->adjust_max_quota) { (*quota)++; + } } else if (reason == PS3_QOS_QUOTA_ADJUST_QFULL) { ps3_spin_lock_irqsave(&qos_pd_mgr->adjust_quota_lock, &flag); - if (*quota > qos_pd_mgr->adjust_min_quota) + if (*quota > qos_pd_mgr->adjust_min_quota) { (*quota)--; + } } else if (reason == PS3_QOS_QUOTA_ADJUST_DEFULAT) { ps3_spin_lock_irqsave(&qos_pd_mgr->adjust_quota_lock, &flag); *quota = qos_pd_mgr->adjust_max_quota; @@ -2671,72 +2507,65 @@ void ps3_qos_adjust_pd_rsc(struct scsi_device *sdev, goto l_out; } ps3_spin_unlock_irqrestore(&qos_pd_mgr->adjust_quota_lock, flag); - LOG_INFO_IN_IRQ( - instance, - "hno:%u dev[%u:%u] qos quota change to [%d] reason [%d]\n", + LOG_INFO_IN_IRQ(instance,"hno:%u dev[%u:%u] qos quota change to [%d] reason [%d]\n", PS3_HOST(instance), sdev->channel, sdev->id, *quota, reason); l_out: return; } -struct ps3_qos_pd_mgr *ps3_qos_pd_mgr_init(struct ps3_instance *instance, - struct ps3_pd_entry *pd_entry) + struct ps3_qos_pd_mgr* ps3_qos_pd_mgr_init(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry) { - unsigned short pd_id = 0; + U16 pd_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - - if (!PS3_QOS_INITED(instance)) + if (!PS3_QOS_INITED(instance)) { goto _out; + } pd_id = PS3_PDID(&pd_entry->disk_pos); qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); if ((ps3_atomic_add_unless(&qos_pd_mgr->valid, 1, 1) != 0) || -#if defined(PS3_SUPPORT_LINX80) - ((ps3_sas_is_support_smp(instance)) && - (!ps3_check_pd_is_vd_member(pd_entry->config_flag))) || - (pd_entry->config_flag == MIC_PD_STATE_JBOD)) { +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 9, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) + ((ps3_sas_is_support_smp(instance)) && (!ps3_check_pd_is_vd_member(pd_entry->config_flag))) || + (pd_entry->config_flag == MIC_PD_STATE_JBOD)) { #else - (pd_entry->config_flag == MIC_PD_STATE_JBOD)) { + (pd_entry->config_flag == MIC_PD_STATE_JBOD)) { #endif - if (pd_entry->config_flag == MIC_PD_STATE_JBOD) + if (pd_entry->config_flag == MIC_PD_STATE_JBOD) { ps3_qos_vd_member_del(instance, &pd_entry->disk_pos); + } ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); qos_pd_mgr->disk_id = pd_id; qos_pd_mgr->vd_id = 0; - qos_pd_mgr->workq_id = - ps3_qos_pd_workq_id_get(&instance->qos_context.pd_ctx); + qos_pd_mgr->workq_id = ps3_qos_pd_workq_id_get(&instance->qos_context.pd_ctx); qos_pd_mgr->clearing = PS3_FALSE; - LOG_INFO_IN_IRQ( - instance, - "host_no:%u pd_id:%u dev_type:%u device qos init\n", + LOG_INFO_IN_IRQ(instance, "host_no:%u pd_id:%u dev_type:%u device qos init\n", PS3_HOST(instance), pd_id, qos_pd_mgr->dev_type); } _out: return qos_pd_mgr; } -void ps3_qos_pd_mgr_reset(struct ps3_instance *instance, unsigned short pd_id) +void ps3_qos_pd_mgr_reset(struct ps3_instance *instance, U16 pd_id) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - - if (!PS3_QOS_INITED(instance)) + if (!PS3_QOS_INITED(instance)) { return; + } qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); qos_pd_mgr->clearing = PS3_FALSE; } void ps3_qos_vd_attr_change(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry_old, - struct PS3VDEntry *vd_entry) + struct PS3VDEntry *vd_entry_old, struct PS3VDEntry *vd_entry) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - unsigned short change_type = PS3_QOS_VD_TYPE_CHANGE_INVALID; - unsigned short i = 0; - unsigned short j = 0; - unsigned short pd_id = 0; + U16 change_type = PS3_QOS_VD_TYPE_CHANGE_INVALID; + U16 i = 0; + U16 j = 0; + U16 pd_id = 0; if (!PS3_QOS_INITED(instance) || vd_entry->isNvme) goto l_out; @@ -2748,27 +2577,18 @@ void ps3_qos_vd_attr_change(struct ps3_instance *instance, for (i = 0; i < vd_entry->spanCount; i++) { for (j = 0; j < vd_entry->span[i].spanPdNum; j++) { - pd_id = vd_entry->span[i] - .extent[j] - .phyDiskID.ps3Dev.phyDiskID; + pd_id = vd_entry->span[i].extent[j].phyDiskID.ps3Dev.phyDiskID; if (pd_id <= PS3_MAX_PD_COUNT(instance)) { - qos_pd_mgr = - ps3_qos_pd_mgr_get(instance, pd_id); + qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); switch (change_type) { case PS3_QOS_VD_TYPE_CHANGE_TO_SSD: - qos_pd_mgr->pd_quota = - qos_pd_mgr->adjust_max_quota; + qos_pd_mgr->pd_quota = qos_pd_mgr->adjust_max_quota; break; case PS3_QOS_VD_TYPE_CHANGE_TO_HDD: - if (vd_entry_old != NULL) { - qos_pd_mgr->pd_quota = - instance->cmd_context - .max_scsi_cmd_count; - } else { - qos_pd_mgr->pd_quota = - qos_pd_mgr - ->adjust_max_quota; - } + if (vd_entry_old != NULL) + qos_pd_mgr->pd_quota = instance->cmd_context.max_scsi_cmd_count; + else + qos_pd_mgr->pd_quota = qos_pd_mgr->adjust_max_quota; break; default: break; @@ -2777,38 +2597,32 @@ void ps3_qos_vd_attr_change(struct ps3_instance *instance, } } - LOG_INFO_IN_IRQ(instance, - "host_no:%u qos vd[%u:%u:%u] attr change:%u complete\n", - PS3_HOST(instance), PS3_CHANNEL(&vd_entry->diskPos), - PS3_TARGET(&vd_entry->diskPos), - PS3_VDID(&vd_entry->diskPos), change_type); + LOG_INFO_IN_IRQ(instance, "host_no:%u qos vd[%u:%u:%u] attr change:%u complete\n", + PS3_HOST(instance), PS3_CHANNEL(&vd_entry->diskPos), + PS3_TARGET(&vd_entry->diskPos), PS3_VDID(&vd_entry->diskPos), change_type); l_out: return; } -void ps3_qos_vd_member_change(struct ps3_instance *instance, - struct ps3_pd_entry *pd_entry, - struct scsi_device *sdev, - unsigned char is_vd_member) +void ps3_qos_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry, + struct scsi_device *sdev, Bool is_vd_member) { - unsigned short pd_id = 0; + U16 pd_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_scsi_priv_data *priv_data = NULL; - - if (!PS3_QOS_INITED(instance)) + if (!PS3_QOS_INITED(instance)) { goto _out; + } pd_id = PS3_PDID(&pd_entry->disk_pos); ps3_mutex_lock(&instance->dev_context.dev_priv_lock); priv_data = PS3_SDEV_PRI_DATA(sdev); if (priv_data != NULL) { if (is_vd_member) { - ps3_hba_qos_pd_clean(instance, priv_data, - PS3_STATUS_DEVICE_NOT_FOUND); + ps3_hba_qos_pd_clean(instance, priv_data, PS3_STATUS_DEVICE_NOT_FOUND); ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); } else { - ps3_hba_qos_pd_clean(instance, priv_data, - PS3_STATUS_VD_MEMBER_OFFLINE); + ps3_hba_qos_pd_clean(instance, priv_data, PS3_STATUS_VD_MEMBER_OFFLINE); ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); @@ -2817,47 +2631,38 @@ void ps3_qos_vd_member_change(struct ps3_instance *instance, } else { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); } - LOG_INFO( - "update pd qos rsc. host_no:%u pd_id:%u dev_type:%u is_vd_member:%u\n", + LOG_INFO("update pd qos rsc. host_no:%u pd_id:%u dev_type:%u is_vd_member:%u\n", PS3_HOST(instance), pd_id, pd_entry->dev_type, is_vd_member); _out: return; } -void ps3_hba_qos_vd_init(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry) +void ps3_hba_qos_vd_init(struct ps3_instance *instance, struct PS3VDEntry *vd_entry) { struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - unsigned short vd_id = 0; + U16 vd_id = 0; vd_id = PS3_VDID(&vd_entry->diskPos); qos_vd_mgr = ps3_qos_vd_mgr_get_by_id(instance, vd_id); - ps3_atomic_set(&qos_vd_mgr->vd_quota, - g_ps3_qos_hdd_pd_quota * vd_entry->physDrvCnt); + ps3_atomic_set(&qos_vd_mgr->vd_quota, g_ps3_qos_hdd_pd_quota * vd_entry->physDrvCnt); qos_vd_mgr->vd_entry = vd_entry; qos_vd_mgr->valid = PS3_TRUE; } static void ps3_qos_r1x_member_init(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_pd_entry *pd_entry, - unsigned short judge_type) + struct ps3_pd_entry *pd_entry, U16 judge_type) { switch (judge_type) { case PS3_IS_SSD_ODD_R1X_VD: if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { - qos_pd_mgr->direct_quota = - qos_pd_mgr->pd_init_quota >> 1; + qos_pd_mgr->direct_quota = qos_pd_mgr->pd_init_quota >> 1; qos_pd_mgr->adjust_max_quota = qos_pd_mgr->direct_quota; - qos_pd_mgr->adjust_min_quota = - qos_pd_mgr->direct_quota - - (qos_pd_mgr->direct_quota / 10); + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->direct_quota - (qos_pd_mgr->direct_quota / 10); } else { qos_pd_mgr->pd_quota = qos_pd_mgr->pd_init_quota >> 1; qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_min_quota = - qos_pd_mgr->pd_quota - - (qos_pd_mgr->pd_quota / 10); + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); } break; case PS3_IS_SSD_EVEN_R1X_VD: @@ -2874,148 +2679,133 @@ static void ps3_qos_r1x_member_init(struct ps3_qos_pd_mgr *qos_pd_mgr, void ps3_qos_vd_init(struct ps3_instance *instance, struct PS3VDEntry *vd_entry) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - unsigned short vd_id = 0; - unsigned short pd_id = 0; + U16 vd_id = 0; + U16 pd_id = 0; struct ps3_pd_entry *pd_entry = NULL; - unsigned short i, j = 0; - unsigned short judge_type = PS3_IS_VALID_R1X_VD; + U16 i, j = 0; + U16 judge_type = PS3_IS_VALID_R1X_VD; - if (!PS3_QOS_INITED(instance)) + if(!PS3_QOS_INITED(instance)) { return; + } vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), - PS3_VDID(&vd_entry->diskPos)); + PS3_VDID(&vd_entry->diskPos)); judge_type = ps3_odd_r1x_judge(vd_entry); for (i = 0; i < vd_entry->spanCount; i++) { for (j = 0; j < vd_entry->span[i].spanPdNum; j++) { - pd_id = vd_entry->span[i] - .extent[j] - .phyDiskID.ps3Dev.phyDiskID; - if (pd_id > PS3_MAX_PD_COUNT(instance)) - continue; - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( - instance, pd_id); - if (pd_entry) { - qos_pd_mgr = ps3_qos_pd_mgr_init( - instance, pd_entry); - if (unlikely(qos_pd_mgr->dev_type != - pd_entry->dev_type)) { - ps3_qos_pd_rsc_init(qos_pd_mgr, - pd_entry); - if (!vd_entry->isSsd) { - qos_pd_mgr->pd_quota = - instance->cmd_context - .max_scsi_cmd_count; + pd_id = vd_entry->span[i].extent[j].phyDiskID.ps3Dev.phyDiskID; + if (pd_id <= PS3_MAX_PD_COUNT(instance)) { + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, pd_id); + if (pd_entry) { + qos_pd_mgr = ps3_qos_pd_mgr_init(instance, pd_entry); + if (unlikely(qos_pd_mgr->dev_type != pd_entry->dev_type)) { + ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); + if (!vd_entry->isSsd) + qos_pd_mgr->pd_quota = instance->cmd_context.max_scsi_cmd_count; } - } - ps3_qos_r1x_member_init(qos_pd_mgr, - pd_entry, - judge_type); - if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { - if (qos_pd_mgr->pd_quota > - qos_pd_mgr->direct_quota) { - qos_pd_mgr->pd_quota = - qos_pd_mgr - ->direct_quota; + ps3_qos_r1x_member_init(qos_pd_mgr, pd_entry, judge_type); + if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { + if (qos_pd_mgr->pd_quota > qos_pd_mgr->direct_quota) { + qos_pd_mgr->pd_quota = qos_pd_mgr->direct_quota; + } } + qos_pd_mgr->vd_id = vd_id; } - qos_pd_mgr->vd_id = vd_id; } } } - if (instance->qos_context.opts.qos_vd_init) + if (instance->qos_context.opts.qos_vd_init) { instance->qos_context.opts.qos_vd_init(instance, vd_entry); + } - LOG_INFO_IN_IRQ(instance, - "host_no:%u disk_pos[%u:%u:%u] device qos init\n", - PS3_HOST(instance), PS3_CHANNEL(&vd_entry->diskPos), - PS3_TARGET(&vd_entry->diskPos), vd_id); + LOG_INFO_IN_IRQ(instance, "host_no:%u disk_pos[%u:%u:%u] device qos init\n", + PS3_HOST(instance), PS3_CHANNEL(&vd_entry->diskPos), + PS3_TARGET(&vd_entry->diskPos), vd_id); } -void ps3_hba_qos_vd_reset(struct ps3_instance *instance, unsigned short disk_id) +void ps3_hba_qos_vd_reset(struct ps3_instance *instance, U16 disk_id) { struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - qos_vd_mgr = ps3_qos_vd_mgr_get_by_id(instance, disk_id); qos_vd_mgr->valid = PS3_FALSE; } -void ps3_qos_vd_reset(struct ps3_instance *instance, unsigned short disk_id) +void ps3_qos_vd_reset(struct ps3_instance *instance, U16 disk_id) { - if (!PS3_QOS_INITED(instance)) + if (!PS3_QOS_INITED(instance)) { return; + } - if (instance->qos_context.opts.qos_vd_reset) + if (instance->qos_context.opts.qos_vd_reset) { instance->qos_context.opts.qos_vd_reset(instance, disk_id); + } } static void ps3_qos_pd_notify_timeout(struct ps3_instance *instance) { struct ps3_qos_pd_context *qos_pd_ctx = NULL; - unsigned short i = 0; + U16 i = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - unsigned long timeout_jiffies = 0; + ULong timeout_jiffies = 0; qos_pd_ctx = &instance->qos_context.pd_ctx; for (i = 1; i <= instance->qos_context.max_pd_count; i++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, i); - timeout_jiffies = qos_pd_mgr->last_sched_jiffies + - PS3_QOS_WAITQ_TIMEOUT * HZ; + timeout_jiffies = qos_pd_mgr->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; if (time_after(jiffies, timeout_jiffies)) { if (ps3_qos_single_pd_notify(qos_pd_ctx, qos_pd_mgr)) { - LOG_INFO( - "awake qos pd quota waitq by poll. host_no:%u vid:%u pid:%u\n", - PS3_HOST(instance), qos_pd_mgr->vd_id, - qos_pd_mgr->disk_id); + LOG_INFO("awake qos pd quota waitq by poll. host_no:%u vid:%u pid:%u\n", + PS3_HOST(instance), qos_pd_mgr->vd_id, qos_pd_mgr->disk_id); } } + } } -static unsigned char ps3_qos_vd_notify_timeout(struct ps3_instance *instance) +static Bool ps3_qos_vd_notify_timeout(struct ps3_instance *instance) { struct ps3_qos_vd_context *qos_vd_ctx = NULL; - unsigned short i = 0; + U16 i = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - unsigned long timeout_jiffies = 0; - unsigned char notified = PS3_FALSE; + ULong timeout_jiffies = 0; + Bool notified = PS3_FALSE; for (i = 1; i <= instance->qos_context.max_vd_count; i++) { qos_vd_ctx = &instance->qos_context.vd_ctx; qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[i]; - timeout_jiffies = qos_vd_mgr->last_sched_jiffies + - PS3_QOS_WAITQ_TIMEOUT * HZ; + timeout_jiffies = qos_vd_mgr->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; if (time_after(jiffies, timeout_jiffies)) { if (ps3_qos_single_vd_notify(qos_vd_ctx, qos_vd_mgr)) { notified = PS3_TRUE; - LOG_INFO( - "awake qos vd quota waitq by poll. host_no:%u vid:%u\n", + LOG_INFO("awake qos vd quota waitq by poll. host_no:%u vid:%u\n", PS3_HOST(instance), qos_vd_mgr->id); } + } + } return notified; } -static unsigned char ps3_qos_tg_notify_timeout(struct ps3_instance *instance) +static Bool ps3_qos_tg_notify_timeout(struct ps3_instance *instance) { struct ps3_qos_tg_context *qos_tg_ctx = NULL; - unsigned char notified = PS3_FALSE; - unsigned long timeout_jiffies = 0; + Bool notified = PS3_FALSE; + ULong timeout_jiffies = 0; qos_tg_ctx = &instance->qos_context.tg_ctx; - timeout_jiffies = - qos_tg_ctx->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; + timeout_jiffies = qos_tg_ctx->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; if (qos_tg_ctx->total_wait_cmd_cnt && - ps3_qos_tag_rsc_available(instance) && - time_after(jiffies, timeout_jiffies)) { + ps3_qos_tag_rsc_available(instance) && + time_after(jiffies, timeout_jiffies)) { queue_work(qos_tg_ctx->work_queue, &qos_tg_ctx->resend_work); notified = PS3_TRUE; LOG_INFO("awake qos cmd waitq by poll. host_no:%u\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } return notified; @@ -3024,15 +2814,17 @@ static unsigned char ps3_qos_tg_notify_timeout(struct ps3_instance *instance) void ps3_hba_qos_waitq_poll(struct ps3_instance *instance) { if (!ps3_qos_tg_notify_timeout(instance)) { - if (!ps3_qos_vd_notify_timeout(instance)) + if (!ps3_qos_vd_notify_timeout(instance)) { ps3_qos_pd_notify_timeout(instance); + } } } void ps3_qos_waitq_poll(struct ps3_instance *instance) { - if (!PS3_QOS_INITED(instance)) + if (!PS3_QOS_INITED(instance)) { return; + } if (++instance->qos_context.poll_count == PS3_QOS_POLL_INTERVAL) { instance->qos_context.poll_count = 0; @@ -3046,25 +2838,21 @@ static void ps3_hba_qos_reset(struct ps3_instance *instance) struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_qos_tg_context *qos_tg_ctx = NULL; - unsigned short i = 0; + U16 i = 0; struct ps3_pd_entry *pd_entry = NULL; qos_tg_ctx = &instance->qos_context.tg_ctx; - ps3_atomic_set(&qos_tg_ctx->mgr_free_cnt, - qos_tg_ctx->mgr_exclusive_cnt); + ps3_atomic_set(&qos_tg_ctx->mgr_free_cnt, qos_tg_ctx->mgr_exclusive_cnt); ps3_atomic_set(&qos_tg_ctx->mgr_share_used, 0); ps3_atomic_set(&qos_tg_ctx->share_free_cnt, qos_tg_ctx->share); for (i = 1; i <= qos_ctx->max_vd_count; i++) { qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[i]; if (i == qos_ctx->max_vd_count) { - ps3_atomic_set(&qos_vd_mgr->vd_quota, - g_ps3_qos_vd_quota); - ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, - g_ps3_qos_jbod_exclusive); + ps3_atomic_set(&qos_vd_mgr->vd_quota, g_ps3_qos_vd_quota); + ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, g_ps3_qos_jbod_exclusive); } else { - ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, - g_ps3_qos_vd_exclusive); + ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, g_ps3_qos_vd_exclusive); } ps3_atomic_set(&qos_vd_mgr->share_cmd_used, 0); } @@ -3073,73 +2861,72 @@ static void ps3_hba_qos_reset(struct ps3_instance *instance) for (i = 1; i <= qos_ctx->max_pd_count; i++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, i); if (ps3_atomic_read(&qos_pd_mgr->valid) == 1) { - pd_entry = - ps3_dev_mgr_lookup_pd_info_by_id(instance, i); - if (pd_entry != NULL) + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, i); + if (pd_entry != NULL) { ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); + } } } } void ps3_qos_close(struct ps3_instance *instance) { - if (!PS3_QOS_INITED(instance)) + if (!PS3_QOS_INITED(instance)) { return; + } ps3_qos_wait_io_end(instance); - instance->qos_context.opts.qos_waitq_clear( - instance, PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR)); + instance->qos_context.opts.qos_waitq_clear(instance, + PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR)); LOG_INFO("qos close. host_no:%u\n", PS3_HOST(instance)); } void ps3_qos_open(struct ps3_instance *instance) { - if (!PS3_QOS_INITED(instance)) + if (!PS3_QOS_INITED(instance)) { return; + } instance->qos_context.opts.qos_reset(instance); } -static unsigned char ps3_qos_waitq_flag_get(struct ps3_qos_softq_mgr *softq_mgr) +static U8 ps3_qos_waitq_flag_get(struct ps3_qos_softq_mgr *softq_mgr) { - unsigned char waitq_flag = 0; - + U8 waitq_flag = 0; switch (softq_mgr->id) { - case PS3_QOS_MGRQ: - waitq_flag = PS3_QOS_CMD_IN_MGR; - break; - case PS3_QOS_CMDQ_0: - waitq_flag = PS3_QOS_CMD_IN_CMDQ0; - break; - case PS3_QOS_CMDQ_1: - waitq_flag = PS3_QOS_CMD_IN_CMDQ1; - break; - case PS3_QOS_CMDQ_2: - waitq_flag = PS3_QOS_CMD_IN_CMDQ2; - break; - case PS3_QOS_CMDQ_3: - waitq_flag = PS3_QOS_CMD_IN_CMDQ3; - break; - default: - LOG_ERROR_IN_IRQ(softq_mgr->instance, - "invalid softq id. host_no:%u id:%u\n", - PS3_HOST(softq_mgr->instance), softq_mgr->id); - } + case PS3_QOS_MGRQ: + waitq_flag = PS3_QOS_CMD_IN_MGR; + break; + case PS3_QOS_CMDQ_0: + waitq_flag = PS3_QOS_CMD_IN_CMDQ0; + break; + case PS3_QOS_CMDQ_1: + waitq_flag = PS3_QOS_CMD_IN_CMDQ1; + break; + case PS3_QOS_CMDQ_2: + waitq_flag = PS3_QOS_CMD_IN_CMDQ2; + break; + case PS3_QOS_CMDQ_3: + waitq_flag = PS3_QOS_CMD_IN_CMDQ3; + break; + default: + LOG_ERROR_IN_IRQ(softq_mgr->instance, "invalid softq id. host_no:%u id:%u\n", + PS3_HOST(softq_mgr->instance), softq_mgr->id); + } return waitq_flag; } -static unsigned char ps3_qos_cq_rc_get(struct ps3_cmd *cmd, - struct ps3_qos_softq_mgr *softq_mgr, - struct qos_wait_queue *wait_q) +static Bool ps3_qos_cq_rc_get(struct ps3_cmd *cmd, + struct ps3_qos_softq_mgr *softq_mgr, struct qos_wait_queue *wait_q) { - unsigned char can_get = PS3_FALSE; - unsigned long flag = 0; - - if (ps3_atomic_dec_return(&softq_mgr->free_cnt) >= 0) + Bool can_get = PS3_FALSE; + ULong flag = 0; + if (ps3_atomic_dec_return(&softq_mgr->free_cnt) >= 0) { can_get = PS3_TRUE; - else + } else { ps3_atomic_inc(&softq_mgr->free_cnt); + } if (!can_get) { ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); @@ -3148,28 +2935,26 @@ static unsigned char ps3_qos_cq_rc_get(struct ps3_cmd *cmd, softq_mgr->total_wait_cmd_cnt++; cmd->qos_waitq_flag = ps3_qos_waitq_flag_get(softq_mgr); ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); - LOG_DEBUG("insert qos cq waitq.host_no:%u:t_id:0x%llx\n" - "\tCFID:%u que_id:%u diskid:%u waitq:%u\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - softq_mgr->id, cmd->io_attr.disk_id, wait_q->count); + LOG_DEBUG("insert qos cq waitq.host_no:%u:t_id:0x%llx " + "CFID:%u que_id:%u diskid:%u waitq:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, softq_mgr->id, + cmd->io_attr.disk_id, wait_q->count); } return can_get; } -static struct qos_wait_queue * -ps3_qos_cq_waitq_get(struct ps3_cmd *cmd, struct ps3_qos_softq_mgr *softq_mgr) +static struct qos_wait_queue* ps3_qos_cq_waitq_get(struct ps3_cmd *cmd, + struct ps3_qos_softq_mgr *softq_mgr) { - unsigned short waitq_id = 0; + U16 waitq_id = 0; struct qos_wait_queue *waitq = NULL; - if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - waitq_id = get_offset_of_vdid( - PS3_VDID_OFFSET(cmd->instance), - PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); + waitq_id = get_offset_of_vdid(PS3_VDID_OFFSET(cmd->instance), + PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); } else { - waitq_id = cmd->instance->qos_context.max_vd_count; + waitq_id = cmd->instance->qos_context.max_vd_count; } waitq = &softq_mgr->waitqs[waitq_id]; } else { @@ -3179,17 +2964,18 @@ ps3_qos_cq_waitq_get(struct ps3_cmd *cmd, struct ps3_qos_softq_mgr *softq_mgr) return waitq; } -static unsigned char ps3_qos_cq_rc_check(struct ps3_cmd *cmd, - struct ps3_qos_softq_mgr *softq_mgr) +static Bool ps3_qos_cq_rc_check(struct ps3_cmd *cmd, + struct ps3_qos_softq_mgr *softq_mgr) { - unsigned char can_get = PS3_FALSE; - unsigned long flag = 0; + Bool can_get = PS3_FALSE; + ULong flag = 0; struct qos_wait_queue *waitq = NULL; waitq = ps3_qos_cq_waitq_get(cmd, softq_mgr); if (likely(softq_mgr->total_wait_cmd_cnt == 0)) { can_get = ps3_qos_cq_rc_get(cmd, softq_mgr, waitq); } else { + INJECT_START(PS3_ERR_IJ_QOS_WAIT_SOFT_WAITQ_CLEAR, cmd->instance) ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); if (softq_mgr->total_wait_cmd_cnt > 0) { list_add_tail(&cmd->qos_list, &waitq->wait_list); @@ -3198,12 +2984,10 @@ static unsigned char ps3_qos_cq_rc_check(struct ps3_cmd *cmd, cmd->qos_waitq_flag = ps3_qos_waitq_flag_get(softq_mgr); ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); can_get = PS3_FALSE; - LOG_DEBUG( - "insert qos cq waitq.host_no:%u:t_id:0x%llx CFID:%u\n" - "\tque_id:%u diskid:%u waitq:%u\n", - PS3_HOST(cmd->instance), cmd->trace_id, - cmd->index, softq_mgr->id, cmd->io_attr.disk_id, - waitq->count); + LOG_DEBUG("insert qos cq waitq.host_no:%u:t_id:0x%llx CFID:%u " + "que_id:%u diskid:%u waitq:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, softq_mgr->id, + cmd->io_attr.disk_id, waitq->count); } else { ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); can_get = ps3_qos_cq_rc_get(cmd, softq_mgr, waitq); @@ -3213,36 +2997,36 @@ static unsigned char ps3_qos_cq_rc_check(struct ps3_cmd *cmd, return can_get; } -static inline struct ps3_qos_softq_mgr * -ps3_qos_cmdq_mgr_get(struct ps3_instance *instance, unsigned short index) +static inline struct ps3_qos_softq_mgr *ps3_qos_cmdq_mgr_get(struct ps3_instance *instance, U16 index) { return &instance->qos_context.cq_ctx.cmdqs[index]; } static void ps3_qos_update_target_cmdq(struct ps3_cmd *cmd) { - unsigned char que_id = 0; - unsigned char qmask = 0; + U8 que_id = 0; + U8 qmask = 0; cmd->cmdq_count = 0; qmask = cmd->cmd_word.qMask; while (que_id < cmd->instance->ctrl_info.vdQueueNum) { if (qmask & (1 << que_id)) { cmd->cmdq_info[cmd->cmdq_count].que_id = que_id; - if (++cmd->cmdq_count == PS3_QOS_MAX_CMDQ_ONE_CMD) + if (++cmd->cmdq_count == PS3_QOS_MAX_CMDQ_ONE_CMD) { break; + } } que_id++; } } -static unsigned char ps3_qos_cq_decision(struct ps3_cmd *cmd) +static Bool ps3_qos_cq_decision(struct ps3_cmd *cmd) { - unsigned char can_get = PS3_TRUE; + Bool can_get = PS3_TRUE; struct ps3_instance *instance = cmd->instance; struct ps3_qos_softq_mgr *softq_mgr = NULL; - unsigned short cmdq_index = 0; - unsigned char i = 0; + U16 cmdq_index = 0; + U8 i = 0; if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_MGR_PRO); @@ -3250,8 +3034,7 @@ static unsigned char ps3_qos_cq_decision(struct ps3_cmd *cmd) can_get = ps3_qos_cq_rc_check(cmd, softq_mgr); PS3_QOS_STAT_END(cmd->instance, cmd, PS3_QOS_MGR_PRO); if (!can_get) { - PS3_QOS_STAT_START(cmd->instance, cmd, - PS3_QOS_MGR_QUEUE); + PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_MGR_QUEUE); } } else { PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_CMD_PRO); @@ -3262,29 +3045,27 @@ static unsigned char ps3_qos_cq_decision(struct ps3_cmd *cmd) can_get = ps3_qos_cq_rc_check(cmd, softq_mgr); if (can_get) { cmd->cmdq_info[i].get_rc = PS3_TRUE; - } else { + } else { can_get = PS3_FALSE; break; } } PS3_QOS_STAT_END(cmd->instance, cmd, PS3_QOS_CMD_PRO); if (!can_get) { - PS3_QOS_STAT_START(cmd->instance, cmd, - PS3_QOS_CMD_QUEUE); + PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_CMD_QUEUE); } } - return can_get; + return can_get; } -unsigned char ps3_raid_qos_decision(struct ps3_cmd *cmd) +Bool ps3_raid_qos_decision(struct ps3_cmd *cmd) { - unsigned char can_get = PS3_FALSE; - + Bool can_get = PS3_FALSE; if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { can_get = ps3_qos_pd_quota_decision(cmd); if (!can_get || - cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) { + cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) { goto _out; } } @@ -3295,31 +3076,29 @@ unsigned char ps3_raid_qos_decision(struct ps3_cmd *cmd) static void ps3_qos_update_cmdq_rc(struct ps3_cmd *cmd) { - unsigned char i = 0; - unsigned char index = 0; + U8 i = 0; + U8 index = 0; struct ps3_qos_softq_mgr *softq_mgr = NULL; - int cmdq_free = 0; + S32 cmdq_free = 0; for (i = 0; i < cmd->cmdq_count; i++) { index = cmd->cmdq_info[i].que_id; softq_mgr = ps3_qos_cmdq_mgr_get(cmd->instance, index); cmdq_free = ps3_atomic_inc_return(&softq_mgr->free_cnt); - LOG_DEBUG( - "update cmdq rc. host_no:%u t_id:0x%llx CFID:%u rc[%u,%d] dev_t:%u\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - softq_mgr->id, cmdq_free, cmd->io_attr.dev_type); + LOG_DEBUG("update cmdq rc. host_no:%u t_id:0x%llx CFID:%u rc[%u,%d] dev_t:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, softq_mgr->id, cmdq_free, + cmd->io_attr.dev_type); } } static void ps3_qos_update_mgrq_rc(struct ps3_cmd *cmd) { - struct ps3_qos_cq_context *qos_cq_ctx = - &cmd->instance->qos_context.cq_ctx; - int free_cnt = 0; + struct ps3_qos_cq_context *qos_cq_ctx = &cmd->instance->qos_context.cq_ctx; + S32 free_cnt = 0; free_cnt = ps3_atomic_inc_return(&qos_cq_ctx->mgrq.free_cnt); LOG_DEBUG("update mgrq rc. host_no:%u t_id:0x%llx CFID:%u rc:%d\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, free_cnt); + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, free_cnt); } static void ps3_raid_qos_cmd_update(struct ps3_cmd *cmd) @@ -3334,17 +3113,16 @@ static void ps3_raid_qos_cmd_update(struct ps3_cmd *cmd) void ps3_qos_mgrq_resend(struct ps3_qos_softq_mgr *softq_mgr) { - int ret = PS3_SUCCESS; - unsigned long flag = 0; + S32 ret = PS3_SUCCESS; + ULong flag = 0; struct ps3_cmd *cmd = NULL; struct ps3_instance *instance = softq_mgr->instance; struct qos_wait_queue *waitq = &softq_mgr->waitqs[0]; - unsigned char waitq_cleared = PS3_FALSE; + Bool waitq_cleared = PS3_FALSE; ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); while (waitq->count > 0) { - cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, - qos_list); + cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); if (ps3_atomic_dec_return(&softq_mgr->free_cnt) < 0) { ps3_atomic_inc(&softq_mgr->free_cnt); break; @@ -3359,20 +3137,19 @@ void ps3_qos_mgrq_resend(struct ps3_qos_softq_mgr *softq_mgr) ps3_qos_cmd_resend_fail(cmd, ret); } else { cmd->qos_waitq_flag = 0; - LOG_DEBUG( - "raid qos mgr waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - cmd->cmd_word.type); + LOG_DEBUG("raid qos mgr waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, cmd->cmd_word.type); } } - if (softq_mgr->total_wait_cmd_cnt == 0) + if (softq_mgr->total_wait_cmd_cnt == 0) { waitq_cleared = PS3_TRUE; + } ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); if (waitq_cleared) { LOG_DEBUG("hno:%u resend all mgrq waited cmds\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } softq_mgr->last_sched_jiffies = jiffies; } @@ -3380,17 +3157,17 @@ void ps3_qos_mgrq_resend(struct ps3_qos_softq_mgr *softq_mgr) static void ps3_qos_mgrq_resend_work(struct work_struct *work) { struct ps3_qos_softq_mgr *softq_mgr = - ps3_container_of(work, struct ps3_qos_softq_mgr, resend_work); + ps3_container_of(work, struct ps3_qos_softq_mgr, resend_work); ps3_qos_mgrq_resend(softq_mgr); + return; } -static int ps3_qos_mgrq_init(struct ps3_instance *instance, - struct ps3_qos_softq_mgr *softq_mgr) +static S32 ps3_qos_mgrq_init(struct ps3_instance *instance, struct ps3_qos_softq_mgr *softq_mgr) { - int ret = PS3_SUCCESS; - unsigned int mgrq_depth = 0; - unsigned int high_mgr_cmd = 0; - char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = { 0 }; + S32 ret = PS3_SUCCESS; + U32 mgrq_depth = 0; + U32 high_mgr_cmd = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; if (!ps3_ioc_multi_func_support(instance)) high_mgr_cmd = PS3_QOS_HIGH_PRI_MGR_CMD_COUNT; @@ -3401,8 +3178,8 @@ static int ps3_qos_mgrq_init(struct ps3_instance *instance, if (mgrq_depth <= high_mgr_cmd) { ret = -PS3_FAILED; LOG_ERROR("hno:%u:mgrq_depth is too small func:%u depth:%u\n", - PS3_HOST(softq_mgr->instance), - ps3_get_pci_function(instance->pdev), mgrq_depth); + PS3_HOST(softq_mgr->instance), ps3_get_pci_function(instance->pdev), + mgrq_depth); goto _out; } @@ -3411,12 +3188,12 @@ static int ps3_qos_mgrq_init(struct ps3_instance *instance, ps3_spin_lock_init(&softq_mgr->rc_lock); ps3_atomic_set(&softq_mgr->free_cnt, mgrq_depth - high_mgr_cmd); softq_mgr->waitq_cnt = 1; - softq_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc( - instance, sizeof(struct qos_wait_queue)); + softq_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc(instance, sizeof(struct qos_wait_queue)); + INJECT_START(PS3_ERR_IJ_QOS_MGRQ_INIT_FAIL_1, softq_mgr) if (softq_mgr->waitqs == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for waitqs\n", - PS3_HOST(softq_mgr->instance)); - ret = -PS3_FAILED; + PS3_HOST(softq_mgr->instance)); + ret = -PS3_FAILED; goto _out; } INIT_LIST_HEAD(&softq_mgr->waitqs[0].wait_list); @@ -3425,8 +3202,9 @@ static int ps3_qos_mgrq_init(struct ps3_instance *instance, softq_mgr->total_wait_cmd_cnt = 0; softq_mgr->last_sched_jiffies = 0; snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "mgrq_wq_f%u", - ps3_get_pci_function(instance->pdev)); + ps3_get_pci_function(instance->pdev)); softq_mgr->work_queue = create_singlethread_workqueue(workq_name); + INJECT_START(PS3_ERR_IJ_QOS_MGRQ_INIT_FAIL_2, softq_mgr) if (softq_mgr->work_queue == NULL) { LOG_ERROR("qos mgr workq create failed\n"); ret = -PS3_FAILED; @@ -3434,8 +3212,8 @@ static int ps3_qos_mgrq_init(struct ps3_instance *instance, } LOG_INFO("hno:%u:mgrq init success func:%u depth:%u\n", - PS3_HOST(softq_mgr->instance), - ps3_get_pci_function(instance->pdev), mgrq_depth); + PS3_HOST(softq_mgr->instance), ps3_get_pci_function(instance->pdev), + mgrq_depth); goto _out; _release_waitq: ps3_vfree(instance, softq_mgr->waitqs); @@ -3444,12 +3222,11 @@ static int ps3_qos_mgrq_init(struct ps3_instance *instance, return ret; } -static unsigned char ps3_qos_softq_notify(struct ps3_qos_softq_mgr *softq_mgr) +static Bool ps3_qos_softq_notify(struct ps3_qos_softq_mgr *softq_mgr) { - unsigned char notified = PS3_FALSE; - + Bool notified = PS3_FALSE; if (softq_mgr->total_wait_cmd_cnt > 0 && - ps3_atomic_read(&softq_mgr->free_cnt) > 0) { + ps3_atomic_read(&softq_mgr->free_cnt) > 0) { queue_work(softq_mgr->work_queue, &softq_mgr->resend_work); notified = PS3_TRUE; } @@ -3457,10 +3234,10 @@ static unsigned char ps3_qos_softq_notify(struct ps3_qos_softq_mgr *softq_mgr) return notified; } -static unsigned char ps3_qos_cq_notify(struct ps3_instance *instance) +static Bool ps3_qos_cq_notify(struct ps3_instance *instance) { - unsigned char i = 0; - unsigned char notified = PS3_FALSE; + U8 i = 0; + Bool notified = PS3_FALSE; struct ps3_qos_cq_context *qos_cq_ctx = &instance->qos_context.cq_ctx; struct ps3_qos_softq_mgr *softq_mgr = NULL; @@ -3469,8 +3246,9 @@ static unsigned char ps3_qos_cq_notify(struct ps3_instance *instance) for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { softq_mgr = ps3_qos_cmdq_mgr_get(instance, i); - if (ps3_qos_softq_notify(softq_mgr)) + if (ps3_qos_softq_notify(softq_mgr)) { notified = PS3_TRUE; + } } return notified; @@ -3478,15 +3256,14 @@ static unsigned char ps3_qos_cq_notify(struct ps3_instance *instance) void ps3_raid_qos_waitq_notify(struct ps3_instance *instance) { - if (!ps3_qos_cq_notify(instance)) + if (!ps3_qos_cq_notify(instance)) { ps3_qos_pd_notify(instance); + } } -static unsigned char -ps3_qos_cmdq_resend_judge(struct ps3_qos_softq_mgr *softq_mgr, - struct ps3_cmd *cmd) +static Bool ps3_qos_cmdq_resend_judge(struct ps3_qos_softq_mgr *softq_mgr, struct ps3_cmd *cmd) { - unsigned char can_get = PS3_TRUE; + Bool can_get = PS3_TRUE; struct ps3_instance *instance = NULL; struct ps3_qos_softq_mgr *next_softq_mgr = NULL; @@ -3496,44 +3273,43 @@ ps3_qos_cmdq_resend_judge(struct ps3_qos_softq_mgr *softq_mgr, } else { if (cmd->cmdq_info[0].que_id == softq_mgr->id) { cmd->cmdq_info[0].get_rc = PS3_TRUE; - next_softq_mgr = ps3_qos_cmdq_mgr_get( - instance, cmd->cmdq_info[1].que_id); + next_softq_mgr = ps3_qos_cmdq_mgr_get(instance, cmd->cmdq_info[1].que_id); can_get = ps3_qos_cq_rc_check(cmd, next_softq_mgr); - if (can_get) + if (can_get) { cmd->cmdq_info[1].get_rc = PS3_TRUE; + } } else { cmd->cmdq_info[1].get_rc = PS3_TRUE; } } - if (can_get) + if (can_get) { PS3_QOS_STAT_END(instance, cmd, PS3_QOS_CMD_QUEUE); + } - LOG_DEBUG( - "raid resend cmdq judge:host_no:%u t_id:0x%llx CFID:%u cmdq_id:%u ret:%u\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - softq_mgr->id, can_get); + LOG_DEBUG("raid resend cmdq judge:host_no:%u t_id:0x%llx CFID:%u cmdq_id:%u ret:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, softq_mgr->id, can_get); return can_get; } static void ps3_qos_resend_multi_cmd(struct ps3_qos_softq_mgr *softq_mgr, - struct qos_wait_queue *waitq, int count) + struct qos_wait_queue *waitq, S32 count) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_instance *instance = softq_mgr->instance; - unsigned int can_send = 0; + U32 can_send = 0; can_send = PS3_MIN(ps3_atomic_read(&softq_mgr->free_cnt), count); - while (waitq->count > 0 && can_send > 0) { - cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, - qos_list); + while(waitq->count > 0 && can_send > 0) { + cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); list_del(&cmd->qos_list); softq_mgr->total_wait_cmd_cnt--; waitq->count--; - if (ps3_qos_vd_seq_check(cmd)) + if (ps3_qos_vd_seq_check(cmd)) { continue; + } can_send--; ps3_atomic_dec(&softq_mgr->free_cnt); if (ps3_qos_cmdq_resend_judge(softq_mgr, cmd)) { @@ -3543,10 +3319,8 @@ static void ps3_qos_resend_multi_cmd(struct ps3_qos_softq_mgr *softq_mgr, ps3_qos_cmd_resend_fail(cmd, ret); } else { cmd->qos_waitq_flag = 0; - LOG_DEBUG( - "raid qos cmdq waitq resend:host_no:%u t_id:0x%llx CFID:%u qid:%u\n", - PS3_HOST(instance), cmd->trace_id, - cmd->index, waitq->id); + LOG_DEBUG("raid qos cmdq waitq resend:host_no:%u t_id:0x%llx CFID:%u qid:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, waitq->id); } } } @@ -3554,21 +3328,21 @@ static void ps3_qos_resend_multi_cmd(struct ps3_qos_softq_mgr *softq_mgr, static void ps3_qos_cmdq_resend(struct ps3_qos_softq_mgr *softq_mgr) { - unsigned long flag = 0; + ULong flag = 0; struct ps3_instance *instance = softq_mgr->instance; struct qos_wait_queue *waitq = NULL; - unsigned short cur_que_id = softq_mgr->poll_que_id; + U16 cur_que_id = softq_mgr->poll_que_id; ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); - while (ps3_atomic_read(&softq_mgr->free_cnt) > 0 && - softq_mgr->total_wait_cmd_cnt > 0) { + while (ps3_atomic_read(&softq_mgr->free_cnt) > 0 + && softq_mgr->total_wait_cmd_cnt > 0) { waitq = &softq_mgr->waitqs[cur_que_id]; if (waitq->count > 0) { - ps3_qos_resend_multi_cmd(softq_mgr, waitq, - softq_mgr->poll_cmd_cnt); + ps3_qos_resend_multi_cmd(softq_mgr, waitq, softq_mgr->poll_cmd_cnt); } - if (++cur_que_id > instance->qos_context.max_vd_count) + if (++cur_que_id > instance->qos_context.max_vd_count) { cur_que_id = 1; + } } ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); softq_mgr->poll_que_id = cur_que_id; @@ -3579,37 +3353,36 @@ static void ps3_qos_cmdq_resend(struct ps3_qos_softq_mgr *softq_mgr) static void ps3_qos_cmdq_resend_work(struct work_struct *work) { struct ps3_qos_softq_mgr *softq_mgr = - ps3_container_of(work, struct ps3_qos_softq_mgr, resend_work); + ps3_container_of(work, struct ps3_qos_softq_mgr, resend_work); ps3_qos_cmdq_resend(softq_mgr); + return; } -static int ps3_qos_cmdq_init(struct ps3_instance *instance, - struct ps3_qos_softq_mgr *softq_mgr) +static S32 ps3_qos_cmdq_init(struct ps3_instance *instance, struct ps3_qos_softq_mgr *softq_mgr) { - int ret = PS3_SUCCESS; - unsigned short i = 0; + S32 ret = PS3_SUCCESS; + U16 i = 0; struct qos_wait_queue *waitq = NULL; - char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = { 0 }; - unsigned int cmdq_depth = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; + U32 cmdq_depth = 0; cmdq_depth = instance->qos_context.cq_ctx.cmdq_depth; softq_mgr->instance = instance; ps3_spin_lock_init(&softq_mgr->rc_lock); ps3_atomic_set(&softq_mgr->free_cnt, cmdq_depth); softq_mgr->waitq_cnt = instance->qos_context.max_vd_count + 1; - softq_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc( - instance, softq_mgr->waitq_cnt * sizeof(struct qos_wait_queue)); + softq_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc(instance, + softq_mgr->waitq_cnt * sizeof(struct qos_wait_queue)); + INJECT_START(PS3_ERR_IJ_QOS_CMDQ_INIT_FAIL_1, softq_mgr) if (softq_mgr->waitqs == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for waitqs\n", - PS3_HOST(instance)); - ret = -PS3_FAILED; + PS3_HOST(instance)); + ret = -PS3_FAILED; goto _out; } - memset(softq_mgr->waitqs, 0, - (instance->qos_context.max_vd_count + 1) * - sizeof(struct qos_wait_queue)); + memset(softq_mgr->waitqs, 0, (instance->qos_context.max_vd_count + 1) * sizeof(struct qos_wait_queue)); for (i = 1; i < softq_mgr->waitq_cnt; i++) { - waitq = &softq_mgr->waitqs[i]; + waitq = &softq_mgr->waitqs[i]; waitq->id = i; INIT_LIST_HEAD(&waitq->wait_list); waitq->count = 0; @@ -3621,8 +3394,9 @@ static int ps3_qos_cmdq_init(struct ps3_instance *instance, softq_mgr->total_wait_cmd_cnt = 0; softq_mgr->last_sched_jiffies = 0; snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "cmdq_wq_f%u_%u", - ps3_get_pci_function(instance->pdev), softq_mgr->id); + ps3_get_pci_function(instance->pdev), softq_mgr->id); softq_mgr->work_queue = create_singlethread_workqueue(workq_name); + INJECT_START(PS3_ERR_IJ_QOS_CMDQ_INIT_FAIL_2, softq_mgr) if (softq_mgr->work_queue == NULL) { LOG_ERROR("qos mgr workq create failed\n"); ret = -PS3_FAILED; @@ -3630,9 +3404,8 @@ static int ps3_qos_cmdq_init(struct ps3_instance *instance, } LOG_INFO("hno:%u:cmdq init success func:%u depth:%u id:%u\n", - PS3_HOST(softq_mgr->instance), - ps3_get_pci_function(instance->pdev), cmdq_depth, - softq_mgr->id); + PS3_HOST(softq_mgr->instance), ps3_get_pci_function(instance->pdev), + cmdq_depth, softq_mgr->id); goto _out; _release_waitq: ps3_vfree(instance, softq_mgr->waitqs); @@ -3641,8 +3414,7 @@ static int ps3_qos_cmdq_init(struct ps3_instance *instance, return ret; } -static void ps3_qos_softq_exit(struct ps3_instance *instance, - struct ps3_qos_softq_mgr *softq_mgr) +static void ps3_qos_softq_exit(struct ps3_instance *instance, struct ps3_qos_softq_mgr *softq_mgr) { cancel_work_sync(&softq_mgr->resend_work); flush_workqueue(softq_mgr->work_queue); @@ -3651,33 +3423,34 @@ static void ps3_qos_softq_exit(struct ps3_instance *instance, softq_mgr->waitqs = NULL; } -static int ps3_qos_cq_context_init(struct ps3_instance *instance) +static S32 ps3_qos_cq_context_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned short i = 0; - unsigned short j = 0; + S32 ret = PS3_SUCCESS; + U16 i = 0; + U16 j = 0; struct ps3_qos_cq_context *qos_cq_ctx = NULL; struct ps3_qos_softq_mgr *softq_mgr = NULL; - unsigned long long mgrq_depth = 0; - unsigned long long cmdq_depth = 0; + U64 mgrq_depth = 0; + U64 cmdq_depth = 0; qos_cq_ctx = &instance->qos_context.cq_ctx; ps3_mgrq_depth_get(instance, &mgrq_depth); + INJECT_START(PS3_ERR_IJ_QOS_FORCE_MGRQ_ZERO_DEPTH, &mgrq_depth) if (mgrq_depth == 0) { ret = -PS3_FAILED; LOG_ERROR("hno:%u:mgrq_depth is invalid func:%u\n", - PS3_HOST(instance), - ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance),ps3_get_pci_function(instance->pdev)); goto _out; } qos_cq_ctx->mgrq_depth = mgrq_depth; ps3_cmdq_depth_get(instance, &cmdq_depth); + INJECT_START(PS3_ERR_IJ_QOS_FORCE_CMDQ_ZERO_DEPTH, &cmdq_depth) if (cmdq_depth == 0) { - ret = -PS3_FAILED; + ret = -PS3_FAILED; LOG_ERROR("hno:%u:cmdq_depth is invalid func:%u\n", - PS3_HOST(instance), - ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), + ps3_get_pci_function(instance->pdev)); goto _out; } qos_cq_ctx->cmdq_depth = cmdq_depth; @@ -3688,12 +3461,11 @@ static int ps3_qos_cq_context_init(struct ps3_instance *instance) } qos_cq_ctx->cmdq_cnt = instance->ctrl_info.vdQueueNum; - qos_cq_ctx->cmdqs = (struct ps3_qos_softq_mgr *)ps3_vzalloc( - instance, - qos_cq_ctx->cmdq_cnt * sizeof(struct ps3_qos_softq_mgr)); + qos_cq_ctx->cmdqs = (struct ps3_qos_softq_mgr *)ps3_vzalloc(instance, + qos_cq_ctx->cmdq_cnt * sizeof(struct ps3_qos_softq_mgr)); if (qos_cq_ctx->cmdqs == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for cmdqs\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto _mgrq_exit; } @@ -3708,7 +3480,7 @@ static int ps3_qos_cq_context_init(struct ps3_instance *instance) } LOG_INFO("hno:%u: qos cq context init success cmdq_cnt:%u\n", - PS3_HOST(instance), qos_cq_ctx->cmdq_cnt); + PS3_HOST(instance), qos_cq_ctx->cmdq_cnt); goto _out; _cmdq_exit: for (j = 0; j < i; j++) { @@ -3726,7 +3498,7 @@ static int ps3_qos_cq_context_init(struct ps3_instance *instance) static void ps3_qos_cq_context_exit(struct ps3_instance *instance) { struct ps3_qos_cq_context *qos_cq_ctx = NULL; - unsigned short i = 0; + U16 i = 0; struct ps3_qos_softq_mgr *softq_mgr = NULL; qos_cq_ctx = &instance->qos_context.cq_ctx; @@ -3743,17 +3515,19 @@ static void ps3_qos_cq_context_exit(struct ps3_instance *instance) LOG_INFO("hno:%u: qos cq context exit success\n", PS3_HOST(instance)); } -int ps3_raid_qos_init(struct ps3_instance *instance) +S32 ps3_raid_qos_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; ret = ps3_qos_cq_context_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto _out; + } ret = ps3_qos_pd_context_init(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto _cq_ctx_exit; + } goto _out; _cq_ctx_exit: @@ -3762,12 +3536,11 @@ int ps3_raid_qos_init(struct ps3_instance *instance) return ret; } -static unsigned char ps3_qos_softq_abort(struct ps3_qos_softq_mgr *softq_mgr, - struct ps3_cmd *cmd, - unsigned char waitq_flag) +static Bool ps3_qos_softq_abort(struct ps3_qos_softq_mgr *softq_mgr, + struct ps3_cmd *cmd, U8 waitq_flag) { - unsigned long lock_flag = 0; - unsigned char found = PS3_FALSE; + ULong lock_flag = 0; + Bool found = PS3_FALSE; struct qos_wait_queue *waitq = NULL; waitq = ps3_qos_cq_waitq_get(cmd, softq_mgr); @@ -3785,53 +3558,52 @@ static unsigned char ps3_qos_softq_abort(struct ps3_qos_softq_mgr *softq_mgr, static void ps3_qos_peer_cmdq_rc_update(struct ps3_cmd *cmd) { - unsigned char i = 0; + U8 i = 0; struct ps3_qos_softq_mgr *softq_mgr = NULL; - for (i = 0; i < cmd->cmdq_count; i++) { if (cmd->cmdq_info[i].get_rc) { - softq_mgr = ps3_qos_cmdq_mgr_get( - cmd->instance, cmd->cmdq_info[i].que_id); + softq_mgr = ps3_qos_cmdq_mgr_get(cmd->instance, cmd->cmdq_info[i].que_id); ps3_atomic_inc(&softq_mgr->free_cnt); } } } -static unsigned char ps3_qos_cmdq_abort(struct ps3_cmd *cmd) +static Bool ps3_qos_cmdq_abort(struct ps3_cmd *cmd) { - unsigned char i = 0; - unsigned char waitq_flag = 0; - unsigned char found = PS3_FALSE; + U8 i = 0; + U8 waitq_flag = 0; + Bool found = PS3_FALSE; struct ps3_qos_softq_mgr *qos_softq_mgr = NULL; for (i = 0; i < cmd->cmdq_count; i++) { - qos_softq_mgr = ps3_qos_cmdq_mgr_get(cmd->instance, - cmd->cmdq_info[i].que_id); + qos_softq_mgr = ps3_qos_cmdq_mgr_get(cmd->instance, cmd->cmdq_info[i].que_id); waitq_flag = ps3_qos_waitq_flag_get(qos_softq_mgr); if (cmd->qos_waitq_flag == waitq_flag) { - found = ps3_qos_softq_abort(qos_softq_mgr, cmd, - waitq_flag); - if (found) + found = ps3_qos_softq_abort(qos_softq_mgr, cmd, waitq_flag); + if (found) { break; + } } } return found; } -unsigned char ps3_raid_qos_waitq_abort(struct ps3_cmd *cmd) +Bool ps3_raid_qos_waitq_abort(struct ps3_cmd *cmd) { - unsigned char found = PS3_FALSE; + Bool found = PS3_FALSE; struct ps3_qos_softq_mgr *softq_mgr = NULL; - if (cmd->qos_waitq_flag == 0) + if (cmd->qos_waitq_flag == 0) { goto _out; + } if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { if (cmd->qos_waitq_flag == PS3_QOS_CMD_IN_PD) { found = ps3_pd_quota_waiq_abort(cmd); - if (found) + if (found) { goto _out; + } } found = ps3_qos_cmdq_abort(cmd); @@ -3842,8 +3614,7 @@ unsigned char ps3_raid_qos_waitq_abort(struct ps3_cmd *cmd) } else { if (cmd->qos_waitq_flag == PS3_QOS_CMD_IN_MGR) { softq_mgr = &cmd->instance->qos_context.cq_ctx.mgrq; - found = ps3_qos_softq_abort(softq_mgr, cmd, - PS3_QOS_CMD_IN_MGR); + found = ps3_qos_softq_abort(softq_mgr, cmd, PS3_QOS_CMD_IN_MGR); } } @@ -3852,51 +3623,45 @@ unsigned char ps3_raid_qos_waitq_abort(struct ps3_cmd *cmd) } static void ps3_qos_mgrq_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, - int resp_status) + struct ps3_scsi_priv_data *priv_data, S32 resp_status) { struct ps3_qos_softq_mgr *softq_mgr = NULL; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct qos_wait_queue *waitq = NULL; - unsigned long flag = 0; + ULong flag = 0; softq_mgr = &instance->qos_context.cq_ctx.mgrq; waitq = &softq_mgr->waitqs[0]; ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); if (waitq->count > 0) { - list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, - qos_list) { + list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, qos_list) { if (priv_data == NULL || - priv_data == scsi_device_private_data(cmd->scmd)) { - LOG_DEBUG( - "qos clean mgrq. hno:%u t_id:0x%llx CFID:%d\n", - PS3_HOST(instance), cmd->trace_id, - cmd->index); + priv_data == scsi_device_private_data(cmd->scmd)) { + LOG_DEBUG("qos clean mgrq. hno:%u t_id:0x%llx CFID:%d\n", + PS3_HOST(instance), cmd->trace_id, cmd->index); list_del(&cmd->qos_list); waitq->count--; softq_mgr->total_wait_cmd_cnt--; - ps3_scsih_drv_io_reply_scsi( - cmd->scmd, cmd, resp_status, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); } } } ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); - if (priv_data == NULL) + if (priv_data == NULL) { cancel_work_sync(&softq_mgr->resend_work); + } } -static void ps3_qos_cmdq_clean(struct ps3_instance *instance, - unsigned short disk_id, - struct ps3_scsi_priv_data *priv_data, - int resp_status) +static void ps3_qos_cmdq_clean(struct ps3_instance *instance, U16 disk_id, + struct ps3_scsi_priv_data *priv_data, S32 resp_status) { - unsigned char i = 0; + U8 i = 0; struct ps3_qos_softq_mgr *softq_mgr = NULL; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct qos_wait_queue *waitq = NULL; - unsigned long flag = 0; + ULong flag = 0; struct ps3_qos_cq_context *qos_cq_ctx = &instance->qos_context.cq_ctx; for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { @@ -3904,24 +3669,16 @@ static void ps3_qos_cmdq_clean(struct ps3_instance *instance, waitq = &softq_mgr->waitqs[disk_id]; if (waitq->count > 0) { ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); - list_for_each_entry_safe(cmd, cmd_next, - &waitq->wait_list, qos_list) { + list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, qos_list) { if (priv_data == NULL || - priv_data == scsi_device_private_data( - cmd->scmd)) { - LOG_DEBUG( - "qos clean cmdq. hno:%u t_id:0x%llx CFID:%d cmdq:%u\n", - PS3_HOST(instance), - cmd->trace_id, cmd->index, - softq_mgr->id); + priv_data == scsi_device_private_data(cmd->scmd)) { + LOG_DEBUG("qos clean cmdq. hno:%u t_id:0x%llx CFID:%d cmdq:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, softq_mgr->id); list_del(&cmd->qos_list); waitq->count--; softq_mgr->total_wait_cmd_cnt--; ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, - cmd, - resp_status, - PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); } } ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); @@ -3929,15 +3686,15 @@ static void ps3_qos_cmdq_clean(struct ps3_instance *instance, } } -static void ps3_qos_cmdq_clear(struct ps3_instance *instance, int resp_status) +static void ps3_qos_cmdq_clear(struct ps3_instance *instance, S32 resp_status) { - unsigned short i = 0; - unsigned short j = 0; + U16 i = 0; + U16 j = 0; struct ps3_qos_softq_mgr *softq_mgr = NULL; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct qos_wait_queue *waitq = NULL; - unsigned long flag = 0; + ULong flag = 0; struct ps3_qos_cq_context *qos_cq_ctx = &instance->qos_context.cq_ctx; for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { @@ -3945,27 +3702,17 @@ static void ps3_qos_cmdq_clear(struct ps3_instance *instance, int resp_status) for (j = 1; j <= instance->qos_context.max_vd_count; j++) { waitq = &softq_mgr->waitqs[j]; if (waitq->count > 0) { - ps3_spin_lock_irqsave(&softq_mgr->rc_lock, - &flag); - list_for_each_entry_safe(cmd, cmd_next, - &waitq->wait_list, - qos_list) { - LOG_DEBUG( - "qos clean cmdq. hno:%u t_id:0x%llx CFID:%d cmdq:%u\n", - PS3_HOST(instance), - cmd->trace_id, cmd->index, - softq_mgr->id); + ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); + list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, qos_list) { + LOG_DEBUG("qos clean cmdq. hno:%u t_id:0x%llx CFID:%d cmdq:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, softq_mgr->id); list_del(&cmd->qos_list); waitq->count--; softq_mgr->total_wait_cmd_cnt--; ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, - cmd, - resp_status, - PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); } - ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, - flag); + ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); } } cancel_work_sync(&softq_mgr->resend_work); @@ -3973,11 +3720,10 @@ static void ps3_qos_cmdq_clear(struct ps3_instance *instance, int resp_status) } static void ps3_raid_qos_pd_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, - int resp_status) + struct ps3_scsi_priv_data *priv_data, S32 resp_status) { - unsigned short pd_id = 0; - unsigned short vd_id = 0; + U16 pd_id = 0; + U16 vd_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; pd_id = PS3_PDID(&priv_data->disk_pos); @@ -3990,26 +3736,22 @@ static void ps3_raid_qos_pd_clean(struct ps3_instance *instance, ps3_qos_mgrq_clean(instance, priv_data, resp_status); } - LOG_INFO("qos clean vd. host_no:%u did:%u vid:%u\n", PS3_HOST(instance), - pd_id, vd_id); + LOG_INFO("qos clean vd. host_no:%u did:%u vid:%u\n", + PS3_HOST(instance), pd_id, vd_id); } static void ps3_raid_qos_vd_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, - int resp_status) + struct ps3_scsi_priv_data *priv_data, S32 resp_status) { - unsigned short vd_id = 0; - unsigned short pd_id = 0; + U16 vd_id = 0; + U16 pd_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), - PS3_VDID(&priv_data->disk_pos)); + vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), PS3_VDID(&priv_data->disk_pos)); for (pd_id = 1; pd_id <= instance->qos_context.max_pd_count; pd_id++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); - if (ps3_atomic_read(&qos_pd_mgr->valid) == 1 && - PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr)) { - ps3_pd_quota_waitq_clean(qos_pd_mgr, vd_id, - resp_status); + if (ps3_atomic_read(&qos_pd_mgr->valid) == 1 && PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr)) { + ps3_pd_quota_waitq_clean(qos_pd_mgr, vd_id, resp_status); } } @@ -4017,13 +3759,12 @@ static void ps3_raid_qos_vd_clean(struct ps3_instance *instance, ps3_qos_mgrq_clean(instance, priv_data, resp_status); LOG_FILE_INFO("qos clean vd. host_no:%u type:%u disk_id:%u\n", - PS3_HOST(instance), priv_data->dev_type, vd_id); + PS3_HOST(instance), priv_data->dev_type, vd_id); } -void ps3_raid_qos_waitq_clear_all(struct ps3_instance *instance, - int resp_status) +void ps3_raid_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status) { - unsigned short i = 0; + U16 i = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; for (i = 1; i <= instance->qos_context.max_pd_count; i++) { @@ -4038,44 +3779,43 @@ void ps3_raid_qos_waitq_clear_all(struct ps3_instance *instance, ps3_qos_mgrq_clean(instance, NULL, resp_status); - LOG_INFO("host_no:%u:clear all qos waitq\n", PS3_HOST(instance)); + LOG_INFO("host_no:%u:clear all qos waitq\n", + PS3_HOST(instance)); } -static unsigned char -ps3_qos_softq_notify_timeout(struct ps3_qos_softq_mgr *qos_softq_mgr) +static Bool ps3_qos_softq_notify_timeout(struct ps3_qos_softq_mgr *qos_softq_mgr) { - unsigned char notified = PS3_FALSE; - unsigned long timeout_jiffies = 0; + Bool notified = PS3_FALSE; + ULong timeout_jiffies = 0; - timeout_jiffies = - qos_softq_mgr->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; + timeout_jiffies = qos_softq_mgr->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; if (qos_softq_mgr->total_wait_cmd_cnt && - ps3_atomic_read(&qos_softq_mgr->free_cnt) > 0 && - time_after(jiffies, timeout_jiffies)) { - queue_work(qos_softq_mgr->work_queue, - &qos_softq_mgr->resend_work); + ps3_atomic_read(&qos_softq_mgr->free_cnt) > 0 && + time_after(jiffies, timeout_jiffies)) { + queue_work(qos_softq_mgr->work_queue, &qos_softq_mgr->resend_work); notified = PS3_TRUE; LOG_INFO("awake qos softq by poll. host_no:%u q_id:%u\n", - PS3_HOST(qos_softq_mgr->instance), qos_softq_mgr->id); + PS3_HOST(qos_softq_mgr->instance), qos_softq_mgr->id); } return notified; } -static unsigned char ps3_qos_cq_notify_timeout(struct ps3_instance *instance) +static Bool ps3_qos_cq_notify_timeout(struct ps3_instance *instance) { struct ps3_qos_cq_context *qos_cq_ctx = NULL; struct ps3_qos_softq_mgr *qos_softq_mgr = NULL; - unsigned char notified = PS3_FALSE; - unsigned char i = 0; + Bool notified = PS3_FALSE; + U8 i = 0; qos_cq_ctx = &instance->qos_context.cq_ctx; ps3_qos_softq_notify_timeout(&qos_cq_ctx->mgrq); for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { qos_softq_mgr = &qos_cq_ctx->cmdqs[i]; - if (ps3_qos_softq_notify_timeout(qos_softq_mgr)) + if (ps3_qos_softq_notify_timeout(qos_softq_mgr)) { notified = PS3_TRUE; + } } return notified; @@ -4083,8 +3823,9 @@ static unsigned char ps3_qos_cq_notify_timeout(struct ps3_instance *instance) void ps3_raid_qos_waitq_poll(struct ps3_instance *instance) { - if (!ps3_qos_cq_notify_timeout(instance)) + if (!ps3_qos_cq_notify_timeout(instance)) { ps3_qos_pd_notify_timeout(instance); + } } static void ps3_raid_qos_reset(struct ps3_instance *instance) @@ -4093,33 +3834,31 @@ static void ps3_raid_qos_reset(struct ps3_instance *instance) struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_qos_cq_context *qos_cq_ctx = NULL; struct ps3_qos_softq_mgr *qos_softq_mgr = NULL; - unsigned short i = 0; + U16 i = 0; struct ps3_pd_entry *pd_entry = NULL; qos_cq_ctx = &instance->qos_context.cq_ctx; qos_softq_mgr = &qos_cq_ctx->mgrq; ps3_atomic_set(&qos_softq_mgr->free_cnt, - qos_ctx->cq_ctx.mgrq_depth - - (PS3_QOS_HIGH_PRI_MGR_CMD_COUNT >> 1)); + qos_ctx->cq_ctx.mgrq_depth - (PS3_QOS_HIGH_PRI_MGR_CMD_COUNT >> 1)); for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { qos_softq_mgr = &qos_cq_ctx->cmdqs[i]; - ps3_atomic_set(&qos_softq_mgr->free_cnt, - qos_ctx->cq_ctx.cmdq_depth); + ps3_atomic_set(&qos_softq_mgr->free_cnt, qos_ctx->cq_ctx.cmdq_depth); } qos_ctx->pd_ctx.nvme_normal_quota = g_ps3_qos_raid_nvme_normal_quota; for (i = 1; i <= qos_ctx->max_pd_count; i++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, i); if (ps3_atomic_read(&qos_pd_mgr->valid) == 1) { - pd_entry = - ps3_dev_mgr_lookup_pd_info_by_id(instance, i); - if (pd_entry != NULL) + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, i); + if (pd_entry != NULL) { ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); + } } } } -static unsigned char ps3_raid_qos_pd_resend_check(struct ps3_cmd *cmd) +static Bool ps3_raid_qos_pd_resend_check(struct ps3_cmd *cmd) { return ps3_qos_cq_decision(cmd); } @@ -4139,20 +3878,17 @@ void ps3_hba_qos_prepare(struct ps3_instance *instance) instance->qos_context.opts.qos_decision = ps3_hba_qos_decision; instance->qos_context.opts.qos_cmd_update = ps3_hba_qos_cmd_update; instance->qos_context.opts.qos_waitq_notify = ps3_hba_qos_waitq_notify; - instance->qos_context.opts.qos_pd_resend_check = - ps3_hba_qos_pd_resend_check; + instance->qos_context.opts.qos_pd_resend_check = ps3_hba_qos_pd_resend_check; instance->qos_context.opts.qos_waitq_abort = ps3_hba_qos_waitq_abort; instance->qos_context.opts.qos_vd_clean = ps3_hba_qos_vd_clean; instance->qos_context.opts.qos_pd_clean = ps3_hba_qos_pd_clean; instance->qos_context.opts.qos_waitq_poll = ps3_hba_qos_waitq_poll; - instance->qos_context.opts.qos_waitq_clear = - ps3_hba_qos_waitq_clear_all; + instance->qos_context.opts.qos_waitq_clear = ps3_hba_qos_waitq_clear_all; instance->qos_context.opts.qos_reset = ps3_hba_qos_reset; instance->qos_context.opts.qos_vd_init = ps3_hba_qos_vd_init; instance->qos_context.opts.qos_vd_reset = ps3_hba_qos_vd_reset; instance->qos_context.qos_switch = 1; - instance->qos_context.pd_ctx.nvme_normal_quota = - g_ps3_qos_hba_nvme_normal_quota; + instance->qos_context.pd_ctx.nvme_normal_quota = g_ps3_qos_hba_nvme_normal_quota; } void ps3_raid_qos_prepare(struct ps3_instance *instance) @@ -4162,37 +3898,36 @@ void ps3_raid_qos_prepare(struct ps3_instance *instance) instance->qos_context.opts.qos_decision = ps3_raid_qos_decision; instance->qos_context.opts.qos_cmd_update = ps3_raid_qos_cmd_update; instance->qos_context.opts.qos_waitq_notify = ps3_raid_qos_waitq_notify; - instance->qos_context.opts.qos_pd_resend_check = - ps3_raid_qos_pd_resend_check; + instance->qos_context.opts.qos_pd_resend_check = ps3_raid_qos_pd_resend_check; instance->qos_context.opts.qos_waitq_abort = ps3_raid_qos_waitq_abort; instance->qos_context.opts.qos_vd_clean = ps3_raid_qos_vd_clean; instance->qos_context.opts.qos_pd_clean = ps3_raid_qos_pd_clean; instance->qos_context.opts.qos_waitq_poll = ps3_raid_qos_waitq_poll; - instance->qos_context.opts.qos_waitq_clear = - ps3_raid_qos_waitq_clear_all; + instance->qos_context.opts.qos_waitq_clear = ps3_raid_qos_waitq_clear_all; instance->qos_context.opts.qos_reset = ps3_raid_qos_reset; instance->qos_context.opts.qos_vd_init = NULL; instance->qos_context.opts.qos_vd_reset = NULL; instance->qos_context.qos_switch = 1; - instance->qos_context.pd_ctx.nvme_normal_quota = - g_ps3_qos_raid_nvme_normal_quota; + instance->qos_context.pd_ctx.nvme_normal_quota = g_ps3_qos_raid_nvme_normal_quota; } -int ps3_qos_decision(struct ps3_cmd *cmd) +S32 ps3_qos_decision(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - unsigned char can_get = PS3_TRUE; + S32 ret = PS3_SUCCESS; + Bool can_get = PS3_TRUE; struct ps3_instance *instance = NULL; cmd->qos_processing = PS3_TRUE; - wmb(); /* in order to force CPU ordering */ + wmb(); instance = cmd->instance; - if (!ps3_qos_enable(cmd->instance) || !PS3_QOS_INITED(instance)) + if (!ps3_qos_enable(cmd->instance) || !PS3_QOS_INITED(instance)) { goto _exit; + } ret = ps3_qos_pre_check(instance, cmd); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto _exit; + } can_get = instance->qos_context.opts.qos_decision(cmd); if (!can_get) { @@ -4204,35 +3939,36 @@ int ps3_qos_decision(struct ps3_cmd *cmd) return ret; } -void ps3_qos_cmd_update(struct ps3_instance *instance, struct ps3_cmd *cmd) +void ps3_qos_cmd_update(struct ps3_instance *instance, struct ps3_cmd *cmd) { - if (!ps3_qos_enable(instance) || !PS3_QOS_INITED(instance)) + if (!ps3_qos_enable(instance) || !PS3_QOS_INITED(instance)) { return; + } instance->qos_context.opts.qos_cmd_update(cmd); } void ps3_qos_waitq_notify(struct ps3_instance *instance) { - if (!ps3_qos_enable(instance) || !PS3_QOS_INITED(instance)) + + if (!ps3_qos_enable(instance) || !PS3_QOS_INITED(instance)) { return; + } instance->qos_context.opts.qos_waitq_notify(instance); } -unsigned char ps3_qos_waitq_abort(struct ps3_cmd *cmd) +Bool ps3_qos_waitq_abort(struct ps3_cmd *cmd) { - unsigned char found = PS3_FALSE; - - if (!PS3_QOS_INITED(cmd->instance)) + Bool found = PS3_FALSE; + if (!PS3_QOS_INITED(cmd->instance)) { goto out; + } found = cmd->instance->qos_context.opts.qos_waitq_abort(cmd); - LOG_INFO( - "task abort cmd in qos waitq t_id:0x%llx CFID:%u flag:%u ret:%u\n", + LOG_INFO("task abort cmd in qos waitq t_id:0x%llx CFID:%u flag:%u ret:%u\n", cmd->trace_id, cmd->index, cmd->qos_waitq_flag, found); if (found) { - ps3_scsih_drv_io_reply_scsi( - cmd->scmd, cmd, SCSI_STATUS_TASK_ABORTED, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, SCSI_STATUS_TASK_ABORTED, PS3_FALSE); } out: return found; @@ -4240,36 +3976,36 @@ unsigned char ps3_qos_waitq_abort(struct ps3_cmd *cmd) void ps3_qos_hard_reset(struct ps3_instance *instance) { - int resp_status = 0; - - if (ps3_pci_err_recovery_get(instance)) + S32 resp_status = 0; + if (ps3_pci_err_recovery_get(instance)) { resp_status = PS3_STATUS_PCI_RECOVERY; - else + } else { resp_status = PS3_STATUS_HOST_RESET; + } ps3_qos_waitq_clear_all(instance, resp_status); } -void ps3_qos_waitq_clear_all(struct ps3_instance *instance, int resp_status) +void ps3_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status) { - if (!PS3_QOS_INITED(instance)) + if (!PS3_QOS_INITED(instance)) { return; + } ps3_qos_wait_io_end(instance); instance->qos_context.opts.qos_waitq_clear(instance, resp_status); } -int ps3_qos_init(struct ps3_instance *instance) +S32 ps3_qos_init(struct ps3_instance *instance) { struct ps3_qos_context *qos_ctx = &instance->qos_context; - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; qos_ctx->max_vd_count = instance->ctrl_info.maxVdCount + 1; qos_ctx->max_pd_count = instance->ctrl_info.maxPdCount; qos_ctx->inited = 0; - LOG_INFO( - "hno:%u ps3 qos info:tfifo:%u sas_pd_quota[%u %u] sata_pd_quota[%u %u] nvme_quota[%u %u %u]\n", + LOG_INFO("hno:%u ps3 qos info:tfifo:%u sas_pd_quota[%u %u] sata_pd_quota[%u %u] nvme_quota[%u %u %u]\n", PS3_HOST(instance), instance->ctrl_info.qosInfo.tfifoDepth, instance->ctrl_info.qosInfo.sasHddQuota, instance->ctrl_info.qosInfo.sasSsdQuota, @@ -4282,10 +4018,8 @@ int ps3_qos_init(struct ps3_instance *instance) if (qos_ctx->opts.qos_init) { if (qos_ctx->opts.qos_init(instance) == PS3_SUCCESS) { qos_ctx->inited = 1; - LOG_INFO( - "hno:%u:ps3 qos init success, vd_count:%u pd_count:%u\n", - PS3_HOST(instance), qos_ctx->max_vd_count, - qos_ctx->max_pd_count); + LOG_INFO("hno:%u:ps3 qos init success, vd_count:%u pd_count:%u\n", + PS3_HOST(instance), qos_ctx->max_vd_count, qos_ctx->max_pd_count); } else { ret = -PS3_FAILED; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_qos.h b/drivers/scsi/linkdata/ps3stor/ps3_qos.h index 190132718470..8a90acd3e352 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_qos.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_qos.h @@ -1,26 +1,24 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_QOS_H_ #define _PS3_QOS_H_ #include "ps3_platform_utils.h" #include "ps3_htp.h" #include "ps3_cmd_channel.h" -#include "ps3_kernel_version.h" #define QOS_HIGH_PRI_EXCLUSIVE_CMD_COUNT 32 #define QOS_MGR_EXCLUSIVE_CMD_COUNT 64 #define PS3_QOS_DEFAULT_PD_QUOTA 40 #define PS3_QOS_SAS_PD_QUOTA 125 -#define PS3_QOS_NVME_MEMBER_QUOTA 127 +#define PS3_QOS_NVME_MEMBER_QUOTA 127 #define PS3_QOS_NVME_DIRECT_QUOTA 127 #define PS3_QOS_HBA_NVME_NORMAL_QUOTA 126 #define PS3_QOS_RAID_NVME_NORMAL_QUOTA 252 #define PS3_QOS_FUNC1_JBOD_VD_QUOTA 768 #define PS3_QOS_VD_EXCLUSIVE_CMD_COUNT 40 #define PS3_QOS_JBOD_EXCLUSIVE_CMD_COUNT 128 -#define PS3_QOS_POLL_INTERVAL 2 -#define PS3_QOS_WAITQ_TIMEOUT 5 +#define PS3_QOS_POLL_INTERVAL 2 +#define PS3_QOS_WAITQ_TIMEOUT 5 #define PS3_QOS_HBA_MAX_CMD 944 #define PS3_QOS_CS_FUNC0_SHARE_CMD 80 #define PS3_QOS_CS_FUNC0_JBOD_VD_QUOTA 80 @@ -29,9 +27,9 @@ #define PS3_QOS_FUNC1_PD_WORKQ_COUNT 4 #define PS3_QOS_POLL_CMD_COUNT 16 -#define PS3_CMD_NEED_QOS(cmd) \ - ((cmd)->cmd_word.direct == PS3_CMDWORD_DIRECT_NORMAL || \ - (cmd)->cmd_word.direct == PS3_CMDWORD_DIRECT_ADVICE) +#define PS3_CMD_NEED_QOS(cmd) \ + ((cmd)->cmd_word.direct == PS3_CMDWORD_DIRECT_NORMAL || \ + (cmd)->cmd_word.direct == PS3_CMDWORD_DIRECT_ADVICE) #define PS3_QOS_INITED(instance) ((instance)->qos_context.inited) @@ -71,162 +69,153 @@ enum ps3_qos_vd_change_type { }; struct qos_wait_queue { - struct list_head wait_list; - unsigned int count; - unsigned short id; - spinlock_t *rsc_lock; - int *free_rsc; - atomic_t *used_rsc; - unsigned int *total_waited_cnt; - unsigned short can_resend; - unsigned short has_resend; - unsigned long last_sched_jiffies; + ps3_list_head wait_list; + U32 count; + U16 id; + ps3_spinlock *rsc_lock; + S32 *free_rsc; + ps3_atomic32 *used_rsc; + U32 *total_waited_cnt; + U16 can_resend; + U16 has_resend; + ULong last_sched_jiffies; }; struct ps3_qos_vd_mgr { - unsigned char valid; - unsigned short id; - unsigned char workq_id; - atomic_t vd_quota; - spinlock_t rsc_lock; + Bool valid; + U16 id; + U8 workq_id; + ps3_atomic32 vd_quota; + ps3_spinlock rsc_lock; struct qos_wait_queue vd_quota_wait_q; - atomic_t exclusive_cmd_cnt; - atomic_t share_cmd_used; + ps3_atomic32 exclusive_cmd_cnt; + ps3_atomic32 share_cmd_used; struct PS3VDEntry *vd_entry; struct ps3_instance *instance; struct work_struct resend_work; - unsigned long long last_sched_jiffies; + U64 last_sched_jiffies; }; struct ps3_qos_pd_mgr { - atomic_t valid; - unsigned char workq_id; - unsigned char dev_type; - unsigned char clearing; - unsigned short disk_id; - unsigned short vd_id; - int pd_quota; - atomic_t pd_used_quota; + ps3_atomic32 valid; + U8 workq_id; + U8 dev_type; + Bool clearing; + U16 disk_id; + U16 vd_id; + S32 pd_quota; + ps3_atomic32 pd_used_quota; struct ps3_instance *instance; struct work_struct resend_work; - unsigned long long last_sched_jiffies; + U64 last_sched_jiffies; struct qos_wait_queue *waitqs; - unsigned short waitq_cnt; - unsigned int total_wait_cmd_cnt; - spinlock_t rc_lock; - unsigned short poll_que_id; - unsigned short poll_start_que_id; - unsigned short poll_cmd_cnt; - spinlock_t direct_rsc_lock; - int direct_quota; - atomic_t direct_used_quota; - unsigned int total_waited_direct_cmd; - atomic_t processing_cnt; - spinlock_t adjust_quota_lock; - int adjust_max_quota; - int adjust_min_quota; - int pd_init_quota; + U16 waitq_cnt; + U32 total_wait_cmd_cnt; + ps3_spinlock rc_lock; + U16 poll_que_id; + U16 poll_start_que_id; + U16 poll_cmd_cnt; + ps3_spinlock direct_rsc_lock; + S32 direct_quota; + ps3_atomic32 direct_used_quota; + U32 total_waited_direct_cmd; + ps3_atomic32 processing_cnt; + ps3_spinlock adjust_quota_lock; + S32 adjust_max_quota; + S32 adjust_min_quota; + S32 pd_init_quota; }; struct ps3_qos_pd_context { struct ps3_qos_pd_mgr *qos_pd_mgrs; struct workqueue_struct **work_queues; - unsigned short sas_sata_hdd_quota; - unsigned short sas_sata_ssd_quota; - unsigned short nvme_normal_quota; - unsigned short nvme_direct_quota; - atomic_t workq_id_cnt; - unsigned char workq_count; + U16 sas_sata_hdd_quota; + U16 sas_sata_ssd_quota; + U16 nvme_normal_quota; + U16 nvme_direct_quota; + ps3_atomic32 workq_id_cnt; + U8 workq_count; }; struct ps3_qos_vd_context { struct ps3_qos_vd_mgr *qos_vd_mgrs; struct workqueue_struct **work_queues; - unsigned short jbod_exclusive_cnt; - unsigned short vd_exclusive_cnt; - unsigned char workq_count; - unsigned char inited; + U16 jbod_exclusive_cnt; + U16 vd_exclusive_cnt; + U8 workq_count; + Bool inited; }; struct ps3_qos_tg_context { - unsigned int share; - unsigned int mgr_exclusive_cnt; - unsigned short high_pri_exclusive_cnt; - atomic_t mgr_free_cnt; - atomic_t mgr_share_used; - atomic_t share_free_cnt; + U32 share; + U32 mgr_exclusive_cnt; + U16 high_pri_exclusive_cnt; + ps3_atomic32 mgr_free_cnt; + ps3_atomic32 mgr_share_used; + ps3_atomic32 share_free_cnt; struct qos_wait_queue mgr_cmd_wait_q; struct qos_wait_queue *vd_cmd_waitqs; - unsigned int total_wait_cmd_cnt; - unsigned char poll_vd_id; - spinlock_t lock; + U32 total_wait_cmd_cnt; + U8 poll_vd_id; + ps3_spinlock lock; struct ps3_instance *instance; struct workqueue_struct *work_queue; struct work_struct resend_work; - unsigned long long last_sched_jiffies; + U64 last_sched_jiffies; }; struct ps3_qos_ops { - int (*qos_init)(struct ps3_instance *instance); + S32 (*qos_init)(struct ps3_instance *instance); void (*qos_exit)(struct ps3_instance *instance); - void (*qos_vd_init)(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry); - void (*qos_vd_reset)(struct ps3_instance *instance, - unsigned short disk_id); - unsigned char (*qos_decision)(struct ps3_cmd *cmd); + void (*qos_vd_init)(struct ps3_instance *instance, struct PS3VDEntry *vd_entry); + void (*qos_vd_reset)(struct ps3_instance *instance, U16 disk_id); + Bool (*qos_decision)(struct ps3_cmd *cmd); void (*qos_cmd_update)(struct ps3_cmd *cmd); void (*qos_waitq_notify)(struct ps3_instance *instance); - unsigned char (*qos_pd_resend_check)(struct ps3_cmd *cmd); - unsigned char (*qos_waitq_abort)(struct ps3_cmd *cmd); - void (*qos_vd_clean)(struct ps3_instance *instance, - struct ps3_scsi_priv_data *pri_data, int ret_code); - void (*qos_pd_clean)(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, - int ret_code); - void (*qos_waitq_clear)(struct ps3_instance *instance, int ret_code); + Bool (*qos_pd_resend_check)(struct ps3_cmd *cmd); + Bool (*qos_waitq_abort)(struct ps3_cmd *cmd); + void (*qos_vd_clean)(struct ps3_instance *instance, struct ps3_scsi_priv_data *pri_data, S32 ret_code); + void (*qos_pd_clean)(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data, S32 ret_code); + void (*qos_waitq_clear)(struct ps3_instance *instance, S32 ret_code); void (*qos_waitq_poll)(struct ps3_instance *instance); - void (*qos_reset)(struct ps3_instance *instance); + void (*qos_reset)(struct ps3_instance *instance); }; -int ps3_hba_qos_init(struct ps3_instance *instance); +Bool inline ps3_qos_enable(struct ps3_instance *instance); + +S32 ps3_hba_qos_init(struct ps3_instance *instance); void ps3_hba_qos_exit(struct ps3_instance *instance); -void ps3_qos_vd_init(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry); +void ps3_qos_vd_init(struct ps3_instance *instance, struct PS3VDEntry *vd_entry); -void ps3_qos_vd_reset(struct ps3_instance *instance, unsigned short disk_id); +void ps3_qos_vd_reset(struct ps3_instance *instance, U16 disk_id); -struct ps3_qos_pd_mgr *ps3_qos_pd_mgr_init(struct ps3_instance *instance, - struct ps3_pd_entry *pd_entry); +struct ps3_qos_pd_mgr* ps3_qos_pd_mgr_init(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry); -void ps3_qos_pd_mgr_reset(struct ps3_instance *instance, unsigned short pd_id); +void ps3_qos_pd_mgr_reset(struct ps3_instance *instance, U16 pd_id); -void ps3_qos_vd_member_change(struct ps3_instance *instance, - struct ps3_pd_entry *pd_entry, - struct scsi_device *sdev, - unsigned char is_vd_member); +void ps3_qos_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry, + struct scsi_device *sdev, Bool is_vd_member); -int ps3_qos_decision(struct ps3_cmd *cmd); +S32 ps3_qos_decision(struct ps3_cmd *cmd); void ps3_qos_cmd_update(struct ps3_instance *instance, struct ps3_cmd *cmd); void ps3_qos_waitq_notify(struct ps3_instance *instance); -unsigned char ps3_qos_waitq_abort(struct ps3_cmd *aborted_cmd); +Bool ps3_qos_waitq_abort(struct ps3_cmd *aborted_cmd); -void ps3_qos_device_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *pri_data, int ret_code); +void ps3_qos_device_clean(struct ps3_instance *instance, struct ps3_scsi_priv_data *pri_data, + S32 ret_code); -void ps3_qos_disk_del(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data); +void ps3_qos_disk_del(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data); -void ps3_qos_vd_member_del(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos); +void ps3_qos_vd_member_del(struct ps3_instance *instance, struct PS3DiskDevPos *dev_pos); void ps3_qos_hard_reset(struct ps3_instance *instance); -void ps3_qos_waitq_clear_all(struct ps3_instance *instance, int resp_status); +void ps3_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status); void ps3_qos_waitq_poll(struct ps3_instance *instance); @@ -243,26 +232,26 @@ void ps3_raid_qos_prepare(struct ps3_instance *instance); #define PS3_QOS_MGRQ_DEPTH 1024 #define PS3_QOS_HIGH_PRI_MGR_CMD_COUNT 32 struct ps3_qos_softq_mgr { - unsigned short id; + U16 id; struct ps3_instance *instance; - spinlock_t rc_lock; - atomic_t free_cnt; + ps3_spinlock rc_lock; + ps3_atomic32 free_cnt; struct qos_wait_queue *waitqs; - unsigned short waitq_cnt; - unsigned int total_wait_cmd_cnt; + U16 waitq_cnt; + U32 total_wait_cmd_cnt; struct workqueue_struct *work_queue; struct work_struct resend_work; - unsigned long long last_sched_jiffies; - unsigned short poll_cmd_cnt; - unsigned short poll_que_id; + U64 last_sched_jiffies; + U16 poll_cmd_cnt; + U16 poll_que_id; }; struct ps3_qos_cq_context { struct ps3_qos_softq_mgr mgrq; struct ps3_qos_softq_mgr *cmdqs; - unsigned char cmdq_cnt; - unsigned int mgrq_depth; - unsigned int cmdq_depth; + U8 cmdq_cnt; + U32 mgrq_depth; + U32 cmdq_depth; }; struct ps3_qos_context { @@ -271,34 +260,31 @@ struct ps3_qos_context { struct ps3_qos_vd_context vd_ctx; struct ps3_qos_tg_context tg_ctx; struct ps3_qos_cq_context cq_ctx; - unsigned short max_vd_count; - unsigned short max_pd_count; - unsigned char poll_count; - unsigned char qos_switch; - unsigned char inited; + U16 max_vd_count; + U16 max_pd_count; + U8 poll_count; + U8 qos_switch; + U8 inited; }; -int ps3_raid_qos_init(struct ps3_instance *instance); +S32 ps3_raid_qos_init(struct ps3_instance *instance); void ps3_raid_qos_exit(struct ps3_instance *instance); -int ps3_qos_init(struct ps3_instance *instance); +S32 ps3_qos_init(struct ps3_instance *instance); void ps3_qos_exit(struct ps3_instance *instance); void ps3_qos_adjust_pd_rsc(struct scsi_device *sdev, - struct ps3_instance *instance, int reason); + struct ps3_instance *instance, S32 reason); void ps3_qos_vd_attr_change(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry_old, - struct PS3VDEntry *vd_entry); + struct PS3VDEntry *vd_entry_old, struct PS3VDEntry *vd_entry); -void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_pd_entry *pd_entry); +void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_pd_entry *pd_entry); -#if defined(PS3_SUPPORT_LINX80) -void ps3_linx80_vd_member_change(struct ps3_instance *instance, - struct ps3_pd_entry *pd_entry); +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 9, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) +void ps3_linx80_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry); #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.c b/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.c index 807edc3b8827..a935cce6b632 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #ifndef _WINDOWS #include #include @@ -14,7 +12,7 @@ #include "ps3_driver_log.h" #include "ps3_rb_tree.h" #include "ps3_inner_data.h" -#include "ps3_htp_meta.h" +#include "ps3_meta.h" #include "ps3_cmd_channel.h" #include "ps3_scsih_cmd_parse.h" #include "ps3_r1x_write_lock.h" @@ -26,7 +24,7 @@ #include "ps3_scsi_cmd_err.h" #include "ps3_module_para.h" -enum { +enum{ PS3_CONFLICT_QUEUE_EMPTY = 0, PS3_CONFLICT_QUEUE_CONFLICT = 1, PS3_CONFLICT_QUEUE_NO_CONFLICT = 2, @@ -34,98 +32,93 @@ enum { #define PS3_R1X_RESEND_COUNT (32) -#define LOCK_BLOCK_SIZE_SHIFT 3 -#define HASH_TABLE_SIZE_SHIFT 12 -#define HASH_TABLE_SIZE (1 << HASH_TABLE_SIZE_SHIFT) -#define HASH_TABLE_SIZE_MASK (HASH_TABLE_SIZE - 1) -#define SZBLOCK_SIZE_SHIFT 10 -#define SZBLOCK_SIZE ((unsigned int)(1 << SZBLOCK_SIZE_SHIFT)) -#define SZBLOCK_SIZE_MASK (SZBLOCK_SIZE - 1) -#define VD_QUE_DEPTH 512 -#define CMD_SIZE_MAX 4096 +#define LOCK_BLOCK_SIZE_SHIFT 3 +#define HASH_TABLE_SIZE_SHIFT 12 +#define HASH_TABLE_SIZE (1 << HASH_TABLE_SIZE_SHIFT) +#define HASH_TABLE_SIZE_MASK (HASH_TABLE_SIZE - 1) +#define SZBLOCK_SIZE_SHIFT 10 +#define SZBLOCK_SIZE ((U32)(1 << SZBLOCK_SIZE_SHIFT)) +#define SZBLOCK_SIZE_MASK (SZBLOCK_SIZE - 1) +#define VD_QUE_DEPTH 512 +#define CMD_SIZE_MAX 4096 -#define PS3_R1X_BIT_CNT \ - ((SZBLOCK_SIZE >> LOCK_BLOCK_SIZE_SHIFT) * HASH_TABLE_SIZE) -#define PS3_R1X_BIT_MAP_SIZE (PS3_R1X_BIT_CNT >> 3) +#define PS3_R1X_BIT_CNT ((SZBLOCK_SIZE >> LOCK_BLOCK_SIZE_SHIFT) * HASH_TABLE_SIZE) +#define PS3_R1X_BIT_MAP_SIZE (PS3_R1X_BIT_CNT >> 3) -#define SECTOR_SIZE_4K 4096 -#define SECTOR_512_4K_SHIFT 3 -#define SZ_BLOCK_SPLIT_MAX ((4096 >> SZBLOCK_SIZE_SHIFT) + 2) +#define SECTOR_SIZE_4K 4096 +#define SECTOR_512_4K_SHIFT 3 +#define SZ_BLOCK_SPLIT_MAX ((4096 >> SZBLOCK_SIZE_SHIFT) + 2) -#define RW_R1X_HASHIDX(lba) \ - (((lba) >> SZBLOCK_SIZE_SHIFT) & HASH_TABLE_SIZE_MASK) -#define RW_R1X_HASHIDX_HASH(mgr, lba) \ - ps3_private_r1x_hash((mgr), ((lba) >> SZBLOCK_SIZE_SHIFT)) +#define RW_R1X_HASHIDX(lba) (((lba) >> SZBLOCK_SIZE_SHIFT) & HASH_TABLE_SIZE_MASK) +#define RW_R1X_HASHIDX_HASH(mgr, lba) ps3_private_r1x_hash((mgr), ((lba) >> SZBLOCK_SIZE_SHIFT)) -#define PS3_LBA(lba_hi, lba_lo) \ - ((((unsigned long long)(lba_hi)) << PS3_SHIFT_DWORD) | (lba_lo)) +#define PS3_LBA(lba_hi, lba_lo) ((((U64)(lba_hi)) << PS3_SHIFT_DWORD) | (lba_lo)) #define PS3_SZ_BLOCK_CNT (2560) -enum { - PS3_R1X_IO_CONFLICT = 1, - PS3_R1X_HASH_CONFILICT = 2, - PS3_R1X_BIT_NOT_ENOUGH = 3, +enum{ + PS3_R1X_IO_CONFLICT = 1, + PS3_R1X_HASH_CONFILICT = 2, + PS3_R1X_BIT_NOT_ENOUGH = 3, }; -#define PS3_R1X_LOCK_TRACE(fmt, ...) LOG_DEBUG(fmt "\n", ##__VA_ARGS__) -#define PS3_R1X_LOCK_INFO(fmt, ...) LOG_INFO(fmt "\n", ##__VA_ARGS__) -#define PS3_R1X_LOCK_WARN(fmt, ...) LOG_WARN(fmt "\n", ##__VA_ARGS__) -#define PS3_R1X_LOCK_ERROR(fmt, ...) LOG_ERROR(fmt "\n", ##__VA_ARGS__) +#define PS3_R1X_LOCK_TRACE(fmt, ...) LOG_DEBUG(fmt "\n", ##__VA_ARGS__); +#define PS3_R1X_LOCK_INFO(fmt, ...) LOG_INFO(fmt "\n", ##__VA_ARGS__); +#define PS3_R1X_LOCK_WARN(fmt, ...) LOG_WARN(fmt "\n", ##__VA_ARGS__); +#define PS3_R1X_LOCK_ERROR(fmt, ...) LOG_ERROR(fmt "\n", ##__VA_ARGS__); -#define PS3_R1X_TIMEOUT(cmd, tmo) \ - (time_after(jiffies, (cmd)->scmd->jiffies_at_alloc + (tmo))) +#define PS3_R1X_TIMEOUT(cmd, tmo) (time_after(jiffies, \ + (cmd)->scmd->jiffies_at_alloc + (tmo))) -unsigned int g_ps3_r1x_lock_flag = PS3_R1X_HASHRANGE_LOCK; -unsigned int g_ps3_r1x_lock_enable = 1; +U32 g_ps3_r1x_lock_flag = PS3_R1X_HASHRANGE_LOCK; +U32 g_ps3_r1x_lock_enable = 1; -static int ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, - struct ps3_cmd *cmd); +static S32 ps3_r1x_hash_bit_lock_of_conflict_queue( + struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd); #if PS3_DESC("-----------------------hash bit互斥方案------------------------") -#define LOCK_BLOCK_SIZE (1 << LOCK_BLOCK_SIZE_SHIFT) -#define LOCK_BLOCK_SIZE_MASK (LOCK_BLOCK_SIZE - 1) -#define RW_BIT_TO_BYTE(bit) ((bit) >> 3) -#define RW_BYTE_TO_BIT(byte) ((bit) << 3) -#define RW_BIT_BYTE_MASK 7 -#define RW_R1X_SZBLOCKIDX(lba) (lba >> SZBLOCK_SIZE_SHIFT) -#define RW_SZBLOCK_IDX_INVALID 0xFFFFFFFFFFFF -#define RW_BITMAP_IDX_INVALID 0xFFFF -#define RW_R1X_GET_BITMAP(bit_buff, idx) (bit_buff[idx]) -#define RW_BIT_64_MASK 63 -#define RW_BYTE_TO_U64(n) (n >> 3) - -struct ps3_r1x_hash_bit_item { - unsigned long long sz_block_idx : 48; - unsigned long long bitmap_idx : 16; +#define LOCK_BLOCK_SIZE (1 << LOCK_BLOCK_SIZE_SHIFT) +#define LOCK_BLOCK_SIZE_MASK (LOCK_BLOCK_SIZE - 1) +#define RW_BIT_TO_BYTE(bit) ((bit) >> 3) +#define RW_BYTE_TO_BIT(byte) ((bit) << 3) +#define RW_BIT_BYTE_MASK 7 +#define RW_R1X_SZBLOCKIDX(lba) (lba >> SZBLOCK_SIZE_SHIFT) +#define RW_SZBLOCK_IDX_INVALID 0xFFFFFFFFFFFF +#define RW_BITMAP_IDX_INVALID 0xFFFF +#define RW_R1X_GET_BITMAP(bit_buff,idx) (bit_buff[idx]) +#define RW_BIT_64_MASK 63 +#define RW_BYTE_TO_U64(n) (n >> 3) + +struct ps3_r1x_hash_bit_item{ + U64 sz_block_idx : 48; + U64 bitmap_idx : 16; }; -struct ps3_r1x_bit_block_mgr { - unsigned char *bit_buff; - unsigned char bit_block_size; - unsigned char resv[7]; +struct ps3_r1x_bit_block_mgr +{ + U8* bit_buff; + U8 bit_block_size; + U8 resv[7]; }; -struct ps3_r1x_hash_bit_mgr { - struct ps3_r1x_hash_bit_item hash_item[HASH_TABLE_SIZE]; - struct ps3_r1x_bit_block_mgr bitmap_mgr; +struct ps3_r1x_hash_bit_mgr{ + struct ps3_r1x_hash_bit_item hash_item[HASH_TABLE_SIZE]; + struct ps3_r1x_bit_block_mgr bitmap_mgr; }; -static unsigned short ps3_private_r1x_hash(struct ps3_r1x_lock_mgr *mgr, - unsigned long hashval) +static U16 ps3_private_r1x_hash(struct ps3_r1x_lock_mgr *mgr, ULong hashval) { - unsigned long tmp; - - tmp = (hashval * (unsigned long)mgr) ^ - (GOLDEN_RATIO_PRIME + hashval) / L1_CACHE_BYTES; + ULong tmp; + tmp = (hashval * (ULong)mgr) ^ (GOLDEN_RATIO_PRIME + hashval) / + L1_CACHE_BYTES; tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> HASH_TABLE_SIZE_SHIFT); return tmp & HASH_TABLE_SIZE_MASK; } static inline void ps3_r1x_conflict_queue_del(struct ps3_r1x_lock_mgr *mgr, - struct ps3_cmd *cmd) + struct ps3_cmd *cmd) { - unsigned long flag = 0; + ULong flag = 0; if (cmd->is_inserted_c_q == 1) { ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); @@ -137,12 +130,13 @@ static inline void ps3_r1x_conflict_queue_del(struct ps3_r1x_lock_mgr *mgr, } void ps3_r1x_conflict_queue_clean(struct ps3_scsi_priv_data *pri_data, - int ret_code) + S32 ret_code) { - unsigned long flag = 0; + ULong flag = 0; - if (unlikely(pri_data == NULL) || pri_data->lock_mgr.hash_mgr == NULL) + if(unlikely(pri_data == NULL) || pri_data->lock_mgr.hash_mgr == NULL) { return; + } ps3_spin_lock_irqsave(&pri_data->lock_mgr.mgr_lock, &flag); if (pri_data->lock_mgr.force_ret_code == SCSI_STATUS_GOOD) { @@ -152,64 +146,60 @@ void ps3_r1x_conflict_queue_clean(struct ps3_scsi_priv_data *pri_data, ps3_spin_unlock_irqrestore(&pri_data->lock_mgr.mgr_lock, flag); LOG_FILE_INFO("dev[%u:%u], wait r1x conflict queue clean begin\n", - PS3_CHANNEL(&pri_data->disk_pos), - PS3_TARGET(&pri_data->disk_pos)); - wmb(); /* in order to force CPU ordering */ + PS3_CHANNEL(&pri_data->disk_pos), + PS3_TARGET(&pri_data->disk_pos)); + wmb(); while (pri_data->lock_mgr.force_ret_code != SCSI_STATUS_GOOD) { ps3_msleep(100); - rmb(); /* in order to force CPU ordering */ + rmb(); } LOG_FILE_INFO("dev[%u:%u], wait r1x conflict queue clean end\n", - PS3_CHANNEL(&pri_data->disk_pos), - PS3_TARGET(&pri_data->disk_pos)); + PS3_CHANNEL(&pri_data->disk_pos), + PS3_TARGET(&pri_data->disk_pos)); } void ps3_r1x_conflict_queue_target_reset(struct ps3_instance *instance, - unsigned short target_id) + U16 target_id) { struct PS3ChannelInfo *channel_info = &instance->ctrl_info.channelInfo; - unsigned char i = 0; + U8 i = 0; struct ps3_scsi_priv_data *pri_data = NULL; for (i = 0; i < channel_info->channelNum; i++) { if (channel_info->channels[i].channelType != PS3_DISK_TYPE_VD || - channel_info->channels[i].maxDevNum <= target_id) { + channel_info->channels[i].maxDevNum <= target_id) { continue; } ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - pri_data = - ps3_dev_mgr_lookup_vd_pri_data(instance, i, target_id); - ps3_r1x_conflict_queue_clean(pri_data, - SCSI_STATUS_TASK_ABORTED); + pri_data = ps3_dev_mgr_lookup_vd_pri_data(instance, i, target_id); + ps3_r1x_conflict_queue_clean(pri_data, SCSI_STATUS_TASK_ABORTED); ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); } } void ps3_r1x_conflict_queue_clean_all(struct ps3_instance *instance, - int ret_code, unsigned char is_remove) + S32 ret_code, Bool is_remove) { struct PS3ChannelInfo *channel_info = &instance->ctrl_info.channelInfo; - unsigned short maxDevNum = 0; - unsigned char i = 0; - unsigned short j = 0; + U16 maxDevNum = 0; + U8 i = 0; + U16 j = 0; struct ps3_scsi_priv_data *pri_data = NULL; for (i = 0; i < channel_info->channelNum; i++) { - if (channel_info->channels[i].channelType != PS3_DISK_TYPE_VD) + if (channel_info->channels[i].channelType != PS3_DISK_TYPE_VD) { continue; + } maxDevNum = channel_info->channels[i].maxDevNum; for (j = 0; j < maxDevNum; j++) { ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - pri_data = - ps3_dev_mgr_lookup_vd_pri_data(instance, i, j); - if (unlikely(pri_data == NULL) || - pri_data->lock_mgr.hash_mgr == NULL) { - ps3_mutex_unlock( - &instance->dev_context.dev_priv_lock); + pri_data = ps3_dev_mgr_lookup_vd_pri_data(instance, i, j); + if(unlikely(pri_data == NULL) || pri_data->lock_mgr.hash_mgr == NULL) { + ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); continue; } pri_data->lock_mgr.dev_deling = is_remove; @@ -220,10 +210,9 @@ void ps3_r1x_conflict_queue_clean_all(struct ps3_instance *instance, } } -unsigned char ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, - struct scsi_cmnd *scmd) +Bool ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, struct scsi_cmnd *scmd) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; struct ps3_scsi_priv_data *data = NULL; if (cmd->is_inserted_c_q == 0) { @@ -231,10 +220,11 @@ unsigned char ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, goto l_out; } - LOG_INFO("task abort cmd:%d is in conflict queue !\n", cmd->index); + LOG_INFO("task abort cmd:%d is in conflict queue !\n", + cmd->index); data = (struct ps3_scsi_priv_data *)scmd->device->hostdata; - if (unlikely(data == NULL)) { + if(unlikely(data == NULL)){ ret = PS3_FALSE; goto l_out; } @@ -244,45 +234,46 @@ unsigned char ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, while (cmd->is_inserted_c_q == 1) { ps3_msleep(100); - rmb(); /* in order to force CPU ordering */ + rmb(); } if (cmd->is_r1x_aborting == 0) { ret = PS3_TRUE; while (cmd->cmd_state.state != PS3_CMD_STATE_INIT) { ps3_msleep(10); - rmb(); /* in order to force CPU ordering */ + rmb(); } } else { ret = PS3_FALSE; } LOG_INFO("task abort cmd:%d in conflict queue aborting ret:%d\n", - cmd->index, ret); + cmd->index, ret); l_out: return ret; } -static void ps3_conflict_queue_clean_bitmap(struct ps3_r1x_hash_bit_mgr *mgr) +static void ps3_conflict_queue_clean_bitmap(struct ps3_r1x_hash_bit_mgr* mgr) { - unsigned int i = 0; + U32 i = 0; LOG_FILE_INFO("ready clean conflict queue bitmap\n"); - for (i = 0; i < HASH_TABLE_SIZE; i++) + for (i = 0; i < HASH_TABLE_SIZE; i++) { mgr->hash_item[i].sz_block_idx = RW_SZBLOCK_IDX_INVALID; + } memset(mgr->bitmap_mgr.bit_buff, 0, PS3_R1X_BIT_MAP_SIZE); } static void ps3_conflict_queue_return_all(struct ps3_r1x_lock_mgr *mgr) { - unsigned long flag = 0; - struct list_head conflict_cmd_list_tmp; + ULong flag = 0; + ps3_list_head conflict_cmd_list_tmp; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct scsi_cmnd *s_cmd = NULL; - int ret_result = SCSI_STATUS_GOOD; + S32 ret_result = SCSI_STATUS_GOOD; INIT_LIST_HEAD(&conflict_cmd_list_tmp); ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); @@ -291,22 +282,23 @@ static void ps3_conflict_queue_return_all(struct ps3_r1x_lock_mgr *mgr) if (!list_empty(&mgr->conflict_cmd_list)) { list_for_each_entry_safe(cmd, cmd_next, - &mgr->conflict_cmd_list, cmd_list) { + &mgr->conflict_cmd_list, cmd_list) { list_move_tail(&cmd->cmd_list, &conflict_cmd_list_tmp); } } - ps3_conflict_queue_clean_bitmap( - (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr_conflict); + ps3_conflict_queue_clean_bitmap((struct ps3_r1x_hash_bit_mgr*) + mgr->hash_mgr_conflict); mgr->cmd_count_in_q = 0; ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); - list_for_each_entry_safe(cmd, cmd_next, &conflict_cmd_list_tmp, - cmd_list) { + list_for_each_entry_safe(cmd, cmd_next, + &conflict_cmd_list_tmp, cmd_list) { + LOG_DEBUG("conflict queue cmd:%d t_id:0x%llx return:0x%x\n", - cmd->index, cmd->trace_id, ret_result); + cmd->index, cmd->trace_id, ret_result); ps3_scsi_dma_unmap(cmd); s_cmd = cmd->scmd; @@ -318,15 +310,15 @@ static void ps3_conflict_queue_return_all(struct ps3_r1x_lock_mgr *mgr) SCMD_IO_DONE(s_cmd); } - if (ret_result != SCSI_STATUS_GOOD) + if (ret_result != SCSI_STATUS_GOOD) { mgr->force_ret_code = SCSI_STATUS_GOOD; + } } -static int ps3_conflict_queue_resend(struct ps3_instance *instance, - struct ps3_r1x_lock_mgr *mgr, - struct ps3_cmd *cmd) +static S32 ps3_conflict_queue_resend(struct ps3_instance *instance, + struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_scsi_priv_data *pri_data = NULL; struct scsi_cmnd *s_cmd = cmd->scmd; static unsigned long j; @@ -334,7 +326,7 @@ static int ps3_conflict_queue_resend(struct ps3_instance *instance, ret = instance->ioc_adpter->io_cmd_build(cmd); if (ret == -PS3_IO_CONFLICT_IN_Q) { LOG_DEBUG("t_id:0x%llx hno:%u tag:%d cmd build err ret:%d\n", - cmd->trace_id, PS3_HOST(instance), cmd->index, ret); + cmd->trace_id, PS3_HOST(instance), cmd->index, ret); goto l_out; } @@ -343,15 +335,13 @@ static int ps3_conflict_queue_resend(struct ps3_instance *instance, if (ret == -PS3_IN_QOS_Q) { ret = PS3_SUCCESS; LOG_DEBUG("insert qos waitq. hno:%u t_id:0x%llx tag:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index); + PS3_HOST(instance), cmd->trace_id, cmd->index); goto l_out; } if (ret != PS3_SUCCESS) { s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "t_id:0x%llx hno:%u tag:%d cmd build NOK ret:%d\n", + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "t_id:0x%llx hno:%u tag:%d cmd build NOK ret:%d\n", cmd->trace_id, PS3_HOST(instance), cmd->index, ret); goto l_cmd_release; } @@ -360,15 +350,11 @@ static int ps3_conflict_queue_resend(struct ps3_instance *instance, if (unlikely(ret != PS3_SUCCESS)) { if (ret == -PS3_RECOVERED || ret == -PS3_RETRY) { ps3_errcode_to_scsi_status(instance, s_cmd, - SCSI_STATUS_BUSY, NULL, 0, - cmd); + SCSI_STATUS_BUSY, NULL, 0, cmd); } else { - s_cmd->result = - PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); } - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "t_id:0x%llx hno:%u tag:%d cmd send NOK ret:%d\n", + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "t_id:0x%llx hno:%u tag:%d cmd send NOK ret:%d\n", cmd->trace_id, PS3_HOST(instance), cmd->index, ret); PS3_DEV_IO_START_ERR_INC(instance, cmd); goto l_cmd_release; @@ -385,40 +371,38 @@ static int ps3_conflict_queue_resend(struct ps3_instance *instance, return ret; } -static int ps3_conflict_queue_send_wk(void *data) +static S32 ps3_conflict_queue_send_wk(void *data) { struct scsi_device *sdev = (struct scsi_device *)data; - struct ps3_r1x_lock_mgr *mgr = &PS3_SDEV_PRI_DATA(sdev)->lock_mgr; + struct ps3_r1x_lock_mgr *mgr =&PS3_SDEV_PRI_DATA(sdev)->lock_mgr; struct ps3_instance *instance = - (struct ps3_instance *)sdev->host->hostdata; + (struct ps3_instance*)sdev->host->hostdata; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct scsi_cmnd *s_cmd = NULL; - unsigned long flag = 0; - int ret = PS3_SUCCESS; - unsigned int cur_total_count = 0; - unsigned int cmd_count = 0; - unsigned char try_count = 0; + ULong flag = 0; + S32 ret = PS3_SUCCESS; + U32 cur_total_count = 0; + U32 cmd_count = 0; + U8 try_count = 0; LOG_INFO("hno:%u vd[%u:%u] conflict queue thread enter\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); while (true) { wait_for_completion_interruptible(&mgr->thread_sync); if (mgr->thread_stop || kthread_should_stop()) { LOG_INFO("hno:%u r1x conflict thread, ready stop\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } if (mgr->force_ret_code != SCSI_STATUS_GOOD) { - LOG_INFO( - "hno:%u r1x conflict thread, return all cmd with:0x%x\n", + LOG_INFO("hno:%u r1x conflict thread, return all cmd with:0x%x\n", PS3_HOST(instance), mgr->force_ret_code); ps3_conflict_queue_return_all(mgr); - LOG_INFO( - "hno:%u r1x conflict thread, return all cmd with:0x%x end\n", + LOG_INFO("hno:%u r1x conflict thread, return all cmd with:0x%x end\n", PS3_HOST(instance), mgr->force_ret_code); continue; } @@ -430,40 +414,36 @@ static int ps3_conflict_queue_send_wk(void *data) try_count = 0; list_for_each_entry_safe(cmd, cmd_next, - &mgr->conflict_cmd_list, cmd_list) { + &mgr->conflict_cmd_list, cmd_list) { + if (cmd->is_r1x_aborting == 1) { ps3_scsi_dma_unmap(cmd); s_cmd = cmd->scmd; cmd->is_r1x_aborting = 0; - wmb(); /* in order to force CPU ordering */ + wmb(); ps3_r1x_conflict_queue_del(mgr, cmd); PS3_IO_OUTSTAND_DEC(instance, s_cmd); PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); s_cmd->result = SCSI_STATUS_TASK_ABORTED; SCMD_IO_DONE(s_cmd); + PS3_IJ_SLEEP(2000, PS3_ERR_IJ_R1X_ABORT); ps3_scsi_cmd_free(cmd); - LOG_INFO( - "hno:%u cmd:%d out r1x conflict queue by abort\n", + LOG_INFO("hno:%u cmd:%d out r1x conflict queue by abort\n", PS3_HOST(instance), cmd->index); continue; } LOG_DEBUG("hno:%u cmd:%d t_id:0x%llx ready resend\n", - PS3_HOST(instance), cmd->index, - cmd->trace_id); + PS3_HOST(instance), cmd->index, cmd->trace_id); ret = ps3_conflict_queue_resend(instance, mgr, cmd); if (ret == PS3_SUCCESS) { - LOG_DEBUG( - "hno:%u cmd:%d t_id[%llx] out r1x conflict queue by send success\n", - PS3_HOST(instance), cmd->index, - cmd->trace_id); - } else if (ret == -PS3_IO_CONFLICT_IN_Q) { + LOG_DEBUG("hno:%u cmd:%d t_id[%llx] out r1x conflict queue by send success\n", + PS3_HOST(instance), cmd->index, cmd->trace_id); + } else if(ret == -PS3_IO_CONFLICT_IN_Q) { } else { - LOG_INFO( - "hno:%u cmd:%d tid:0x%llx out r1x conflict queue by send failed\n", - PS3_HOST(instance), cmd->index, - cmd->trace_id); + LOG_INFO("hno:%u cmd:%d tid:0x%llx out r1x conflict queue by send failed\n", + PS3_HOST(instance), cmd->index, cmd->trace_id); ps3_scsi_dma_unmap(cmd); s_cmd = cmd->scmd; PS3_IO_OUTSTAND_DEC(cmd->instance, s_cmd); @@ -473,10 +453,10 @@ static int ps3_conflict_queue_send_wk(void *data) SCMD_IO_DONE(s_cmd); } LOG_DEBUG("hno:%u cmd:%d t_id:0x%llx resend ret:%d\n", - PS3_HOST(instance), cmd->index, cmd->trace_id, - ret); - if (++cmd_count == cur_total_count) + PS3_HOST(instance), cmd->index, cmd->trace_id, ret); + if (++cmd_count == cur_total_count) { break; + } if (++try_count == PS3_R1X_RESEND_COUNT) { cond_resched(); @@ -491,175 +471,155 @@ static int ps3_conflict_queue_send_wk(void *data) PS3_BUG(); } ps3_conflict_queue_clean_bitmap( - (struct ps3_r1x_hash_bit_mgr *) - mgr->hash_mgr_conflict); + (struct ps3_r1x_hash_bit_mgr*) + mgr->hash_mgr_conflict); } ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); + INJECT_START(PS3_ERR_IJ_R1X_CONFLICTQ_PROCESS_FINISH, instance); } l_out: LOG_FILE_INFO("hno:%u vd[%u:%u] conflict queue thread exit\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); return 0; } -static inline void ps3_r1x_bitmap_set(struct ps3_r1x_hash_bit_mgr *pHashbitMgr, - unsigned short bitmap_idx, - unsigned int bit_start, - unsigned int bit_cnt) +static inline void ps3_r1x_bitmap_set(struct ps3_r1x_hash_bit_mgr* pHashbitMgr, + U16 bitmap_idx, U32 bit_start, U32 bit_cnt) { - unsigned int i = 0; - unsigned long *addr = (unsigned long *)(void *)&RW_R1X_GET_BITMAP( - pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); - for (; i < bit_cnt; ++i) - setBitNonAtomic(bit_start + i, addr); + U32 i = 0; + ULong* addr = (ULong*)(void*)&RW_R1X_GET_BITMAP(pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); + for(; i < bit_cnt; ++i){ + setBitNonAtomic(bit_start+i, addr); + } } -static inline void -ps3_r1x_bitmap_clean(struct ps3_r1x_hash_bit_mgr *pHashbitMgr, - unsigned short bitmap_idx, unsigned int bit_start, - unsigned int bit_cnt) +static inline void ps3_r1x_bitmap_clean(struct ps3_r1x_hash_bit_mgr* pHashbitMgr, + U16 bitmap_idx, U32 bit_start, U32 bit_cnt) { - unsigned int i = 0; - unsigned long *addr = (unsigned long *)(void *)&RW_R1X_GET_BITMAP( - pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); - for (; i < bit_cnt; ++i) - clearBitNonAtomic(bit_start + i, addr); + U32 i = 0; + ULong* addr = (ULong*)(void*)&RW_R1X_GET_BITMAP(pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); + for(; i < bit_cnt; ++i){ + clearBitNonAtomic(bit_start+i, addr); + } } -static inline int ps3_r1x_bitmap_check(struct ps3_r1x_hash_bit_mgr *pHashbitMgr, - unsigned short bitmap_idx, - unsigned int bit_start, - unsigned int bit_cnt) +static inline S32 ps3_r1x_bitmap_check(struct ps3_r1x_hash_bit_mgr* pHashbitMgr, + U16 bitmap_idx, U32 bit_start, U32 bit_cnt) { - unsigned int i = 0; - unsigned long *addr = (unsigned long *)(void *)&RW_R1X_GET_BITMAP( - pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); - for (; i < bit_cnt; ++i) { - if (unlikely(testBitNonAtomic(bit_start + i, addr))) - return -PS3_R1X_IO_CONFLICT; - } - return PS3_SUCCESS; + U32 i = 0; + ULong* addr = (ULong*)(void*)&RW_R1X_GET_BITMAP(pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); + for(; i < bit_cnt; ++i){ + if(unlikely(testBitNonAtomic(bit_start+i, addr))){ + return -PS3_R1X_IO_CONFLICT; + } + } + return PS3_SUCCESS; } -static inline unsigned int calc_block_num(unsigned long long lba, - unsigned int len, - unsigned int block_shift, - unsigned int block_mask) +static inline U32 calc_block_num(U64 lba, U32 len, U32 block_shift, U32 block_mask) { - unsigned long long start_align = lba; - unsigned int block_num = 0; - unsigned int remain_len = 0; - - if (lba & block_mask) { - block_num += 1; - start_align = ((lba >> block_shift) + 1) << block_shift; - } - - if (start_align < lba + len) { - remain_len = len - ((unsigned int)(start_align - lba)); - block_num += remain_len >> block_shift; - if (remain_len & block_mask) - block_num += 1; - } - - return block_num; + U64 start_align = lba; + U32 block_num = 0; + U32 remain_len = 0; + + if (lba & block_mask) { + block_num += 1; + start_align = ((lba >> block_shift) + 1) << block_shift; + } + + if(start_align < lba + len){ + remain_len = len - ((U32)(start_align - lba)); + block_num += remain_len >> block_shift; + if(remain_len & block_mask){ + block_num += 1; + } + } + + return block_num; } -struct ps3_write_r1x_hash_tmp { - struct ps3_r1x_hash_bit_item *hash_item; - unsigned int bit_start; - unsigned int bit_cnt; - unsigned char is_new; - unsigned char resv[7]; +struct ps3_write_r1x_hash_tmp{ + struct ps3_r1x_hash_bit_item* hash_item; + U32 bit_start; + U32 bit_cnt; + Bool is_new; + U8 resv[7]; }; -int ps3_r1x_hash_bit_check(struct ps3_r1x_hash_bit_mgr *hash_mgr, - unsigned long long lba, unsigned int len, - struct ps3_write_r1x_hash_tmp *hash_tmp, - unsigned short hash_idx) +S32 ps3_r1x_hash_bit_check(struct ps3_r1x_hash_bit_mgr* hash_mgr, + U64 lba, U32 len, + struct ps3_write_r1x_hash_tmp* hash_tmp, U16 hash_idx) { - unsigned long long sz_block_idx = 0; - unsigned int offset = 0; - struct ps3_r1x_hash_bit_item *hash_item = NULL; - int ret = PS3_SUCCESS; - unsigned int bit_start = 0; - unsigned int bit_cnt = 0; - - hash_item = &hash_mgr->hash_item[hash_idx]; - sz_block_idx = RW_R1X_SZBLOCKIDX(lba); - offset = (unsigned int)(lba & SZBLOCK_SIZE_MASK); - bit_start = offset >> LOCK_BLOCK_SIZE_SHIFT; - bit_cnt = calc_block_num(lba, len, LOCK_BLOCK_SIZE_SHIFT, - LOCK_BLOCK_SIZE_MASK); - hash_tmp->hash_item = hash_item; - hash_tmp->is_new = PS3_FALSE; - hash_tmp->bit_start = bit_start; - hash_tmp->bit_cnt = bit_cnt; - - PS3_R1X_LOCK_TRACE( - "lba=%llu, len=%u, hash_idx=%u, hash item=%p, bit check.", lba, - len, hash_idx, hash_item); + U64 sz_block_idx = 0; + U32 offset = 0; + struct ps3_r1x_hash_bit_item* hash_item = NULL; + S32 ret = PS3_SUCCESS; + U32 bit_start = 0; + U32 bit_cnt = 0; + + hash_item = &hash_mgr->hash_item[hash_idx]; + sz_block_idx = RW_R1X_SZBLOCKIDX(lba); + offset = (U32)(lba & SZBLOCK_SIZE_MASK); + bit_start = offset >> LOCK_BLOCK_SIZE_SHIFT; + bit_cnt = calc_block_num(lba, len, LOCK_BLOCK_SIZE_SHIFT, LOCK_BLOCK_SIZE_MASK); + hash_tmp->hash_item = hash_item; + hash_tmp->is_new = PS3_FALSE; + hash_tmp->bit_start = bit_start; + hash_tmp->bit_cnt = bit_cnt; + + PS3_R1X_LOCK_TRACE("lba=%llu, len=%u, hash_idx=%u, hash item=%p, bit check.", + lba, len, hash_idx, hash_item); if (hash_item->sz_block_idx == RW_SZBLOCK_IDX_INVALID) { - hash_item->sz_block_idx = sz_block_idx; - hash_tmp->is_new = PS3_TRUE; - PS3_R1X_LOCK_TRACE( - "lba=%llu, len=%u, hash_idx=%u, bit_idx=%u, hash item=%p, new hash item.", - lba, len, hash_idx, - (unsigned short)hash_item->bitmap_idx, hash_item); - } else { - if (hash_item->sz_block_idx == sz_block_idx) { - ret = ps3_r1x_bitmap_check( - hash_mgr, (unsigned short)hash_item->bitmap_idx, - bit_start, bit_cnt); - } else { - PS3_R1X_LOCK_TRACE( - "hash item=%p, oldSzBlock=%llu, newSzBlock=%llu, hash conflict.", - hash_item, - (unsigned long long)hash_item->sz_block_idx, - sz_block_idx); - ret = -PS3_R1X_HASH_CONFILICT; - } - } - - return ret; + hash_item->sz_block_idx = sz_block_idx; + hash_tmp->is_new = PS3_TRUE; + PS3_R1X_LOCK_TRACE("lba=%llu, len=%u, hash_idx=%u, bit_idx=%u, hash item=%p, new hash item.", + lba, len, hash_idx, (U16)hash_item->bitmap_idx, hash_item); + } else { + if(hash_item->sz_block_idx == sz_block_idx) { + ret = ps3_r1x_bitmap_check(hash_mgr,(U16)hash_item->bitmap_idx, bit_start, bit_cnt); + } else { + PS3_R1X_LOCK_TRACE("hash item=%p, oldSzBlock=%llu, newSzBlock=%llu, hash conflict.", + hash_item, (U64)hash_item->sz_block_idx, sz_block_idx); + ret = -PS3_R1X_HASH_CONFILICT; + } + } + + return ret; } -static unsigned char -ps3_r1x_hash_bit_check_conflict_queue(struct ps3_r1x_lock_mgr *mgr, - unsigned long long lba, unsigned int len, - unsigned int left) +static Bool ps3_r1x_hash_bit_check_conflict_queue( + struct ps3_r1x_lock_mgr *mgr, U64 lba, U32 len, U32 left) { - unsigned char is_conflict = PS3_TRUE; - int ret = PS3_SUCCESS; - unsigned int i = 0; - unsigned char item_cnt = 0; + Bool is_conflict = PS3_TRUE; + S32 ret = PS3_SUCCESS; + U32 i = 0; + U8 item_cnt = 0; - struct ps3_write_r1x_hash_tmp *hash_tmp = NULL; + struct ps3_write_r1x_hash_tmp* hash_tmp = NULL; struct ps3_write_r1x_hash_tmp tmp_array[SZ_BLOCK_SPLIT_MAX]; - struct ps3_r1x_hash_bit_mgr *hash_mgr = - (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr_conflict; + struct ps3_r1x_hash_bit_mgr* hash_mgr = + (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr_conflict; - LOG_DEBUG("lba=%llu, len=%u, left=%u,\n" - "\tcheck if conflict with conflict queue.\n", - lba, len, left); + LOG_DEBUG("lba=%llu, len=%u, left=%u, " + "check if conflict with conflict queue.\n", + lba, len, left); - do { + do{ len = PS3_MIN(len, left); ret = ps3_r1x_hash_bit_check(hash_mgr, lba, len, - &tmp_array[item_cnt], - RW_R1X_HASHIDX(lba)); + &tmp_array[item_cnt], RW_R1X_HASHIDX(lba)); item_cnt += 1; - if (ret != PS3_SUCCESS) { + if(PS3_SUCCESS != ret) { is_conflict = PS3_TRUE; goto exit_fail; } left -= len; lba += len; len = SZBLOCK_SIZE; - } while (left > 0); + }while(left > 0); is_conflict = PS3_FALSE; @@ -676,86 +636,82 @@ ps3_r1x_hash_bit_check_conflict_queue(struct ps3_r1x_lock_mgr *mgr, return is_conflict; } -void ps3_r1x_conflict_queue_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, - struct ps3_cmd *cmd) +void ps3_r1x_conflict_queue_hash_bit_lock( + struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - unsigned int i = 0; - unsigned char item_cnt = 0; - unsigned int shift = 0; - unsigned long long lba = 0; - unsigned int len = 0; - unsigned int left = 0; - - struct ps3_r1x_hash_bit_mgr *hash_mgr_conflict = - (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr_conflict; - struct ps3_write_r1x_hash_tmp *hash_tmp = NULL; + U32 i = 0; + U8 item_cnt = 0; + U32 shift = 0; + U64 lba = 0; + U32 len = 0; + U32 left = 0; + + struct ps3_r1x_hash_bit_mgr* hash_mgr_conflict = + (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr_conflict; + struct ps3_write_r1x_hash_tmp* hash_tmp = NULL; struct ps3_write_r1x_hash_tmp tmp_array[SZ_BLOCK_SPLIT_MAX]; shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? - 0 : - SECTOR_512_4K_SHIFT; + 0 : SECTOR_512_4K_SHIFT; lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; left = cmd->io_attr.num_blocks << shift; len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); - do { + do{ len = PS3_MIN(len, left); hash_tmp = &tmp_array[item_cnt]; - hash_tmp->hash_item = - &hash_mgr_conflict->hash_item[RW_R1X_HASHIDX(lba)]; + hash_tmp->hash_item = &hash_mgr_conflict->hash_item[ + RW_R1X_HASHIDX(lba)]; hash_tmp->hash_item->sz_block_idx = RW_R1X_SZBLOCKIDX(lba); hash_tmp->is_new = PS3_TRUE; - hash_tmp->bit_start = - ((unsigned int)(lba & SZBLOCK_SIZE_MASK)) >> + hash_tmp->bit_start = ((U32)(lba & SZBLOCK_SIZE_MASK)) >> LOCK_BLOCK_SIZE_SHIFT; - hash_tmp->bit_cnt = calc_block_num( - lba, len, LOCK_BLOCK_SIZE_SHIFT, LOCK_BLOCK_SIZE_MASK); + hash_tmp->bit_cnt = calc_block_num(lba, len, + LOCK_BLOCK_SIZE_SHIFT, LOCK_BLOCK_SIZE_MASK); item_cnt += 1; left -= len; lba += len; len = SZBLOCK_SIZE; - } while (left > 0); + } while(left > 0); - for (i = 0; i < item_cnt; ++i) { + for(i = 0; i < item_cnt; ++i){ hash_tmp = &tmp_array[i]; - ps3_r1x_bitmap_set( - hash_mgr_conflict, - (unsigned short)hash_tmp->hash_item->bitmap_idx, + ps3_r1x_bitmap_set(hash_mgr_conflict, + (U16)hash_tmp->hash_item->bitmap_idx, hash_tmp->bit_start, hash_tmp->bit_cnt); } + return; } -int ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) +S32 ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - unsigned int i = 0; - unsigned char item_cnt = 0; - unsigned char item_cnt_conflict = 0; - unsigned int shift = 0; - unsigned long long lba = 0; - unsigned int len = 0; - unsigned int left = 0; - struct ps3_r1x_hash_bit_mgr *hash_mgr = - (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr; - struct ps3_r1x_hash_bit_mgr *hash_mgr_conflict = - (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr_conflict; - struct ps3_write_r1x_hash_tmp *hash_tmp = NULL; + S32 ret = PS3_SUCCESS; + U32 i = 0; + U8 item_cnt = 0; + U8 item_cnt_conflict = 0; + U32 shift = 0; + U64 lba = 0; + U32 len = 0; + U32 left = 0; + struct ps3_r1x_hash_bit_mgr* hash_mgr = + (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr; + struct ps3_r1x_hash_bit_mgr* hash_mgr_conflict = + (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr_conflict; + struct ps3_write_r1x_hash_tmp* hash_tmp = NULL; struct ps3_write_r1x_hash_tmp tmp_array[SZ_BLOCK_SPLIT_MAX]; struct ps3_write_r1x_hash_tmp tmp_array_conflict[SZ_BLOCK_SPLIT_MAX]; - unsigned long flag = 0; - unsigned char is_conflict_q_empty = PS3_FALSE; + ULong flag = 0; + Bool is_conflict_q_empty = PS3_FALSE; - LOG_DEBUG( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, try lock.\n", + LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, try lock.\n", cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, cmd); shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? - 0 : - SECTOR_512_4K_SHIFT; + 0 : SECTOR_512_4K_SHIFT; lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; len = cmd->io_attr.num_blocks << shift; left = len; @@ -773,55 +729,56 @@ int ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); if (is_conflict_q_empty) { - do { + do{ PS3_BUG_ON(item_cnt >= SZ_BLOCK_SPLIT_MAX); len = PS3_MIN(len, left); ret = ps3_r1x_hash_bit_check(hash_mgr, lba, len, - &tmp_array[item_cnt], - RW_R1X_HASHIDX(lba)); + &tmp_array[item_cnt], + RW_R1X_HASHIDX(lba)); item_cnt += 1; - if (ret != PS3_SUCCESS) + if(PS3_SUCCESS != ret) { goto exit_fail; + } left -= len; lba += len; len = SZBLOCK_SIZE; - } while (left > 0); + } while(left > 0); } else { - do { + do{ PS3_BUG_ON(item_cnt >= SZ_BLOCK_SPLIT_MAX); len = PS3_MIN(len, left); ret = ps3_r1x_hash_bit_check(hash_mgr, lba, len, - &tmp_array[item_cnt], - RW_R1X_HASHIDX(lba)); + &tmp_array[item_cnt], + RW_R1X_HASHIDX(lba)); item_cnt += 1; - if (ret != PS3_SUCCESS) + if(PS3_SUCCESS != ret) { goto exit_fail; - ret = ps3_r1x_hash_bit_check( - hash_mgr_conflict, lba, len, + } + ret = ps3_r1x_hash_bit_check(hash_mgr_conflict, lba, len, &tmp_array_conflict[item_cnt_conflict], RW_R1X_HASHIDX(lba)); item_cnt_conflict += 1; - if (ret != PS3_SUCCESS) + if(PS3_SUCCESS != ret) { goto exit_fail; + } left -= len; lba += len; len = SZBLOCK_SIZE; - } while (left > 0); + } while(left > 0); - for (i = 0; i < item_cnt_conflict; ++i) { + for(i = 0; i < item_cnt_conflict; ++i){ hash_tmp = &tmp_array_conflict[i]; - if (hash_tmp->is_new == PS3_TRUE) { + if(PS3_TRUE == hash_tmp->is_new){ hash_tmp->hash_item->sz_block_idx = RW_SZBLOCK_IDX_INVALID; } } } - for (i = 0; i < item_cnt; ++i) { + for(i = 0; i < item_cnt; ++i){ hash_tmp = &tmp_array[i]; - ps3_r1x_bitmap_set( - hash_mgr, - (unsigned short)hash_tmp->hash_item->bitmap_idx, + ps3_r1x_bitmap_set(hash_mgr, + (U16)hash_tmp->hash_item->bitmap_idx, hash_tmp->bit_start, hash_tmp->bit_cnt); } @@ -830,8 +787,7 @@ int ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) cmd->szblock_cnt = item_cnt; cmd->is_got_r1x = 1; - LOG_DEBUG( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.\n", + LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.\n", cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); @@ -839,25 +795,24 @@ int ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) goto l_out; exit_fail: - LOG_DEBUG( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock failed, ret=%d\n" - "\t(%d: io conflict, %d: hash conflict, %d: bitmap not enough).\n", + LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock faild, ret=%d" + "(%d: io conflict, %d: hash conflict, %d: bitmap not enough).\n", cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, ret, -PS3_R1X_IO_CONFLICT, - -PS3_R1X_HASH_CONFILICT, -PS3_R1X_BIT_NOT_ENOUGH); + -PS3_R1X_HASH_CONFILICT,-PS3_R1X_BIT_NOT_ENOUGH); cmd->szblock_cnt = 0; - for (i = 0; i < item_cnt; ++i) { + for(i = 0; i < item_cnt; ++i){ hash_tmp = &tmp_array[i]; - if (hash_tmp->is_new == PS3_TRUE) { + if(PS3_TRUE == hash_tmp->is_new){ hash_tmp->hash_item->sz_block_idx = RW_SZBLOCK_IDX_INVALID; } } - for (i = 0; i < item_cnt_conflict; ++i) { + for(i = 0; i < item_cnt_conflict; ++i){ hash_tmp = &tmp_array_conflict[i]; - if (hash_tmp->is_new == PS3_TRUE) { + if(PS3_TRUE == hash_tmp->is_new){ hash_tmp->hash_item->sz_block_idx = RW_SZBLOCK_IDX_INVALID; } @@ -873,10 +828,11 @@ int ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) ret = -PS3_IO_CONFLICT_IN_Q; } else { - if (is_conflict_q_empty) + if (is_conflict_q_empty) { ret = -PS3_IO_REQUEUE; - else + } else { ret = -PS3_IO_CONFLICT; + } } } else { ret = -PS3_IO_CONFLICT; @@ -884,9 +840,8 @@ int ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); - LOG_DEBUG( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock failed, fanal ret=%d\n" - "\t(%d: conflict requeue, %d: conflict in queue, %d: conflict busy).\n", + LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock faild, fanal ret=%d" + "(%d: conflict requeue, %d: conflict in queue, %d: conflict busy).\n", cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, ret, -PS3_IO_REQUEUE, -PS3_IO_CONFLICT_IN_Q, -PS3_IO_CONFLICT); @@ -895,59 +850,51 @@ int ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) return ret; } -static int ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, - struct ps3_cmd *cmd) +static S32 ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, + struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - unsigned int i = 0; - unsigned char item_cnt = 0; - unsigned int shift = 0; - unsigned long long lba = 0; - unsigned int len = 0; - unsigned int left = 0; - struct ps3_r1x_hash_bit_mgr *hash_mgr = - (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr; - struct ps3_write_r1x_hash_tmp *hash_tmp = NULL; + S32 ret = PS3_SUCCESS; + U32 i = 0; + U8 item_cnt = 0; + U32 shift = 0; + U64 lba = 0; + U32 len = 0; + U32 left = 0; + struct ps3_r1x_hash_bit_mgr* hash_mgr = (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr; + struct ps3_write_r1x_hash_tmp* hash_tmp = NULL; struct ps3_write_r1x_hash_tmp tmp_array[SZ_BLOCK_SPLIT_MAX]; - unsigned long flag = 0; + ULong flag = 0; - LOG_DEBUG( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, try lock.\n", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, - cmd->io_attr.num_blocks, cmd); + LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, try lock.\n", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, cmd); - shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? - 0 : - SECTOR_512_4K_SHIFT; - ; - lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; - ; + shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? 0 : SECTOR_512_4K_SHIFT;; + lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift;; len = cmd->io_attr.num_blocks << shift; left = len; ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); - do { + do{ PS3_BUG_ON(item_cnt >= SZ_BLOCK_SPLIT_MAX); len = PS3_MIN(len, left); ret = ps3_r1x_hash_bit_check(hash_mgr, lba, len, - &tmp_array[item_cnt], - RW_R1X_HASHIDX(lba)); + &tmp_array[item_cnt], RW_R1X_HASHIDX(lba)); item_cnt += 1; - if (ret != PS3_SUCCESS) + if(PS3_SUCCESS != ret) { goto exit_fail; + } left -= len; lba += len; len = SZBLOCK_SIZE; - } while (left > 0); + }while(left > 0); - for (i = 0; i < item_cnt; ++i) { + for(i = 0; i < item_cnt; ++i){ hash_tmp = &tmp_array[i]; - ps3_r1x_bitmap_set( - hash_mgr, - (unsigned short)hash_tmp->hash_item->bitmap_idx, - hash_tmp->bit_start, hash_tmp->bit_cnt); + ps3_r1x_bitmap_set(hash_mgr, + (U16)hash_tmp->hash_item->bitmap_idx, hash_tmp->bit_start, + hash_tmp->bit_cnt); } ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); @@ -955,8 +902,7 @@ static int ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, cmd->szblock_cnt = item_cnt; cmd->is_got_r1x = 1; - LOG_DEBUG( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.\n", + LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.\n", cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); @@ -964,9 +910,9 @@ static int ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, exit_fail: - for (i = 0; i < item_cnt; ++i) { + for(i = 0; i < item_cnt; ++i){ hash_tmp = &tmp_array[i]; - if (hash_tmp->is_new == PS3_TRUE) { + if(PS3_TRUE == hash_tmp->is_new){ hash_tmp->hash_item->sz_block_idx = RW_SZBLOCK_IDX_INVALID; } @@ -977,91 +923,79 @@ static int ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, cmd->szblock_cnt = 0; ret = -PS3_IO_CONFLICT_IN_Q; - LOG_DEBUG( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, relock failed, ret=%d\n" - "\t(%d: io conflict, %d: hash conflict, %d: bitmap not enough).\n", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, - cmd->io_attr.num_blocks, ret, -PS3_R1X_IO_CONFLICT, - -PS3_R1X_HASH_CONFILICT, -PS3_R1X_BIT_NOT_ENOUGH); + LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, relock faild, ret=%d" + "(%d: io conflict, %d: hash conflict, %d: bitmap not enough).\n", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks,ret, + -PS3_R1X_IO_CONFLICT,-PS3_R1X_HASH_CONFILICT,-PS3_R1X_BIT_NOT_ENOUGH); return ret; } void ps3_r1x_hash_bit_unlock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - struct ps3_r1x_hash_bit_item *hash_item = NULL; - unsigned int bit_start = 0; - unsigned int bit_cnt = 0; - unsigned long long *bit_map = NULL; - unsigned int i = 0; - int is_clean = PS3_TRUE; - unsigned int shift = 0; - unsigned long long lba = 0; - unsigned int len = 0; - unsigned int left = 0; - unsigned long long conflict_check_lba = 0; - unsigned int conflict_check_len = 0; - unsigned int conflict_check_left = 0; - struct ps3_r1x_hash_bit_mgr *hash_mgr = - (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr; - struct ps3_r1x_bit_block_mgr *bit_map_mgr = &hash_mgr->bitmap_mgr; - unsigned long flag = 0; - unsigned char ret_check = PS3_CONFLICT_QUEUE_EMPTY; - - PS3_R1X_LOCK_TRACE( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, unlock.", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, - cmd->io_attr.num_blocks, cmd); - - shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? - 0 : - SECTOR_512_4K_SHIFT; - lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; - left = cmd->io_attr.num_blocks << shift; - len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); + struct ps3_r1x_hash_bit_item* hash_item = NULL; + U32 bit_start = 0; + U32 bit_cnt = 0; + U64* bit_map = NULL; + U32 i = 0; + BOOL is_clean = PS3_TRUE; + U32 shift = 0; + U64 lba = 0; + U32 len = 0; + U32 left = 0; + U64 conflict_check_lba = 0; + U32 conflict_check_len = 0; + U32 conflict_check_left = 0; + struct ps3_r1x_hash_bit_mgr* hash_mgr = (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr; + struct ps3_r1x_bit_block_mgr* bit_map_mgr = &hash_mgr->bitmap_mgr; + ULong flag = 0; + U8 ret_check = PS3_CONFLICT_QUEUE_EMPTY; + + PS3_R1X_LOCK_TRACE("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, unlock.", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, cmd); + + shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? 0 : SECTOR_512_4K_SHIFT; + lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; + left = cmd->io_attr.num_blocks << shift; + len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); conflict_check_lba = lba; conflict_check_len = len; conflict_check_left = left; - ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); - do { - hash_item = &hash_mgr->hash_item[RW_R1X_HASHIDX(lba)]; - len = PS3_MIN(len, left); - bit_start = (lba & SZBLOCK_SIZE_MASK) >> LOCK_BLOCK_SIZE_SHIFT; - bit_cnt = calc_block_num(lba, len, LOCK_BLOCK_SIZE_SHIFT, - LOCK_BLOCK_SIZE_MASK); - ps3_r1x_bitmap_clean(hash_mgr, - (unsigned short)hash_item->bitmap_idx, - bit_start, bit_cnt); - - is_clean = PS3_TRUE; - bit_map = (unsigned long long *)(void *)&RW_R1X_GET_BITMAP( - bit_map_mgr->bit_buff, hash_item->bitmap_idx); - for (i = 0; i < bit_map_mgr->bit_block_size; ++i) { - if (bit_map[i] != 0) - is_clean = PS3_FALSE; - } + ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); + do{ + hash_item = &hash_mgr->hash_item[RW_R1X_HASHIDX(lba)]; + len = PS3_MIN(len, left); + bit_start = (lba & SZBLOCK_SIZE_MASK) >> LOCK_BLOCK_SIZE_SHIFT; + bit_cnt = calc_block_num(lba, len, LOCK_BLOCK_SIZE_SHIFT, LOCK_BLOCK_SIZE_MASK); + ps3_r1x_bitmap_clean(hash_mgr, (U16)hash_item->bitmap_idx, bit_start, bit_cnt); + + is_clean = PS3_TRUE; + bit_map = (U64*)(void*)&RW_R1X_GET_BITMAP(bit_map_mgr->bit_buff, hash_item->bitmap_idx); + for(i = 0; i < bit_map_mgr->bit_block_size; ++i){ + if(bit_map[i] != 0){ + is_clean = PS3_FALSE; + } + } if (is_clean == PS3_TRUE) { - PS3_R1X_LOCK_TRACE( - "t_id:0x%llx lba=%llu, len=%u, szBlockIdx=%llu, bitIdx=%lu,\n" - "\tszblock_cnt=%u, cmd=%p, release hash item.", - cmd->trace_id, lba, len, - (unsigned long long)hash_item->sz_block_idx, - (unsigned long)hash_item->bitmap_idx, + PS3_R1X_LOCK_TRACE("t_id:0x%llx lba=%llu, len=%u, szBlockIdx=%llu, bitIdx=%lu, " + "szblock_cnt=%u, cmd=%p, release hash item.", + cmd->trace_id, lba, len, (U64)hash_item->sz_block_idx, + (unsigned long int)hash_item->bitmap_idx, cmd->szblock_cnt, cmd); hash_item->sz_block_idx = RW_SZBLOCK_IDX_INVALID; } - left -= len; - lba += len; - len = SZBLOCK_SIZE; - } while (left > 0); + left -= len; + lba += len; + len = SZBLOCK_SIZE; + }while(left > 0); if (!list_empty(&mgr->conflict_cmd_list)) { - if (ps3_r1x_hash_bit_check_conflict_queue( - mgr, conflict_check_lba, conflict_check_len, - conflict_check_left)) { + if (ps3_r1x_hash_bit_check_conflict_queue(mgr, + conflict_check_lba, conflict_check_len, + conflict_check_left)) { ret_check = PS3_CONFLICT_QUEUE_CONFLICT; } else { ret_check = PS3_CONFLICT_QUEUE_NO_CONFLICT; @@ -1071,423 +1005,387 @@ void ps3_r1x_hash_bit_unlock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); if (ret_check != PS3_CONFLICT_QUEUE_EMPTY) { - LOG_FILE_INFO("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u,\n" - "\tconflict queue check ret:%d.\n", - cmd->trace_id, cmd->io_attr.lba_hi, - cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, - ret_check); + LOG_FILE_INFO("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u," + " conflict queue check ret:%d.\n", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, + cmd->io_attr.num_blocks, ret_check); - if (ret_check == PS3_CONFLICT_QUEUE_CONFLICT) + if (ret_check == PS3_CONFLICT_QUEUE_CONFLICT) { complete(&mgr->thread_sync); + } } + return; } -static void *ps3_r1x_lock_hash_bit_init(struct ps3_instance *instance) +static void* ps3_r1x_lock_hash_bit_init(struct ps3_instance *instance) { - unsigned int bit_map_size = 0; - unsigned short sz_block_bit_cnt = 0; - unsigned short bitmap_block_size = 0; - unsigned short bitmap_block_cnt = 0; - unsigned int total_size = 0; - struct ps3_r1x_hash_bit_mgr *mgr = NULL; - unsigned char *buff = NULL; - unsigned int i = 0; - (void)instance; - (void)bitmap_block_cnt; + U32 bit_map_size = 0; + U16 sz_block_bit_cnt = 0; + U16 bitmap_block_size = 0; + U16 bitmap_block_cnt = 0; + U32 total_size = 0; + struct ps3_r1x_hash_bit_mgr* mgr = NULL; + U8* buff = NULL; + U32 i = 0; + (void)instance; + (void)bitmap_block_cnt; if (SZBLOCK_SIZE & LOCK_BLOCK_SIZE_MASK) { - LOG_FILE_ERROR("hno: %u, SZBLOCK_SIZE check NOK\n", - PS3_HOST(instance)); + LOG_FILE_ERROR("hno: %u, SZBLOCK_SIZE check NOK\n", PS3_HOST(instance)); goto exit; } - bit_map_size = PS3_R1X_BIT_MAP_SIZE; - sz_block_bit_cnt = SZBLOCK_SIZE >> LOCK_BLOCK_SIZE_SHIFT; + bit_map_size = PS3_R1X_BIT_MAP_SIZE; + sz_block_bit_cnt = SZBLOCK_SIZE >> LOCK_BLOCK_SIZE_SHIFT; if (sz_block_bit_cnt & RW_BIT_64_MASK) { - LOG_FILE_ERROR("hno: %u, sz_block_bit_cnt check NOK\n", - PS3_HOST(instance)); - goto exit; - } - total_size = sizeof(struct ps3_r1x_hash_bit_mgr) + bit_map_size; - buff = (unsigned char *)(void *)ps3_vzalloc(instance, total_size); - if (buff == NULL) { - PS3_R1X_LOCK_ERROR( - "r1x vd alloc write lock mgr failed. totoalSize=%u", - total_size); + LOG_FILE_ERROR("hno: %u, sz_block_bit_cnt check NOK\n", PS3_HOST(instance)); goto exit; } + total_size = sizeof(struct ps3_r1x_hash_bit_mgr) + bit_map_size; + buff = (U8*)(void*)ps3_vzalloc(instance, total_size); + if(NULL == buff) { + PS3_R1X_LOCK_ERROR("r1x vd alloc write lock mgr faild. totoalSize=%u", total_size); + goto exit; + } bitmap_block_size = RW_BIT_TO_BYTE(sz_block_bit_cnt); - mgr = (struct ps3_r1x_hash_bit_mgr *)(void *)buff; + mgr = (struct ps3_r1x_hash_bit_mgr*)(void*)buff; for (i = 0; i < HASH_TABLE_SIZE; ++i) { mgr->hash_item[i].sz_block_idx = RW_SZBLOCK_IDX_INVALID; if (RW_BITMAP_IDX_INVALID < (i * bitmap_block_size)) { - LOG_ERROR("hno: %u, bitmap_block_size check NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno: %u, bitmap_block_size check NOK\n", PS3_HOST(instance)); PS3_BUG(); ps3_vfree(instance, buff); mgr = NULL; goto exit; } - mgr->hash_item[i].bitmap_idx = i * bitmap_block_size; - } - mgr->bitmap_mgr.bit_block_size = - (unsigned char)RW_BYTE_TO_U64(bitmap_block_size); - buff += sizeof(struct ps3_r1x_hash_bit_mgr); - mgr->bitmap_mgr.bit_buff = (unsigned char *)(void *)buff; - buff += bit_map_size; - - LOG_FILE_INFO( - "r1x vd init write lock mgr success,totoalSize=%u, hashTableSize=%u,\n" - "\tbitmapSize=%u(bytes), bitmap_block_cnt=%u, bitmap_block_size=%u.\n", - total_size, HASH_TABLE_SIZE, bit_map_size, bitmap_block_cnt, - bitmap_block_size); + mgr->hash_item[i].bitmap_idx = i*bitmap_block_size; + } + mgr->bitmap_mgr.bit_block_size = (U8)RW_BYTE_TO_U64(bitmap_block_size); + buff += sizeof(struct ps3_r1x_hash_bit_mgr); + mgr->bitmap_mgr.bit_buff = (U8*)(void*)buff; + buff += bit_map_size; + + LOG_FILE_INFO("r1x vd init write lock mgr success,totoalSize=%u, hashTableSize=%u, " + "bitmapSize=%u(bytes), bitmap_block_cnt=%u, bitmap_block_size=%u.\n", + total_size, HASH_TABLE_SIZE, + bit_map_size, bitmap_block_cnt, bitmap_block_size); exit: - return mgr; + return mgr; } #endif #if PS3_DESC("-----------------------hash range互斥方案------------------------") -struct ps3_renge_extent { - unsigned long long start; - unsigned long long end; +struct ps3_renge_extent +{ + U64 start; + U64 end; }; -struct ps3_range_tree_node { - struct Ps3RbNode rbNode; - struct ps3_renge_extent extent; +struct ps3_range_tree_node +{ + Ps3RbNode_s rbNode; + struct ps3_renge_extent extent; }; -struct ps3_range_tree_root { - struct Ps3RbRoot rbRoot; +struct ps3_range_tree_root +{ + Ps3RbRoot_s rbRoot; }; -struct ps3_r1x_hash_range_mgr { - struct ps3_range_tree_root hash_item[HASH_TABLE_SIZE]; +struct ps3_r1x_hash_range_mgr +{ + struct ps3_range_tree_root hash_item[HASH_TABLE_SIZE]; }; -#define RANGETEE_EXTENT(rbNodePtr) \ - ((ps3_container_of(rbNodePtr, struct ps3_range_tree_node, rbNode)) \ - ->extent) +#define RANGETEE_EXTENT(rbNodePtr) ((ps3_container_of(rbNodePtr, struct ps3_range_tree_node, rbNode))->extent) -int ps3_range_check_and_insert(struct ps3_range_tree_root *range_root, - struct ps3_range_tree_node *range_node) +S32 ps3_range_check_and_insert(struct ps3_range_tree_root *range_root, struct ps3_range_tree_node* range_node) { - int ret = PS3_SUCCESS; - struct Ps3RbNode *node = &range_node->rbNode; - struct Ps3RbNode *parent = NULL; - struct Ps3RbNode **pp_linker = NULL; - struct ps3_renge_extent *ext = &range_node->extent; - - PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, check.", - range_root->rbRoot.pRoot, node, ext->start, - ext->end); - - pp_linker = &range_root->rbRoot.pRoot; - while (*pp_linker != NULL) { - parent = *pp_linker; - if (ext->start > RANGETEE_EXTENT(parent).end) { - pp_linker = &parent->pRight; - } else if (ext->end < RANGETEE_EXTENT(parent).start) { - pp_linker = &parent->pLeft; - } else { - ret = -PS3_R1X_IO_CONFLICT; - PS3_R1X_LOCK_TRACE( - "root=%p, rbNode=%p, lba=%llu, endLba=%llu, confilct.", - range_root->rbRoot.pRoot, node, ext->start, - ext->end); - goto exit; - } - } - - node->pParentColor = ((uintptr_t)(void *)parent); - node->pLeft = NULL; - node->pRight = NULL; - (*pp_linker) = node; - ps3RbtColorAfterAdd(&range_root->rbRoot, node); - PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, add.", - range_root->rbRoot.pRoot, node, ext->start, - ext->end); + S32 ret = PS3_SUCCESS; + Ps3RbNode_s *node = &range_node->rbNode; + Ps3RbNode_s *parent = NULL; + Ps3RbNode_s **pp_linker = NULL; + struct ps3_renge_extent* ext = &range_node->extent; + PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, check.", range_root->rbRoot.pRoot, + node, ext->start, ext->end); + + pp_linker = &range_root->rbRoot.pRoot; + while (*pp_linker != NULL){ + parent = *pp_linker; + if (ext->start > RANGETEE_EXTENT(parent).end) { + pp_linker = &parent->pRight; + } else if (ext->end < RANGETEE_EXTENT(parent).start) { + pp_linker = &parent->pLeft; + } else { + ret = -PS3_R1X_IO_CONFLICT; + PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, confilct.", range_root->rbRoot.pRoot, + node, ext->start, ext->end); + goto exit; + } + } + + node->pParentColor = ((uintptr_t)(void*)parent); + node->pLeft = NULL; + node->pRight = NULL; + (*pp_linker) = node; + ps3RbtColorAfterAdd(&range_root->rbRoot, node); + PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, add.", range_root->rbRoot.pRoot, + node, ext->start, ext->end); exit: - return ret; + return ret; } -static inline void ps3_range_del_node(struct ps3_range_tree_root *range_root, - struct ps3_range_tree_node *del_node) +static inline void ps3_range_del_node(struct ps3_range_tree_root *range_root, struct ps3_range_tree_node* del_node) { - PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, del.", - range_root->rbRoot.pRoot, &del_node->rbNode, - del_node->extent.start, del_node->extent.end); - if (unlikely(PS3_SUCCESS != - ps3RbtDelNode(&range_root->rbRoot, &del_node->rbNode))) { - LOG_FILE_ERROR( - "startLba=%llu, endLba=%llu, del range node failed.\n", - del_node->extent.start, del_node->extent.end); - PS3_BUG(); - } + PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, del.", range_root->rbRoot.pRoot, + &del_node->rbNode, del_node->extent.start, del_node->extent.end); + if(unlikely(PS3_SUCCESS != ps3RbtDelNode(&range_root->rbRoot, &del_node->rbNode))){ + LOG_FILE_ERROR("startLba=%llu, endLba=%llu, del range node failed.\n", + del_node->extent.start, del_node->extent.end); + PS3_BUG(); + } } -int ps3_r1x_hash_range_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) +S32 ps3_r1x_hash_range_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - unsigned long long hash_idx = 0; - unsigned char node_num = 0; - unsigned int shift = 0; - unsigned long long lba = 0; - unsigned int len = 0; - unsigned int left = 0; - struct ps3_r1x_hash_range_mgr *hash_range_mgr = - (struct ps3_r1x_hash_range_mgr *)mgr->hash_mgr; - struct ps3_range_tree_node *range_node = - (struct ps3_range_tree_node *)cmd->node_buff; - struct ps3_range_tree_node *del_node = NULL; - unsigned long flag = 0; - - PS3_R1X_LOCK_TRACE( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, try lock.", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, - cmd->io_attr.num_blocks); - - shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? - 0 : - SECTOR_512_4K_SHIFT; - ; - lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; - ; - len = cmd->io_attr.num_blocks << shift; - left = len; - - ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); - - len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); - do { - range_node = &( - (struct ps3_range_tree_node *)cmd->node_buff)[node_num]; - len = PS3_MIN(len, left); - range_node->extent.start = lba; - range_node->extent.end = lba + len - 1; - ps3RbNodeInit(&range_node->rbNode); - hash_idx = RW_R1X_HASHIDX_HASH(mgr, lba); - - ret = ps3_range_check_and_insert( - &hash_range_mgr->hash_item[hash_idx], range_node); - if (unlikely(ret != PS3_SUCCESS)) - goto exit_fail; - - left -= len; - lba += len; - len = SZBLOCK_SIZE; - node_num++; - } while (left > 0); - - ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); - cmd->szblock_cnt = node_num; - cmd->is_got_r1x = 1; - - PS3_R1X_LOCK_TRACE( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, - cmd->io_attr.num_blocks); - return ret; + S32 ret = PS3_SUCCESS; + U64 hash_idx = 0; + U8 node_num = 0; + U32 shift = 0; + U64 lba = 0; + U32 len = 0; + U32 left = 0; + struct ps3_r1x_hash_range_mgr* hash_range_mgr = (struct ps3_r1x_hash_range_mgr*)mgr->hash_mgr; + struct ps3_range_tree_node* range_node = (struct ps3_range_tree_node*)cmd->node_buff; + struct ps3_range_tree_node* del_node = NULL; + ULong flag = 0; + + PS3_R1X_LOCK_TRACE("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, try lock.", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); + + shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? 0 : SECTOR_512_4K_SHIFT;; + lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift;; + len = cmd->io_attr.num_blocks << shift; + left = len; + + ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); + + len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); + do{ + range_node = &((struct ps3_range_tree_node*)cmd->node_buff)[node_num]; + len = PS3_MIN(len, left); + range_node->extent.start = lba; + range_node->extent.end = lba + len - 1; + ps3RbNodeInit(&range_node->rbNode); + hash_idx = RW_R1X_HASHIDX_HASH(mgr, lba); + + ret = ps3_range_check_and_insert(&hash_range_mgr->hash_item[hash_idx], range_node); + if(unlikely(PS3_SUCCESS != ret)){ + goto exit_fail; + } + + left -= len; + lba += len; + len = SZBLOCK_SIZE; + node_num++; + }while(left > 0); + + ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); + + cmd->szblock_cnt = node_num; + cmd->is_got_r1x = 1; + + PS3_R1X_LOCK_TRACE("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); + return ret; exit_fail: - cmd->szblock_cnt = 0; - del_node = (struct ps3_range_tree_node *)cmd->node_buff; - for (; del_node != range_node; del_node++) { - hash_idx = RW_R1X_HASHIDX_HASH(mgr, del_node->extent.start); - ps3_range_del_node(&hash_range_mgr->hash_item[hash_idx], - del_node); - } - ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); - - LOG_DEBUG( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, io conflict, lock failed.\n", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, - cmd->io_attr.num_blocks); - ret = -PS3_IO_REQUEUE; - return ret; + cmd->szblock_cnt = 0; + del_node = (struct ps3_range_tree_node*)cmd->node_buff; + for(; del_node != range_node; del_node++){ + hash_idx = RW_R1X_HASHIDX_HASH(mgr, del_node->extent.start); + ps3_range_del_node(&hash_range_mgr->hash_item[hash_idx], del_node); + } + ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); + + LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, io conflict, lock faild.\n", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); + ret = -PS3_IO_REQUEUE; + return ret; } -void ps3_r1x_hash_range_unlock(struct ps3_r1x_lock_mgr *mgr, - struct ps3_cmd *cmd) +void ps3_r1x_hash_range_unlock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - unsigned int i = 0; - unsigned long long hash_idx = 0; - struct ps3_range_tree_node *range_node = NULL; - struct ps3_r1x_hash_range_mgr *hash_range_mgr = - (struct ps3_r1x_hash_range_mgr *)mgr->hash_mgr; - unsigned long flag = 0; - - PS3_R1X_LOCK_TRACE( - "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, unlock.", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, - cmd->io_attr.num_blocks); + U32 i = 0; + U64 hash_idx = 0; + struct ps3_range_tree_node* range_node = NULL; + struct ps3_r1x_hash_range_mgr* hash_range_mgr = (struct ps3_r1x_hash_range_mgr*)mgr->hash_mgr; + ULong flag = 0; - ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); + PS3_R1X_LOCK_TRACE("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, unlock.", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); - for (i = 0; i < cmd->szblock_cnt; ++i) { - range_node = &((struct ps3_range_tree_node *)cmd->node_buff)[i]; - hash_idx = RW_R1X_HASHIDX_HASH(mgr, range_node->extent.start); - ps3_range_del_node(&hash_range_mgr->hash_item[hash_idx], - range_node); - } - ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); + ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); + for(i = 0; i < cmd->szblock_cnt; ++i){ + range_node = &((struct ps3_range_tree_node*)cmd->node_buff)[i]; + hash_idx = RW_R1X_HASHIDX_HASH(mgr, range_node->extent.start); + ps3_range_del_node(&hash_range_mgr->hash_item[hash_idx], range_node); + } + ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); + + return; } -static void *ps3_r1x_hash_range_init(struct ps3_instance *instance) +static void* ps3_r1x_hash_range_init(struct ps3_instance *instance) { - unsigned int total_size = 0; - unsigned int i = 0; - struct ps3_r1x_hash_range_mgr *mgr = NULL; - - total_size = sizeof(struct ps3_r1x_hash_range_mgr); - mgr = (struct ps3_r1x_hash_range_mgr *)(void *)ps3_vzalloc(instance, - total_size); - if (mgr == NULL) { - PS3_R1X_LOCK_ERROR( - "r1x vd write lock alloc hash range mgr failed. totoalSize=%u", - total_size); - goto exit; - } - - for (i = 0; i < HASH_TABLE_SIZE; ++i) - mgr->hash_item[i].rbRoot.pRoot = NULL; - - LOG_FILE_INFO("r1x vd write lock init hash range mgr success.\n" - "\ttotoalSize=%u, hashTableSize=%u\n", - total_size, HASH_TABLE_SIZE); + U32 total_size = 0; + U32 i = 0; + struct ps3_r1x_hash_range_mgr* mgr = NULL; + + total_size = sizeof(struct ps3_r1x_hash_range_mgr); + mgr = (struct ps3_r1x_hash_range_mgr*)(void*)ps3_vzalloc(instance, total_size); + if(NULL == mgr) { + PS3_R1X_LOCK_ERROR("r1x vd write lock alloc hash range mgr faild. totoalSize=%u", total_size); + goto exit; + } + + for(i = 0; i < HASH_TABLE_SIZE; ++i){ + mgr->hash_item[i].rbRoot.pRoot = NULL; + } + + LOG_FILE_INFO("r1x vd write lock init hash range mgr success." + "totoalSize=%u, hashTableSize=%u\n", + total_size, HASH_TABLE_SIZE); exit: - return mgr; + return mgr; } #endif #if PS3_DESC("-----------------------对外接口------------------------") -unsigned int ps3_r1x_get_node_Buff_size(void) +U32 ps3_r1x_get_node_Buff_size(void) { - return sizeof(struct ps3_range_tree_node) * SZ_BLOCK_SPLIT_MAX; + return sizeof(struct ps3_range_tree_node) * SZ_BLOCK_SPLIT_MAX; } -int ps3_r1x_lock_prepare_for_vd(struct ps3_instance *instance, - struct scsi_device *sdev, - unsigned char raid_level) +typedef S32 (*PS3_R1X_LOCK_FUNC)(struct ps3_r1x_lock_mgr*, void*); +typedef void (*PS3_R1X_UNLOCK_FUNC)(struct ps3_r1x_lock_mgr*, void*); + +S32 ps3_r1x_lock_prepare_for_vd(struct ps3_instance *instance, + struct scsi_device *sdev, U8 raid_level) { - int ret = PS3_SUCCESS; - struct ps3_r1x_lock_mgr *mgr = &PS3_SDEV_PRI_DATA(sdev)->lock_mgr; + S32 ret = PS3_SUCCESS; + struct ps3_r1x_lock_mgr *mgr =&PS3_SDEV_PRI_DATA(sdev)->lock_mgr; - mgr->hash_mgr = NULL; - mgr->try_lock = NULL; - mgr->unlock = NULL; + mgr->hash_mgr = NULL; + mgr->try_lock = NULL; + mgr->unlock = NULL; - if (raid_level != RAID1 && raid_level != RAID1E && - raid_level != RAID10) { - goto exit; - } + if(RAID1 != raid_level && RAID1E != raid_level && RAID10 != raid_level){ + goto exit; + } - ps3_spin_lock_init(&mgr->mgr_lock); + ps3_spin_lock_init(&mgr->mgr_lock); if (g_ps3_r1x_lock_flag == PS3_R1X_HASHBIT_LOCK) { mgr->hash_mgr = ps3_r1x_lock_hash_bit_init(instance); - mgr->try_lock = (int (*)(struct ps3_r1x_lock_mgr *, void *))( - void *)ps3_r1x_hash_bit_lock; - mgr->resend_try_lock = - (int (*)(struct ps3_r1x_lock_mgr *, void *))( - void *)ps3_r1x_hash_bit_lock_of_conflict_queue; - mgr->unlock = (void (*)(struct ps3_r1x_lock_mgr *, void *))( - void *)ps3_r1x_hash_bit_unlock; + mgr->try_lock = (PS3_R1X_LOCK_FUNC)(void *)ps3_r1x_hash_bit_lock; + mgr->resend_try_lock = (PS3_R1X_LOCK_FUNC)(void *)ps3_r1x_hash_bit_lock_of_conflict_queue; + mgr->unlock = (PS3_R1X_UNLOCK_FUNC)(void *)ps3_r1x_hash_bit_unlock; } else if (g_ps3_r1x_lock_flag == PS3_R1X_HASHRANGE_LOCK) { LOG_DEBUG("hno:%u vd[%u:%u] use rb tree r1x\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); mgr->hash_mgr = ps3_r1x_hash_range_init(instance); - mgr->try_lock = (int (*)(struct ps3_r1x_lock_mgr *, void *))( - void *)ps3_r1x_hash_range_lock; - mgr->resend_try_lock = - (int (*)(struct ps3_r1x_lock_mgr *, void *))( - void *)ps3_r1x_hash_range_lock; - mgr->unlock = (void (*)(struct ps3_r1x_lock_mgr *, void *))( - void *)ps3_r1x_hash_range_unlock; + mgr->try_lock = (PS3_R1X_LOCK_FUNC)(void *)ps3_r1x_hash_range_lock; + mgr->resend_try_lock = (PS3_R1X_LOCK_FUNC)(void *)ps3_r1x_hash_range_lock; + mgr->unlock = (PS3_R1X_UNLOCK_FUNC)(void *)ps3_r1x_hash_range_unlock; } + INJECT_START(PS3_ERR_IJ_FORCE_HASH_MGR_NULL, &mgr->hash_mgr); if (unlikely(mgr->hash_mgr == NULL)) { LOG_ERROR("hno:%u vd[%u:%u] r1x hash mgr init failed\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); goto l_err; } mgr->hash_mgr_conflict = ps3_r1x_lock_hash_bit_init(instance); + INJECT_START(PS3_ERR_IJ_FORCE_MGR_CONFLICT_NULL, &mgr->hash_mgr_conflict); if (unlikely(mgr->hash_mgr_conflict == NULL)) { - LOG_ERROR( - "hno:%u vd[%u:%u] r1x hash mgr conflict init failed\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + LOG_ERROR("hno:%u vd[%u:%u] r1x hash mgr conflict init failed\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); goto l_err; } - mgr->thread_stop = PS3_FALSE; - mgr->dev_deling = PS3_FALSE; - mgr->force_ret_code = SCSI_STATUS_GOOD; + mgr->thread_stop = PS3_FALSE; + mgr->dev_deling = PS3_FALSE; + mgr->force_ret_code = SCSI_STATUS_GOOD; - INIT_LIST_HEAD(&mgr->conflict_cmd_list); - mgr->cmd_count_in_q = 0; - init_completion(&mgr->thread_sync); + INIT_LIST_HEAD(&mgr->conflict_cmd_list); + mgr->cmd_count_in_q = 0; + init_completion(&mgr->thread_sync); - mgr->conflict_send_th = - kthread_run(ps3_conflict_queue_send_wk, sdev, "r1x_send"); - if (IS_ERR(mgr->conflict_send_th)) { - LOG_ERROR( - "hno:%u vd[%u:%u] r1x conflict send thread creat failed\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); - goto l_err; - } + mgr->conflict_send_th = kthread_run(ps3_conflict_queue_send_wk, sdev, "r1x_send"); + INJECT_START(PS3_ERR_IJ_FORCE_SEND_TH_NULL, mgr); + if (IS_ERR(mgr->conflict_send_th)) { + LOG_ERROR("hno:%u vd[%u:%u] r1x conflict send thread creat failed\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); + goto l_err; + } - goto exit; + goto exit; l_err: - ps3_r1x_lock_destroy_for_vd(instance, mgr); - ret = -PS3_FAILED; + ps3_r1x_lock_destory_for_vd(instance, mgr); + ret = -PS3_FAILED; exit: - return ret; + return ret; } -static int ps3_kthread_stop(struct ps3_instance *instance, - struct ps3_r1x_lock_mgr *mgr) +static S32 ps3_kthread_stop(struct ps3_instance *instance, + struct ps3_r1x_lock_mgr *mgr) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; (void)instance; mgr->thread_stop = PS3_TRUE; complete(&mgr->thread_sync); - LOG_FILE_INFO("hno:%u r1x conflict destroy, begin stop\n", - PS3_HOST(instance)); + LOG_FILE_INFO("hno:%u r1x conflict destory, begin stop\n", + PS3_HOST(instance)); ret = kthread_stop(mgr->conflict_send_th); - LOG_FILE_INFO("hno:%u r1x conflict destroy, stopped\n", - PS3_HOST(instance)); + LOG_FILE_INFO("hno:%u r1x conflict destory, stoped\n", + PS3_HOST(instance)); return ret; } -void ps3_r1x_lock_destroy_for_vd(struct ps3_instance *instance, - struct ps3_r1x_lock_mgr *mgr) +void ps3_r1x_lock_destory_for_vd(struct ps3_instance *instance, + struct ps3_r1x_lock_mgr *mgr) { - if (mgr->conflict_send_th != NULL) + if (mgr->conflict_send_th != NULL) { ps3_kthread_stop(instance, mgr); + } - if (mgr->hash_mgr_conflict != NULL) + if(mgr->hash_mgr_conflict != NULL){ ps3_vfree(instance, mgr->hash_mgr_conflict); + } - if (mgr->hash_mgr != NULL) + if(mgr->hash_mgr != NULL){ ps3_vfree(instance, mgr->hash_mgr); + } mgr->hash_mgr = NULL; mgr->try_lock = NULL; mgr->unlock = NULL; LOG_FILE_INFO("r1x vd deinit write lock mgr success."); + return; } #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.h b/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.h index 02f0ae8d82b1..55022967da3c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.h @@ -1,63 +1,65 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef __PS3_R1X_WRITE_LOCK_H__ #define __PS3_R1X_WRITE_LOCK_H__ +#include "ps3_types.h" #include "ps3_cmd_channel.h" enum { - PS3_R1X_HASHBIT_LOCK = 0, - PS3_R1X_HASHRANGE_LOCK = 1, + PS3_R1X_HASHBIT_LOCK = 0, + PS3_R1X_HASHRANGE_LOCK = 1, }; -extern unsigned int g_ps3_r1x_lock_flag; -extern unsigned int g_ps3_r1x_lock_enable; +extern U32 g_ps3_r1x_lock_flag; +extern U32 g_ps3_r1x_lock_enable; -unsigned int ps3_r1x_get_node_Buff_size(void); +U32 ps3_r1x_get_node_Buff_size(void); -static inline int ps3_r1x_write_lock(struct ps3_r1x_lock_mgr *mgr, - struct ps3_cmd *cmd) +static inline S32 ps3_r1x_write_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - if (mgr->hash_mgr == NULL) + if (mgr->hash_mgr == NULL) { return PS3_SUCCESS; + } - if (g_ps3_r1x_lock_enable == 0) + if (0 == g_ps3_r1x_lock_enable) { return PS3_SUCCESS; + } - if (!cmd->io_attr.is_confilct_check) + if (!cmd->io_attr.is_confilct_check) { return PS3_SUCCESS; + } - if (cmd->is_inserted_c_q == 0) + if (cmd->is_inserted_c_q == 0) { return mgr->try_lock(mgr, cmd); - else + } else { return mgr->resend_try_lock(mgr, cmd); + } } -static inline void ps3_r1x_write_unlock(struct ps3_r1x_lock_mgr *mgr, - struct ps3_cmd *cmd) +static inline void ps3_r1x_write_unlock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - if (cmd->szblock_cnt == 0) + if(cmd->szblock_cnt == 0){ return; + } mgr->unlock(mgr, cmd); cmd->szblock_cnt = 0; } -int ps3_r1x_lock_prepare_for_vd(struct ps3_instance *instance, - struct scsi_device *sdev, - unsigned char raid_level); -void ps3_r1x_lock_destroy_for_vd(struct ps3_instance *instance, - struct ps3_r1x_lock_mgr *mgr); +S32 ps3_r1x_lock_prepare_for_vd(struct ps3_instance *instance, + struct scsi_device *sdev, U8 raid_level); + +void ps3_r1x_lock_destory_for_vd(struct ps3_instance *instance, + struct ps3_r1x_lock_mgr *mgr); void ps3_r1x_conflict_queue_clean(struct ps3_scsi_priv_data *pri_data, - int ret_code); + S32 ret_code); -unsigned char ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, - struct scsi_cmnd *scmd); +Bool ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, struct scsi_cmnd *scmd); void ps3_r1x_conflict_queue_target_reset(struct ps3_instance *instance, - unsigned short target_id); + U16 target_id); void ps3_r1x_conflict_queue_clean_all(struct ps3_instance *instance, - int ret_code, unsigned char is_remove); + S32 ret_code, Bool is_remove); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.c b/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.c index ff1685064260..68f0a4198b55 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.c @@ -1,589 +1,731 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #include "ps3_rb_tree.h" -static void rbtNodeSetParent(struct Ps3RbNode *pNode, struct Ps3RbNode *pParent) + +static void rbtNodeSetParent(Ps3RbNode_s *pNode, + Ps3RbNode_s *pParent) { - pNode->pParentColor = - ((pNode->pParentColor & 3ULL) | ((uintptr_t)(void *)pParent)); + pNode->pParentColor = + ((pNode->pParentColor & 3ULL) | ((uintptr_t)(void*)pParent)); } -static void rbtNodeSetColor(struct Ps3RbNode *pNode, unsigned int color) +static void rbtNodeSetColor(Ps3RbNode_s *pNode, U32 color) { - pNode->pParentColor = ((pNode->pParentColor & ~1ULL) | color); + pNode->pParentColor = ((pNode->pParentColor & ~1ULL) | color); } -static void rbtRotateLeft(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode) +static void rbtRotateLeft(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode) { - struct Ps3RbNode *pRight = pNode->pRight; - struct Ps3RbNode *pParent = RBT_PARENT(pNode); - - pNode->pRight = pRight->pLeft; - if (pNode->pRight != NULL) - rbtNodeSetParent(pRight->pLeft, pNode); - - pRight->pLeft = pNode; - rbtNodeSetParent(pRight, pParent); - - if (pParent != NULL) { - if (pNode == pParent->pLeft) - pParent->pLeft = pRight; - else - pParent->pRight = pRight; - } else { - pRoot->pRoot = pRight; - } - - rbtNodeSetParent(pNode, pRight); + Ps3RbNode_s *pRight = pNode->pRight; + Ps3RbNode_s *pParent = RBT_PARENT(pNode); + + pNode->pRight = pRight->pLeft; + if (NULL != pNode->pRight) + { + rbtNodeSetParent(pRight->pLeft, pNode); + } + + pRight->pLeft = pNode; + rbtNodeSetParent(pRight, pParent); + + if (NULL != pParent) + { + if (pNode == pParent->pLeft) + { + pParent->pLeft = pRight; + } + else + { + pParent->pRight = pRight; + } + } + else + { + pRoot->pRoot = pRight; + } + + rbtNodeSetParent(pNode, pRight); } -static void rbtRotateRight(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode) +static void rbtRotateRight(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode) { - struct Ps3RbNode *pLeft = pNode->pLeft; - struct Ps3RbNode *pParent = RBT_PARENT(pNode); - - pNode->pLeft = pLeft->pRight; - if (pNode->pLeft != NULL) - rbtNodeSetParent(pLeft->pRight, pNode); - - pLeft->pRight = pNode; - rbtNodeSetParent(pLeft, pParent); - - if (pParent != NULL) { - if (pNode == pParent->pRight) - pParent->pRight = pLeft; - else - pParent->pLeft = pLeft; - } else { - pRoot->pRoot = pLeft; - } - - rbtNodeSetParent(pNode, pLeft); + Ps3RbNode_s *pLeft = pNode->pLeft; + Ps3RbNode_s *pParent = RBT_PARENT(pNode); + + pNode->pLeft = pLeft->pRight; + if (NULL != pNode->pLeft) + { + rbtNodeSetParent(pLeft->pRight, pNode); + } + + pLeft->pRight = pNode; + rbtNodeSetParent(pLeft, pParent); + + if (NULL != pParent) + { + if (pNode == pParent->pRight) + { + pParent->pRight = pLeft; + } + else + { + pParent->pLeft = pLeft; + } + } + else + { + pRoot->pRoot = pLeft; + } + + rbtNodeSetParent(pNode, pLeft); } -static void rbtColorAfterDel(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode, - struct Ps3RbNode *pParent) +static void rbtColorAfterDel(Ps3RbRoot_s *pRoot, + Ps3RbNode_s *pNode, Ps3RbNode_s *pParent) { - struct Ps3RbNode *pOther = NULL; - struct Ps3RbNode *pOLeft = NULL; - struct Ps3RbNode *pORight = NULL; - - while (((pNode == NULL) || RBT_IS_BLACK(pNode)) && - (pNode != pRoot->pRoot)) { - if (pParent->pLeft == pNode) { - pOther = pParent->pRight; - if (RBT_IS_RED(pOther)) { - RBT_SET_BLACK(pOther); - RBT_SET_RED(pParent); - rbtRotateLeft(pRoot, pParent); - pOther = pParent->pRight; - } - if (((pOther->pLeft == NULL) || - RBT_IS_BLACK(pOther->pLeft)) && - ((pOther->pRight == NULL) || - RBT_IS_BLACK(pOther->pRight))) { - RBT_SET_RED(pOther); - pNode = pParent; - pParent = RBT_PARENT(pNode); - - continue; - } - if ((pOther->pRight == NULL) || - RBT_IS_BLACK(pOther->pRight)) { - pOLeft = pOther->pLeft; - if (pOLeft != NULL) - RBT_SET_BLACK(pOLeft); - - RBT_SET_RED(pOther); - rbtRotateRight(pRoot, pOther); - pOther = pParent->pRight; - } - - rbtNodeSetColor(pOther, RBT_COLOR(pParent)); - RBT_SET_BLACK(pParent); - - if (pOther->pRight != NULL) - RBT_SET_BLACK(pOther->pRight); - - rbtRotateLeft(pRoot, pParent); - pNode = pRoot->pRoot; - - break; - } - pOther = pParent->pLeft; - if (RBT_IS_RED(pOther)) { - RBT_SET_BLACK(pOther); - RBT_SET_RED(pParent); - - rbtRotateRight(pRoot, pParent); - pOther = pParent->pLeft; - } - if (((pOther->pLeft == NULL) || RBT_IS_BLACK(pOther->pLeft)) && - ((pOther->pRight == NULL) || - RBT_IS_BLACK(pOther->pRight))) { - RBT_SET_RED(pOther); - pNode = pParent; - pParent = RBT_PARENT(pNode); - - continue; - } - if ((pOther->pLeft == NULL) || RBT_IS_BLACK(pOther->pLeft)) { - pORight = pOther->pRight; - if (pORight != NULL) - RBT_SET_BLACK(pORight); - - RBT_SET_RED(pOther); - rbtRotateLeft(pRoot, pOther); - pOther = pParent->pLeft; - } - - rbtNodeSetColor(pOther, RBT_COLOR(pParent)); - RBT_SET_BLACK(pParent); - - if (pOther->pLeft != NULL) - RBT_SET_BLACK(pOther->pLeft); - - rbtRotateRight(pRoot, pParent); - pNode = pRoot->pRoot; - - break; - } - - if (pNode != NULL) - RBT_SET_BLACK(pNode); + Ps3RbNode_s *pOther = NULL; + Ps3RbNode_s *pOLeft = NULL; + Ps3RbNode_s *pORight = NULL; + + while (((NULL == pNode) || RBT_IS_BLACK(pNode)) && + (pNode != pRoot->pRoot)) + { + if (pParent->pLeft == pNode) + { + pOther = pParent->pRight; + + if (RBT_IS_RED(pOther)) + { + RBT_SET_BLACK(pOther); + RBT_SET_RED(pParent); + rbtRotateLeft(pRoot, pParent); + pOther = pParent->pRight; + } + + if (((NULL == pOther->pLeft) || RBT_IS_BLACK(pOther->pLeft)) && + ((NULL == pOther->pRight) || RBT_IS_BLACK(pOther->pRight))) + { + RBT_SET_RED(pOther); + pNode = pParent; + pParent = RBT_PARENT(pNode); + + continue ; + } + + if ((NULL == pOther->pRight) || RBT_IS_BLACK(pOther->pRight)) + { + pOLeft = pOther->pLeft; + if (NULL != pOLeft) + { + RBT_SET_BLACK(pOLeft); + } + + RBT_SET_RED(pOther); + rbtRotateRight(pRoot, pOther); + pOther = pParent->pRight; + } + + rbtNodeSetColor(pOther, RBT_COLOR(pParent)); + RBT_SET_BLACK(pParent); + + if (NULL != pOther->pRight) + { + RBT_SET_BLACK(pOther->pRight); + } + + rbtRotateLeft(pRoot, pParent); + pNode = pRoot->pRoot; + + break; + } + + pOther = pParent->pLeft; + + if (RBT_IS_RED(pOther)) + { + RBT_SET_BLACK(pOther); + RBT_SET_RED(pParent); + + rbtRotateRight(pRoot, pParent); + pOther = pParent->pLeft; + } + + if (((NULL == pOther->pLeft) || RBT_IS_BLACK(pOther->pLeft)) && + ((NULL == pOther->pRight) || RBT_IS_BLACK(pOther->pRight))) + { + RBT_SET_RED(pOther); + pNode = pParent; + pParent = RBT_PARENT(pNode); + + continue ; + } + + if ((NULL == pOther->pLeft) || RBT_IS_BLACK(pOther->pLeft)) + { + pORight = pOther->pRight; + if (NULL != pORight) + { + RBT_SET_BLACK(pORight); + } + + RBT_SET_RED(pOther); + rbtRotateLeft(pRoot, pOther); + pOther = pParent->pLeft; + } + + rbtNodeSetColor(pOther, RBT_COLOR(pParent)); + RBT_SET_BLACK(pParent); + + if (NULL != pOther->pLeft) + { + RBT_SET_BLACK(pOther->pLeft); + } + + rbtRotateRight(pRoot, pParent); + pNode = pRoot->pRoot; + + break; + } + + if (NULL != pNode) + { + RBT_SET_BLACK(pNode); + } } -void rbtDelNodeDo(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode) +void rbtDelNodeDo(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode) { - struct Ps3RbNode *pParent = NULL; - struct Ps3RbNode *pChild = NULL; - struct Ps3RbNode *pOld = NULL; - unsigned int color = 0; - - if (pNode->pLeft == NULL) { - pChild = pNode->pRight; - } else if (pNode->pRight == NULL) { - pChild = pNode->pLeft; - } else { - pOld = pNode; - - pNode = pNode->pRight; - while (pNode->pLeft != NULL) - pNode = pNode->pLeft; - - pChild = pNode->pRight; - pParent = RBT_PARENT(pNode); - color = RBT_COLOR(pNode); - - if (pChild != NULL) - rbtNodeSetParent(pChild, pParent); - - if (pParent == pOld) { - pParent->pRight = pChild; - pParent = pNode; - } else { - pParent->pLeft = pChild; - } - - pNode->pParentColor = pOld->pParentColor; - pNode->pRight = pOld->pRight; - pNode->pLeft = pOld->pLeft; - - if (RBT_PARENT(pOld) != NULL) { - if (RBT_PARENT(pOld)->pLeft == pOld) - RBT_PARENT(pOld)->pLeft = pNode; - else - RBT_PARENT(pOld)->pRight = pNode; - } else { - pRoot->pRoot = pNode; - } - - rbtNodeSetParent(pOld->pLeft, pNode); - if (pOld->pRight != NULL) - rbtNodeSetParent(pOld->pRight, pNode); - - goto l_color; - } - - pParent = RBT_PARENT(pNode); - color = RBT_COLOR(pNode); - - if (pChild != NULL) - rbtNodeSetParent(pChild, pParent); - - if (pParent != NULL) { - if (pParent->pLeft == pNode) - pParent->pLeft = pChild; - else - pParent->pRight = pChild; - } else { - pRoot->pRoot = pChild; - } + Ps3RbNode_s *pParent = NULL; + Ps3RbNode_s *pChild = NULL; + Ps3RbNode_s *pOld = NULL; + U32 color = 0; + + if (NULL == pNode->pLeft) + { + pChild = pNode->pRight; + } + else if (NULL == pNode->pRight) + { + pChild = pNode->pLeft; + } + else + { + pOld = pNode; + + pNode = pNode->pRight; + while (NULL != pNode->pLeft) + { + pNode = pNode->pLeft; + } + + pChild = pNode->pRight; + pParent = RBT_PARENT(pNode); + color = RBT_COLOR(pNode); + + if (NULL != pChild) + { + rbtNodeSetParent(pChild, pParent); + } + + if (pParent == pOld) + { + pParent->pRight = pChild; + pParent = pNode; + } + else + { + pParent->pLeft = pChild; + } + + pNode->pParentColor = pOld->pParentColor; + pNode->pRight = pOld->pRight; + pNode->pLeft = pOld->pLeft; + + if (NULL != RBT_PARENT(pOld)) + { + if (RBT_PARENT(pOld)->pLeft == pOld) + { + RBT_PARENT(pOld)->pLeft = pNode; + } + else + { + RBT_PARENT(pOld)->pRight = pNode; + } + } + else + { + pRoot->pRoot = pNode; + } + + rbtNodeSetParent(pOld->pLeft, pNode); + if (NULL != pOld->pRight) + { + rbtNodeSetParent(pOld->pRight, pNode); + } + + goto l_color; + } + + pParent = RBT_PARENT(pNode); + color = RBT_COLOR(pNode); + + if (NULL != pChild) + { + rbtNodeSetParent(pChild, pParent); + } + + if (NULL != pParent) + { + if (pParent->pLeft == pNode) + { + pParent->pLeft = pChild; + } + else + { + pParent->pRight = pChild; + } + } + else + { + pRoot->pRoot = pChild; + } l_color: - if (color == RBT_BLACK) - rbtColorAfterDel(pRoot, pChild, pParent); + if (color == RBT_BLACK) + { + rbtColorAfterDel(pRoot, pChild, pParent); + } } -static struct Ps3RbNode *rbtFindNodeDo(struct Ps3RbRoot *pRoot, void *pKey, - struct Ps3RbTreeOps *pOps, - unsigned char intent_addnode, - struct Ps3RbNode **ppParent, - struct Ps3RbNode ***pppLinker) +static Ps3RbNode_s* rbtFindNodeDo(Ps3RbRoot_s *pRoot, void *pKey, + Ps3RbTreeOps_s *pOps, Bool intent_addnode, Ps3RbNode_s **ppParent, + Ps3RbNode_s ***pppLinker) { - struct Ps3RbNode *pNode = NULL; - struct Ps3RbNode *pParent = NULL; - struct Ps3RbNode **ppLinker = NULL; - void *pKeyCur = NULL; - enum Ps3Cmp cmprc = PS3_EQ; + Ps3RbNode_s *pNode = NULL; + Ps3RbNode_s *pParent = NULL; + Ps3RbNode_s **ppLinker = NULL; + void *pKeyCur = NULL; + Ps3Cmp_e cmprc = PS3_EQ; BUG_ON(pOps->cmpkey == NULL); BUG_ON((pOps->getkey == NULL) && - (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, - (unsigned long *)&pOps->flags))); - - ppLinker = &pRoot->pRoot; - while (NULL != (*ppLinker)) { - pParent = (*ppLinker); - - pKeyCur = ps3RbNodeGetKey(pParent, pOps); - cmprc = pOps->cmpkey(pKey, pKeyCur); - if (cmprc == PS3_LT) { - ppLinker = &pParent->pLeft; - } else if (cmprc == PS3_GT) { - ppLinker = &pParent->pRight; - } else if ((intent_addnode == PS3_TRUE) && - testBitNonAtomic( - RBTBF_CONFLICT_ENABLE, - (unsigned long *)&pOps->flags)) { - ppLinker = &pParent->pLeft; - } else { - pNode = pParent; - break; - } - } - - if (pppLinker != NULL) - (*pppLinker) = ppLinker; - - if (ppParent != NULL) { - if (pNode != NULL) - (*ppParent) = RBT_PARENT(pNode); - else - (*ppParent) = pParent; - } - - return pNode; + (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&pOps->flags))); + + ppLinker = &pRoot->pRoot; + while (NULL != (*ppLinker)) + { + pParent = (*ppLinker); + + pKeyCur = ps3RbNodeGetKey(pParent, pOps); + cmprc = pOps->cmpkey(pKey, pKeyCur); + if (PS3_LT == cmprc) + { + ppLinker = &pParent->pLeft; + } + else if (PS3_GT == cmprc) + { + ppLinker = &pParent->pRight; + } + else if ((PS3_TRUE == intent_addnode) && + testBitNonAtomic(RBTBF_CONFLICT_ENABLE, (volatile ULong *)&pOps->flags)) + { + ppLinker = &pParent->pLeft; + } + else + { + pNode = pParent; + break ; + } + } + + if (NULL != pppLinker) + { + (*pppLinker) = ppLinker; + } + + if (NULL != ppParent) + { + if (NULL != pNode) + { + (*ppParent) = RBT_PARENT(pNode); + } + else + { + (*ppParent) = pParent; + } + } + + return pNode; } -void ps3RbtColorAfterAdd(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode) +void ps3RbtColorAfterAdd(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode) { - struct Ps3RbNode *pGparent = NULL; - struct Ps3RbNode *pParent = NULL; - struct Ps3RbNode *pUncle = NULL; - struct Ps3RbNode *pTmp = NULL; - - while (1) { - pParent = RBT_PARENT(pNode); - if ((pParent == NULL) || RBT_IS_BLACK(pParent)) - break; - - pGparent = RBT_PARENT(pParent); - if (pParent == pGparent->pLeft) { - pUncle = pGparent->pRight; - if ((pUncle != NULL) && RBT_IS_RED(pUncle)) { - RBT_SET_BLACK(pUncle); - RBT_SET_BLACK(pParent); - RBT_SET_RED(pGparent); - - pNode = pGparent; - continue; - } - - if (pParent->pRight == pNode) { - rbtRotateLeft(pRoot, pParent); - - pTmp = pParent; - pParent = pNode; - pNode = pTmp; - } - - RBT_SET_BLACK(pParent); - RBT_SET_RED(pGparent); - rbtRotateRight(pRoot, pGparent); - } else { - pUncle = pGparent->pLeft; - if ((pUncle != NULL) && RBT_IS_RED(pUncle)) { - RBT_SET_BLACK(pUncle); - RBT_SET_BLACK(pParent); - RBT_SET_RED(pGparent); - - pNode = pGparent; - continue; - } - - if (pParent->pLeft == pNode) { - rbtRotateRight(pRoot, pParent); - - pTmp = pParent; - pParent = pNode; - pNode = pTmp; - } - - RBT_SET_BLACK(pParent); - RBT_SET_RED(pGparent); - rbtRotateLeft(pRoot, pGparent); - } - } - - RBT_SET_BLACK(pRoot->pRoot); + Ps3RbNode_s *pGparent = NULL; + Ps3RbNode_s *pParent = NULL; + Ps3RbNode_s *pUncle = NULL; + Ps3RbNode_s *pTmp = NULL; + + while (1) + { + pParent = RBT_PARENT(pNode); + if ((NULL == pParent) || RBT_IS_BLACK(pParent)) + { + break ; + } + + pGparent = RBT_PARENT(pParent); + if (pParent == pGparent->pLeft) + { + pUncle = pGparent->pRight; + if ((NULL != pUncle) && RBT_IS_RED(pUncle)) + { + RBT_SET_BLACK(pUncle); + RBT_SET_BLACK(pParent); + RBT_SET_RED(pGparent); + + pNode = pGparent; + continue ; + } + + if (pParent->pRight == pNode) + { + rbtRotateLeft(pRoot, pParent); + + pTmp = pParent; + pParent = pNode; + pNode = pTmp; + } + + RBT_SET_BLACK(pParent); + RBT_SET_RED(pGparent); + rbtRotateRight(pRoot, pGparent); + } + else + { + pUncle = pGparent->pLeft; + if ((NULL != pUncle) && RBT_IS_RED(pUncle)) + { + RBT_SET_BLACK(pUncle); + RBT_SET_BLACK(pParent); + RBT_SET_RED(pGparent); + + pNode = pGparent; + continue ; + } + + if (pParent->pLeft == pNode) + { + rbtRotateRight(pRoot, pParent); + + pTmp = pParent; + pParent = pNode; + pNode = pTmp; + } + + RBT_SET_BLACK(pParent); + RBT_SET_RED(pGparent); + rbtRotateLeft(pRoot, pGparent); + } + } + + RBT_SET_BLACK(pRoot->pRoot); } -struct Ps3RbNode *ps3RbtHeadNode(struct Ps3RbRoot *pRoot) +Ps3RbNode_s* ps3RbtHeadNode(Ps3RbRoot_s *pRoot) { - struct Ps3RbNode *pNode = NULL; + Ps3RbNode_s *pNode = NULL; - pNode = pRoot->pRoot; - if (pNode == NULL) - goto end; + pNode = pRoot->pRoot; + if (NULL == pNode) + { + goto end; + } - while (pNode->pLeft != NULL) - pNode = pNode->pLeft; + while (NULL != pNode->pLeft) + { + pNode = pNode->pLeft; + } end: - return pNode; + return pNode; } -struct Ps3RbNode *ps3RbtTailNode(struct Ps3RbRoot *pRoot) +Ps3RbNode_s* ps3RbtTailNode(Ps3RbRoot_s *pRoot) { - struct Ps3RbNode *pNode = NULL; + Ps3RbNode_s *pNode = NULL; - pNode = pRoot->pRoot; - if (pNode == NULL) - goto end; + pNode = pRoot->pRoot; + if (NULL == pNode) + { + goto end; + } - while (pNode->pRight != NULL) - pNode = pNode->pRight; + while (NULL != pNode->pRight) + { + pNode = pNode->pRight; + } end: - return pNode; + return pNode; } -struct Ps3RbNode *ps3RbtPrevNode(struct Ps3RbNode *pNode) +Ps3RbNode_s* ps3RbtPrevNode(Ps3RbNode_s *pNode) { - struct Ps3RbNode *pParent = NULL; - - if (pNode == NULL) - goto end; - - if (pNode->pLeft != NULL) { - pNode = pNode->pLeft; - while (pNode->pRight != NULL) - pNode = pNode->pRight; - - return pNode; - } - while (1) { - pParent = RBT_PARENT(pNode); - if ((pParent == NULL) || (pNode != pParent->pLeft)) - goto end; - - pNode = pParent; - } + Ps3RbNode_s *pParent = NULL; + + if (NULL == pNode) + { + goto end; + } + + if (NULL != pNode->pLeft) + { + pNode = pNode->pLeft; + while (NULL != pNode->pRight) + { + pNode = pNode->pRight; + } + + return pNode; + } + + while (1) + { + pParent = RBT_PARENT(pNode); + if ((NULL == pParent) || (pNode != pParent->pLeft)) + { + goto end; + } + + pNode = pParent; + } end: - return pParent; + return pParent; } -struct Ps3RbNode *ps3RbtNextNode(struct Ps3RbNode *pNode) +Ps3RbNode_s* ps3RbtNextNode(Ps3RbNode_s *pNode) { - struct Ps3RbNode *pParent = NULL; - - if (pNode == NULL) - goto end; - - if (pNode->pRight != NULL) { - pNode = pNode->pRight; - while (pNode->pLeft != NULL) - pNode = pNode->pLeft; - - return pNode; - } - - while (1) { - pParent = RBT_PARENT(pNode); - if ((pParent == NULL) || (pNode != pParent->pRight)) - goto end; - - pNode = pParent; - } + Ps3RbNode_s *pParent = NULL; + + if (NULL == pNode) + { + goto end; + } + + if (NULL != pNode->pRight) + { + pNode = pNode->pRight; + while (NULL != pNode->pLeft) + { + pNode = pNode->pLeft; + } + + return pNode; + } + + while (1) + { + pParent = RBT_PARENT(pNode); + if ((NULL == pParent) || (pNode != pParent->pRight)) + { + goto end; + } + + pNode = pParent; + } end: - return pParent; + return pParent; } -void ps3RbtReplaceNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNew, - struct Ps3RbNode *pVictim) +void ps3RbtReplaceNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNew, + Ps3RbNode_s *pVictim) { - struct Ps3RbNode *pParent = RBT_PARENT(pVictim); - - if (pParent != NULL) { - if (pVictim == pParent->pLeft) - pParent->pLeft = pNew; - else - pParent->pRight = pNew; - } else { - pRoot->pRoot = pNew; - } - - if (pVictim->pLeft != NULL) - rbtNodeSetParent(pVictim->pLeft, pNew); - - if (pVictim->pRight != NULL) - rbtNodeSetParent(pVictim->pRight, pNew); - - (*pNew) = (*pVictim); + Ps3RbNode_s *pParent = RBT_PARENT(pVictim); + + if (NULL != pParent) + { + if (pVictim == pParent->pLeft) + { + pParent->pLeft = pNew; + } + else + { + pParent->pRight = pNew; + } + } + else + { + pRoot->pRoot = pNew; + } + + if (NULL != pVictim->pLeft) + { + rbtNodeSetParent(pVictim->pLeft, pNew); + } + + if (NULL != pVictim->pRight) + { + rbtNodeSetParent(pVictim->pRight, pNew); + } + + (*pNew) = (*pVictim); } -int ps3RbtDelNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode) +S32 ps3RbtDelNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode) { - int rc = 0; + S32 rc = 0; - if (RBT_NODE_IS_EMPTY(pNode)) { - rc = -PS3_FAILED; - goto end; - } + if (RBT_NODE_IS_EMPTY(pNode)) + { + rc = -PS3_FAILED; + goto end; + } - rbtDelNodeDo(pRoot, pNode); - ps3RbNodeInit(pNode); + rbtDelNodeDo(pRoot, pNode); + ps3RbNodeInit(pNode); end: - return rc; + return rc; } -int ps3RbtAddNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode, - struct Ps3RbTreeOps *pOps) +S32 ps3RbtAddNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode, + Ps3RbTreeOps_s *pOps) { - struct Ps3RbNode *pParent = NULL; - struct Ps3RbNode **ppLinker = NULL; - void *pKey = NULL; - int rc = 0; + Ps3RbNode_s *pParent = NULL; + Ps3RbNode_s **ppLinker = NULL; + void *pKey = NULL; + S32 rc = 0; BUG_ON((pOps->getkey == NULL) && - (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, - (unsigned long *)&pOps->flags))); + (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&pOps->flags))); - if (!RBT_NODE_IS_EMPTY(pNode)) { - rc = -PS3_FAILED; - goto end; - } + if (!RBT_NODE_IS_EMPTY(pNode)) + { + rc = -PS3_FAILED; + goto end; + } - pKey = ps3RbNodeGetKey(pNode, pOps); - if (NULL != - rbtFindNodeDo(pRoot, pKey, pOps, PS3_TRUE, &pParent, &ppLinker)) { - rc = -PS3_FAILED; - goto end; - } + pKey = ps3RbNodeGetKey(pNode, pOps); + if (NULL != rbtFindNodeDo(pRoot, pKey, pOps, PS3_TRUE, &pParent, + &ppLinker)) + { + rc = -PS3_FAILED; + goto end; + } - ps3RbNodeLink(pNode, pParent, ppLinker); - ps3RbtColorAfterAdd(pRoot, pNode); + ps3RbNodeLink(pNode, pParent, ppLinker); + ps3RbtColorAfterAdd(pRoot, pNode); end: - return rc; + return rc; } -struct Ps3RbNode *ps3RbtFindNode(struct Ps3RbRoot *pRoot, void *pKey, - struct Ps3RbTreeOps *pOps) +Ps3RbNode_s* ps3RbtFindNode(Ps3RbRoot_s *pRoot, void *pKey, + Ps3RbTreeOps_s *pOps) { - struct Ps3RbNode *pNode = NULL; + Ps3RbNode_s *pNode = NULL; - if (pKey == NULL) { - pNode = ps3RbtHeadNode(pRoot); - goto end; - } + if (NULL == pKey) + { + pNode = ps3RbtHeadNode(pRoot); + goto end; + } - pNode = rbtFindNodeDo(pRoot, pKey, pOps, PS3_FALSE, NULL, NULL); + pNode = rbtFindNodeDo(pRoot, pKey, pOps, PS3_FALSE, NULL, NULL); end: - return pNode; + return pNode; } -struct Ps3RbNode *ps3RbtFindNextNode(struct Ps3RbRoot *pRoot, void *pKey, - struct Ps3RbTreeOps *pOps) +Ps3RbNode_s* ps3RbtFindNextNode(Ps3RbRoot_s *pRoot, void *pKey, + Ps3RbTreeOps_s *pOps) { - struct Ps3RbNode *pNode = NULL; - struct Ps3RbNode *pParent = NULL; - struct Ps3RbNode **ppLinker = NULL; - void *pKeyCur = NULL; - - if (pKey == NULL) { - pNode = ps3RbtHeadNode(pRoot); - goto end; - } - - pNode = rbtFindNodeDo(pRoot, pKey, pOps, PS3_FALSE, &pParent, - &ppLinker); - if (pNode != NULL) { - pNode = ps3RbtNextNode(pNode); - - if (!testBitNonAtomic(RBTBF_CONFLICT_ENABLE, - (unsigned long *)&pOps->flags)) { - goto end; - } - - while (pNode != NULL) { - pKeyCur = ps3RbNodeGetKey(pNode, pOps); - if (pOps->cmpkey(pKey, pKeyCur) != PS3_EQ) - break; - - pNode = ps3RbtNextNode(pNode); - } - - goto end; - } - - if (pParent == NULL) - goto end; - - if (ppLinker == &pParent->pLeft) { - pNode = pParent; - goto end; - } - - pNode = ps3RbtNextNode(pParent); + Ps3RbNode_s *pNode = NULL; + Ps3RbNode_s *pParent = NULL; + Ps3RbNode_s **ppLinker = NULL; + void *pKeyCur = NULL; + + if (NULL == pKey) + { + pNode = ps3RbtHeadNode(pRoot); + goto end; + } + + pNode = rbtFindNodeDo(pRoot, pKey, pOps, PS3_FALSE, &pParent, + &ppLinker); + if (NULL != pNode) + { + pNode = ps3RbtNextNode(pNode); + + if (!testBitNonAtomic(RBTBF_CONFLICT_ENABLE, (volatile ULong *)&pOps->flags)) + { + goto end; + } + + while (NULL != pNode) + { + pKeyCur = ps3RbNodeGetKey(pNode, pOps); + if (PS3_EQ != pOps->cmpkey(pKey, pKeyCur)) + { + break; + } + + pNode = ps3RbtNextNode(pNode); + } + + goto end; + } + + if (NULL == pParent) + { + goto end; + } + + if (ppLinker == &pParent->pLeft) + { + pNode = pParent; + goto end; + } + + pNode = ps3RbtNextNode(pParent); end: - return pNode; + return pNode; } -void ps3RbtClean(struct Ps3RbRoot *pRoot) +void ps3RbtClean(Ps3RbRoot_s *pRoot) { - struct Ps3RbNode *pNode = NULL; + Ps3RbNode_s *pNode = NULL; - pNode = ps3RbtHeadNode(pRoot); - while (pNode != NULL) { - (void)ps3RbtDelNode(pRoot, pNode); + pNode = ps3RbtHeadNode(pRoot); + while (NULL != pNode) + { + (void)ps3RbtDelNode(pRoot, pNode); - pNode = ps3RbtHeadNode(pRoot); - } + pNode = ps3RbtHeadNode(pRoot); + } } -int ps3RbtTraverse(struct Ps3RbRoot *pRoot, - int (*visit)(struct Ps3RbNode *pNode, void *pCtxt), - void *p_ctxt) +S32 ps3RbtTraverse(Ps3RbRoot_s *pRoot, ps3RbtreeVisitFunc visit, + void *p_ctxt) { - struct Ps3RbNode *pNode = NULL; - struct Ps3RbNode *pNext = NULL; - int rc = 0; + Ps3RbNode_s *pNode = NULL; + Ps3RbNode_s *pNext = NULL; + S32 rc = 0; BUG_ON(visit == NULL); - RBT_FOR_EACH_SAFE(pNode, pNext, pRoot) - { - rc = visit(pNode, p_ctxt); - if (rc < 0) - goto end; - } + RBT_FOR_EACH_SAFE(pNode, pNext, pRoot) + { + rc = visit(pNode, p_ctxt); + if (rc < 0) + { + goto end; + } + } end: - return rc; + return rc; } + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.h b/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.h index ae85e767e013..80bd58e88daf 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.h @@ -1,326 +1,341 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef __PS3_RBTREE_H__ #define __PS3_RBTREE_H__ #ifndef _WINDOWS #include #include -#include #endif #include "ps3_driver_log.h" +#include "ps3_define.h" #include "ps3_err_def.h" -static inline void setBitNonAtomic(unsigned int nr, - unsigned long *addr) +static inline void setBitNonAtomic(U32 nr, volatile ULong *addr) { - set_bit(nr, addr); + ULong mask = BIT_MASK(nr); + ULong *p = ((ULong *)addr) + BIT_WORD(nr); + + *p |= mask; } -static inline void clearBitNonAtomic(unsigned int nr, - unsigned long *addr) +static inline void clearBitNonAtomic(U32 nr, volatile ULong *addr) { - clear_bit(nr, addr); + ULong mask = BIT_MASK(nr); + ULong *p = ((ULong *)addr) + BIT_WORD(nr); + + *p &= ~mask; } -static inline int testBitNonAtomic(unsigned int nr, - const unsigned long *addr) +static inline S32 testBitNonAtomic(U32 nr, const volatile ULong *addr) { - return test_bit(nr, addr); + return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); } -struct Ps3RbNode { - __aligned(8) unsigned long long pParentColor; +typedef struct Ps3RbNode +{ + __attribute__((__aligned__(8))) + U64 pParentColor; + + struct + { + struct Ps3RbNode *pLeft; + struct Ps3RbNode *pRight; + }; +} Ps3RbNode_s; + +typedef struct Ps3RbRoot +{ + Ps3RbNode_s *pRoot; +} Ps3RbRoot_s; - struct { - struct Ps3RbNode *pLeft; - struct Ps3RbNode *pRight; - }; -}; +#define PS3_RBROOT_INITNIL {NULL} -struct Ps3RbRoot { - struct Ps3RbNode *pRoot; -}; +typedef enum Ps3Cmp +{ + PS3_EQ = 0, + PS3_GT = 1, + PS3_LT = 2, + PS3_CMPNR = 3, +} Ps3Cmp_e; -#define PS3_RBROOT_INITNIL \ - { \ - NULL \ - } +typedef Ps3Cmp_e (*ps3CmpKeyFunc)(void *pKey1, void *pKey2); -enum Ps3Cmp { - PS3_EQ = 0, - PS3_GT = 1, - PS3_LT = 2, - PS3_CMPNR = 3, -}; +typedef void* (*ps3RbtreeGetKeyFunc)(Ps3RbNode_s *pNode, void *pCtxt); -enum Ps3RbtreebFlag { - RBTBF_KEYOFFSET_ENABLE = 0, - RBTBF_CONFLICT_ENABLE, -}; +typedef S32 (*ps3RbtreeVisitFunc)(Ps3RbNode_s *pNode, void *pCtxt); + +typedef enum Ps3RbtreebFlag +{ + RBTBF_KEYOFFSET_ENABLE = 0, + RBTBF_CONFLICT_ENABLE, +} Ps3RbtreebFlag_e; -struct Ps3RbTreeOps { - enum Ps3Cmp (*cmpkey)(void *pKey1, void *pKey2); +typedef struct Ps3RbTreeOps +{ + ps3CmpKeyFunc cmpkey; - union { - void *(*getkey)(struct Ps3RbNode *pNode, void *pCtxt); - unsigned long long keyoffset; - }; + union + { + ps3RbtreeGetKeyFunc getkey; + U64 keyoffset; + }; - unsigned int flags; - void *pCtxt; -}; + U32 flags; + void *pCtxt; +} Ps3RbTreeOps_s; -struct Ps3RbTree { - struct Ps3RbRoot root; - unsigned int nodenr; - struct Ps3RbTreeOps ops; -}; +typedef struct Ps3RbTree +{ + Ps3RbRoot_s root; + U32 nodenr; + Ps3RbTreeOps_s ops; +} Ps3RbTree_s; -static inline void ps3RbNodeInit(struct Ps3RbNode *pNode) +static inline void ps3RbNodeInit(Ps3RbNode_s *pNode) { - pNode->pParentColor = ((uintptr_t)(void *)pNode); + pNode->pParentColor = ((uintptr_t)(void*)pNode); } -static inline void ps3RbNodeLink(struct Ps3RbNode *pNode, - struct Ps3RbNode *pParent, - struct Ps3RbNode **ppLinker) +static inline void ps3RbNodeLink(Ps3RbNode_s *pNode, + Ps3RbNode_s *pParent, Ps3RbNode_s **ppLinker) { - pNode->pParentColor = ((uintptr_t)(void *)pParent); - pNode->pLeft = NULL; - pNode->pRight = NULL; + pNode->pParentColor = ((uintptr_t)(void*)pParent); + pNode->pLeft = NULL; + pNode->pRight = NULL; - (*ppLinker) = pNode; + (*ppLinker) = pNode; } -static inline void *ps3RbNodeGetKey(struct Ps3RbNode *pNode, - struct Ps3RbTreeOps *pOps) +static inline void* ps3RbNodeGetKey(Ps3RbNode_s *pNode, + Ps3RbTreeOps_s *pOps) { - if (testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, - (unsigned long *)&pOps->flags)) { - return (void *)((unsigned char *)pNode + pOps->keyoffset); - } + if (testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&pOps->flags)) + { + return (void *)((U8 *)pNode + pOps->keyoffset); + } - return pOps->getkey(pNode, pOps->pCtxt); + return pOps->getkey(pNode, pOps->pCtxt); } -static inline void ps3RbRootInit(struct Ps3RbRoot *pRoot) +static inline void ps3RbRootInit(Ps3RbRoot_s *pRoot) { - pRoot->pRoot = NULL; + pRoot->pRoot = NULL; } -static inline void ps3RbRootFini(struct Ps3RbRoot *pRoot) +static inline void ps3RbRootFini(Ps3RbRoot_s *pRoot) { BUG_ON(pRoot->pRoot != NULL); } -void ps3RbtColorAfterAdd(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode); +void ps3RbtColorAfterAdd(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode); -struct Ps3RbNode *ps3RbtHeadNode(struct Ps3RbRoot *pRoot); +Ps3RbNode_s* ps3RbtHeadNode(Ps3RbRoot_s *pRoot); -struct Ps3RbNode *ps3RbtTailNode(struct Ps3RbRoot *pRoot); +Ps3RbNode_s* ps3RbtTailNode(Ps3RbRoot_s *pRoot); -struct Ps3RbNode *ps3RbtPrevNode(struct Ps3RbNode *pNode); +Ps3RbNode_s* ps3RbtPrevNode(Ps3RbNode_s *pNode); -struct Ps3RbNode *ps3RbtNextNode(struct Ps3RbNode *pNode); +Ps3RbNode_s* ps3RbtNextNode(Ps3RbNode_s *pNode); -void ps3RbtReplaceNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNew, - struct Ps3RbNode *pVictim); +void ps3RbtReplaceNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNew, + Ps3RbNode_s *pVictim); -int ps3RbtDelNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode); +S32 ps3RbtDelNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode); -int ps3RbtAddNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode, - struct Ps3RbTreeOps *pOps); +S32 ps3RbtAddNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode, + Ps3RbTreeOps_s *pOps); -struct Ps3RbNode *ps3RbtFindNode(struct Ps3RbRoot *pRoot, void *pKey, - struct Ps3RbTreeOps *pOps); +Ps3RbNode_s* ps3RbtFindNode(Ps3RbRoot_s *pRoot, void *pKey, + Ps3RbTreeOps_s *pOps); -struct Ps3RbNode *ps3RbtFindNextNode(struct Ps3RbRoot *pRoot, void *pKey, - struct Ps3RbTreeOps *pOps); +Ps3RbNode_s* ps3RbtFindNextNode(Ps3RbRoot_s *pRoot, void *pKey, + Ps3RbTreeOps_s *pOps); -void ps3RbtClean(struct Ps3RbRoot *pRoot); +void ps3RbtClean(Ps3RbRoot_s *pRoot); -int ps3RbtTraverse(struct Ps3RbRoot *pRoot, - int (*visit)(struct Ps3RbNode *pNode, void *pCtxt), - void *pCtxt); +S32 ps3RbtTraverse(Ps3RbRoot_s *pRoot, ps3RbtreeVisitFunc visit, + void *pCtxt); -static inline unsigned char ps3RbtIsEmpty(struct Ps3RbRoot *pRoot) +static inline Bool ps3RbtIsEmpty(Ps3RbRoot_s *pRoot) { - return (unsigned char)(pRoot->pRoot == NULL); + return (Bool)(pRoot->pRoot == NULL); } -static inline int ps3RbTreeInit(struct Ps3RbTree *pTree, - struct Ps3RbTreeOps *pOps) +static inline S32 ps3RbTreeInit(Ps3RbTree_s *pTree, + Ps3RbTreeOps_s *pOps) { - int rc = 0; + S32 rc = 0; - ps3RbRootInit(&pTree->root); - pTree->nodenr = 0; + ps3RbRootInit(&pTree->root); + pTree->nodenr = 0; - memset(&pTree->ops, 0, sizeof(struct Ps3RbTreeOps)); - if (pOps != NULL) - pTree->ops = (*pOps); + memset(&pTree->ops, 0, sizeof(Ps3RbTreeOps_s)); + if (NULL != pOps) + { + pTree->ops = (*pOps); + } - return rc; + return rc; } -static inline int -ps3RbTreeInitGetKey(struct Ps3RbTree *pTree, - enum Ps3Cmp (*cmpkey)(void *pKey1, void *pKey2), - void *(*getkey)(struct Ps3RbNode *pNode, void *pCtxt), - void *pCtxt) +static inline S32 ps3RbTreeInitGetKey(Ps3RbTree_s *pTree, + ps3CmpKeyFunc cmpkey, ps3RbtreeGetKeyFunc getkey, void *pCtxt) { - struct Ps3RbTreeOps ops; + Ps3RbTreeOps_s ops; - memset(&ops, 0, sizeof(struct Ps3RbTreeOps)); - ops.cmpkey = cmpkey; - ops.getkey = getkey; - ops.pCtxt = pCtxt; + memset(&ops, 0, sizeof(Ps3RbTreeOps_s)); + ops.cmpkey = cmpkey; + ops.getkey = getkey; + ops.pCtxt = pCtxt; - return ps3RbTreeInit(pTree, &ops); + return ps3RbTreeInit(pTree, &ops); } -static inline int -ps3RbTreeInitKeyOffset(struct Ps3RbTree *pTree, - enum Ps3Cmp (*cmpkey)(void *pKey1, void *pKey2), - unsigned long long keyoffset, void *pCtxt) +static inline S32 ps3RbTreeInitKeyOffset(Ps3RbTree_s *pTree, + ps3CmpKeyFunc cmpkey, U64 keyoffset, void *pCtxt) { - struct Ps3RbTreeOps ops; + Ps3RbTreeOps_s ops; - memset(&ops, 0, sizeof(struct Ps3RbTreeOps)); - ops.cmpkey = cmpkey; - ops.keyoffset = keyoffset; - ops.pCtxt = pCtxt; - setBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, - (unsigned long *)&ops.flags); + memset(&ops, 0, sizeof(Ps3RbTreeOps_s)); + ops.cmpkey = cmpkey; + ops.keyoffset = keyoffset; + ops.pCtxt = pCtxt; + setBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&ops.flags); - return ps3RbTreeInit(pTree, &ops); + return ps3RbTreeInit(pTree, &ops); } -static inline void ps3RbTreeFini(struct Ps3RbTree *pTree) +static inline void ps3RbTreeFini(Ps3RbTree_s *pTree) { BUG_ON(pTree->nodenr != 0); ps3RbRootFini(&pTree->root); } -static inline struct Ps3RbNode *ps3RbTreeHeadNode(struct Ps3RbTree *pTree) +static inline Ps3RbNode_s* ps3RbTreeHeadNode(Ps3RbTree_s *pTree) { - return ps3RbtHeadNode(&pTree->root); + return ps3RbtHeadNode(&pTree->root); } -static inline struct Ps3RbNode *ps3RbTreeTailNode(struct Ps3RbTree *pTree) +static inline Ps3RbNode_s* ps3RbTreeTailNode(Ps3RbTree_s *pTree) { - return ps3RbtTailNode(&pTree->root); + return ps3RbtTailNode(&pTree->root); } -static inline struct Ps3RbNode *ps3RbTreePrevNode(struct Ps3RbNode *pNode) +static inline Ps3RbNode_s* ps3RbTreePrevNode(Ps3RbNode_s *pNode) { - return ps3RbtPrevNode(pNode); + return ps3RbtPrevNode(pNode); } -static inline struct Ps3RbNode *ps3RbTreeNextNode(struct Ps3RbNode *pNode) +static inline Ps3RbNode_s* ps3RbTreeNextNode(Ps3RbNode_s *pNode) { - return ps3RbtNextNode(pNode); + return ps3RbtNextNode(pNode); } -static inline void ps3RbTreeReplaceNode(struct Ps3RbTree *pTree, - struct Ps3RbNode *pNew, - struct Ps3RbNode *pVictim) +static inline void ps3RbTreeReplaceNode(Ps3RbTree_s *pTree, + Ps3RbNode_s *pNew, Ps3RbNode_s *pVictim) { - ps3RbtReplaceNode(&pTree->root, pNew, pVictim); + ps3RbtReplaceNode(&pTree->root, pNew, pVictim); } -static inline int ps3RbTreeDelNode(struct Ps3RbTree *pTree, - struct Ps3RbNode *pNode) +static inline S32 ps3RbTreeDelNode(Ps3RbTree_s *pTree, + Ps3RbNode_s *pNode) { - int rc = 0; + S32 rc = 0; - rc = ps3RbtDelNode(&pTree->root, pNode); - if (rc >= 0) - pTree->nodenr--; + rc = ps3RbtDelNode(&pTree->root, pNode); + if (rc >= 0) + { + pTree->nodenr--; + } - return rc; + return rc; } -static inline int ps3RbTreeAddNode(struct Ps3RbTree *pTree, - struct Ps3RbNode *pNode) +static inline S32 ps3RbTreeAddNode(Ps3RbTree_s *pTree, + Ps3RbNode_s *pNode) { - int rc = 0; + S32 rc = 0; - rc = ps3RbtAddNode(&pTree->root, pNode, &pTree->ops); - if (rc >= 0) - pTree->nodenr++; + rc = ps3RbtAddNode(&pTree->root, pNode, &pTree->ops); + if (rc >= 0) + { + pTree->nodenr++; + } - return rc; + return rc; } -static inline struct Ps3RbNode *ps3RbTreeFindNode(struct Ps3RbTree *pTree, - void *pKey) +static inline Ps3RbNode_s* ps3RbTreeFindNode(Ps3RbTree_s *pTree, + void *pKey) { - return ps3RbtFindNode(&pTree->root, pKey, &pTree->ops); + return ps3RbtFindNode(&pTree->root, pKey, &pTree->ops); } -static inline struct Ps3RbNode *ps3RbTreeFindNextNode(struct Ps3RbTree *pTree, - void *pKey) +static inline Ps3RbNode_s* ps3RbTreeFindNextNode(Ps3RbTree_s *pTree, + void *pKey) { - return ps3RbtFindNextNode(&pTree->root, pKey, &pTree->ops); + return ps3RbtFindNextNode(&pTree->root, pKey, &pTree->ops); } -static inline void ps3RbTreeClean(struct Ps3RbTree *pTree) +static inline void ps3RbTreeClean(Ps3RbTree_s *pTree) { - ps3RbtClean(&pTree->root); - pTree->nodenr = 0; + ps3RbtClean(&pTree->root); + pTree->nodenr = 0; } -static inline int ps3RbTreeTraverse(struct Ps3RbTree *pTree, - int (*visit)(struct Ps3RbNode *pNode, - void *pCtxt), - void *pCtxt) +static inline S32 ps3RbTreeTraverse(Ps3RbTree_s *pTree, + ps3RbtreeVisitFunc visit, void *pCtxt) { - return ps3RbtTraverse(&pTree->root, visit, pCtxt); + return ps3RbtTraverse(&pTree->root, visit, pCtxt); } -static inline unsigned char ps3RbTreeIsEmpty(struct Ps3RbTree *pTree) +static inline Bool ps3RbTreeIsEmpty(Ps3RbTree_s *pTree) { - return (unsigned char)(pTree->root.pRoot == NULL); + return (Bool)(pTree->root.pRoot == NULL); } -static inline unsigned int ps3RbTreeNodeNr(struct Ps3RbTree *pTree) +static inline U32 ps3RbTreeNodeNr(Ps3RbTree_s *pTree) { - return pTree->nodenr; + return pTree->nodenr; } -#define RBT_RED (0) -#define RBT_BLACK (1) - -#define RBT_PARENT(_n) \ - ((struct Ps3RbNode *)(uintptr_t)((_n)->pParentColor & ~3ULL)) -#define RBT_COLOR(_n) ((_n)->pParentColor & 1ULL) - -#define RBT_IS_RED(_n) (!RBT_COLOR(_n)) -#define RBT_IS_BLACK(_n) RBT_COLOR(_n) -#define RBT_SET_RED(_n) ((_n)->pParentColor &= ~1ULL) -#define RBT_SET_BLACK(_n) ((_n)->pParentColor |= 1ULL) -#define RBT_ROOT_IS_EMPTY(_r) ((_r)->pRoot == NULL) -#define RBT_TREE_IS_EMPTY(_t) RBT_ROOT_IS_EMPTY(&(_t)->root) -#define RBT_NODE_IS_EMPTY(_n) (RBT_PARENT(_n) == (_n)) -#define RBT_NODE_CLEAR(_n) (ps3RbNodeInit(_n)) -#define RBT_FOR_EACH(_p_node, _p_root) \ - for (_p_node = ps3RbtHeadNode(_p_root); _p_node != NULL; \ - _p_node = ps3RbtNextNode(_p_node)) - -#define RBT_FOR_EACH_SAFE(_p_node, _p_next, _p_root) \ - for (_p_node = ps3RbtHeadNode(_p_root), \ - _p_next = ps3RbtNextNode(_p_node); \ - _p_node != NULL; \ - _p_node = _p_next, _p_next = ps3RbtNextNode(_p_node)) - -#define RBTREE_FOR_EACH(_p_node, _p_tree) \ - RBT_FOR_EACH((_p_node), &(_p_tree)->root) - -#define RBTREE_FOR_EACH_SAFE(_p_node, _p_next, _p_tree) \ - RBT_FOR_EACH_SAFE((_p_node), (_p_next), &(_p_tree)->root) +#define RBT_RED (0) +#define RBT_BLACK (1) + +#define RBT_PARENT(_n) ((Ps3RbNode_s*)(uintptr_t)((_n)->pParentColor & ~3ULL)) +#define RBT_COLOR(_n) ((_n)->pParentColor & 1ULL) + +#define RBT_IS_RED(_n) (!RBT_COLOR(_n)) +#define RBT_IS_BLACK(_n) RBT_COLOR(_n) +#define RBT_SET_RED(_n) \ + do { (_n)->pParentColor &= ~1ULL; } while (0) +#define RBT_SET_BLACK(_n) \ + do { (_n)->pParentColor |= 1ULL; } while (0) + +#define RBT_ROOT_IS_EMPTY(_r) ((_r)->pRoot == NULL) +#define RBT_TREE_IS_EMPTY(_t) RBT_ROOT_IS_EMPTY(&(_t)->root) +#define RBT_NODE_IS_EMPTY(_n) (RBT_PARENT(_n) == (_n)) +#define RBT_NODE_CLEAR(_n) do { ps3RbNodeInit(_n); } while (0) + +#define RBT_FOR_EACH(_p_node, _p_root) \ + for (_p_node = ps3RbtHeadNode(_p_root); \ + _p_node != NULL; \ + _p_node = ps3RbtNextNode(_p_node)) + +#define RBT_FOR_EACH_SAFE(_p_node, _p_next, _p_root) \ + for (_p_node = ps3RbtHeadNode(_p_root), \ + _p_next = ps3RbtNextNode(_p_node); \ + _p_node != NULL; \ + _p_node = _p_next, \ + _p_next = ps3RbtNextNode(_p_node)) + +#define RBTREE_FOR_EACH(_p_node, _p_tree) \ + RBT_FOR_EACH((_p_node), &(_p_tree)->root) + +#define RBTREE_FOR_EACH_SAFE(_p_node, _p_next, _p_tree) \ + RBT_FOR_EACH_SAFE((_p_node), (_p_next), &(_p_tree)->root) #endif + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_recovery.c b/drivers/scsi/linkdata/ps3stor/ps3_recovery.c index 766820c93291..e1fc235753a6 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_recovery.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_recovery.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #include "ps3_recovery.h" #ifndef _WINDOWS @@ -20,27 +19,23 @@ #include "ps3_r1x_write_lock.h" #include "ps3_ioc_state.h" #include "ps3_module_para.h" +#include "ps3_err_inject.h" #include "ps3_ioctl.h" #include "ps3_dump.h" #include "ps3_cli_debug.h" -#include "ps3_kernel_version.h" - -int ps3_recovery_cancel_work_sync(struct ps3_instance *instance); +S32 ps3_recovery_cancel_work_sync(struct ps3_instance *instance); #ifndef _WINDOWS -static void ps3_recovery_work(struct work_struct *work); +static void ps3_recovery_work(struct work_struct* work); #else static void ps3_recovery_work(void *work); #endif -static int ps3_hard_recovery_handle(struct ps3_instance *instance); -static int ps3_soft_recovery_handle(struct ps3_instance *instance); -static int ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance); -static int ps3_recovery_ready_to_running(struct ps3_instance *instance); -static void ps3_can_queue_reset(struct ps3_instance *instance, - unsigned int cur_max_fw_cmds); -static void ps3_cmd_reset_flag_set(struct ps3_instance *instance, - unsigned char reset_flag); -static int -ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance); +static S32 ps3_hard_recovery_handle(struct ps3_instance *instance); +static S32 ps3_soft_recovery_handle(struct ps3_instance *instance); +static S32 ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance); +static S32 ps3_recovery_ready_to_running(struct ps3_instance *instance); +static void ps3_can_queue_reset(struct ps3_instance *instance, U32 cur_max_fw_cmds); +static void ps3_cmd_reset_flag_set(struct ps3_instance *instance, U8 reset_flag); +static S32 ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance); enum { PS3_RECOVERY_INTER_ERR_SUCCESS = 0, @@ -51,21 +46,19 @@ enum { PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME = 5, }; -static inline void -ps3_wait_watchdog_dect_recovery(struct ps3_instance *instance) +static inline void ps3_wait_watchdog_dect_recovery( + struct ps3_instance *instance) { - unsigned short wait_step = 100; - unsigned short cur_cnt = 0; - unsigned char printed = PS3_TRUE; + U16 wait_step = 100; + U16 cur_cnt = 0; + Bool printed = PS3_TRUE; - while (!instance->watchdog_context.is_halt && - instance->watchdog_context.watchdog_queue != NULL) { + while(!instance->watchdog_context.is_halt && + instance->watchdog_context.watchdog_queue != NULL) { ps3_msleep(wait_step); - if (printed && ((++cur_cnt) * wait_step > - PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && ((++cur_cnt) * wait_step > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u wait watchdog recovery.\n", - PS3_HOST(instance)); + LOG_WARN("host:%u wait watchdog recovery.\n", PS3_HOST(instance)); } } } @@ -74,7 +67,8 @@ struct ps3_recovery_context *ps3_recovery_context_alloc(void) { struct ps3_recovery_context *context; - context = kzalloc(sizeof(struct ps3_recovery_context), GFP_KERNEL); + context = (struct ps3_recovery_context *)kzalloc(sizeof(struct ps3_recovery_context), GFP_KERNEL); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_ALLOC_FAIL, &context) if (!context) return NULL; @@ -82,8 +76,10 @@ struct ps3_recovery_context *ps3_recovery_context_alloc(void) } void ps3_recovery_context_free(struct ps3_recovery_context *context) { - if (context != NULL) + if (context != NULL) { kfree(context); + } + return; } void ps3_recovery_context_delete(struct ps3_recovery_context *context) @@ -96,38 +92,33 @@ void ps3_recovery_context_delete(struct ps3_recovery_context *context) kfree(context); context = NULL; } + return; } #ifndef _WINDOWS -static void ps3_recovery_irq_service(struct work_struct *work) +static void ps3_recovery_irq_service(struct work_struct* work) { struct ps3_instance *instance = - ps3_container_of(work, struct ps3_instance, recovery_irq_work); - int ret = PS3_SUCCESS; - unsigned int count = 0; - - LOG_INFO("hno:%u recovery irq triggered\n", PS3_HOST(instance)); + ps3_container_of(work, struct ps3_instance, + recovery_irq_work); + S32 ret = PS3_SUCCESS; + U32 count = 0; + LOG_INFO("hno:%u recovery irq triggered\n", + PS3_HOST(instance)); - if ((instance->recovery_context->heartbeat_recovery == - PS3_HEARTBEAT_HARDRESET_DECIDE || - instance->recovery_context->heartbeat_recovery == - PS3_HEARTBEAT_HARDRESET_RECOVERY) && - (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE)) { + if ((instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE || + instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY) + &&(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { goto l_out; } - ps3_mutex_lock( - &instance->recovery_context->ps3_watchdog_recovery_mutex); - if (instance->recovery_context->heartbeat_recovery == - PS3_HEARTBEAT_NULL) { + ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_NULL) { instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_DECIDE; } - ps3_mutex_unlock( - &instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); while ((ret = ps3_hard_recovery_request(instance)) == -PS3_RETRY) { if (count++ == ps3_use_hard_reset_max_retry()) { ret = -PS3_FAILED; @@ -136,40 +127,40 @@ static void ps3_recovery_irq_service(struct work_struct *work) ps3_mdelay(10); } if (ret == PS3_SUCCESS) { - LOG_INFO("hno[%u], recovery success!\n", PS3_HOST(instance)); - } else { + LOG_INFO("hno[%u], recovery success!\n", + PS3_HOST(instance)); + }else{ LOG_ERROR("hno[%u], recovery request NOK, %s!\n", - PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read( - &instance->state_machine.state))); + PS3_HOST(instance), + namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); } l_out: return; } -int ps3_recovery_irq_start(struct ps3_instance *instance) +S32 ps3_recovery_irq_start(struct ps3_instance *instance) { - char request_irq_queue_name[PS3_RECOVERY_IRQ_NAME_MAX_LENGTH]; - struct work_struct *recovery_irq_work = &instance->recovery_irq_work; + S8 request_irq_queue_name[PS3_RECOVERY_IRQ_NAME_MAX_LENTH]; + struct work_struct* recovery_irq_work = &instance->recovery_irq_work; + INJECT_START(PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE, instance) if (instance->recovery_irq_queue != NULL) { LOG_DEBUG("hno:%u watchdog for is already started!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - memset(request_irq_queue_name, 0, PS3_RECOVERY_IRQ_NAME_MAX_LENGTH); + memset(request_irq_queue_name, 0, PS3_RECOVERY_IRQ_NAME_MAX_LENTH); INIT_WORK(recovery_irq_work, ps3_recovery_irq_service); - snprintf(request_irq_queue_name, PS3_RECOVERY_IRQ_NAME_MAX_LENGTH, - "ps3_irq_recovery_start_service_host%d", - instance->host->host_no); + snprintf(request_irq_queue_name, PS3_RECOVERY_IRQ_NAME_MAX_LENTH, + "ps3_irq_recovery_start_service_host%d", instance->host->host_no); instance->recovery_irq_queue = create_singlethread_workqueue(request_irq_queue_name); if (instance->recovery_irq_queue == NULL) { LOG_ERROR("hno:%u watchdog work queue create failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return -PS3_FAILED; } instance->recovery_irq_enable = PS3_TRUE; @@ -177,53 +168,55 @@ int ps3_recovery_irq_start(struct ps3_instance *instance) return PS3_SUCCESS; } -irqreturn_t ps3_recovery_irq_handler(int virq, void *dev_id) +irqreturn_t ps3_recovery_irq_handler(S32 virq, void *dev_id) { struct ps3_irq_recovery *irq = (struct ps3_irq_recovery *)dev_id; struct ps3_instance *instance = irq->instance; - if (instance->ioc_adpter->ioc_heartbeat_detect == NULL) + if (instance->ioc_adpter->ioc_heartbeat_detect == NULL) { goto l_out; + } - if (instance->ioc_adpter->ioc_heartbeat_detect(instance) == PS3_TRUE && - !ps3_pci_err_recovery_get(instance) && - instance->recovery_irq_enable) { + if (instance->ioc_adpter->ioc_heartbeat_detect(instance) == PS3_TRUE + && !ps3_pci_err_recovery_get(instance) + && instance->recovery_irq_enable) { - LOG_DEBUG( - "hno:%u recovery irq received, virq: %d, dev_id: 0x%llx\n", - PS3_HOST(instance), virq, - (unsigned long long)(uintptr_t)dev_id); + + LOG_DEBUG("hno:%u recovery irq recieved, virq: %d, dev_id: 0x%llx\n", + PS3_HOST(instance), virq, (U64)dev_id); if (!work_busy(&instance->recovery_irq_work)) { - queue_work(instance->recovery_irq_queue, - &instance->recovery_irq_work); + queue_work(instance->recovery_irq_queue, &instance->recovery_irq_work); } } l_out: return IRQ_HANDLED; } -void ps3_recovery_irq_queue_destroy(struct ps3_instance *instance) +void ps3_recovery_irq_queue_destory(struct ps3_instance *instance) { if (instance->recovery_irq_queue) { flush_workqueue(instance->recovery_irq_queue); destroy_workqueue(instance->recovery_irq_queue); instance->recovery_irq_queue = NULL; } + return; } -void ps3_recovery_work_queue_destroy(struct ps3_instance *instance) +void ps3_recovery_work_queue_destory(struct ps3_instance *instance) { struct ps3_recovery_context *context = instance->recovery_context; - struct workqueue_struct *wq = context->recovery_wq; + struct workqueue_struct* wq = context->recovery_wq; if (!ps3_is_latest_func(instance)) { - LOG_DEBUG("hno:%u not latest func\n", PS3_HOST(instance)); - goto l_out; + LOG_DEBUG("hno:%u not latest func\n", + PS3_HOST(instance)); + goto l_out; } context->recovery_wq = NULL; - if (wq == NULL) + if (wq == NULL) { return; + } flush_workqueue(wq); destroy_workqueue(wq); @@ -234,55 +227,47 @@ void ps3_recovery_work_queue_destroy(struct ps3_instance *instance) void ps3_recovery_function_init(struct ps3_instance *instance) { instance->recovery_function.halt_handle_cb = NULL; - instance->recovery_function.hardreset_handle_init_running_cb = - ps3_hardreset_handle_init_running; - instance->recovery_function.hardreset_handle_post_cb = - ps3_hardreset_handle_post; - instance->recovery_function.hardreset_handle_pre_cb = - ps3_hardreset_handle_pre; - instance->recovery_function.hardreset_handle_wait_ready_cb = - ps3_hardreset_handle_wait_ready; - instance->recovery_function.hardreset_handle_finish_cb = - ps3_hardreset_handle_finish; - instance->recovery_function.hardreset_handle_offline_cb = - ps3_hardreset_handle_offline; + instance->recovery_function.hardreset_handle_init_running_cb = ps3_hardreset_handle_init_running; + instance->recovery_function.hardreset_handle_post_cb = ps3_hardreset_handle_post; + instance->recovery_function.hardreset_handle_pre_cb = ps3_hardreset_handle_pre; + instance->recovery_function.hardreset_handle_wait_ready_cb = ps3_hardreset_handle_wait_ready; + instance->recovery_function.hardreset_handle_finish_cb = ps3_hardreset_handle_finish; + instance->recovery_function.hardreset_handle_offline_cb = ps3_hardreset_handle_offline; instance->recovery_function.recovery_handle_cb = NULL; - instance->recovery_function.softreset_handle_post_cb = - ps3_softreset_handle_post; - instance->recovery_function.softreset_handle_pre_cb = - ps3_softreset_handle_pre; + instance->recovery_function.softreset_handle_post_cb = ps3_softreset_handle_post; + instance->recovery_function.softreset_handle_pre_cb = ps3_softreset_handle_pre; + return; } -int ps3_recovery_context_init(struct ps3_instance *instance) +S32 ps3_recovery_context_init(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_recovery_context *context = NULL; ps3_recovery_function_init(instance); if (instance->peer_instance != NULL) { - instance->recovery_context = - instance->peer_instance->recovery_context; + instance->recovery_context = instance->peer_instance->recovery_context; goto l_recovery_irq_init; } context = ps3_recovery_context_alloc(); + INJECT_START(PS3_ERR_RECOVERY_CONTEXT_ALLOC_FAILED, &context); if (context == NULL) { LOG_ERROR("hno:%u, alloc recovery context failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } LOG_DEBUG("recovery context add!\n"); snprintf(context->recovery_wq_name, 20, "ps3_rec_th_%d", - instance->host->host_no); + instance->host->host_no); context->recovery_wq = create_singlethread_workqueue(context->recovery_wq_name); if (context->recovery_wq == NULL) { - LOG_ERROR("hno:%u create recovery_wq NOK !\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u create recovery_wq NOK !\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -302,14 +287,15 @@ int ps3_recovery_context_init(struct ps3_instance *instance) l_recovery_irq_init: if (ps3_recovery_irq_start(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u recovery irq NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u recovery irq NOK\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_recovery_start_failed; } return ret; l_recovery_start_failed: - ps3_recovery_irq_queue_destroy(instance); + ps3_recovery_irq_queue_destory(instance); ps3_mutex_destroy(&context->ps3_watchdog_recovery_mutex); ps3_mutex_destroy(&context->free_cmd_lock); instance->recovery_context = NULL; @@ -321,9 +307,9 @@ int ps3_recovery_context_init(struct ps3_instance *instance) void ps3_recovery_clean(struct ps3_instance *instance) { struct ps3_recovery_context *context = instance->recovery_context; - - if (context == NULL) + if(context == NULL) { goto l_out; + } if (!ps3_is_latest_func(instance)) { instance->recovery_context = NULL; @@ -335,48 +321,50 @@ void ps3_recovery_clean(struct ps3_instance *instance) ps3_recovery_context_free(instance->recovery_context); instance->recovery_context = NULL; l_out: - return; + return ; } -void ps3_recovery_destroy(struct ps3_instance *instance) +void ps3_recovery_destory(struct ps3_instance *instance) { #ifndef _WINDOWS ps3_recovery_cancel_work_sync(instance); - ps3_recovery_work_queue_destroy(instance); + ps3_recovery_work_queue_destory(instance); #else struct ps3_recovery_context *context = instance->recovery_context; - ps3_worker_exit(&context->recovery_work); #endif + return ; } void ps3_recovery_context_exit(struct ps3_instance *instance) { - ps3_recovery_irq_queue_destroy(instance); + ps3_recovery_irq_queue_destory(instance); if (instance->peer_instance == NULL && - instance->recovery_context != NULL) { - ps3_recovery_destroy(instance); + instance->recovery_context != NULL) { + ps3_recovery_destory(instance); ps3_recovery_clean(instance); } + return ; } -int ps3_recovery_state_transfer(struct ps3_instance *instance, - unsigned int dest_state) +S32 ps3_recovery_state_transfer(struct ps3_instance *instance, + U32 dest_state) { - unsigned int recovery_origin_state; + U32 recovery_origin_state; ps3_mutex_lock(&instance->state_machine.lock); recovery_origin_state = instance->recovery_context->recovery_state; - if (recovery_origin_state == dest_state) + if (recovery_origin_state == dest_state) { goto l_fail; + } - switch (recovery_origin_state) { + switch(recovery_origin_state) { case PS3_SOFT_RECOVERY_PROBE_PROCESS: if (dest_state == PS3_SOFT_RECOVERY_SHALLOW || - dest_state == PS3_SOFT_RECOVERY_DEEP || - dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY || - dest_state == PS3_HARD_RECOVERY_DECIDE) { + dest_state == PS3_SOFT_RECOVERY_DEEP || + dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY || + dest_state == PS3_HARD_RECOVERY_DECIDE) { goto l_success; } else { goto l_fail; @@ -386,8 +374,8 @@ int ps3_recovery_state_transfer(struct ps3_instance *instance, case PS3_SOFT_RECOVERY_DEEP: case PS3_SOFT_RECOVERY_IOC_RECOVERY: if ((dest_state == PS3_HARD_RECOVERY_DECIDE) || - (dest_state == PS3_HARD_RECOVERY_SHALLOW) || - (dest_state == PS3_SOFT_RECOVERY_FINISH)) { + (dest_state == PS3_HARD_RECOVERY_SHALLOW)|| + (dest_state == PS3_SOFT_RECOVERY_FINISH)) { goto l_success; } else { goto l_fail; @@ -395,10 +383,10 @@ int ps3_recovery_state_transfer(struct ps3_instance *instance, break; case PS3_SOFT_RECOVERY_FINISH: if ((dest_state == PS3_HARD_RECOVERY_DECIDE) || - (dest_state == PS3_SOFT_RECOVERY_SHALLOW) || - (dest_state == PS3_SOFT_RECOVERY_DEEP) || - (dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) || - (dest_state == PS3_HARD_RECOVERY_SHALLOW)) { + (dest_state == PS3_SOFT_RECOVERY_SHALLOW) || + (dest_state == PS3_SOFT_RECOVERY_DEEP) || + (dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) || + (dest_state == PS3_HARD_RECOVERY_SHALLOW)) { goto l_success; } else { goto l_fail; @@ -406,7 +394,7 @@ int ps3_recovery_state_transfer(struct ps3_instance *instance, break; case PS3_HARD_RECOVERY_DECIDE: if (dest_state == PS3_HARD_RECOVERY_SHALLOW || - dest_state == PS3_HARD_RECOVERY_FINISH) { + dest_state == PS3_HARD_RECOVERY_FINISH) { goto l_success; } else { goto l_fail; @@ -414,20 +402,21 @@ int ps3_recovery_state_transfer(struct ps3_instance *instance, break; case PS3_HARD_RECOVERY_FINISH: if ((dest_state == PS3_HARD_RECOVERY_DECIDE) || - (dest_state == PS3_SOFT_RECOVERY_SHALLOW) || - (dest_state == PS3_SOFT_RECOVERY_DEEP) || - (dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) || - (dest_state == PS3_HARD_RECOVERY_SHALLOW)) { + (dest_state == PS3_SOFT_RECOVERY_SHALLOW) || + (dest_state == PS3_SOFT_RECOVERY_DEEP) || + (dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) || + (dest_state == PS3_HARD_RECOVERY_SHALLOW)) { goto l_success; } else { goto l_fail; } break; case PS3_HARD_RECOVERY_SHALLOW: - if (dest_state == PS3_HARD_RECOVERY_FINISH) + if (dest_state == PS3_HARD_RECOVERY_FINISH) { goto l_success; - else + } else { goto l_fail; + } break; default: goto l_fail; @@ -435,25 +424,28 @@ int ps3_recovery_state_transfer(struct ps3_instance *instance, l_fail: ps3_mutex_unlock(&instance->state_machine.lock); - LOG_ERROR("hno:%u recovery state transfer NOK! [cur_state:%d][dest_state:%d]\n", - PS3_HOST(instance), recovery_origin_state, dest_state); + LOG_ERROR("hno:%u recovery state transfer NOK!" + "[cur_state:%d][dest_state:%d]\n", + PS3_HOST(instance), + recovery_origin_state,dest_state); return -PS3_FAILED; l_success: instance->recovery_context->recovery_state = dest_state; ps3_mutex_unlock(&instance->state_machine.lock); LOG_FILE_INFO("hno:%u recovery state transfer from %d to %d!\n", - PS3_HOST(instance), recovery_origin_state, dest_state); + PS3_HOST(instance), + recovery_origin_state,dest_state); return PS3_SUCCESS; } #ifndef _WINDOWS -static int ps3_recovery_work_start(struct ps3_instance *instance) +static S32 ps3_recovery_work_start(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_recovery_context *context = instance->recovery_context; - + INJECT_START(PS3_ERR_IJ_FORCE_START_DESTROY_RECOVERY, instance) if (unlikely(context->recovery_wq == NULL)) { ret = -PS3_FAILED; @@ -466,36 +458,31 @@ static int ps3_recovery_work_start(struct ps3_instance *instance) l_out: return ret; } -static inline void ps3_wait_hard_reset_finish(struct ps3_instance *instance) + static inline void ps3_wait_hard_reset_finish(struct ps3_instance *instance) { - while (ps3_atomic_read(&instance->recovery_context->hardreset_ref) != - 0) { + while(ps3_atomic_read(&instance->recovery_context->hardreset_ref) != 0){ ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); } - if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { - do { + if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + do{ ps3_msleep(100); - if (likely(instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE)) { + if (likely(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { continue; } else { - cancel_work_sync(&instance->recovery_context - ->recovery_work); + cancel_work_sync(&instance->recovery_context->recovery_work); break; } - } while (1); + }while(1); } else { cancel_work_sync(&instance->recovery_context->recovery_work); } } -int ps3_recovery_cancel_work_sync(struct ps3_instance *instance) +S32 ps3_recovery_cancel_work_sync(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_recovery_context *context = instance->recovery_context; - if (unlikely(context->recovery_wq == NULL)) { ret = -PS3_FAILED; goto l_out; @@ -507,36 +494,33 @@ int ps3_recovery_cancel_work_sync(struct ps3_instance *instance) return ret; } -static int ps3_recovery_start(struct ps3_instance *instance) +static S32 ps3_recovery_start(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - + S32 ret = PS3_SUCCESS; ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW) { + INJECT_START(PS3_ERR_IJ_FORCE_START_DUL_RECOVERY, instance) + if(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW){ LOG_ERROR("hno:%u hard recovery work proc,exit!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); + INJECT_START(PS3_ERR_IJ_FORCE_DESTROY_RECOVERY, instance) if (unlikely(instance->recovery_context->recovery_wq == NULL)) { ret = -PS3_FAILED; LOG_ERROR("hno:%u recovery work sync NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } cancel_work_sync(&instance->recovery_context->recovery_work); ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { - if (ps3_instance_no_lock_state_transfer( - instance, PS3_INSTANCE_STATE_RECOVERY) != - PS3_SUCCESS) { - LOG_ERROR( - "hno:%u transfer to PS3_INSTANCE_STATE_RECOVERY NOK!\n", + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, instance) + if(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + if(ps3_instance_no_lock_state_transfer(instance, PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + LOG_ERROR("hno:%u transfer to PS3_INSTANCE_STATE_RECOVERY NOK!\n", PS3_HOST(instance)); ret = -PS3_FAILED; ps3_mutex_unlock(&instance->state_machine.lock); @@ -547,18 +531,13 @@ static int ps3_recovery_start(struct ps3_instance *instance) if (instance->peer_instance != NULL) { ps3_mutex_lock(&instance->peer_instance->state_machine.lock); - if (instance->peer_instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { - if (ps3_instance_no_lock_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_RECOVERY) != - PS3_SUCCESS) { - LOG_ERROR( - "hno:%u transfer to PS3_INSTANCE_STATE_RECOVERY NOK!\n", + if(instance->peer_instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PEER_STATE_DEAD, instance->peer_instance) + if(ps3_instance_no_lock_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + LOG_ERROR("hno:%u transfer to PS3_INSTANCE_STATE_RECOVERY NOK!\n", PS3_HOST(instance->peer_instance)); ret = -PS3_FAILED; - ps3_mutex_unlock(&instance->peer_instance - ->state_machine.lock); + ps3_mutex_unlock(&instance->peer_instance->state_machine.lock); goto l_out; } } @@ -568,21 +547,19 @@ static int ps3_recovery_start(struct ps3_instance *instance) ret = ps3_recovery_work_start(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u recovery work start NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } l_out: return ret; } #else -static int ps3_recovery_start(struct ps3_instance *instance) +static S32 ps3_recovery_start(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - struct ps3_recovery_context *context = instance->recovery_context; - + S32 ret = PS3_SUCCESS; + struct ps3_recovery_context* context = instance->recovery_context; if (ps3_worker_start(&context->recovery_work) != PS3_SUCCESS) { - LOG_ERROR( - "trace_id[0x%llx], hno:%u recovery start worker failed\n", + LOG_ERROR("trace_id[0x%llx], hno:%u recovery start worker failed\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; @@ -592,45 +569,45 @@ static int ps3_recovery_start(struct ps3_instance *instance) } #endif -static unsigned char ps3_recovery_is_state_halt(struct ps3_instance *instance) +static Bool ps3_recovery_is_state_halt(struct ps3_instance *instance) { - unsigned char ret = PS3_FALSE; - struct ps3_instance_state_machine *state_machine = - &instance->state_machine; - unsigned int cur_state = 0; - unsigned int ioc_state = instance->ioc_adpter->ioc_state_get(instance); + Bool ret = PS3_FALSE; + struct ps3_instance_state_machine *state_machine + = &instance->state_machine; + U32 cur_state = 0; + U32 ioc_state = instance->ioc_adpter->ioc_state_get(instance); cur_state = ps3_atomic_read(&state_machine->state); if (cur_state == PS3_INSTANCE_STATE_DEAD) { - LOG2_INFO_LIM( - "hno:%u ioc_state:%s, drv_state:PS3_INSTANCE_STATE_DEAD, stop recovery!\n", - PS3_HOST(instance), ps3_ioc_state_print(ioc_state)); + LOG2_INFO_LIM("hno:%u ioc_state:%s, " + "drv_state:PS3_INSTANCE_STATE_DEAD, stop recovery!\n", + PS3_HOST(instance), + ps3_ioc_state_print(ioc_state)); ret = PS3_TRUE; goto l_out; } if (ioc_state == PS3_FW_STATE_HALT && - instance->recovery_context->heartbeat_recovery != - PS3_HEARTBEAT_HARDRESET_DECIDE) { + instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_DECIDE) { ps3_atomic_set(&state_machine->state, PS3_INSTANCE_STATE_DEAD); - LOG2_INFO_LIM( - "hno:%u ioc_state:PS3_FW_STATE_HALT, stop recovery!\n", + LOG2_INFO_LIM("hno:%u ioc_state:PS3_FW_STATE_HALT, stop recovery!\n", PS3_HOST(instance)); - while (1) + while(1) { ps3_msleep(10); + } ret = PS3_TRUE; goto l_out; } if (PS3_IOC_STATE_HALT_SUPPORT(instance) && - instance->recovery_context->heartbeat_recovery != - PS3_HEARTBEAT_HARDRESET_DECIDE) { + instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_DECIDE) { instance->ioc_adpter->ioc_force_to_halt(instance); ps3_atomic_set(&state_machine->state, PS3_INSTANCE_STATE_DEAD); LOG_WARN("hno:%u IOC support HALT, enter HALT!\n", - PS3_HOST(instance)); - while (1) + PS3_HOST(instance)); + while(1) { ps3_msleep(10); + } ret = PS3_TRUE; } l_out: @@ -638,97 +615,74 @@ static unsigned char ps3_recovery_is_state_halt(struct ps3_instance *instance) return ret; } -static inline int -ps3_hard_recovery_request_decide(struct ps3_instance *instance, - unsigned int cur_state, - unsigned int peer_cur_state) +static inline S32 ps3_hard_recovery_request_decide( + struct ps3_instance *instance, U32 cur_state, U32 peer_cur_state) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { + if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { LOG_INFO("hno:%u instance state during hard recovery!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; goto l_out; } if ((cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || - (cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_DEAD) || - (cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY) || - (cur_state == PS3_INSTANCE_STATE_INIT)) { + (cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || + (cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || + (cur_state == PS3_INSTANCE_STATE_DEAD) || + (cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY) || + (cur_state == PS3_INSTANCE_STATE_INIT)) { if (instance->is_need_event) { - if (instance->event_context.event_abort_cmd != NULL) { - complete(&instance->event_context - .event_abort_cmd->sync_done); - } else if (instance->dev_context.vdpending_abort_cmd != - NULL) { - complete(&instance->dev_context - .vdpending_abort_cmd - ->sync_done); - } else if (instance->webSubscribe_context - .web_abort_cmd != NULL) { - complete(&instance->webSubscribe_context - .web_abort_cmd->sync_done); - } + if(instance->event_context.event_abort_cmd != NULL){ + complete(&instance->event_context.event_abort_cmd->sync_done); + } else if (instance->dev_context.vdpending_abort_cmd != NULL){ + complete(&instance->dev_context.vdpending_abort_cmd->sync_done); + } else if (instance->webSubscribe_context.web_abort_cmd != NULL){ + complete(&instance->webSubscribe_context.web_abort_cmd->sync_done); + } } if (instance->peer_instance == NULL) { - instance->recovery_context->recovery_state = - PS3_HARD_RECOVERY_DECIDE; + instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_DECIDE; LOG_INFO("hno:%u instance state to recovery!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; } } else { LOG_INFO("hno:%u instance state during hard recovery!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; goto l_out; } if (instance->peer_instance != NULL) { + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_DECIDE_PEER_INSTANCE_FAIL, + &peer_cur_state) if ((peer_cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (peer_cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || - (peer_cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (peer_cur_state == PS3_INSTANCE_STATE_DEAD) || - (peer_cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY) || - (peer_cur_state == PS3_INSTANCE_STATE_INIT)) { + (peer_cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || + (peer_cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || + (peer_cur_state == PS3_INSTANCE_STATE_DEAD) || + (peer_cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY) || + (peer_cur_state == PS3_INSTANCE_STATE_INIT)) { if (instance->peer_instance->is_need_event) { - if (instance->peer_instance->event_context - .event_abort_cmd != NULL) { - complete(&instance->peer_instance - ->event_context - .event_abort_cmd - ->sync_done); - } else if (instance->peer_instance->dev_context - .vdpending_abort_cmd != - NULL) { - complete(&instance->peer_instance - ->dev_context - .vdpending_abort_cmd - ->sync_done); - } else if (instance->webSubscribe_context - .web_abort_cmd != NULL) { - complete(&instance->webSubscribe_context - .web_abort_cmd - ->sync_done); - } + if(instance->peer_instance->event_context.event_abort_cmd != NULL){ + complete(&instance->peer_instance->event_context.event_abort_cmd->sync_done); + } else if (instance->peer_instance->dev_context.vdpending_abort_cmd != NULL){ + complete(&instance->peer_instance->dev_context.vdpending_abort_cmd->sync_done); + } else if (instance->webSubscribe_context.web_abort_cmd != NULL){ + complete(&instance->webSubscribe_context.web_abort_cmd->sync_done); + } } - instance->peer_instance->recovery_context - ->recovery_state = PS3_HARD_RECOVERY_DECIDE; + instance->peer_instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_DECIDE; LOG_INFO("hno:%u instance state to recovery!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; } else { - LOG_INFO( - "hno:%u instance state during hard recovery!\n", + LOG_INFO("hno:%u instance state during hard recovery!\n", PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; } @@ -737,140 +691,125 @@ ps3_hard_recovery_request_decide(struct ps3_instance *instance, return ret; } -static int ps3_hard_recovery_request_prepare(struct ps3_instance *instance) +static S32 ps3_hard_recovery_request_prepare(struct ps3_instance *instance) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - unsigned int ioc_state = 0; - struct ps3_instance_state_machine *state_machine = - &instance->state_machine; - unsigned int cur_state = 0; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + U32 ioc_state = 0; + struct ps3_instance_state_machine *state_machine + = &instance->state_machine; + U32 cur_state = 0; struct ps3_instance_state_machine *state_machine_peer = NULL; - unsigned int peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; - + U32 peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; + INJECT_START(PS3_ERR_IJ_PCIE_FROZEN, instance) if (instance->reg_set == NULL) return ret; + ioc_state = instance->ioc_adpter->ioc_state_get(instance); ps3_mutex_lock(&state_machine->lock); cur_state = ps3_atomic_read(&state_machine->state); - LOG_INFO("hno:%u hard recovery request:%s, %s\n", PS3_HOST(instance), - ps3_ioc_state_print(ioc_state), - namePS3InstanceState(cur_state)); + LOG_INFO("hno:%u hard recovery request:%s, %s\n", + PS3_HOST(instance), + ps3_ioc_state_print(ioc_state), namePS3InstanceState(cur_state)); if (instance->peer_instance != NULL) { state_machine_peer = &instance->peer_instance->state_machine; + INJECT_START(PS3_ERR_IJ_PEER_PCIE_FROZEN, instance->peer_instance) if (instance->peer_instance->reg_set == NULL) goto l_clean; - ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get( - instance->peer_instance); + + ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get(instance->peer_instance); ps3_mutex_lock(&state_machine_peer->lock); peer_cur_state = ps3_atomic_read(&state_machine_peer->state); LOG_INFO("hno:%u hard recovery request:%s, %s\n", - PS3_HOST(instance->peer_instance), - ps3_ioc_state_print(ioc_state), - namePS3InstanceState(peer_cur_state)); + PS3_HOST(instance->peer_instance), + ps3_ioc_state_print(ioc_state), namePS3InstanceState(peer_cur_state)); } - ps3_mutex_lock( - &instance->recovery_context->ps3_watchdog_recovery_mutex); - if (instance->recovery_context->heartbeat_recovery == - PS3_HEARTBEAT_HARDRESET_DECIDE) { - ret = ps3_hard_recovery_request_decide(instance, cur_state, - peer_cur_state); + ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE) { + ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { LOG_INFO("hno:%u heartbeat hard recovery start\n", - PS3_HOST(instance)); - instance->recovery_context->heartbeat_recovery = - PS3_HEARTBEAT_HARDRESET_RECOVERY; + PS3_HOST(instance)); + instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_RECOVERY; } - ps3_mutex_unlock(&instance->recovery_context - ->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); goto l_out; } - ps3_mutex_unlock( - &instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); - ret = ps3_hard_recovery_request_decide(instance, cur_state, - peer_cur_state); + ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); l_out: - if (instance->peer_instance != NULL) + if (instance->peer_instance != NULL) { ps3_mutex_unlock(&state_machine_peer->lock); + } l_clean: ps3_mutex_unlock(&state_machine->lock); return ret; } -int ps3_hard_recovery_request(struct ps3_instance *instance) +S32 ps3_hard_recovery_request(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_instance *instance_recovery = NULL; - LOG_WARN( - "hno:%u ps3 hard recovery request start, IOC outstanding: %d!!\n", - PS3_HOST(instance), + LOG_WARN("hno:%u ps3 hard recovery request start, IOC outstanding: %d!!\n", PS3_HOST(instance), ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); ps3_atomic_inc(&instance->recovery_context->hardreset_ref); - mb(); /* in order to force CPU ordering */ + mb(); + INJECT_START(PS3_ERR_IJ_ADD_INSTANCE, &instance->recovery_context->instance_change) if (instance->recovery_context->instance_change) { - LOG_INFO("hno:%u peer instance is change\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); ret = -PS3_RETRY; goto l_out; } + INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_PROBE, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_REMOVE, instance) while (instance->peer_instance != NULL && - PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { - if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_INIT; + PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { + + INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY, instance) + if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || \ + instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; goto l_out; } + INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE, &instance->recovery_context->instance_change) if (instance->recovery_context->instance_change) { - LOG_INFO("hno:%u peer instance is change\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); ret = -PS3_RETRY; goto l_out; } - if (instance->recovery_context->parall_hardreset_state == - PS3_PARALLEL_HARDRESET_STATE_INIT) { - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_PENDING; + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_INIT) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_PENDING; } + INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, instance) ps3_atomic_dec(&instance->recovery_context->hardreset_ref); ps3_msleep(10); - if (instance->recovery_context->parall_hardreset_state == - PS3_PARALLEL_HARDRESET_STATE_CONTINUE) { - ps3_atomic_inc( - &instance->recovery_context->hardreset_ref); - mb(); /* in order to force CPU ordering */ - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_INIT; + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_CONTINUE) { + ps3_atomic_inc(&instance->recovery_context->hardreset_ref); + mb(); + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; break; } ps3_atomic_inc(&instance->recovery_context->hardreset_ref); - mb(); /* in order to force CPU ordering */ + mb(); } - if (instance->recovery_context->parall_hardreset_state == - PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_INIT; + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; } - LOG_INFO( - "hno:%u peer_instance[%p], hard recovery request Function[%d]\n", - PS3_HOST(instance), instance->peer_instance, - ps3_get_pci_function(instance->pdev)); + LOG_INFO("hno:%u peer_instance[%p], hard recovery request Function[%d]\n", + PS3_HOST(instance), instance->peer_instance, ps3_get_pci_function(instance->pdev)); if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_0 || - (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1 && - instance->peer_instance == NULL)) { + (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1 && instance->peer_instance == NULL)) { instance_recovery = instance; } else { instance_recovery = instance->peer_instance; @@ -878,15 +817,14 @@ int ps3_hard_recovery_request(struct ps3_instance *instance) if (ps3_recovery_is_state_halt(instance_recovery)) { LOG_WARN("hno:%u driver_state:DEAD or HALT now !!!\n", - PS3_HOST(instance_recovery)); + PS3_HOST(instance_recovery)); ret = -PS3_FAILED; goto l_out; } - if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance_recovery)) || - (!ps3_hard_reset_enable_query())) { - LOG_ERROR( - "hno:%u soc feature unsupport Hard reset[%d] or unable[%d]!!\n", + if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance_recovery)) || \ + (!ps3_hard_reset_enable_query())) { + LOG_ERROR("hno:%u soc feature unsupport Hard reset[%d] or unable[%d]!!\n", PS3_HOST(instance_recovery), PS3_IOC_HARD_RECOVERY_SUPPORT(instance_recovery), ps3_hard_reset_enable_query()); @@ -895,159 +833,138 @@ int ps3_hard_recovery_request(struct ps3_instance *instance) } ret = ps3_hard_recovery_request_prepare(instance_recovery); - if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) + if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) { ret = PS3_SUCCESS; - else if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) + } else if(ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { ret = ps3_recovery_start(instance_recovery); - else + } else { ret = -PS3_FAILED; - + } + INJECT_START(PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE_1, &ret) l_out: LOG_INFO("hno:%u hard recovery request end, ret:%d!\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); ps3_atomic_dec(&instance->recovery_context->hardreset_ref); return ret; } -static inline int -ps3_ioc_soft_recovery_request_decide(struct ps3_instance *instance, - unsigned int ioc_state) +static inline S32 ps3_ioc_soft_recovery_request_decide( + struct ps3_instance *instance, U32 ioc_state) { - unsigned int ioc_recovery_count = 0; - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - struct ps3_instance_state_machine *state_machine = - &instance->state_machine; - int recovery_state = 0; + U32 ioc_recovery_count = 0; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + struct ps3_instance_state_machine *state_machine + = &instance->state_machine; + S32 recovery_state = 0; recovery_state = instance->recovery_context->recovery_state; - if (recovery_state == PS3_HARD_RECOVERY_SHALLOW || - recovery_state == PS3_HARD_RECOVERY_DECIDE) { - LOG_INFO( - "hno:%u instance state %s,recovery_state %d,hard reset doing, IOC soft return!\n", + if(recovery_state == PS3_HARD_RECOVERY_SHALLOW|| + recovery_state == PS3_HARD_RECOVERY_DECIDE){ + LOG_INFO("hno:%u instance state %s,recovery_state %d,hard reset doing, IOC soft return!\n", PS3_HOST(instance), - namePS3InstanceState( - ps3_atomic_read(&state_machine->state)), + namePS3InstanceState(ps3_atomic_read(&state_machine->state)), recovery_state); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; - } else if (recovery_state == PS3_SOFT_RECOVERY_SHALLOW || - recovery_state == PS3_SOFT_RECOVERY_DEEP || - recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) { - LOG_INFO( - "hno:%u instance state %s,recovery_state %d,repeat request!\n", + }else if(recovery_state == PS3_SOFT_RECOVERY_SHALLOW || + recovery_state == PS3_SOFT_RECOVERY_DEEP || + recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY){ + LOG_INFO("hno:%u instance state %s,recovery_state %d,repeat request!\n", PS3_HOST(instance), - namePS3InstanceState( - ps3_atomic_read(&state_machine->state)), + namePS3InstanceState(ps3_atomic_read(&state_machine->state)), recovery_state); goto l_out; } if (!ps3_ioc_recovery_count_get(instance, &ioc_recovery_count)) { - LOG_INFO( - "hno:%u entry IOC soft recovery request decide!,ioc_state:%s,\n" - "\tsave_recovery_count:%d, ioc_recovery_count:%d\n", - PS3_HOST(instance), ps3_ioc_state_print(ioc_state), - instance->recovery_context->ioc_recovery_count, - ioc_recovery_count); + LOG_INFO("hno:%u entry IOC soft recovery request decide!,ioc_state:%s," + " save_recovery_count:%d, ioc_recovery_count:%d\n", + PS3_HOST(instance), + ps3_ioc_state_print(ioc_state), + instance->recovery_context->ioc_recovery_count, ioc_recovery_count); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - LOG_INFO("hno:%u entry IOC soft recovery request decide!,ioc_state:%s,\n" - "\tsave_recovery_count:%d, ioc_recovery_count:%d\n", - PS3_HOST(instance), ps3_ioc_state_print(ioc_state), - instance->recovery_context->ioc_recovery_count, - ioc_recovery_count); + LOG_INFO("hno:%u entry IOC soft recovery request decide!,ioc_state:%s," + " save_recovery_count:%d, ioc_recovery_count:%d\n", + PS3_HOST(instance), + ps3_ioc_state_print(ioc_state), + instance->recovery_context->ioc_recovery_count, ioc_recovery_count); - if (instance->recovery_context->ioc_recovery_count == - ioc_recovery_count) { + if (instance->recovery_context->ioc_recovery_count == ioc_recovery_count) { goto l_out; } - if (ps3_instance_no_lock_state_transfer( - instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != - PS3_SUCCESS) { + if(ps3_instance_no_lock_state_transfer(instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (instance->peer_instance != NULL) { - if (ps3_instance_no_lock_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_SOFT_RECOVERY) != PS3_SUCCESS) { + if(ps3_instance_no_lock_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } } - instance->recovery_context->recovery_state = - PS3_SOFT_RECOVERY_IOC_RECOVERY; + instance->recovery_context->recovery_state + = PS3_SOFT_RECOVERY_IOC_RECOVERY; ret = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; l_out: return ret; } -static inline int -ps3_soft_recovery_request_decide(struct ps3_instance *instance, - unsigned int ioc_state) +static inline S32 ps3_soft_recovery_request_decide( + struct ps3_instance *instance, U32 ioc_state) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - struct ps3_instance_state_machine *state_machine = - &instance->state_machine; - int recovery_state = instance->recovery_context->recovery_state; - - if (recovery_state == PS3_HARD_RECOVERY_SHALLOW || - recovery_state == PS3_HARD_RECOVERY_DECIDE) { - LOG_INFO( - "hno:%u instance state %s,recovery_state %d,repeat request!\n", + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + struct ps3_instance_state_machine *state_machine + = &instance->state_machine; + S32 recovery_state = instance->recovery_context->recovery_state; + if( recovery_state == PS3_HARD_RECOVERY_SHALLOW || + recovery_state == PS3_HARD_RECOVERY_DECIDE){ + LOG_INFO("hno:%u instance state %s,recovery_state %d,repeat request!\n", PS3_HOST(instance), - namePS3InstanceState( - ps3_atomic_read(&state_machine->state)), + namePS3InstanceState(ps3_atomic_read(&state_machine->state)), recovery_state); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; - } else if (recovery_state == PS3_SOFT_RECOVERY_SHALLOW || - recovery_state == PS3_SOFT_RECOVERY_DEEP || - recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) { - LOG_INFO( - "hno:%u instance state %s,recovery_state %d,repeat request!\n", + }else if(recovery_state == PS3_SOFT_RECOVERY_SHALLOW || + recovery_state == PS3_SOFT_RECOVERY_DEEP || + recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY){ + LOG_INFO("hno:%u instance state %s,recovery_state %d,repeat request!\n", PS3_HOST(instance), - namePS3InstanceState( - ps3_atomic_read(&state_machine->state)), + namePS3InstanceState(ps3_atomic_read(&state_machine->state)), recovery_state); goto l_out; } if (ioc_state == PS3_FW_STATE_RUNNING) { - if (ps3_instance_no_lock_state_transfer( - instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != - PS3_SUCCESS) { + if(ps3_instance_no_lock_state_transfer(instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (instance->peer_instance != NULL) { - if (ps3_instance_no_lock_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_SOFT_RECOVERY) != - PS3_SUCCESS) { + if(ps3_instance_no_lock_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } } - instance->recovery_context->recovery_state = - PS3_SOFT_RECOVERY_SHALLOW; + instance->recovery_context->recovery_state + = PS3_SOFT_RECOVERY_SHALLOW; LOG_INFO("hno:%u instance state to soft recovery shallow!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; } @@ -1055,69 +972,62 @@ ps3_soft_recovery_request_decide(struct ps3_instance *instance, return ret; } -static int ps3_recovery_request_prepare(struct ps3_instance *instance) +static S32 ps3_recovery_request_prepare(struct ps3_instance *instance) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - unsigned int ioc_state = 0; - struct ps3_instance_state_machine *state_machine = - &instance->state_machine; - unsigned int cur_state = 0; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + U32 ioc_state = 0; + struct ps3_instance_state_machine *state_machine + = &instance->state_machine; + U32 cur_state = 0; struct ps3_instance_state_machine *state_machine_peer = NULL; - unsigned int peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; + U32 peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; ps3_mutex_lock(&state_machine->lock); ioc_state = instance->ioc_adpter->ioc_state_get(instance); cur_state = ps3_atomic_read(&state_machine->state); - LOG_INFO("hno:%u recovery request:%s, %s\n", PS3_HOST(instance), - ps3_ioc_state_print(ioc_state), - namePS3InstanceState(cur_state)); + INJECT_START(PS3_ERR_IJ_CHANGE_FW_TO_HALT_IN_PREPARE, &ioc_state); + LOG_INFO("hno:%u recovery request:%s, %s\n", + PS3_HOST(instance), + ps3_ioc_state_print(ioc_state), namePS3InstanceState(cur_state)); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PCIE_ERR, instance) if (ps3_pci_err_recovery_get(instance) || - (instance->peer_instance != NULL && - ps3_pci_err_recovery_get(instance->peer_instance))) { + (instance->peer_instance != NULL && ps3_pci_err_recovery_get(instance->peer_instance))) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; goto l_out; } - ps3_mutex_lock( - &instance->recovery_context->ps3_watchdog_recovery_mutex); - if (instance->recovery_context->heartbeat_recovery == - PS3_HEARTBEAT_HARDRESET_DECIDE) { - ret = ps3_hard_recovery_request_decide(instance, cur_state, - peer_cur_state); + ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE) { + ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { LOG_INFO("hno:%u heartbeat recovery start\n", - PS3_HOST(instance)); - instance->recovery_context->heartbeat_recovery = - PS3_HEARTBEAT_HARDRESET_RECOVERY; + PS3_HOST(instance)); + instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_RECOVERY; } - ps3_mutex_unlock(&instance->recovery_context - ->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); goto l_out; } - ps3_mutex_unlock( - &instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_IOC_HALT, instance) if (ioc_state == PS3_FW_STATE_HALT) { ps3_instance_state_transfer_to_dead_nolock(instance); - if (instance->peer_instance != NULL) { - ps3_instance_state_transfer_to_dead_nolock( - instance->peer_instance); - } - LOG_ERROR( - "hno:%u IOC state has halt, instance state to dead!\n", + if (instance->peer_instance != NULL) + ps3_instance_state_transfer_to_dead_nolock(instance->peer_instance); + + LOG_ERROR("hno:%u IOC state has halt, instance state to dead!\n", PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (cur_state == PS3_INSTANCE_STATE_DEAD || - cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_SUSPEND) { - LOG_ERROR( - "hno:%u instance state is %s, and ioc_state is %s!\n", + cur_state == PS3_INSTANCE_STATE_QUIT || + cur_state == PS3_INSTANCE_STATE_SUSPEND) { + LOG_ERROR("hno:%u instance state is %s, and ioc_state is %s!\n", PS3_HOST(instance), namePS3InstanceState(cur_state), ps3_ioc_state_print(ioc_state)); ret = PS3_RECOVERY_INTER_ERR_FAILED; @@ -1126,38 +1036,35 @@ static int ps3_recovery_request_prepare(struct ps3_instance *instance) if (instance->peer_instance != NULL) { state_machine_peer = &instance->peer_instance->state_machine; + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_PCIE_ERR, instance) if (ps3_pci_err_recovery_get(instance->peer_instance)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; goto l_out; } ps3_mutex_lock(&state_machine_peer->lock); - ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get( - instance); + ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get(instance); peer_cur_state = ps3_atomic_read(&state_machine->state); LOG_INFO("hno:%u recovery request:%s, %s\n", - PS3_HOST(instance->peer_instance), - ps3_ioc_state_print(ioc_state), - namePS3InstanceState(peer_cur_state)); + PS3_HOST(instance->peer_instance), + ps3_ioc_state_print(ioc_state), namePS3InstanceState(peer_cur_state)); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_IOC_HALT, instance) if (ioc_state == PS3_FW_STATE_HALT) { - ps3_instance_state_transfer_to_dead_nolock( - instance->peer_instance); + ps3_instance_state_transfer_to_dead_nolock(instance->peer_instance); ps3_instance_state_transfer_to_dead_nolock(instance); - LOG_ERROR( - "hno:%u ioc state has halt, instance state to dead!\n", + LOG_ERROR("hno:%u ioc state has halt, instance state to dead!\n", PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out_peer; } + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, instance) if (peer_cur_state == PS3_INSTANCE_STATE_DEAD || - peer_cur_state == PS3_INSTANCE_STATE_QUIT || - peer_cur_state == PS3_INSTANCE_STATE_SUSPEND) { - LOG_ERROR( - "hno:%u instance state is %s, and ioc_state is %s!\n", - PS3_HOST(instance->peer_instance), - namePS3InstanceState(peer_cur_state), + peer_cur_state == PS3_INSTANCE_STATE_QUIT || + peer_cur_state == PS3_INSTANCE_STATE_SUSPEND) { + LOG_ERROR("hno:%u instance state is %s, and ioc_state is %s!\n", + PS3_HOST(instance->peer_instance), namePS3InstanceState(peer_cur_state), ps3_ioc_state_print(ioc_state)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out_peer; @@ -1165,125 +1072,109 @@ static int ps3_recovery_request_prepare(struct ps3_instance *instance) } if (ioc_state == PS3_FW_STATE_FAULT || - ioc_state == PS3_FW_STATE_CRITICAL) { - LOG_ERROR( - "hno:%u instance state is %s, and ioc_state is %s!\n", - PS3_HOST(instance), - namePS3InstanceState(peer_cur_state), + ioc_state == PS3_FW_STATE_CRITICAL) { + LOG_ERROR("hno:%u instance state is %s, and ioc_state is %s!\n", + PS3_HOST(instance), namePS3InstanceState(peer_cur_state), ps3_ioc_state_print(ioc_state)); - ret = ps3_hard_recovery_request_decide(instance, cur_state, - peer_cur_state); + ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); goto l_out_peer; } - if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL || - peer_cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { - LOG_INFO( - "hno:%u instance state is %s:%s! no need repeat recovery requeset\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), - namePS3InstanceState(cur_state)); + if(cur_state != PS3_INSTANCE_STATE_OPERATIONAL || + peer_cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { + LOG_INFO("hno:%u instance state is %s:%s! no need repeat recovery requeset\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), namePS3InstanceState(cur_state)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; goto l_out_peer; } ret = ps3_ioc_soft_recovery_request_decide(instance, ioc_state); if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY || - ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { + ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { goto l_out_peer; - } else if (ret == PS3_RECOVERY_INTER_ERR_FAILED) { + }else if (ret == PS3_RECOVERY_INTER_ERR_FAILED) { goto l_hardreset; } ret = ps3_soft_recovery_request_decide(instance, ioc_state); if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY || - ret == PS3_RECOVERY_INTER_ERR_SUCCESS || - ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { + ret == PS3_RECOVERY_INTER_ERR_SUCCESS || + ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { goto l_out_peer; - } else if (ret == PS3_RECOVERY_INTER_ERR_FAILED) { + }else if (ret == PS3_RECOVERY_INTER_ERR_FAILED) { goto l_hardreset; } LOG_ERROR("hno:%u UNEXPECT!!! hard recovery!,ioc_state:%s, %s:%s\n", - PS3_HOST(instance), ps3_ioc_state_print(ioc_state), - namePS3InstanceState(cur_state), - namePS3InstanceState(peer_cur_state)); + PS3_HOST(instance), + ps3_ioc_state_print(ioc_state), namePS3InstanceState(cur_state), namePS3InstanceState(peer_cur_state)); l_hardreset: - ret = ps3_hard_recovery_request_decide(instance, cur_state, - peer_cur_state); + ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); l_out_peer: - if (instance->peer_instance != NULL) + if (instance->peer_instance != NULL) { ps3_mutex_unlock(&state_machine_peer->lock); + } l_out: ps3_mutex_unlock(&state_machine->lock); return ret; } -int ps3_recovery_request(struct ps3_instance *instance) +S32 ps3_recovery_request(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_instance *instance_recovery = NULL; - LOG_WARN("hno:%u ps3 recovery request start, IOC outstanding: %d!!\n", - PS3_HOST(instance), - ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); + LOG_WARN("hno:%u ps3 recovery request start, IOC outstanding: %d!!\n", PS3_HOST(instance), + ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); ps3_atomic_inc(&instance->recovery_context->hardreset_ref); - mb(); /* in order to force CPU ordering */ + mb(); + INJECT_START(PS3_ERR_IJ_ADD_INSTANCE, &instance->recovery_context->instance_change) if (instance->recovery_context->instance_change) { - LOG_INFO("hno:%u peer instance is change\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); ret = -PS3_RETRY; goto l_out; } + INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_PROBE, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_REMOVE, instance) while (instance->peer_instance != NULL && - PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { - if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_INIT; + PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { + if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || \ + instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; goto l_out; } - if (instance->recovery_context->parall_hardreset_state == - PS3_PARALLEL_HARDRESET_STATE_INIT) { - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_PENDING; + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_INIT) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_PENDING; } + INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE, &instance->recovery_context->instance_change) if (instance->recovery_context->instance_change) { - LOG_INFO("hno:%u peer instance is change\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); ret = -PS3_RETRY; goto l_out; } ps3_atomic_dec(&instance->recovery_context->hardreset_ref); ps3_msleep(10); - if (instance->recovery_context->parall_hardreset_state == - PS3_PARALLEL_HARDRESET_STATE_CONTINUE) { - ps3_atomic_inc( - &instance->recovery_context->hardreset_ref); - mb(); /* in order to force CPU ordering */ - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_INIT; + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_CONTINUE) { + ps3_atomic_inc(&instance->recovery_context->hardreset_ref); + mb(); + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; break; } ps3_atomic_inc(&instance->recovery_context->hardreset_ref); - mb(); /* in order to force CPU ordering */ + mb(); } - if (instance->recovery_context->parall_hardreset_state == - PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_INIT; + INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, instance) + if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; } - LOG_INFO( - "hno:%u peer_instance[%p], hard recovery request Function[%d]\n", - PS3_HOST(instance), instance->peer_instance, - ps3_get_pci_function(instance->pdev)); + LOG_INFO("hno:%u peer_instance[%p], hard recovery request Function[%d]\n", + PS3_HOST(instance), instance->peer_instance, ps3_get_pci_function(instance->pdev)); + INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_3, instance) if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_0 || - (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1 && - instance->peer_instance == NULL)) { + (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1 && instance->peer_instance == NULL)) { instance_recovery = instance; } else { instance_recovery = instance->peer_instance; @@ -1291,32 +1182,30 @@ int ps3_recovery_request(struct ps3_instance *instance) if (ps3_pci_err_recovery_get(instance_recovery)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance_recovery)); + PS3_HOST(instance_recovery)); ret = PS3_SUCCESS; goto l_out; } if (ps3_recovery_is_state_halt(instance_recovery)) { LOG_INFO_LIM("hno:%u driver_state:DEAD or HALT now !!!\n", - PS3_HOST(instance_recovery)); + PS3_HOST(instance_recovery)); ret = -PS3_FAILED; goto l_out; } if (instance_recovery->peer_instance != NULL) { - if (ps3_pci_err_recovery_get( - instance_recovery->peer_instance)) { + if (ps3_pci_err_recovery_get(instance_recovery->peer_instance)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance_recovery->peer_instance)); + PS3_HOST(instance_recovery->peer_instance)); ret = PS3_SUCCESS; goto l_out; } if (instance_recovery->peer_instance->reg_set == NULL || - ps3_recovery_is_state_halt( - instance_recovery->peer_instance)) { + ps3_recovery_is_state_halt(instance_recovery->peer_instance)) { LOG_WARN("hno:%u driver_state:DEAD or HALT now !!!\n", - PS3_HOST(instance_recovery->peer_instance)); + PS3_HOST(instance_recovery->peer_instance)); ret = -PS3_FAILED; goto l_out; } @@ -1324,165 +1213,154 @@ int ps3_recovery_request(struct ps3_instance *instance) ret = ps3_recovery_request_prepare(instance_recovery); if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS || - ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { + ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { ret = PS3_SUCCESS; - } else if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + } else if(ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { ret = ps3_recovery_start(instance_recovery); } else { ret = -PS3_FAILED; } l_out: - LOG_INFO("hno:%u recovery request end, ret:%d!\n", PS3_HOST(instance), - ret); + LOG_INFO("hno:%u recovery request end, ret:%d!\n", + PS3_HOST(instance), ret); ps3_atomic_dec(&instance->recovery_context->hardreset_ref); return ret; } -static unsigned char ps3_recovery_reg(struct ps3_instance *instance) +static Bool ps3_recovery_reg(struct ps3_instance *instance) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; union HilReg0Ps3RegisterFPs3FirmwareVersion *pver = NULL; - unsigned int cur_max_fw_cmds = 0; - unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; - unsigned long long value = 0; - unsigned long long ver = 0; + U32 cur_max_fw_cmds = 0; + U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; + U64 value = 0; + U64 ver = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, - value); - if (value == U64_MAX) + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + if (value == U64_MAX) { goto l_out; - ps3_feature_support = - (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, - ps3FirmwareVersion, ver); - if (ver == U64_MAX) + } + ps3_feature_support = (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FirmwareVersion, ver); + if (ver == U64_MAX) { goto l_out; + } pver = (union HilReg0Ps3RegisterFPs3FirmwareVersion *)&ver; - if (!ps3_ioc_mgr_max_fw_cmd_get(instance, &cur_max_fw_cmds)) + if (!ps3_ioc_mgr_max_fw_cmd_get(instance, &cur_max_fw_cmds)) { goto l_out; + } fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - if (fw_cur_state != PS3_FW_STATE_RUNNING) - goto l_out; - instance->is_ioc_halt_support = - (ps3_feature_support->reg.fwHaltSupport == 1); - instance->dump_context.is_dump_support = - (ps3_feature_support->reg.dumpCrashSupport == 1); - instance->is_shallow_soft_recovery_support = - (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); - instance->is_deep_soft_recovery_support = - (ps3_feature_support->reg.deepSoftRecoverySupport == 1); - instance->is_hard_recovery_support = - (ps3_feature_support->reg.hardRecoverySupport == 1); - instance->ioc_fw_version = (unsigned long long)pver->reg.ps3FmVer; + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_REG_FAILED, &fw_cur_state) + if (fw_cur_state != PS3_FW_STATE_RUNNING) { + goto l_out; + } + instance->is_ioc_halt_support = (ps3_feature_support->reg.fwHaltSupport == 1); + instance->dump_context.is_dump_support = (ps3_feature_support->reg.dumpCrashSupport == 1); + instance->is_shallow_soft_recovery_support = (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); + instance->is_deep_soft_recovery_support = (ps3_feature_support->reg.deepSoftRecoverySupport == 1); + instance->is_hard_recovery_support = (ps3_feature_support->reg.hardRecoverySupport == 1); + instance->ioc_fw_version = (U64)pver->reg.ps3FmVer; ps3_can_queue_reset(instance, cur_max_fw_cmds); ret = PS3_TRUE; l_out: return ret; } -static int ps3_recovery_finish(struct ps3_instance *instance) +static S32 ps3_recovery_finish(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - - if (!ps3_recovery_reg(instance)) - LOG_WARN("hno:%u recovery reg NOK\n", PS3_HOST(instance)); + S32 ret = PS3_SUCCESS; + if (!ps3_recovery_reg(instance)) { + LOG_WARN("hno:%u recovery reg NOK\n",PS3_HOST(instance)); + } return ret; } -static int ps3_recovery_complete(struct ps3_instance *instance) +static S32 ps3_recovery_complete(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_13, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } - if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) + if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { goto l_out; + } + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_14, instance) if (ps3_recovery_finish(instance) != PS3_SUCCESS) { ps3_instance_state_transfer_to_dead(instance); LOG_ERROR("hno:%u recovery finish process failed, to DEAD\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } l_out: - return ret; + return ret; } static void ps3_hard_recovery(struct ps3_instance *instance) { struct ps3_recovery_context *context = instance->recovery_context; - if (ps3_hard_recovery_handle(instance) != PS3_SUCCESS) { context->recovery_result = -PS3_FAILED; LOG_ERROR("hno:%u hard recovery failed!\n", - PS3_HOST(instance)); - } else { + PS3_HOST(instance)); + }else{ context->recovery_result = PS3_SUCCESS; LOG_WARN("hno:%u hard recovery success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } - ps3_mutex_lock( - &instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_NULL; - ps3_mutex_unlock( - &instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + return; } #ifndef _WINDOWS -static void ps3_recovery_work(struct work_struct *work) +static void ps3_recovery_work(struct work_struct* work) { - struct ps3_recovery_context *context = ps3_container_of( - work, struct ps3_recovery_context, recovery_work); + struct ps3_recovery_context *context = + ps3_container_of(work, struct ps3_recovery_context, recovery_work); struct ps3_instance *instance = context->work_instance; #else static void ps3_recovery_work(void *ins) { - struct ps3_instance *instance = (struct ps3_instance *)ins; + struct ps3_instance *instance = (struct ps3_instance*)ins; struct ps3_recovery_context *context = instance->recovery_context; #endif - unsigned int cur_state = - ps3_atomic_read(&instance->state_machine.state); - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + U32 cur_state = ps3_atomic_read(&instance->state_machine.state); + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_INFO("hno:%u recovery work start, %s recovery state[%d]\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), - context->recovery_state); + PS3_HOST(instance), namePS3InstanceState(cur_state), context->recovery_state); if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); - + PS3_HOST(instance)); - if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { - ps3_recovery_state_transfer(instance, - PS3_HARD_RECOVERY_FINISH); - } else { - ps3_recovery_state_transfer(instance, - PS3_SOFT_RECOVERY_FINISH); + if(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE){ + ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_FINISH); + }else{ + ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); } - ps3_mutex_lock(&instance->recovery_context - ->ps3_watchdog_recovery_mutex); + ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); instance->recovery_context->heartbeat_recovery = - PS3_HEARTBEAT_NULL; - ps3_mutex_unlock(&instance->recovery_context - ->ps3_watchdog_recovery_mutex); + PS3_HEARTBEAT_NULL; + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); goto l_out; } context->recovery_result = PS3_SUCCESS; if (cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) { ps3_mutex_lock(&instance->state_machine.lock); - if (context->recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) { + if (context->recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY){ ps3_mutex_unlock(&instance->state_machine.lock); goto l_soft_reset; } @@ -1498,55 +1376,39 @@ static void ps3_recovery_work(void *ins) } LOG_ERROR("hno:%u nothing to do %s,recovery_state %d!\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), - context->recovery_state); + PS3_HOST(instance),namePS3InstanceState(cur_state),context->recovery_state); ps3_mutex_unlock(&instance->state_machine.lock); - if (ps3_instance_state_transfer( - instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { if (instance->peer_instance == NULL || - instance->peer_instance->recovery_context == NULL) { + instance->peer_instance->recovery_context == NULL) { context->recovery_result = -PS3_FAILED; - LOG_ERROR( - "hno:%u hard recovery NOK,recovery_state %d!\n", - PS3_HOST(instance), - context->recovery_state); - ps3_recovery_state_transfer( - instance, PS3_HARD_RECOVERY_FINISH); + LOG_ERROR("hno:%u hard recovery NOK,recovery_state %d!\n", + PS3_HOST(instance),context->recovery_state); + ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_FINISH); goto l_out; } } if (instance->peer_instance != NULL && - ps3_instance_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_SOFT_RECOVERY, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { context->recovery_result = -PS3_FAILED; - LOG_ERROR( - "hno:%u hard recovery NOK,recovery_state %d!\n", - PS3_HOST(instance->peer_instance), - context->recovery_state); - ps3_recovery_state_transfer(instance->peer_instance, - PS3_HARD_RECOVERY_FINISH); + LOG_ERROR("hno:%u hard recovery NOK,recovery_state %d!\n", + PS3_HOST(instance->peer_instance),context->recovery_state); + ps3_recovery_state_transfer(instance->peer_instance, PS3_HARD_RECOVERY_FINISH); goto l_out; } } else if (cur_state == PS3_INSTANCE_STATE_RECOVERY) { goto l_hard_reset; } else { - LOG_ERROR( - "hno:%u nothing to do %s,recovery_state %d, cur_state:%s!\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), - context->recovery_state, - namePS3InstanceState(ps3_atomic_read( - &instance->state_machine.state))); - if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { - ps3_recovery_state_transfer(instance, - PS3_HARD_RECOVERY_FINISH); - } else { - ps3_recovery_state_transfer(instance, - PS3_SOFT_RECOVERY_FINISH); + LOG_ERROR("hno:%u nothing to do %s,recovery_state %d, cur_state:%s!\n", + PS3_HOST(instance),namePS3InstanceState(cur_state),context->recovery_state, + namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); + if(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE){ + ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_FINISH); + }else{ + ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); } goto l_out; } @@ -1556,25 +1418,24 @@ static void ps3_recovery_work(void *ins) if (ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { context->recovery_result = PS3_SUCCESS; LOG_INFO("hno:%u soft recovery interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); - } else if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) { + } else if(ret == PS3_RECOVERY_INTER_ERR_SUCCESS){ context->recovery_result = PS3_SUCCESS; ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); LOG_WARN("hno:%u soft recovery success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } else { LOG_INFO("hno:%u soft recovery to hard recovery!\n", - PS3_HOST(instance)); - if (ps3_soft_recovery_fail_to_hard_recovery(instance) != - PS3_SUCCESS) { + PS3_HOST(instance)); + if(ps3_soft_recovery_fail_to_hard_recovery(instance) != PS3_SUCCESS){ context->recovery_result = -PS3_FAILED; LOG_ERROR("hno:%u soft to hard recovery failed!\n", - PS3_HOST(instance)); - } else { + PS3_HOST(instance)); + }else{ context->recovery_result = PS3_SUCCESS; LOG_INFO("hno:%u soft to hard recovery success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } } goto l_out; @@ -1584,24 +1445,23 @@ static void ps3_recovery_work(void *ins) l_out: if (ps3_pci_err_recovery_get(instance)) { - LOG_INFO( - "hno:%u recovery is interrupted by pci err recovery.\n", + LOG_INFO("hno:%u recovery is interrupted by pci err recovery.\n", PS3_HOST(instance)); ps3_instance_state_transfer_to_pcie_recovery(instance); if (instance->peer_instance != NULL) { - ps3_instance_state_transfer_to_pcie_recovery( - instance->peer_instance); + ps3_instance_state_transfer_to_pcie_recovery(instance->peer_instance); } } + return; } -static int ps3_soft_recovery_cmd_reply_check(struct ps3_instance *instance) +static S32 ps3_soft_recovery_cmd_reply_check(struct ps3_instance *instance) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - unsigned int i = 0; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + U32 i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - unsigned int no_reply_count = 0; + U32 no_reply_count = 0; for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; @@ -1609,52 +1469,51 @@ static int ps3_soft_recovery_cmd_reply_check(struct ps3_instance *instance) ps3_mutex_lock(&instance->state_machine.lock); if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); - if (cmd->cmd_state.reset_flag != PS3_CMD_FLAG_SOFTRESET) + if (cmd->cmd_state.reset_flag != PS3_CMD_FLAG_SOFTRESET) { continue; + } - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { continue; + } - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == - PS3_CMD_WORD_NO_REPLY_WORD && - ps3_cmd_resp_status(cmd) != U32_MAX) { + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NO_REPLY_WORD && + ps3_cmd_resp_status(cmd) != U32_MAX) { continue; } if (cmd == instance->event_context.event_cmd || - cmd == instance->dev_context.vd_pending_cmd || - cmd == instance->webSubscribe_context.webSubscribe_cmd) { + cmd == instance->dev_context.vd_pending_cmd || + cmd == instance->webSubscribe_context.webSubscribe_cmd) { continue; } no_reply_count++; - LOG_DEBUG( - "hno:%u no reply cmd,CFID[%d], %s,max_scsi_cmd_count %u, max_cmd_count %u\n", - PS3_HOST(instance), i, - namePS3CmdState(cmd->cmd_state.state), + LOG_DEBUG("hno:%u no reply cmd,CFID[%d], %s,max_scsi_cmd_count %u, max_cmd_count %u\n", + PS3_HOST(instance), i, namePS3CmdState(cmd->cmd_state.state), context->max_scsi_cmd_count, context->max_cmd_count); } - if (no_reply_count > 0) + if (no_reply_count > 0) { ret = PS3_RECOVERY_INTER_ERR_FAILED; + } l_out: return ret; } -static int -ps3_soft_recovery_cmd_reply_polling_check(struct ps3_instance *instance, - unsigned int wait_seconds) +static S32 ps3_soft_recovery_cmd_reply_polling_check( + struct ps3_instance *instance, U32 wait_seconds) { - int ret = PS3_RECOVERY_INTER_ERR_FAILED; - const unsigned int interval_check_ms = 20; - unsigned int msecs = U32_MAX; - unsigned int i = 0; + S32 ret = PS3_RECOVERY_INTER_ERR_FAILED; + const U32 interval_check_ms = 20; + U32 msecs = U32_MAX; + U32 i = 0; if (wait_seconds != 0) { #ifndef _WINDOWS @@ -1671,9 +1530,9 @@ ps3_soft_recovery_cmd_reply_polling_check(struct ps3_instance *instance, } ps3_mutex_lock(&instance->state_machine.lock); - if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { + if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); break; @@ -1682,16 +1541,16 @@ ps3_soft_recovery_cmd_reply_polling_check(struct ps3_instance *instance, if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u host in pci err recovery\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; break; } ret = ps3_soft_recovery_cmd_reply_check(instance); if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS || - ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { + ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { LOG_WARN("hno:%u no mgr cmd pending\n", - PS3_HOST(instance)); + PS3_HOST(instance)); break; } @@ -1701,15 +1560,15 @@ ps3_soft_recovery_cmd_reply_polling_check(struct ps3_instance *instance, return ret; } -static int ps3_soft_recovery_to_pre_operational(struct ps3_instance *instance) +static S32 ps3_soft_recovery_to_pre_operational(struct ps3_instance *instance) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; ps3_mutex_lock(&instance->state_machine.lock); - if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { + if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } @@ -1720,81 +1579,74 @@ static int ps3_soft_recovery_to_pre_operational(struct ps3_instance *instance) ret = ps3_ioc_state_transfer_wait_to_running(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u soft recovery to running failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - ret = ps3_soft_recovery_cmd_reply_polling_check( - instance, PS3_SOFT_RESET_WAIT_TIMEOUT); + ret = ps3_soft_recovery_cmd_reply_polling_check(instance, PS3_SOFT_RESET_WAIT_TIMEOUT); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u pending mgr cmd no reply all!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + ret = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_INFO("hno:%u soft recovery to pre-operational success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: return ret; } -static int -ps3_hard_recovery_pre_operational_to_operational(struct ps3_instance *instance) +static S32 ps3_hard_recovery_pre_operational_to_operational(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - if (!ps3_ioc_recovery_count_get( - instance, - &instance->recovery_context->ioc_recovery_count)) { + if (!ps3_ioc_recovery_count_get(instance, + &instance->recovery_context->ioc_recovery_count)) { LOG_ERROR("hno:%u get recovery count NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } LOG_INFO("hno:%u pre-operational to operational success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: return ret; } -static int -ps3_soft_recovery_pre_operational_to_operational(struct ps3_instance *instance) +static S32 ps3_soft_recovery_pre_operational_to_operational(struct ps3_instance *instance) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; ps3_mutex_lock(&instance->state_machine.lock); - if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { + if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); - if (!ps3_ioc_recovery_count_get( - instance, - &instance->recovery_context->ioc_recovery_count)) { + if (!ps3_ioc_recovery_count_get(instance, + &instance->recovery_context->ioc_recovery_count)) { ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - LOG_INFO( - "hno:%u pre-operational to operational success!,reset count:%d\n", - PS3_HOST(instance), - instance->recovery_context->ioc_recovery_count); + LOG_INFO("hno:%u pre-operational to operational success!,reset count:%d\n", + PS3_HOST(instance), instance->recovery_context->ioc_recovery_count); l_out: return ret; } -static int ps3_cmd_resubscribe(struct ps3_instance *instance) +static S32 ps3_cmd_resubscribe(struct ps3_instance *instance) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; ps3_mutex_lock(&instance->state_machine.lock); - if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { + if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; @@ -1803,15 +1655,15 @@ static int ps3_cmd_resubscribe(struct ps3_instance *instance) ret = ps3_soft_reset_event_resubscribe(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u event unsubscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } ps3_mutex_lock(&instance->state_machine.lock); - if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { + if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; @@ -1821,95 +1673,83 @@ static int ps3_cmd_resubscribe(struct ps3_instance *instance) ret = ps3_dev_mgr_vd_info_resubscribe(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u vd pending unsubscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - ps3_mutex_lock(&instance->state_machine.lock); - if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { - LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); - ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; - ps3_mutex_unlock(&instance->state_machine.lock); - goto l_out; - } - ps3_mutex_unlock(&instance->state_machine.lock); - - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == - 1) { - ret = ps3_soft_reset_web_resubscribe(instance); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u web unsubscribe failed!\n", - PS3_HOST(instance)); - ret = PS3_RECOVERY_INTER_ERR_FAILED; - goto l_out; - } - } - - ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + ps3_mutex_lock(&instance->state_machine.lock); + if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ + LOG_WARN("hno:%u soft reset proc is interrupt!\n", + PS3_HOST(instance)); + ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; + ps3_mutex_unlock(&instance->state_machine.lock); + goto l_out; + } + ps3_mutex_unlock(&instance->state_machine.lock); + + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { + ret = ps3_soft_reset_web_resubscribe(instance); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u web unsubscribe failed!\n", + PS3_HOST(instance)); + ret = PS3_RECOVERY_INTER_ERR_FAILED; + goto l_out; + } + } + + ret = PS3_RECOVERY_INTER_ERR_SUCCESS; l_out: - return ret; + return ret; } -static int ps3_soft_recovery_complete(struct ps3_instance *instance) +static S32 ps3_soft_recovery_complete(struct ps3_instance *instance) { - int ret = ps3_soft_recovery_to_pre_operational(instance); - + S32 ret = ps3_soft_recovery_to_pre_operational(instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_WARN("hno:%u ioc soft reset failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - if (ps3_instance_state_transfer( - instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, - PS3_INSTANCE_STATE_PRE_OPERATIONAL) != PS3_SUCCESS) { + if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, + PS3_INSTANCE_STATE_PRE_OPERATIONAL) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to pre operational failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } - if (instance->peer_instance != NULL && - instance->peer_instance->recovery_function.softreset_handle_pre_cb != - NULL) { - ret = instance->peer_instance->recovery_function - .softreset_handle_pre_cb(instance->peer_instance); + if (instance->peer_instance != NULL && \ + instance->peer_instance->recovery_function.softreset_handle_pre_cb != NULL) { + ret = instance->peer_instance->recovery_function.softreset_handle_pre_cb(instance->peer_instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_WARN("hno:%u softreset handle pre cb failed\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); goto l_out; } - if (ps3_instance_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_SOFT_RECOVERY, - PS3_INSTANCE_STATE_PRE_OPERATIONAL) != - PS3_SUCCESS) { - LOG_ERROR( - "hno:%u transfer to pre operational failed!\n", + if (ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, + PS3_INSTANCE_STATE_PRE_OPERATIONAL) != PS3_SUCCESS) { + LOG_ERROR("hno:%u transfer to pre operational failed!\n", PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } } - ret = ps3_soft_recovery_pre_operational_to_operational(instance); + ret = ps3_soft_recovery_pre_operational_to_operational(instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_WARN("hno:%u ioc soft reset failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - if (instance->peer_instance != NULL && - instance->peer_instance->recovery_function - .softreset_handle_post_cb != NULL) { - ret = instance->peer_instance->recovery_function - .softreset_handle_post_cb( - instance->peer_instance); + if (instance->peer_instance != NULL && \ + instance->peer_instance->recovery_function.softreset_handle_post_cb != NULL) { + ret = instance->peer_instance->recovery_function.softreset_handle_post_cb(instance->peer_instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_WARN("hno:%u softreset handle post cb failed\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); goto l_out; } } @@ -1918,64 +1758,53 @@ static int ps3_soft_recovery_complete(struct ps3_instance *instance) return ret; } -static int -ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance) +static S32 ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance) { - int ret = -PS3_FAILED; - unsigned int cur_state = - ps3_atomic_read(&instance->state_machine.state); - int ret_peer = PS3_SUCCESS; - unsigned int peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; + S32 ret = -PS3_FAILED; + U32 cur_state = ps3_atomic_read(&instance->state_machine.state); + S32 ret_peer = PS3_SUCCESS; + U32 peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; + PS3_IJ_SLEEP(10000, PS3_ERR_IJ_SOFT_TO_HARD); ps3_mutex_lock(&instance->state_machine.lock); if (instance->peer_instance != NULL) { ps3_mutex_lock(&instance->peer_instance->state_machine.lock); - peer_cur_state = ps3_atomic_read( - &instance->peer_instance->state_machine.state); + peer_cur_state = ps3_atomic_read(&instance->peer_instance->state_machine.state); } - ret = ps3_hard_recovery_request_decide(instance, cur_state, - peer_cur_state); - if (instance->peer_instance != NULL) + ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); + if (instance->peer_instance != NULL) { ps3_mutex_unlock(&instance->peer_instance->state_machine.lock); + } ps3_mutex_unlock(&instance->state_machine.lock); if (ret != PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { LOG_WARN("hno:%u decide no need to hard recovery\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } - ret = ps3_instance_state_transfer(instance, - PS3_INSTANCE_STATE_SOFT_RECOVERY, - PS3_INSTANCE_STATE_RECOVERY); + ret = ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, + PS3_INSTANCE_STATE_RECOVERY); if (ret != PS3_SUCCESS) { - ret = ps3_instance_state_transfer( - instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + ret = ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, PS3_INSTANCE_STATE_RECOVERY); } if (ret != PS3_SUCCESS) { - ret = ps3_instance_state_transfer( - instance, PS3_INSTANCE_STATE_OPERATIONAL, + ret = ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_OPERATIONAL, PS3_INSTANCE_STATE_RECOVERY); } if (instance->peer_instance != NULL) { - ret_peer = ps3_instance_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_SOFT_RECOVERY, + ret_peer = ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, PS3_INSTANCE_STATE_RECOVERY); if (ret_peer != PS3_SUCCESS) { - ret_peer = ps3_instance_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_PRE_OPERATIONAL, + ret_peer = ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, PS3_INSTANCE_STATE_RECOVERY); } if (ret_peer != PS3_SUCCESS) { - ret_peer = ps3_instance_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_OPERATIONAL, + ret_peer = ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_OPERATIONAL, PS3_INSTANCE_STATE_RECOVERY); } } @@ -1984,188 +1813,168 @@ ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance) ps3_need_wait_hard_reset_request(instance); ret = ps3_hard_recovery_handle(instance); } else { - LOG_ERROR( - "hno:%u transfer to recovery failed!, cur_state:%s\n", + LOG_ERROR("hno:%u transfer to recovery failed!, cur_state:%s\n", PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read( - &instance->state_machine.state))); + namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); } if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u hard reset failed!\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u hard reset failed!\n", + PS3_HOST(instance)); } else { LOG_INFO("hno:%u hard reset success and finished!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } l_out: return ret; } -static int ps3_ioc_soft_recovery(struct ps3_instance *instance) +static S32 ps3_ioc_soft_recovery(struct ps3_instance *instance) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; ret = ps3_soft_recovery_complete(instance); if (ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { LOG_WARN("hno:%u IOC soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } else if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_INFO("hno:%u IOC soft reset success!\n", - PS3_HOST(instance)); - goto l_reset_success; + PS3_HOST(instance)); + goto l_reset_sucess; } else { - LOG_ERROR( - "hno:%u IOC self soft reset failed! need to hard reset\n", + LOG_ERROR("hno:%u IOC self soft reset failed! need to hard reset\n", PS3_HOST(instance)); goto l_out; } -l_reset_success: - ret = ps3_instance_state_transfer(instance, - PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_OPERATIONAL); +l_reset_sucess: + ret = ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_OPERATIONAL); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to operational failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } ret = ps3_cmd_resubscribe(instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u cmd unsubscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ret = ps3_recovery_complete(instance); - if (ret != PS3_SUCCESS) { - LOG_INFO( - "hno:%u IOC soft reset opeational but complete failed! cur_state:%s,ret %d\n", - PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read( - &instance->state_machine.state)), - ret); + if(ret != PS3_SUCCESS){ + LOG_INFO("hno:%u IOC soft reset opeational but complete failed! cur_state:%s,ret %d\n", + PS3_HOST(instance), namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state)),ret); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (instance->peer_instance != NULL) { - ret = ps3_instance_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_PRE_OPERATIONAL, + ret = ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, PS3_INSTANCE_STATE_OPERATIONAL); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to operational failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } LOG_INFO("hno:%u soft reset success and finished!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = ps3_cmd_resubscribe(instance->peer_instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u cmd unsubscribe failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); goto l_out; } ret = ps3_recovery_complete(instance->peer_instance); - if (ret != PS3_SUCCESS) { - LOG_INFO( - "hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", + if(ret != PS3_SUCCESS){ + LOG_INFO("hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", PS3_HOST(instance->peer_instance), - namePS3InstanceState(ps3_atomic_read( - &instance->peer_instance->state_machine - .state)), - ret); + namePS3InstanceState(ps3_atomic_read(&instance->peer_instance->state_machine.state)),ret); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } } ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); - ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + ret = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_INFO("hno:%u soft reset success and finished!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: return ret; } -static int ps3_host_shallow_soft_recovery(struct ps3_instance *instance) +static S32 ps3_host_shallow_soft_recovery(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - - if (PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT(instance) == PS3_FALSE) { + S32 ret = PS3_SUCCESS; + S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + if (PS3_FALSE == PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT(instance)) { LOG_ERROR("hno:%u soc feature unsupport soft reset Shallow!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; goto l_out; } if (instance->peer_instance != NULL) { - if (PS3_FALSE == PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT( - instance->peer_instance)) { - LOG_ERROR( - "hno:%u soc feature unsupport soft reset Shallow!\n", + if (PS3_FALSE == PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT(instance->peer_instance)) { + LOG_ERROR("hno:%u soc feature unsupport soft reset Shallow!\n", PS3_HOST(instance->peer_instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; goto l_out; } } ps3_mutex_lock(&instance->state_machine.lock); - if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { + if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ LOG_WARN("hno:%u shallow soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); if (instance->ioc_adpter->ioc_shallow_soft_reset != NULL) { - ps3_recovery_state_transfer(instance, - PS3_SOFT_RECOVERY_SHALLOW); + ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_SHALLOW); ret = instance->ioc_adpter->ioc_shallow_soft_reset(instance); } else { LOG_ERROR("hno:%u driver unsupport soft reset shallow!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; goto l_out; } if (ret == PS3_SUCCESS) { LOG_INFO("hno:%u shallow soft reset entry complete prcoess!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = ps3_soft_recovery_complete(instance); } else { LOG_ERROR("hno:%u shallow soft reset fail!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; } LOG_INFO("hno:%u shallow soft reset finished!:ret:%d, err_code:%d\n", - PS3_HOST(instance), ret, err_code); + PS3_HOST(instance), ret, err_code); l_out: return err_code; } -static int ps3_host_deep_soft_recovery(struct ps3_instance *instance) +static S32 ps3_host_deep_soft_recovery(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - - if (PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT(instance) == PS3_FALSE) { - LOG_ERROR("hno:%u soc feature unsupport soft reset Deep!\n", - PS3_HOST(instance)); - err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; - goto l_out; + S32 ret = PS3_SUCCESS; + S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + if (PS3_FALSE == PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT(instance)) { + LOG_ERROR("hno:%u soc feature unsupport soft reset Deep!\n", + PS3_HOST(instance)); + err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; + goto l_out; } if (instance->peer_instance != NULL) { - if (PS3_FALSE == PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT( - instance->peer_instance)) { - LOG_ERROR( - "hno:%u soc feature unsupport soft reset Deep!\n", + if (PS3_FALSE == PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT(instance->peer_instance)) { + LOG_ERROR("hno:%u soc feature unsupport soft reset Deep!\n", PS3_HOST(instance->peer_instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; goto l_out; @@ -2173,35 +1982,32 @@ static int ps3_host_deep_soft_recovery(struct ps3_instance *instance) } ps3_mutex_lock(&instance->state_machine.lock); - if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { + if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ LOG_WARN("hno:%u deep soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); - ps3_instance_state_transfer(instance, - PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_SOFT_RECOVERY); + ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_SOFT_RECOVERY); if (ps3_atomic_read(&instance->state_machine.state) != - PS3_INSTANCE_STATE_SOFT_RECOVERY) { + PS3_INSTANCE_STATE_SOFT_RECOVERY) { LOG_ERROR("hno:%u soft reovery has been interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } if (instance->peer_instance != NULL) { - ps3_instance_state_transfer(instance->peer_instance, - PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_SOFT_RECOVERY); + ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_SOFT_RECOVERY); - if (ps3_atomic_read( - &instance->peer_instance->state_machine.state) != - PS3_INSTANCE_STATE_SOFT_RECOVERY) { + if (ps3_atomic_read(&instance->peer_instance->state_machine.state) != + PS3_INSTANCE_STATE_SOFT_RECOVERY) { LOG_ERROR("hno:%u soft reovery has been interrupt!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } @@ -2212,75 +2018,72 @@ static int ps3_host_deep_soft_recovery(struct ps3_instance *instance) ret = instance->ioc_adpter->ioc_deep_soft_reset(instance); } else { LOG_ERROR("hno:%u driver unsupport soft reset deep!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; goto l_out; } if (ret == PS3_SUCCESS) { LOG_INFO("hno:%u deep soft reset entry complete prcoess!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = ps3_soft_recovery_complete(instance); } else { LOG_ERROR("hno:%u deep soft reset fail!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; } LOG_INFO("hno:%u deep soft reset finished!:ret:%d, err_code:%d\n", - PS3_HOST(instance), ret, err_code); + PS3_HOST(instance), ret, err_code); l_out: return err_code; } -static inline int -ps3_wait_event_vdpending_cmd_complete(struct ps3_instance *instance) +static inline S32 ps3_wait_event_vdpending_cmd_complete(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int count = 0; - + S32 ret = PS3_SUCCESS; + U32 count = 0; - const unsigned int retry_max = PS3_WAIT_EVENT_CMD_LOOP_COUNT; + const U32 retry_max = PS3_WAIT_EVENT_CMD_LOOP_COUNT; - while (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0 || - ps3_atomic_read(&instance->dev_context.abort_vdpending_cmd) != 0 || - ps3_atomic_read(&instance->webSubscribe_context.abort_webcmd) != 0) { + while(instance->event_context.abort_eventcmd != 0 || + instance->dev_context.abort_vdpending_cmd != 0 || + instance->webSubscribe_context.abort_webcmd != 0){ ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - if (count++ > retry_max) { + if(count++ > retry_max){ LOG_INFO("hno:%u wait event proc over:%d ms,failed\n", - PS3_HOST(instance), - retry_max * PS3_LOOP_TIME_INTERVAL_100MS); - ret = -PS3_FAILED; + PS3_HOST(instance), + retry_max*PS3_LOOP_TIME_INTERVAL_100MS); + ret = -PS3_FAILED; break; } } return ret; } -static int ps3_soft_recovery_handle(struct ps3_instance *instance) +static S32 ps3_soft_recovery_handle(struct ps3_instance *instance) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; struct ps3_recovery_context *context = instance->recovery_context; if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u pci error recovery resetting\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - if (ps3_wait_event_vdpending_cmd_complete(instance) != PS3_SUCCESS) { + if(ps3_wait_event_vdpending_cmd_complete(instance) != PS3_SUCCESS){ ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (instance->peer_instance != NULL) { if (ps3_pci_err_recovery_get(instance->peer_instance)) { LOG_WARN("hno:%u pci error recovery resetting\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); goto l_out; } - if (ps3_wait_event_vdpending_cmd_complete( - instance->peer_instance) != PS3_SUCCESS) { + if(ps3_wait_event_vdpending_cmd_complete(instance->peer_instance) != PS3_SUCCESS){ ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } @@ -2296,99 +2099,86 @@ static int ps3_soft_recovery_handle(struct ps3_instance *instance) ret = ps3_host_shallow_soft_recovery(instance); if (ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { LOG_WARN("hno:%u shallow soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } else if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_WARN("hno:%u shallow soft reset success!\n", - PS3_HOST(instance)); - goto l_reset_success; + PS3_HOST(instance)); + goto l_reset_sucess; } else { - LOG_WARN( - "hno:%u shallow soft reset fail, need to deep recovery!\n", + LOG_WARN("hno:%u shallow soft reset fail, need to deep recovery!\n", PS3_HOST(instance)); } ret = ps3_host_deep_soft_recovery(instance); if (ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { LOG_WARN("hno:%u deep soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } else if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_INFO("hno:%u deep soft reset success!\n", - PS3_HOST(instance)); - goto l_reset_success; + PS3_HOST(instance)); + goto l_reset_sucess; } else { - LOG_INFO( - "hno:%u deep soft reset fail, need to hard recovery!\n", + LOG_INFO("hno:%u deep soft reset fail, need to hard recovery!\n", PS3_HOST(instance)); goto l_out; } -l_reset_success: - ret = ps3_instance_state_transfer(instance, - PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_OPERATIONAL); +l_reset_sucess: + ret = ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_OPERATIONAL); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to operational failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } LOG_INFO("hno:%u soft reset success and finished!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = ps3_cmd_resubscribe(instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u cmd unsubscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ret = ps3_recovery_complete(instance); - if (ret != PS3_SUCCESS) { - LOG_INFO( - "hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", - PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read( - &instance->state_machine.state)), - ret); + if(ret != PS3_SUCCESS){ + LOG_INFO("hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", + PS3_HOST(instance), namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state)),ret); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (instance->peer_instance != NULL) { - ret = ps3_instance_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_PRE_OPERATIONAL, + ret = ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, PS3_INSTANCE_STATE_OPERATIONAL); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to operational failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } LOG_INFO("hno:%u soft reset success and finished!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = ps3_cmd_resubscribe(instance->peer_instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u cmd unsubscribe failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); goto l_out; } ret = ps3_recovery_complete(instance->peer_instance); - if (ret != PS3_SUCCESS) { - LOG_INFO( - "hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", + if(ret != PS3_SUCCESS){ + LOG_INFO("hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", PS3_HOST(instance->peer_instance), - namePS3InstanceState(ps3_atomic_read( - &instance->peer_instance->state_machine - .state)), - ret); + namePS3InstanceState(ps3_atomic_read(&instance->peer_instance->state_machine.state)),ret); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } } LOG_INFO("hno:%u soft reset success and finished!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; return ret; @@ -2396,71 +2186,71 @@ static int ps3_soft_recovery_handle(struct ps3_instance *instance) return ret; } -static int ps3_hard_recovery_to_ready(struct ps3_instance *instance) +static S32 ps3_hard_recovery_to_ready(struct ps3_instance *instance) { - int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - unsigned int ioc_state = 0; - int ret = PS3_SUCCESS; + S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + U32 ioc_state = 0; + S32 ret = PS3_SUCCESS; + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_3, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; goto l_out; } - ret = ps3_ioc_hard_reset_to_ready(instance); - if (ret != PS3_SUCCESS) { + if ((ret = ps3_ioc_hard_reset_to_ready(instance)) != PS3_SUCCESS) { ioc_state = instance->ioc_adpter->ioc_state_get(instance); LOG_ERROR("hno:%u hard reset to ready NOK,%s!\n", - PS3_HOST(instance), ps3_ioc_state_print(ioc_state)); - if (ret == -PS3_IN_PCIE_ERR) + PS3_HOST(instance), + ps3_ioc_state_print(ioc_state)); + if (ret == -PS3_IN_PCIE_ERR) { err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; - else + } else { err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; + } goto l_out; } if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_RECOVERY, - PS3_INSTANCE_STATE_READY) != - PS3_SUCCESS) { + PS3_INSTANCE_STATE_READY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; } l_out: return err_code; } -static int ps3_hard_recovery_to_pre_operational(struct ps3_instance *instance) +static S32 ps3_hard_recovery_to_pre_operational(struct ps3_instance *instance) { - int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - int ret = PS3_SUCCESS; + S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 ret = PS3_SUCCESS; + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_7, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; goto l_out; } - if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) + if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { goto l_out; + } - ret = ps3_recovery_ready_to_running(instance); - if (ret != PS3_SUCCESS) { + if ((ret = ps3_recovery_ready_to_running(instance)) != PS3_SUCCESS) { LOG_ERROR("hno:%u hard reset to running NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); if (ret == -PS3_IN_PCIE_ERR) { err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; goto l_out; } - if (ps3_instance_state_transfer( - instance, PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL, instance) + if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_READY, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to recovery NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } @@ -2473,18 +2263,17 @@ static int ps3_hard_recovery_to_pre_operational(struct ps3_instance *instance) #ifndef _WINDOWS ps3_irqpolls_enable(instance); #endif - if (instance->is_need_event && - ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == - 1) { - ps3_web_cmd_clear(instance); - } - if (instance->is_need_event) + if (instance->is_need_event && ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { + ps3_web_cmd_clear(instance); + } + if (instance->is_need_event) { ps3_dev_mgr_vd_info_clear(instance); + } + INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL, instance) if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_PRE_OPERATIONAL) != - PS3_SUCCESS) { + PS3_INSTANCE_STATE_PRE_OPERATIONAL) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to pre-operational NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } @@ -2494,32 +2283,32 @@ static int ps3_hard_recovery_to_pre_operational(struct ps3_instance *instance) return err_code; } -static int ps3_hard_recovery_to_operational(struct ps3_instance *instance) +static S32 ps3_hard_recovery_to_operational(struct ps3_instance *instance) { - int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - int ret; - unsigned long flags = 0; + S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 ret; + ULong flags = 0; struct ps3_cmd *cmd = NULL; - unsigned char need_subscribe = PS3_FALSE; + Bool need_subscribe = PS3_FALSE; + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_10, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; goto l_out; } - if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) + if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { goto l_out; + } - if (ps3_hard_recovery_pre_operational_to_operational(instance) != - PS3_SUCCESS) { - LOG_ERROR("hno:%u pre operational NOK!\n", PS3_HOST(instance)); - if (ps3_instance_state_transfer( - instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + if (ps3_hard_recovery_pre_operational_to_operational(instance) != PS3_SUCCESS) { + LOG_ERROR("hno:%u pre operational NOK!\n", + PS3_HOST(instance)); + if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to recovery NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } @@ -2528,35 +2317,37 @@ static int ps3_hard_recovery_to_operational(struct ps3_instance *instance) goto l_out; } - if (ps3_instance_state_transfer( - instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_OPERATIONAL) != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_OPE_FAIL, instance) + if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_OPERATIONAL) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to operational NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } + INJECT_START(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_INT, instance) + INJECT_START(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_PROC, instance) + INJECT_START(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_SUBCRIBE, instance) if (!instance->is_need_event) { - LOG_INFO("hno:%u not need event\n", PS3_HOST(instance)); + LOG_INFO("hno:%u not need event\n", + PS3_HOST(instance)); goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); cmd = instance->event_context.event_cmd; if (cmd == NULL) { LOG_WARN_IN_IRQ(instance, "hno:%u Event is not register yet\n", - PS3_HOST(instance)); + PS3_HOST(instance)); need_subscribe = PS3_TRUE; goto l_subscribe; } - if (ps3_atomic_read(&instance->event_context.subwork) == 0) { - if (ps3_atomic_read(&instance->hardreset_event) != 0) { - ps3_atomic_set(&instance->hardreset_event, 0); - LOG_INFO_IN_IRQ(instance, - "hno:%u event cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + if (instance->event_context.subwork == 0) { + if (instance->hardreset_event != 0) { + instance->hardreset_event = 0; + LOG_INFO_IN_IRQ(instance, "hno:%u event cmd free, CFID:%d\n", + PS3_HOST(instance), cmd->index); instance->event_context.event_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); need_subscribe = PS3_TRUE; @@ -2564,38 +2355,34 @@ static int ps3_hard_recovery_to_operational(struct ps3_instance *instance) } l_subscribe: - if (need_subscribe == PS3_TRUE) { - instance->event_req_info.eventTypeMapProcResult = - instance->event_req_info.eventTypeMap; + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_11, instance) + if(need_subscribe == PS3_TRUE) { + instance->event_req_info.eventTypeMapProcResult = instance->event_req_info.eventTypeMap; ret = ps3_event_subscribe(instance); if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) { err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - ps3_spin_unlock_irqrestore( - &instance->recovery_context->recovery_lock, - flags); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); LOG_WARN("hno:%u IOC event subscribe NOK ret[%d]\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); ret = ps3_dev_mgr_vd_info_subscribe(instance); if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) { err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_WARN("hno:%u vd info subscribe NOK ret[%d]\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == - 1) { + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { ret = ps3_web_subscribe(instance); if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) { err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_WARN("hno:%u web subscribe NOK ret[%d]\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } } @@ -2608,18 +2395,17 @@ static inline void ps3_hard_reset_unnormal_handle(struct ps3_instance *instance) ps3_recovery_ready_to_force_cmd_stop(instance); ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_RECOVERY); - instance->is_half_hard_reset = PS3_TRUE; + PS3_INSTANCE_STATE_RECOVERY); + instance ->is_half_hard_reset = PS3_TRUE; if (!instance->state_machine.is_load || - instance->state_machine.is_suspend) { + instance->state_machine.is_suspend) { ps3_ioc_notify_unload(instance); } } -static inline int -ps3_hard_reset_error_code_decide(struct ps3_instance *instance) +static inline S32 ps3_hard_reset_error_code_decide(struct ps3_instance *instance) { - int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; if (PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance)) { err_code = PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME; @@ -2627,7 +2413,7 @@ ps3_hard_reset_error_code_decide(struct ps3_instance *instance) } if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) && - instance->peer_instance == NULL) { + instance->peer_instance == NULL) { err_code = PS3_RECOVERY_INTER_ERR_FAILED; } @@ -2635,40 +2421,35 @@ ps3_hard_reset_error_code_decide(struct ps3_instance *instance) return err_code; } -static inline int -ps3_hard_reset_multi_unnormal_handle(struct ps3_instance *instance) +static inline S32 ps3_hard_reset_multi_unnormal_handle(struct ps3_instance *instance) { + if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { - LOG_WARN("host_no[%u], reset while probe or in shutdown/remove,\n" - "\tfinish[%d], flag[%d], is_load[%d]\n", - PS3_HOST(instance), instance->is_probe_finish, - instance->is_probe_failed, - instance->state_machine.is_load); - if (((PS3_IS_INSTANCE_PROBE(instance) || - PS3_IS_INSTANCE_RESUME(instance)) && - instance->state_machine.is_load) || - PS3_IS_INSTANCE_REMOVE(instance)) { + LOG_WARN("host_no[%u], reset while probe or in shutdown/remove," + " finish[%d], flag[%d], is_load[%d]\n", + PS3_HOST(instance), instance->is_probe_finish, + instance->is_probe_failed, + instance->state_machine.is_load); + if (((PS3_IS_INSTANCE_PROBE(instance) || PS3_IS_INSTANCE_RESUME(instance)) && \ + instance->state_machine.is_load) || \ + PS3_IS_INSTANCE_REMOVE(instance)) { ps3_hard_reset_unnormal_handle(instance); ps3_instance_state_transfer_to_dead(instance); } else if (PS3_IS_INSTANCE_SUSPEND(instance)) { ps3_hard_reset_unnormal_handle(instance); } } - if (instance->peer_instance != NULL && - PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { - LOG_WARN("host_no[%u], reset while probe or in shutdown/remove,\n" - "\tfinish[%d], flag[%d], is_load[%d]\n", - PS3_HOST(instance->peer_instance), - instance->peer_instance->is_probe_finish, - instance->peer_instance->is_probe_failed, - instance->peer_instance->state_machine.is_load); - if (((PS3_IS_INSTANCE_PROBE(instance->peer_instance) || - PS3_IS_INSTANCE_RESUME(instance->peer_instance)) && - instance->peer_instance->state_machine.is_load) || - PS3_IS_INSTANCE_REMOVE(instance->peer_instance)) { + if (instance->peer_instance != NULL && PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { + LOG_WARN("host_no[%u], reset while probe or in shutdown/remove," + " finish[%d], flag[%d], is_load[%d]\n", + PS3_HOST(instance->peer_instance), instance->peer_instance->is_probe_finish, + instance->peer_instance->is_probe_failed, + instance->peer_instance->state_machine.is_load); + if (((PS3_IS_INSTANCE_PROBE(instance->peer_instance) || PS3_IS_INSTANCE_RESUME(instance->peer_instance)) && \ + instance->peer_instance->state_machine.is_load) || \ + PS3_IS_INSTANCE_REMOVE(instance->peer_instance)) { ps3_hard_reset_unnormal_handle(instance->peer_instance); - ps3_instance_state_transfer_to_dead( - instance->peer_instance); + ps3_instance_state_transfer_to_dead(instance->peer_instance); } else if (PS3_IS_INSTANCE_SUSPEND(instance->peer_instance)) { ps3_hard_reset_unnormal_handle(instance->peer_instance); } @@ -2678,82 +2459,83 @@ ps3_hard_reset_multi_unnormal_handle(struct ps3_instance *instance) static void ps3_recovery_wait_reg_access_done(struct ps3_instance *instance) { - unsigned short cur_cnt = 0; - unsigned char printed = PS3_TRUE; + U16 cur_cnt = 0; + Bool printed = PS3_TRUE; LOG_DEBUG("hno:%u recovery wait reg access done start\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_wait_scsi_cmd_done(instance, PS3_TRUE); ps3_wait_mgr_cmd_done(instance, PS3_TRUE); while (ps3_atomic_read(&instance->reg_op_count) != 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); - if (printed && ((++cur_cnt) * PS3_LOOP_TIME_INTERVAL_20MS > - PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && ((++cur_cnt) * PS3_LOOP_TIME_INTERVAL_20MS > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u wait reg access done.\n", - PS3_HOST(instance)); + LOG_WARN("host:%u wait reg access done.\n", PS3_HOST(instance)); } } LOG_DEBUG("hno:%u recovery wait reg access done end\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } -void ps3_hard_recovery_state_finish(struct ps3_instance *instance) -{ +void ps3_hard_recovery_state_finish(struct ps3_instance *instance) { ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state == - PS3_HOST_RESET_START) { - instance->recovery_context->host_reset_state = - PS3_HOST_RESET_HARD_RESET_DONE; + if (instance->recovery_context->host_reset_state == PS3_HOST_RESET_START) { + instance->recovery_context->host_reset_state = PS3_HOST_RESET_HARD_RESET_DONE; } ps3_mutex_unlock(&instance->state_machine.lock); ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_FINISH); + INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ, instance) } -static int ps3_hard_recovery_handle(struct ps3_instance *instance) +static S32 ps3_hard_recovery_handle(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int retries = 0; - unsigned int cur_state = 0; - unsigned int ioc_state = 0; - int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - unsigned int wait_count = 0; - unsigned long flags = 0; - unsigned short cur_cnt = 0; - unsigned char printed = PS3_TRUE; + S32 ret = PS3_SUCCESS; + U32 retries = 0; + U32 cur_state = 0; + U32 ioc_state = 0; + S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + U32 wait_count = 0; + ULong flags = 0; + U16 cur_cnt = 0; + Bool printed = PS3_TRUE; + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_0, instance) if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - if (((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) || - (!ps3_hard_reset_enable_query())) && - (instance->recovery_context->heartbeat_recovery != - PS3_HEARTBEAT_HARDRESET_RECOVERY)) { - LOG_ERROR( - "hno:%u soc feature unsupport Hard reset! need to be offline!\n", + if (((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) + || (!ps3_hard_reset_enable_query())) + && (instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_RECOVERY)) { + LOG_ERROR("hno:%u soc feature unsupport Hard reset! need to be offline!\n", PS3_HOST(instance)); goto l_offline; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags); - if (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0) - ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); + INJECT_START(PS3_ERR_IJ_FLAG_WAIT_EVENT_INT, instance) + INJECT_START(PS3_ERR_IJ_FLAG_WAIT_EVENT_PROC, instance) + INJECT_START(PS3_ERR_IJ_FLAG_WAIT_EVENT_SUBCRIBE, instance) + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); + if (instance->event_context.abort_eventcmd != 0) { + instance->event_context.abort_eventcmd = 0; + } - if (ps3_atomic_read(&instance->hardreset_event) == 0) - ps3_atomic_set(&instance->hardreset_event, 1); - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags); + if (instance->hardreset_event == 0) { + instance->hardreset_event = 1; + } + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + INJECT_START(PS3_ERR_IJ_HOST_RESET_WAIT_DECIDE, instance) ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_SHALLOW); - if (instance->is_scan_host_finish && !instance->is_probe_finish) { + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC1_PROBE, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC1_REMOVE, instance) + if (instance->is_scan_host_finish + && !instance->is_probe_finish) { LOG_INFO("hno:%u recovery wait until probe finish/failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); while (wait_count < PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT) { - if (instance->is_probe_finish || - instance->is_probe_failed) { + if (instance->is_probe_finish || instance->is_probe_failed) { break; } @@ -2761,263 +2543,214 @@ static int ps3_hard_recovery_handle(struct ps3_instance *instance) ps3_msleep(PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS); } - LOG_INFO( - "hno:%u probe finish(%d)/failed(%d), continue recovery\n", - PS3_HOST(instance), instance->is_probe_finish, - instance->is_probe_failed); + LOG_INFO("hno:%u probe finish(%d)/failed(%d), continue recovery\n", + PS3_HOST(instance), instance->is_probe_finish, instance->is_probe_failed); } ps3_wait_watchdog_dect_recovery(instance); - if (instance->peer_instance != NULL && - instance->peer_instance->recovery_function.hardreset_handle_pre_cb != - NULL) { - ret = instance->peer_instance->recovery_function - .hardreset_handle_pre_cb(instance->peer_instance); + if (instance->peer_instance != NULL && \ + instance->peer_instance->recovery_function.hardreset_handle_pre_cb != NULL) { + ret = instance->peer_instance->recovery_function.hardreset_handle_pre_cb(instance->peer_instance); if (ret != PS3_SUCCESS) { LOG_WARN("hno:%u hardreset handle pre cb NOK\n", - PS3_HOST(instance)); - if (ret == -PS3_IN_PCIE_ERR) + PS3_HOST(instance)); + if (ret == -PS3_IN_PCIE_ERR) { goto l_out; - else + } else { goto l_offline; + } } } - while (ps3_use_hard_reset_max_retry() > retries) { + while(ps3_use_hard_reset_max_retry() > retries) { LOG_DEBUG("hno:%u request IOC state to fault! retries:%d\n", - PS3_HOST(instance), retries); - ps3_mutex_lock(&instance->recovery_context - ->ps3_watchdog_recovery_mutex); - if (instance->recovery_context->heartbeat_recovery == - PS3_HEARTBEAT_HARDRESET_RECOVERY && - retries != 0) { - instance->recovery_context->heartbeat_recovery = - PS3_HEARTBEAT_HARDRESET_RETRY; - } - ps3_mutex_unlock(&instance->recovery_context - ->ps3_watchdog_recovery_mutex); + PS3_HOST(instance), retries); + ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY && + retries != 0) { + instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_RETRY; + } + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); instance->dump_context.is_hard_recovered = PS3_TRUE; - if (instance->recovery_context->heartbeat_recovery != - PS3_HEARTBEAT_HARDRESET_RECOVERY) { - ret = instance->ioc_adpter->ioc_force_to_fault( - instance); + if (instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_RECOVERY) { + ret = instance->ioc_adpter->ioc_force_to_fault(instance); if (ret != PS3_SUCCESS) { - LOG_WARN( - "hno:%u hardreset handle force to fault NOK\n", + LOG_WARN("hno:%u hardreset handle force to fault NOK\n", PS3_HOST(instance)); - if (ret == -PS3_IN_PCIE_ERR) + if (ret == -PS3_IN_PCIE_ERR) { goto l_out; + } } } else { ps3_recovery_wait_reg_access_done(instance); if (instance->peer_instance != NULL) { - ps3_recovery_wait_reg_access_done( - instance->peer_instance); + ps3_recovery_wait_reg_access_done(instance->peer_instance); } } ioc_state = instance->ioc_adpter->ioc_state_get(instance); LOG_DEBUG("hno:%u IOC state is %s! retries:%d\n", - PS3_HOST(instance), ps3_ioc_state_print(ioc_state), - retries); + PS3_HOST(instance), ps3_ioc_state_print(ioc_state), retries); - while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { ps3_msleep(10); - if (printed && ((++cur_cnt) * 10 > - PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u wait err scsi process\n", - PS3_HOST(instance)); + LOG_WARN("host:%u wait err scsi process\n", PS3_HOST(instance)); } } instance->ioc_adpter->irq_disable(instance); + INJECT_START(PS3_ERR_IJ_WAIT_IOCTL_IN_RECOVERY, instance) #ifndef _WINDOWS ps3_irqs_sync(instance); #endif + INJECT_START(PS3_ERR_IJ_WAIT_READY, instance); + INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_4, instance); err_code = ps3_hard_recovery_to_ready(instance); if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO( - "hno:%u IOC state to ready failed! retries:%d\n", + LOG_INFO("hno:%u IOC state to ready failed! retries:%d\n", PS3_HOST(instance), retries); if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { retries++; continue; - } else if (err_code == - PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { goto l_out; } else { goto l_offline; } } LOG_INFO("hno:%u IOC state to ready success! retries:%d\n", - PS3_HOST(instance), retries); + PS3_HOST(instance), retries); - if (instance->peer_instance != NULL && - instance->peer_instance->recovery_function - .hardreset_handle_wait_ready_cb != NULL) { - err_code = instance->peer_instance->recovery_function - .hardreset_handle_wait_ready_cb( - instance->peer_instance); + if (instance->peer_instance != NULL && \ + instance->peer_instance->recovery_function.hardreset_handle_wait_ready_cb != NULL) { + err_code = instance->peer_instance->recovery_function.hardreset_handle_wait_ready_cb( \ + instance->peer_instance); if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO( - "hno:%u ioc state to ready failed! retries:%d\n", + LOG_INFO("hno:%u ioc state to ready failed! retries:%d\n", PS3_HOST(instance), retries); - if (err_code == - PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { retries++; continue; - } else if (err_code == - PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { goto l_out; } else { goto l_offline; } } - LOG_INFO( - "hno:%u ioc state to ready success! retries:%d\n", + LOG_INFO("hno:%u ioc state to ready success! retries:%d\n", PS3_HOST(instance), retries); } + INJECT_START(PS3_ERR_IJ_FWSTATE_REMOVE, instance) err_code = ps3_hard_reset_multi_unnormal_handle(instance); if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_INFO("driver loading or unloading err_code:%d\n", - err_code); + err_code); if (err_code == PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME) goto l_out; else goto l_offline; } + INJECT_START(PS3_ERR_IJ_FORCE_WAIT_CLI_CMD, instance); + INJECT_START(PS3_ERR_IJ_WATCHDOG_WAIT_RUNNING, instance); err_code = ps3_hard_recovery_to_pre_operational(instance); if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO( - "hno:%u IOC state to pre-operatioal failed! retries:%d\n", + LOG_INFO("hno:%u IOC state to pre-operatioal failed! retries:%d\n", PS3_HOST(instance), retries); + INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL1, instance->peer_instance) if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { - if (instance->peer_instance != NULL) { - if (ps3_instance_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_RECOVERY) != - PS3_SUCCESS) { - LOG_WARN( - "hno:%u transfer to recovery NOK!\n", - PS3_HOST( - instance->peer_instance)); + if(instance->peer_instance != NULL) { + if (ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_READY, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + LOG_WARN("hno:%u transfer to recovery NOK!\n", + PS3_HOST(instance->peer_instance)); goto l_offline; } } retries++; continue; - } else if (err_code == - PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { goto l_out; } else { goto l_offline; } } - LOG_INFO( - "hno:%u IOC state to pre-operatioal success! retries:%d\n", + LOG_INFO("hno:%u IOC state to pre-operatioal success! retries:%d\n", PS3_HOST(instance), retries); - if (instance->peer_instance != NULL && - !PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance) && - instance->peer_instance->recovery_function - .hardreset_handle_init_running_cb != NULL) { - if (ps3_atomic_read(&instance->peer_instance - ->state_machine.state) != - PS3_INSTANCE_STATE_DEAD) { - err_code = - instance->peer_instance - ->recovery_function - .hardreset_handle_init_running_cb( - instance->peer_instance); - if (err_code == - PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO( - "hno:%u IOC state to pre-operatioal success! retries:%d\n", + + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_1, instance) + if (instance->peer_instance != NULL && !PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance) && + instance->peer_instance->recovery_function.hardreset_handle_init_running_cb != NULL) { + if(ps3_atomic_read(&instance->peer_instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ + err_code = instance->peer_instance->recovery_function.hardreset_handle_init_running_cb( \ + instance->peer_instance); + if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { + LOG_INFO("hno:%u IOC state to pre-operatioal failed! retries:%d\n", PS3_HOST(instance), retries); - goto l_operational; - } - LOG_INFO( - "hno:%u IOC state to pre-operatioal failed! retries:%d\n", - PS3_HOST(instance), retries); - if (err_code == - PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { - if (ps3_instance_state_transfer( - instance, - PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_RECOVERY) != - PS3_SUCCESS) { - LOG_WARN( - "hno:%u transfer to recovery NOK!\n", - PS3_HOST( - instance->peer_instance)); + if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_PEER_DEAD_FAIL, + instance->peer_instance) + if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + LOG_WARN("hno:%u transfer to recovery NOK!\n", + PS3_HOST(instance->peer_instance)); + goto l_offline; + } + retries++; + continue; + } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + goto l_out; + } else { goto l_offline; } - retries++; - continue; - } else if (err_code == - PS3_RECOVERY_INTER_ERR_PCIE_ERR) { - goto l_out; - } else { - goto l_offline; } + LOG_INFO("hno:%u IOC state to pre-operatioal success! retries:%d\n", + PS3_HOST(instance), retries); } } - -l_operational: + INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_2, instance) err_code = ps3_hard_recovery_to_operational(instance); if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO( - "hno:%u IOC state to operatioal failed! retries:%d\n", + LOG_INFO("hno:%u IOC state to operatioal failed! retries:%d\n", PS3_HOST(instance), retries); if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { retries++; continue; - } else if (err_code == - PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { goto l_out; } else { goto l_offline; } } - LOG_INFO( - "hno:%u IOC state to operatioal success! retries:%d\n", + LOG_INFO("hno:%u IOC state to operatioal success! retries:%d\n", PS3_HOST(instance), retries); - if (instance->peer_instance != NULL && - instance->peer_instance->recovery_function - .hardreset_handle_post_cb != NULL) { - if (!PS3_IS_INSTANCE_NOT_LOAD_NORMAL( - instance->peer_instance) && - ps3_atomic_read(&instance->peer_instance - ->state_machine.state) != - PS3_INSTANCE_STATE_DEAD) { - err_code = - instance->peer_instance - ->recovery_function - .hardreset_handle_post_cb( - instance->peer_instance); - if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO( - "hno:%u IOC state to operatioal failed! retries:%d\n", - PS3_HOST(instance), - retries); - if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { - retries++; - continue; - } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { - goto l_out; - } else { - goto l_offline; + if (instance->peer_instance != NULL && \ + instance->peer_instance->recovery_function.hardreset_handle_post_cb != NULL) { + if (!PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { + if(ps3_atomic_read(&instance->peer_instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ + err_code = instance->peer_instance->recovery_function.hardreset_handle_post_cb( \ + instance->peer_instance); + if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { + LOG_INFO("hno:%u IOC state to operatioal failed! retries:%d\n", + PS3_HOST(instance), retries); + if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + retries++; + continue; + } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + goto l_out; + } else { + goto l_offline; + } } + LOG_INFO("hno:%u IOC state to operatioal success! retries:%d\n", + PS3_HOST(instance), retries); } - LOG_INFO( - "hno:%u IOC state to operatioal success! retries:%d\n", - PS3_HOST(instance), retries); } } break; @@ -3025,98 +2758,87 @@ static int ps3_hard_recovery_handle(struct ps3_instance *instance) cur_state = ps3_atomic_read(&instance->state_machine.state); if ((cur_state != PS3_INSTANCE_STATE_OPERATIONAL || - ps3_use_hard_reset_max_retry() == retries) && - !PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { + ps3_use_hard_reset_max_retry() == retries) && !PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { LOG_ERROR("hno:%u hard reset failed! cur_state:%s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), + namePS3InstanceState(cur_state)); goto l_offline; } ret = ps3_recovery_complete(instance); - if (ret != PS3_SUCCESS) { - LOG_WARN( - "hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), - ret); - if (ret == -PS3_IN_PCIE_ERR) + if(ret != PS3_SUCCESS){ + LOG_WARN("hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state),ret); + if (ret == -PS3_IN_PCIE_ERR) { goto l_out; - else + } else { goto l_offline; + } } - if (instance->peer_instance == NULL || - instance->peer_instance->recovery_function - .hardreset_handle_finish_cb == NULL) { + if (instance->peer_instance == NULL || \ + instance->peer_instance->recovery_function.hardreset_handle_finish_cb == NULL) { ps3_hard_recovery_state_finish(instance); LOG_INFO("hno:%u hard reset finish! cur_state:%s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); } else { if (!PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { - if (ps3_atomic_read(&instance->peer_instance - ->state_machine.state) != - PS3_INSTANCE_STATE_DEAD) { - ret = instance->peer_instance->recovery_function - .hardreset_handle_finish_cb( - instance->peer_instance); + if(ps3_atomic_read(&instance->peer_instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ + ret = instance->peer_instance->recovery_function.hardreset_handle_finish_cb( \ + instance->peer_instance); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PEER_COMPLETE_FAILED, &ret) } if (ret != PS3_SUCCESS) { - LOG_WARN( - "hno:%u hardreset handle running cb NOK\n", + LOG_WARN("hno:%u hardreset handle running cb NOK\n", PS3_HOST(instance->peer_instance)); - if (ret == -PS3_IN_PCIE_ERR) + if (ret == -PS3_IN_PCIE_ERR) { goto l_out; - else + } else { goto l_offline; + } } } else { ps3_hard_recovery_state_finish(instance); } } ps3_ioc_can_hardreset_set(instance, PS3_IOC_CAN_HARDRESET); - if (instance->peer_instance != NULL) { - ps3_ioc_can_hardreset_set(instance->peer_instance, - PS3_IOC_CAN_HARDRESET); - } + if (instance->peer_instance != NULL) + ps3_ioc_can_hardreset_set(instance->peer_instance, PS3_IOC_CAN_HARDRESET); return ret; l_offline: ps3_instance_state_transfer_to_dead(instance); - if (instance->peer_instance != NULL && - instance->peer_instance->recovery_function - .hardreset_handle_offline_cb != NULL) { - instance->peer_instance->recovery_function - .hardreset_handle_offline_cb(instance->peer_instance); + if (instance->peer_instance != NULL && \ + instance->peer_instance->recovery_function.hardreset_handle_offline_cb != NULL) { + instance->peer_instance->recovery_function.hardreset_handle_offline_cb( \ + instance->peer_instance); } l_out: ps3_hard_recovery_state_finish(instance); if (ps3_pci_err_recovery_get(instance)) { - ps3_mutex_lock(&instance->recovery_context - ->ps3_watchdog_recovery_mutex); + ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); instance->recovery_context->heartbeat_recovery = - PS3_HEARTBEAT_NULL; - ps3_mutex_unlock(&instance->recovery_context - ->ps3_watchdog_recovery_mutex); + PS3_HEARTBEAT_NULL; + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); } LOG_WARN("hno:%u hard reset finish! cur_state:%s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = -PS3_FAILED; return ret; } -static int ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance) +static S32 ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned short cur_cnt = 0; - unsigned char printed = PS3_TRUE; + S32 ret = PS3_SUCCESS; + U16 cur_cnt = 0; + Bool printed = PS3_TRUE; ps3_cmd_reset_flag_set(instance, PS3_CMD_FLAG_HARDRESET); - while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { ps3_msleep(10); - if (printed && - ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u cmd stop wait err scsi process\n", - PS3_HOST(instance)); + LOG_WARN("host:%u cmd stop wait err scsi process\n", PS3_HOST(instance)); } } @@ -3124,65 +2846,63 @@ static int ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance) ps3_cmd_force_stop(instance); - LOG2_DEBUG("hno:%u force cmd stop end\n", PS3_HOST(instance)); + LOG2_DEBUG("hno:%u force cmd stop end\n", + PS3_HOST(instance)); return ret; } -static int ps3_recovery_ready_to_running(struct ps3_instance *instance) +static S32 ps3_recovery_ready_to_running(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned short cur_cnt = 0; - unsigned char printed = PS3_TRUE; + S32 ret = PS3_SUCCESS; + U16 cur_cnt = 0; + Bool printed = PS3_TRUE; ps3_cmd_reset_flag_set(instance, PS3_CMD_FLAG_HARDRESET); - while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { ps3_msleep(10); - if (printed && - ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u to running wait err scsi process\n", - PS3_HOST(instance)); + LOG_WARN("host:%u to running wait err scsi process\n", PS3_HOST(instance)); } } ps3_all_reply_fifo_complete(instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_BLOCK_BEFORE_RUNNING, instance); ps3_cmd_force_stop(instance); if (!ps3_bit_pos_update(instance)) { - LOG_ERROR("hno:%u update bit pos NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u update bit pos NOK\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - ret = instance->ioc_adpter->ioc_init_proc(instance); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init IOC frame NOK\n", PS3_HOST(instance)); + if ((ret = instance->ioc_adpter->ioc_init_proc(instance)) != PS3_SUCCESS) { + LOG_ERROR("hno:%u init IOC frame NOK\n", + PS3_HOST(instance)); goto l_out; } l_out: - LOG_DEBUG("hno:%u ready to running :%d\n", PS3_HOST(instance), ret); + LOG_DEBUG("hno:%u ready to running :%d\n", + PS3_HOST(instance), ret); return ret; } -static void ps3_can_queue_reset(struct ps3_instance *instance, - unsigned int cur_max_fw_cmds) +static void ps3_can_queue_reset(struct ps3_instance *instance, U32 cur_max_fw_cmds) { - unsigned long flag = 0; - - LOG_INFO("hno:%u IOC cur max fw cmd is %d!\n", PS3_HOST(instance), - cur_max_fw_cmds); + ULong flag = 0; + LOG_INFO("hno:%u IOC cur max fw cmd is %d!\n", + PS3_HOST(instance), cur_max_fw_cmds); if (cur_max_fw_cmds <= instance->cmd_context.max_cmd_count) { - instance->cmd_attr.cur_can_que = - cur_max_fw_cmds - + instance->cmd_attr.cur_can_que = cur_max_fw_cmds - instance->cmd_context.max_mgr_cmd_count - instance->cmd_context.max_r1x_cmd_count; spin_lock_irqsave(instance->host->host_lock, flag); instance->host->can_queue = instance->cmd_attr.cur_can_que; - LOG_INFO_IN_IRQ( - instance, + LOG_INFO_IN_IRQ(instance, "hno:%u IOC cur max fw cmd %d is less than %d, can queue is updated to %d!\n", PS3_HOST(instance), cur_max_fw_cmds, instance->cmd_context.max_cmd_count, @@ -3191,63 +2911,66 @@ static void ps3_can_queue_reset(struct ps3_instance *instance, } } -static void ps3_cmd_reset_flag_set(struct ps3_instance *instance, - unsigned char reset_flag) +static void ps3_cmd_reset_flag_set(struct ps3_instance *instance, U8 reset_flag) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - unsigned long flags = 0; + ULong flags = 0; - if (context->cmd_buf == NULL) + if (context->cmd_buf == NULL) { return; + } for (i = 0; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state != PS3_CMD_STATE_INIT) + if (cmd->cmd_state.state != PS3_CMD_STATE_INIT) { cmd->cmd_state.reset_flag = reset_flag; + } ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } } -static unsigned char ps3_is_scsi_task_cmd(struct ps3_cmd *cmd) +static Bool ps3_is_scsi_task_cmd(struct ps3_cmd *cmd) { - unsigned char cmd_type = cmd->req_frame->word[0]; + U8 cmd_type = cmd->req_frame->word[0]; - if (cmd_type == PS3_CMD_SCSI_TASK_MANAGEMENT) + if (cmd_type == PS3_CMD_SCSI_TASK_MANAGEMENT) { return PS3_TRUE; - else + } else { return PS3_FALSE; + } } void ps3_scsi_cmd_force_stop(struct ps3_instance *instance) { - int i = 0; + S32 i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *peer_cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; struct scsi_cmnd *s_cmd = NULL; struct ps3_scsi_priv_data *data = NULL; - unsigned short count = 0; + U16 count = 0; #ifndef _WINDOWS - int ret_code = 0; + S32 ret_code = 0 ; - if (ps3_pci_err_recovery_get(instance)) + if (ps3_pci_err_recovery_get(instance)) { ret_code = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - else + } else { ret_code = ps3_get_requeue_or_reset(); + } #endif ps3_mutex_lock(&instance->recovery_context->free_cmd_lock); for (i = 0; i < instance->cmd_attr.cur_can_que; i++) { cmd = context->cmd_buf[i]; if ((cmd->cmd_state.state == PS3_CMD_STATE_INIT) || - (cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE)) { + (cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE)) { continue; } LOG_INFO("hno:%u force stop scsi CFID[%d] [%u]\n", - PS3_HOST(instance), i, cmd->cmd_state.state); + PS3_HOST(instance), i, cmd->cmd_state.state); s_cmd = cmd->scmd; count++; @@ -3255,8 +2978,7 @@ void ps3_scsi_cmd_force_stop(struct ps3_instance *instance) PS3_IO_OUTSTAND_DEC(instance, s_cmd); PS3_VD_OUTSTAND_DEC(instance, s_cmd); PS3_DEV_IO_OUTSTAND_DEC(instance, cmd); - PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd, - PS3_REPLY_WORD_FLAG_FAIL); + PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); ps3_qos_cmd_update(instance, cmd); #ifndef _WINDOWS @@ -3264,31 +2986,26 @@ void ps3_scsi_cmd_force_stop(struct ps3_instance *instance) PS3_DEV_BUSY_DEC(s_cmd); s_cmd->result = ret_code; -#if defined(PS3_SUPPORT_CMD_SCP) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) s_cmd->SCp.ptr = NULL; #endif ps3_scsi_dma_unmap(cmd); - if (likely(cmd && cmd->scmd && cmd->scmd->device && - cmd->scmd->device->hostdata)) { - data = (struct ps3_scsi_priv_data *) - cmd->scmd->device->hostdata; + if (likely(cmd && cmd->scmd && cmd->scmd->device && cmd->scmd->device->hostdata)) { + data = (struct ps3_scsi_priv_data *)cmd->scmd->device->hostdata; if (likely(data != NULL) && - data->lock_mgr.hash_mgr != NULL) { + data->lock_mgr.hash_mgr != NULL) { ps3_r1x_write_unlock(&data->lock_mgr, cmd); } } else { - LOG_WARN( - "hno:%u force stop scsi has Null pointer CFID[%u]\n", + LOG_WARN("hno:%u force stop scsi has Null pointer CFID[%u]\n", PS3_HOST(instance), i); } peer_cmd = cmd->r1x_peer_cmd; ps3_scsi_cmd_free(cmd); if (peer_cmd != NULL) { - LOG_DEBUG( - "hno:%u force stop r1x scsi CFID[%d] and CFID[%d]\n", + LOG_DEBUG("hno:%u force stop r1x scsi CFID[%d] and CFID[%d]\n", PS3_HOST(instance), i, peer_cmd->index); - PS3_IOC_DRV2IOC_BACK_INC(peer_cmd->instance, peer_cmd, - PS3_REPLY_WORD_FLAG_FAIL); + PS3_IOC_DRV2IOC_BACK_INC(peer_cmd->instance, peer_cmd, PS3_REPLY_WORD_FLAG_FAIL); ps3_r1x_peer_cmd_free_nolock(peer_cmd); } SCMD_IO_DONE(s_cmd); @@ -3296,193 +3013,177 @@ void ps3_scsi_cmd_force_stop(struct ps3_instance *instance) PS3_IO_BACK_ERR_INC(cmd->instance, s_cmd, cmd->index); scsi_cmnd_hoststatus_set(s_cmd, DID_RESET); data = scsi_device_private_data(s_cmd); - if (likely(data != NULL) && data->lock_mgr.hash_mgr != NULL) + if(likely(data != NULL) && data->lock_mgr.hash_mgr != NULL){ ps3_r1x_write_unlock(&data->lock_mgr, cmd); + } ps3_scsi_cmd_done(cmd); #endif } ps3_mutex_unlock(&instance->recovery_context->free_cmd_lock); LOG_WARN("hno:%u force stop scsi cmd count[%u] during hard recovery\n", - PS3_HOST(instance), count); + PS3_HOST(instance), count); + return; } void ps3_mgr_cmd_force_stop(struct ps3_instance *instance) { - unsigned int i = 0; + U32 i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - unsigned long cmd_lock_flags = 0; + ULong cmd_lock_flags = 0; for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &cmd_lock_flags); if ((cmd->cmd_state.state == PS3_CMD_STATE_INIT) || - (cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE)) { - LOG_FILE_WARN("hno:%u init or complete CFID:%d\n", - PS3_HOST(instance), i); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, - cmd_lock_flags); + (cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE)) { + LOG_FILE_WARN("hno:%u init or complete CFID:%d\n", PS3_HOST(instance), i); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); continue; } if (cmd->cmd_state.state == PS3_CMD_STATE_DEAD) { - LOG_FILE_WARN("hno:%u force free CFID:%d\n", - PS3_HOST(instance), i); - PS3_MGR_CMD_BACK_INC(instance, cmd, - PS3_REPLY_WORD_FLAG_FAIL); - if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) { - LOG_FILE_WARN( - "hno:%u force free CFID:%d ioctl buff\n", - PS3_HOST(instance), i); + LOG_FILE_WARN("hno:%u force free CFID:%d\n", PS3_HOST(instance), i); + PS3_MGR_CMD_BACK_INC(instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); + + if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL){ + LOG_FILE_WARN("hno:%u force free CFID:%d ioctl buff\n", PS3_HOST(instance), i); ps3_ioctl_buff_release(cmd); } - if (cmd == instance->event_context.event_cmd) + if (cmd == instance->event_context.event_cmd) { instance->event_context.event_cmd = NULL; + } ps3_mgr_cmd_free_nolock(instance, cmd); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, - cmd_lock_flags); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); continue; } - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == - PS3_CMD_WORD_NO_REPLY_WORD) { - LOG_FILE_WARN( - "hno:%u force complete no reply word CFID:%d\n", + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NO_REPLY_WORD) { + LOG_FILE_WARN("hno:%u force complete no reply word CFID:%d\n", PS3_HOST(instance), i); if (ps3_is_scsi_task_cmd(cmd)) { - cmd->resp_frame->normalRespFrame.respStatus = - SCSI_STATUS_GOOD; + cmd->resp_frame->normalRespFrame.respStatus = SCSI_STATUS_GOOD; } else { - cmd->resp_frame->normalRespFrame.respStatus = - PS3_DRV_MGR_BUSY; + cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; } - PS3_MGR_CMD_BACK_INC(instance, cmd, - PS3_REPLY_WORD_FLAG_FAIL); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, - cmd_lock_flags); + PS3_MGR_CMD_BACK_INC(instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); continue; } if (ps3_is_scsi_task_cmd(cmd)) { - cmd->resp_frame->normalRespFrame.respStatus = - SCSI_STATUS_GOOD; - PS3_MGR_CMD_BACK_INC(instance, cmd, - PS3_REPLY_WORD_FLAG_FAIL); + cmd->resp_frame->normalRespFrame.respStatus = SCSI_STATUS_GOOD; + PS3_MGR_CMD_BACK_INC(instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; complete(&cmd->sync_done); - LOG_FILE_WARN( - "hno:%u force complete task mgr CFID:%d\n", + LOG_FILE_WARN("hno:%u force complete task mgr CFID:%d\n", PS3_HOST(instance), i); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, - cmd_lock_flags); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); continue; } if (cmd->req_frame->mgrReq.syncFlag == 1) { - PS3_MGR_CMD_BACK_INC(instance, cmd, - PS3_REPLY_WORD_FLAG_FAIL); - cmd->resp_frame->normalRespFrame.respStatus = - PS3_DRV_MGR_BUSY; + PS3_MGR_CMD_BACK_INC(instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); + cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; - LOG_FILE_WARN( - "hno:%u force complete sync mgr CFID:%d\n", + LOG_FILE_WARN("hno:%u force complete sync mgr CFID:%d\n", PS3_HOST(instance), i); complete(&cmd->sync_done); } else { if (instance->is_need_event) { - if (cmd == instance->event_context.event_cmd || + if (cmd == instance->event_context.event_cmd || cmd == instance->dev_context.vd_pending_cmd || - cmd == instance->webSubscribe_context - .webSubscribe_cmd) { - ps3_spin_unlock_irqrestore( - &cmd->cmd_state.lock, - cmd_lock_flags); - LOG_INFO( - "trace_id[0x%llx], hno:%u Event cmd:%d ignore!\n", - cmd->trace_id, - PS3_HOST(instance), cmd->index); - continue; - } - } + cmd == instance->webSubscribe_context.webSubscribe_cmd) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); + LOG_INFO("trace_id[0x%llx], hno:%u Event cmd:%d ignore!\n", + cmd->trace_id, PS3_HOST(instance), cmd->index); + continue; + } + } } - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, - cmd_lock_flags); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); } if (instance->is_need_event) { - if (instance->event_context.event_abort_cmd != NULL) { + if(instance->event_context.event_abort_cmd != NULL){ abort_cmd = instance->event_context.event_abort_cmd; instance->event_context.event_abort_cmd = NULL; } - if (abort_cmd != NULL) + if(abort_cmd != NULL){ ps3_task_cmd_free(instance, abort_cmd); + } - if (instance->dev_context.vdpending_abort_cmd != NULL) { + if(instance->dev_context.vdpending_abort_cmd != NULL){ abort_cmd = instance->dev_context.vdpending_abort_cmd; instance->dev_context.vdpending_abort_cmd = NULL; } - if (abort_cmd != NULL) + if(abort_cmd != NULL){ ps3_task_cmd_free(instance, abort_cmd); - - if (instance->webSubscribe_context.web_abort_cmd != NULL) { - abort_cmd = - instance->webSubscribe_context.web_abort_cmd; - instance->webSubscribe_context.web_abort_cmd = NULL; } - if (abort_cmd != NULL) - ps3_task_cmd_free(instance, abort_cmd); + + if(instance->webSubscribe_context.web_abort_cmd != NULL){ + abort_cmd = instance->webSubscribe_context.web_abort_cmd; + instance->webSubscribe_context.web_abort_cmd = NULL; + } + if(abort_cmd != NULL){ + ps3_task_cmd_free(instance, abort_cmd); + } } } void ps3_cmd_force_stop(struct ps3_instance *instance) { - int ret_code = 0; + S32 ret_code = 0; struct ps3_cmd_context *context = &instance->cmd_context; - - if (context->cmd_buf == NULL) + if (context->cmd_buf == NULL) { return; + } - if (ps3_pci_err_recovery_get(instance)) + if (ps3_pci_err_recovery_get(instance)) { ret_code = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - else + } else { ret_code = ps3_get_requeue_or_reset(); + } ps3_r1x_conflict_queue_clean_all(instance, ret_code, PS3_FALSE); ps3_qos_hard_reset(instance); +#ifdef PS3_SUPPORT_INJECT + ps3_inject_clear(); +#endif ps3_scsi_cmd_force_stop(instance); ps3_mgr_cmd_force_stop(instance); } -unsigned char ps3_is_need_hard_reset(struct ps3_instance *instance) +Bool ps3_is_need_hard_reset(struct ps3_instance *instance) { - unsigned char need_hardreset = PS3_FALSE; - unsigned char is_support_halt = PS3_FALSE; - unsigned int hard_reset_enable = 0; - int cur_state = PS3_INSTANCE_STATE_INIT; - - if (!ps3_feature_support_reg_get(instance)) + Bool need_hardreset = PS3_FALSE; + Bool is_support_halt = PS3_FALSE; + U32 hard_reset_enable = 0; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + if (!ps3_feature_support_reg_get(instance)) { goto l_out; + } is_support_halt = PS3_IOC_STATE_HALT_SUPPORT(instance); LOG_INFO("hno:%u instance state not support hardreset!\n", - PS3_HOST(instance)); - - if (is_support_halt && (cur_state != PS3_INSTANCE_STATE_DEAD)) { + PS3_HOST(instance)); + if(is_support_halt && (cur_state != PS3_INSTANCE_STATE_DEAD)){ ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_DEAD); + PS3_INSTANCE_STATE_DEAD); instance->ioc_adpter->ioc_force_to_halt(instance); LOG_INFO("hno:%u instance state while support halt!\n", - PS3_HOST(instance)); - while (1) + PS3_HOST(instance)); + while (1) { ps3_msleep(10); + } } - if (PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(instance)) { + if(PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(instance)) { need_hardreset = PS3_TRUE; goto l_out; } @@ -3491,11 +3192,11 @@ unsigned char ps3_is_need_hard_reset(struct ps3_instance *instance) cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_WARN("hno[%u], ready to hard reset,instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); - if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) || - (!hard_reset_enable)) { + PS3_HOST(instance), namePS3InstanceState(cur_state)); + if((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) + || (!hard_reset_enable)){ LOG_INFO("hno:%u instance state not support hardreset!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_instance_state_transfer_to_dead(instance); } else { need_hardreset = PS3_TRUE; @@ -3505,25 +3206,20 @@ unsigned char ps3_is_need_hard_reset(struct ps3_instance *instance) return need_hardreset; } -int ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance) +S32 ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - + S32 ret = PS3_SUCCESS; if (instance->peer_instance != NULL && - instance->recovery_context->parall_hardreset_state == - PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_CONTINUE; - while (instance->recovery_context->parall_hardreset_state != - PS3_PARALLEL_HARDRESET_STATE_INIT) { - ps3_msleep( - PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); + instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_CONTINUE; + while (instance->recovery_context->parall_hardreset_state != PS3_PARALLEL_HARDRESET_STATE_INIT) { + ps3_msleep(PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); } } else { ret = ps3_hard_recovery_request(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS){ LOG_WARN("hno:%u hard recovery request NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } } @@ -3532,56 +3228,48 @@ int ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance) l_out: return ret; } -int ps3_init_fail_hard_reset_with_doorbell(struct ps3_instance *instance) +S32 ps3_init_fail_hard_reset_with_doorbell(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; LOG_WARN("hno[%u], ready to hard reset\n", PS3_HOST(instance)); - if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW) { + if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW){ goto l_out; } if (instance->peer_instance != NULL && - instance->recovery_context->parall_hardreset_state == - PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = - PS3_PARALLEL_HARDRESET_STATE_CONTINUE; - while (instance->recovery_context->parall_hardreset_state != - PS3_PARALLEL_HARDRESET_STATE_INIT) { - ps3_msleep( - PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); + instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_CONTINUE; + while (instance->recovery_context->parall_hardreset_state != PS3_PARALLEL_HARDRESET_STATE_INIT) { + ps3_msleep(PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); } } else { ret = ps3_hard_recovery_request_with_retry(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS){ LOG_WARN("hno:%u hard recovery request NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } } ps3_recovery_cancel_work_sync(instance); - if (instance->ioc_adpter->ioc_state_get(instance) != - PS3_FW_STATE_READY) { + if (instance->ioc_adpter->ioc_state_get(instance) != PS3_FW_STATE_READY) { ret = -PS3_FAILED; } - LOG_WARN("device[%d] hard reset success,exit init proc %d.\n", - instance->pdev->dev.id, ret); + LOG_WARN("device[%d] hard reset success,exit init proc %d.\n", instance->pdev->dev.id, ret); return ret; l_out: - if (ps3_recovery_is_state_halt(instance)) { + if (ps3_recovery_is_state_halt(instance)) { LOG_WARN("hno:%u driver_state:DEAD or HALT now !!!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_end; } - if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) || - (!ps3_hard_reset_enable_query())) { - LOG_ERROR( - "hno:%u soc feature unsupport Hard reset! need to be offline!\n", + if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) + || (!ps3_hard_reset_enable_query())) { + LOG_ERROR("hno:%u soc feature unsupport Hard reset! need to be offline!\n", PS3_HOST(instance)); ret = -PS3_FAILED; @@ -3591,68 +3279,65 @@ int ps3_init_fail_hard_reset_with_doorbell(struct ps3_instance *instance) ret = instance->ioc_adpter->ioc_force_to_fault(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("device[%d] doorbell fault NOK.\n", - instance->pdev->dev.id); + LOG_ERROR("device[%d] doorbell fault NOK.\n", instance->pdev->dev.id); } if (!instance->ioc_adpter->ioc_hard_reset) { ret = -PS3_FAILED; - LOG_ERROR("device[%d] ioc_hard_reset is null.\n", - instance->pdev->dev.id); + LOG_ERROR("device[%d] ioc_hard_reset is null.\n", instance->pdev->dev.id); goto l_end; } ret = instance->ioc_adpter->ioc_hard_reset(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("device[%d] hard reset NOK,exit init proc.\n", - instance->pdev->dev.id); + LOG_ERROR("device[%d] hard reset NOK,exit init proc.\n", instance->pdev->dev.id); goto l_end; } - LOG_WARN("device[%d] hard reset success,exit init proc.\n", - instance->pdev->dev.id); + LOG_WARN("device[%d] hard reset success,exit init proc.\n", instance->pdev->dev.id); ret = -PS3_FAILED; l_end: return ret; } -int ps3_hardreset_handle_pre(struct ps3_instance *instance) +S32 ps3_hardreset_handle_pre(struct ps3_instance *instance) { - unsigned int wait_count = 0; - unsigned long flags = 0; + U32 wait_count = 0; + ULong flags = 0; LOG_DEBUG("hno:%u functoin[%d], hardreset handle pre start\n", - PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_1, instance) if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return -PS3_IN_PCIE_ERR; } - if (!PS3_IS_INSTANCE_PROBE_INIT(instance)) { - if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) || - (!ps3_hard_reset_enable_query())) { - LOG_ERROR( - "hno:%u soc feature unsupport Hard reset! need to be offline!\n", + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_NOT_SUPPORT, instance) + if(!PS3_IS_INSTANCE_PROBE_INIT(instance)) { + + if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) + || (!ps3_hard_reset_enable_query())) { + LOG_ERROR("hno:%u soc feature unsupport Hard reset! need to be offline!\n", PS3_HOST(instance)); return -PS3_FAILED; } } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, - &flags); - if (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0) - ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); + if (instance->event_context.abort_eventcmd != 0) { + instance->event_context.abort_eventcmd = 0; + } - if (ps3_atomic_read(&instance->hardreset_event) == 0) - ps3_atomic_set(&instance->hardreset_event, 1); - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, - flags); + if (instance->hardreset_event == 0) { + instance->hardreset_event = 1; + } + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); - if (PS3_IS_INSTANCE_PROBE(instance) && instance->is_scan_host_finish && - !instance->is_probe_finish) { + if (PS3_IS_INSTANCE_PROBE(instance) && instance->is_scan_host_finish + && !instance->is_probe_finish) { LOG_INFO("hno:%u recovery wait until probe finish/failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); while (wait_count < PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT) { - if (instance->is_probe_finish || - instance->is_probe_failed) { + if (instance->is_probe_finish || instance->is_probe_failed) { break; } @@ -3660,44 +3345,39 @@ int ps3_hardreset_handle_pre(struct ps3_instance *instance) ps3_msleep(PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS); } - LOG_INFO( - "hno:%u probe finish(%d)/failed(%d), continue recovery\n", - PS3_HOST(instance), instance->is_probe_finish, - instance->is_probe_failed); + LOG_INFO("hno:%u probe finish(%d)/failed(%d), continue recovery\n", + PS3_HOST(instance), instance->is_probe_finish, instance->is_probe_failed); } ps3_wait_watchdog_dect_recovery(instance); LOG_DEBUG("hno:%u functoin[%d], hardreset handle pre end\n", - PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); return PS3_SUCCESS; } -int ps3_hardreset_handle_wait_ready(struct ps3_instance *instance) +S32 ps3_hardreset_handle_wait_ready(struct ps3_instance *instance) { - int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - unsigned int ioc_state = 0; - int ret = PS3_SUCCESS; - unsigned short cur_cnt = 0; - unsigned char printed = PS3_TRUE; + S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + U32 ioc_state = 0; + S32 ret = PS3_SUCCESS; + U16 cur_cnt = 0; + Bool printed = PS3_TRUE; LOG_DEBUG("hno:%u function[%d], hardreset handle wait ready start.\n", - PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); instance->dump_context.is_hard_recovered = PS3_TRUE; ioc_state = instance->ioc_adpter->ioc_state_get(instance); - LOG_DEBUG("hno:%u ioc state is %s! function:%d\n", PS3_HOST(instance), - ps3_ioc_state_print(ioc_state), - ps3_get_pci_function(instance->pdev)); + LOG_DEBUG("hno:%u ioc state is %s! function:%d\n", + PS3_HOST(instance), ps3_ioc_state_print(ioc_state), ps3_get_pci_function(instance->pdev)); - while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { ps3_msleep(10); - if (printed && - ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u wait ready wait err scsi process\n", - PS3_HOST(instance)); + LOG_WARN("host:%u wait ready wait err scsi process\n", PS3_HOST(instance)); } } instance->ioc_adpter->irq_disable(instance); @@ -3705,27 +3385,25 @@ int ps3_hardreset_handle_wait_ready(struct ps3_instance *instance) ps3_irqs_sync(instance); #endif + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_6, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; goto l_out; } - ret = ps3_ioc_state_transfer_to_ready(instance); - if (ret != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_HARD_WAIT_READY_FAILED_F1, instance); + if ((ret = ps3_ioc_state_transfer_to_ready(instance)) != PS3_SUCCESS) { LOG_ERROR("hno:%u hard reset to ready NOK,%s!\n", - PS3_HOST(instance), ps3_ioc_state_print(ioc_state)); + PS3_HOST(instance), + ps3_ioc_state_print(ioc_state)); if (ret == -PS3_IN_PCIE_ERR) { err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; } else { - if (ps3_instance_state_transfer( - instance->peer_instance, - PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_RECOVERY) != - PS3_SUCCESS) { + if (ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_READY, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { LOG_WARN("hno:%u transfer to recovery NOK!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } @@ -3734,144 +3412,142 @@ int ps3_hardreset_handle_wait_ready(struct ps3_instance *instance) goto l_out; } if (instance->state_machine.is_load || - instance->state_machine.is_suspend) { - if (ps3_instance_state_transfer( - instance, PS3_INSTANCE_STATE_RECOVERY, - PS3_INSTANCE_STATE_READY) != PS3_SUCCESS) { + instance->state_machine.is_suspend) { + if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_RECOVERY, + PS3_INSTANCE_STATE_READY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; } } l_out: LOG_DEBUG("hno:%u function[%d], hardreset handle wait ready end.\n", - PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); return err_code; } -int ps3_hardreset_handle_init_running(struct ps3_instance *instance) +S32 ps3_hardreset_handle_init_running(struct ps3_instance *instance) { - unsigned int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + U32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; if (!instance->is_probe_finish || instance->is_probe_failed || - !instance->state_machine.is_load) { + !instance->state_machine.is_load) { ps3_recovery_ready_to_force_cmd_stop(instance); - LOG_ERROR("hno:%u reset while probe or in shutdown/remove,\n" - "\tfinish[%d], failed[%d], is_load[%d]\n", - PS3_HOST(instance), instance->is_probe_finish, - instance->is_probe_failed, - instance->state_machine.is_load); + LOG_ERROR("hno:%u reset while probe or in shutdown/remove," + " finish[%d], failed[%d], is_load[%d]\n", + PS3_HOST(instance), instance->is_probe_finish, + instance->is_probe_failed, + instance->state_machine.is_load); ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_RECOVERY); - instance->is_half_hard_reset = PS3_TRUE; - if (!instance->state_machine.is_load) + PS3_INSTANCE_STATE_RECOVERY); + instance ->is_half_hard_reset = PS3_TRUE; + if (!instance->state_machine.is_load) { ps3_ioc_notify_unload(instance); + } goto l_out; } + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_9, instance) err_code = ps3_hard_recovery_to_pre_operational(instance); l_out: return err_code; } -int ps3_hardreset_handle_post(struct ps3_instance *instance) +S32 ps3_hardreset_handle_post(struct ps3_instance *instance) { + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_12, instance) return ps3_hard_recovery_to_operational(instance); } -int ps3_hardreset_handle_finish(struct ps3_instance *instance) +S32 ps3_hardreset_handle_finish(struct ps3_instance *instance) { - unsigned int cur_state = 0; - int ret = PS3_SUCCESS; + U32 cur_state = 0; + S32 ret = PS3_SUCCESS; cur_state = ps3_atomic_read(&instance->state_machine.state); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_FINISH_STATE_NOOPERATIONAL, &cur_state) if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { ps3_instance_state_transfer_to_dead(instance); LOG_ERROR("hno:%u hard reset NOK! cur_state:%s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), + namePS3InstanceState(cur_state)); return -PS3_FAILED; } + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_15, instance) ret = ps3_recovery_complete(instance); - if (ret != PS3_SUCCESS) { - LOG_WARN( - "hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), - ret); + if(ret != PS3_SUCCESS){ + LOG_WARN("hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state),ret); return ret; } ps3_hard_recovery_state_finish(instance); LOG_INFO("hno:%u hard reset finish! cur_state:%s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); return PS3_SUCCESS; } -int ps3_hardreset_handle_offline(struct ps3_instance *instance) +S32 ps3_hardreset_handle_offline(struct ps3_instance *instance) { - unsigned int cur_state = 0; - + U32 cur_state = 0; ps3_instance_state_transfer_to_dead(instance); cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_ERROR("hno:%u hard reset finish! cur_state:%s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); return PS3_SUCCESS; } -int ps3_softreset_handle_pre(struct ps3_instance *instance) +S32 ps3_softreset_handle_pre(struct ps3_instance *instance) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; ps3_cmd_reset_flag_set(instance, PS3_CMD_FLAG_SOFTRESET); ret = ps3_ioc_state_transfer_wait_to_running(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u soft recovery to running failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - ret = ps3_soft_recovery_cmd_reply_polling_check( - instance, PS3_SOFT_RESET_WAIT_TIMEOUT); + ret = ps3_soft_recovery_cmd_reply_polling_check(instance, PS3_SOFT_RESET_WAIT_TIMEOUT); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u pending mgr cmd no reply all!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ret = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_INFO("hno:%u soft recovery to pre-operational success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: return ret; } -int ps3_softreset_handle_post(struct ps3_instance *instance) +S32 ps3_softreset_handle_post(struct ps3_instance *instance) { - int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - if (!ps3_ioc_recovery_count_get( - instance, - &instance->recovery_context->ioc_recovery_count)) { + if (!ps3_ioc_recovery_count_get(instance, + &instance->recovery_context->ioc_recovery_count)) { ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - LOG_INFO( - "hno:%u pre-operational to operational success!,reset count:%d\n", - PS3_HOST(instance), - instance->recovery_context->ioc_recovery_count); + LOG_INFO("hno:%u pre-operational to operational success!,reset count:%d\n", + PS3_HOST(instance), instance->recovery_context->ioc_recovery_count); l_out: return ret; } -int ps3_hard_recovery_request_with_retry(struct ps3_instance *instance) +S32 ps3_hard_recovery_request_with_retry(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int count = 0; + S32 ret = PS3_SUCCESS; + U32 count = 0; while ((ret = ps3_hard_recovery_request(instance)) == -PS3_RETRY) { if (count++ == ps3_use_hard_reset_max_retry()) { @@ -3883,10 +3559,10 @@ int ps3_hard_recovery_request_with_retry(struct ps3_instance *instance) return ret; } -int ps3_recovery_request_with_retry(struct ps3_instance *instance) +S32 ps3_recovery_request_with_retry(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - unsigned int count = 0; + S32 ret = PS3_SUCCESS; + U32 count = 0; while ((ret = ps3_recovery_request(instance)) == -PS3_RETRY) { if (count++ == ps3_use_hard_reset_max_retry()) { diff --git a/drivers/scsi/linkdata/ps3stor/ps3_recovery.h b/drivers/scsi/linkdata/ps3stor/ps3_recovery.h index 08662cf0c4ab..a046d41f2e60 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_recovery.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_recovery.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_RECOVERY_H_ #define _PS3_RECOVERY_H_ @@ -28,8 +27,8 @@ enum { }; enum { - PS3_HOST_RESET_INIT = 0, - PS3_HOST_RESET_START = 1, + PS3_HOST_RESET_INIT = 0, + PS3_HOST_RESET_START = 1, PS3_HOST_RESET_HARD_RESET_DONE = 2, }; enum { @@ -39,11 +38,11 @@ enum { }; #define PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL (5) #define PS3_RECOVERY_CONTEXT_MAX_NUM (8) -#define PS3_RECOVERY_IRQ_NAME_MAX_LENGTH (48) +#define PS3_RECOVERY_IRQ_NAME_MAX_LENTH (48) #define PS3_RECOVERY_WHILE_PRINT_REACH_TIME (10 * 1000) enum { - PS3_HEARTBEAT_NULL = 0, + PS3_HEARTBEAT_NULL = 0, PS3_HEARTBEAT_HARDRESET_DECIDE = 1, PS3_HEARTBEAT_HARDRESET_RECOVERY = 2, PS3_HEARTBEAT_HARDRESET_RETRY = 3, @@ -54,68 +53,61 @@ enum { PS3_IOC_CAN_HARDRESET = 1, }; -struct ps3_recovery_context { - struct mutex free_cmd_lock; - spinlock_t recovery_lock; - spinlock_t ps3_hardreset_lock; - unsigned int ioc_recovery_count; - unsigned char recovery_state; - unsigned char reserved1; - unsigned char host_reset_state; - unsigned char heartbeat_recovery; +struct ps3_recovery_context +{ + ps3_mutex free_cmd_lock; + ps3_spinlock recovery_lock; + ps3_spinlock ps3_hardreset_lock; + U32 ioc_recovery_count; + U8 recovery_state; + U8 reserved1; + U8 host_reset_state; + U8 heartbeat_recovery; #ifndef _WINDOWS struct workqueue_struct *recovery_wq; - char recovery_wq_name[20]; + S8 recovery_wq_name[20]; struct work_struct recovery_work; #else struct ps3_worker recovery_work; #endif struct ps3_instance *instance[2]; struct ps3_instance *work_instance; - int recovery_result; - unsigned int hardreset_count; - unsigned char parall_hardreset_state; - unsigned char instance_change; - unsigned char reserved[6]; - atomic_t hardreset_ref; - struct mutex ps3_watchdog_recovery_mutex; + S32 recovery_result; + U32 hardreset_count; + U8 parall_hardreset_state; + U8 instance_change; + U8 reserved[6]; + ps3_atomic32 hardreset_ref; + ps3_mutex ps3_watchdog_recovery_mutex; }; -#define PS3_IS_INTERRUPT_SOFT_RECOVERY(instance) \ +#define PS3_IS_INTERRUPT_SOFT_RECOVERY(instance) \ (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) -#define PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) \ - (PS3_IS_INSTANCE_PROBE(instance) || \ - PS3_IS_INSTANCE_REMOVE(instance) || \ - PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance)) +#define PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) (PS3_IS_INSTANCE_PROBE(instance) || \ + PS3_IS_INSTANCE_REMOVE(instance) || PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance)) -#define PS3_IS_INSTANCE_PROBE(instance) \ - (!(instance)->state_machine.is_suspend && \ - !((instance)->is_probe_finish || (instance)->is_probe_failed)) +#define PS3_IS_INSTANCE_PROBE(instance) (!(instance)->state_machine.is_suspend && !((instance)->is_probe_finish || \ + (instance)->is_probe_failed)) -#define PS3_IS_INSTANCE_REMOVE(instance) \ - (!(instance)->state_machine.is_suspend && \ - ((instance)->is_probe_finish || (instance)->is_probe_failed) && \ - !(instance)->state_machine.is_load) +#define PS3_IS_INSTANCE_REMOVE(instance) (!(instance)->state_machine.is_suspend && ((instance)->is_probe_finish || \ + (instance)->is_probe_failed) && !(instance)->state_machine.is_load) -#define PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(instance) \ - (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) || \ - ((instance)->peer_instance != NULL && \ - PS3_IS_INSTANCE_NOT_LOAD_NORMAL((instance)->peer_instance))) +#define PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(instance) (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) || \ + ((instance)->peer_instance != NULL && PS3_IS_INSTANCE_NOT_LOAD_NORMAL((instance)->peer_instance))) -#define PS3_IS_INSTANCE_PROBE_INIT(instance) \ - (!((instance)->is_probe_finish || (instance)->is_probe_failed) && \ - !(instance)->state_machine.is_load) +#define PS3_IS_INSTANCE_PROBE_INIT(instance) (!((instance)->is_probe_finish || (instance)->is_probe_failed) && \ + !(instance)->state_machine.is_load) -#define PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance) \ - (PS3_IS_INSTANCE_SUSPEND(instance) || PS3_IS_INSTANCE_RESUME(instance)) +#define PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance) (PS3_IS_INSTANCE_SUSPEND(instance) || \ + PS3_IS_INSTANCE_RESUME(instance)) -#define PS3_IS_INSTANCE_SUSPEND(instance) \ - ((instance)->state_machine.is_suspend && (instance)->is_suspend) +#define PS3_IS_INSTANCE_SUSPEND(instance) ((instance)->state_machine.is_suspend && \ + (instance)->is_suspend) -#define PS3_IS_INSTANCE_RESUME(instance) \ - ((instance)->state_machine.is_suspend && (instance)->is_resume) +#define PS3_IS_INSTANCE_RESUME(instance) ((instance)->state_machine.is_suspend && \ + (instance)->is_resume) -int ps3_recovery_context_init(struct ps3_instance *instance); +S32 ps3_recovery_context_init(struct ps3_instance *instance); void ps3_recovery_function_init(struct ps3_instance *instance); @@ -123,44 +115,44 @@ void ps3_recovery_context_exit(struct ps3_instance *instance); void ps3_recovery_clean(struct ps3_instance *instance); -void ps3_recovery_destroy(struct ps3_instance *instance); +void ps3_recovery_destory(struct ps3_instance *instance); -int ps3_recovery_request(struct ps3_instance *instance); +S32 ps3_recovery_request(struct ps3_instance *instance); -int ps3_hard_recovery_request(struct ps3_instance *instance); +S32 ps3_hard_recovery_request(struct ps3_instance *instance); void ps3_scsi_cmd_force_stop(struct ps3_instance *instance); void ps3_mgr_cmd_force_stop(struct ps3_instance *instance); -int ps3_recovery_cancel_work_sync(struct ps3_instance *instance); +S32 ps3_recovery_cancel_work_sync(struct ps3_instance *instance); #ifndef _WINDOWS -int ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance); -int ps3_init_fail_hard_reset_with_doorbell(struct ps3_instance *instance); -unsigned char ps3_is_need_hard_reset(struct ps3_instance *instance); +S32 ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance); +S32 ps3_init_fail_hard_reset_with_doorbell(struct ps3_instance *instance); +Bool ps3_is_need_hard_reset(struct ps3_instance *instance); -void ps3_recovery_work_queue_destroy(struct ps3_instance *instance); +void ps3_recovery_work_queue_destory(struct ps3_instance *instance); #endif -int ps3_hardreset_handle_pre(struct ps3_instance *instance); +S32 ps3_hardreset_handle_pre(struct ps3_instance *instance); -int ps3_hardreset_handle_wait_ready(struct ps3_instance *instance); +S32 ps3_hardreset_handle_wait_ready(struct ps3_instance *instance); -int ps3_hardreset_handle_init_running(struct ps3_instance *instance); +S32 ps3_hardreset_handle_init_running(struct ps3_instance *instance); -int ps3_hardreset_handle_post(struct ps3_instance *instance); +S32 ps3_hardreset_handle_post(struct ps3_instance *instance); -int ps3_hardreset_handle_finish(struct ps3_instance *instance); +S32 ps3_hardreset_handle_finish(struct ps3_instance *instance); -int ps3_hardreset_handle_offline(struct ps3_instance *instance); +S32 ps3_hardreset_handle_offline(struct ps3_instance *instance); -int ps3_softreset_handle_pre(struct ps3_instance *instance); +S32 ps3_softreset_handle_pre(struct ps3_instance *instance); -int ps3_softreset_handle_post(struct ps3_instance *instance); -int ps3_hard_recovery_request_with_retry(struct ps3_instance *instance); -int ps3_recovery_request_with_retry(struct ps3_instance *instance); -irqreturn_t ps3_recovery_irq_handler(int virq, void *dev_id); -int ps3_recovery_irq_start(struct ps3_instance *instance); +S32 ps3_softreset_handle_post(struct ps3_instance *instance); +S32 ps3_hard_recovery_request_with_retry(struct ps3_instance *instance); +S32 ps3_recovery_request_with_retry(struct ps3_instance *instance); +irqreturn_t ps3_recovery_irq_handler(S32 virq, void *dev_id); +S32 ps3_recovery_irq_start(struct ps3_instance *instance); void ps3_cmd_force_stop(struct ps3_instance *instance); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.c b/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.c index 5937fd88e1fe..9b5b7c67f490 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #ifndef _WINDOWS #include @@ -11,10 +9,9 @@ #include "ps3_driver_log.h" #include "ps3_device_manager_sas.h" -static struct scsi_transport_template *ps3_sas_transport_template; -extern struct ps3_sas_node * -ps3_sas_find_node_by_sas_addr(struct ps3_instance *instance, - unsigned long long sas_addr); +static struct scsi_transport_template *ps3_sas_transport_template = NULL; +extern struct ps3_sas_node* ps3_sas_find_node_by_sas_addr( + struct ps3_instance *instance, U64 sas_addr); struct scsi_transport_template *ps3_sas_transport_get(void) { return ps3_sas_transport_template; @@ -23,24 +20,21 @@ struct scsi_transport_template *ps3_sas_transport_get(void) static inline struct ps3_instance *phy_to_ps3_instance(struct sas_phy *phy) { struct Scsi_Host *s_host = dev_to_shost(phy->dev.parent); - return (struct ps3_instance *)s_host->hostdata; } static inline struct ps3_instance *rphy_to_ps3_instance(struct sas_rphy *rphy) { struct Scsi_Host *s_host = dev_to_shost(rphy->dev.parent); - return (struct ps3_instance *)s_host->hostdata; } -static inline int ps3_sas_request_pre_check(struct ps3_instance *instance) +static inline S32 ps3_sas_request_pre_check(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; if (!instance->state_machine.is_load) { - LOG_WARN("hno:%u instance state not is_load\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u instance state not is_load\n", PS3_HOST(instance)); ret = -EFAULT; goto l_out; } @@ -51,7 +45,8 @@ static inline int ps3_sas_request_pre_check(struct ps3_instance *instance) } if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno[%u] host in pci recovery\n", PS3_HOST(instance)); + LOG_WARN("hno[%u] host in pci recovery\n", + PS3_HOST(instance)); ret = -EFAULT; goto l_out; } @@ -60,18 +55,19 @@ static inline int ps3_sas_request_pre_check(struct ps3_instance *instance) return ret; } -static inline int ps3_sas_smp_pre_check(struct ps3_instance *instance) +static inline S32 ps3_sas_smp_pre_check(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; ret = ps3_sas_request_pre_check(instance); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } LOG_INFO("hno:%u ready get semaphore\n", PS3_HOST(instance)); - if (down_interruptible( - &instance->sas_dev_context.ps3_sas_smp_semaphore)) { - LOG_WARN("hno:%u smp concurrency full\n", PS3_HOST(instance)); + if (down_interruptible(&instance->sas_dev_context.ps3_sas_smp_semaphore)) { + LOG_WARN("hno:%u smp concurrency full\n", + PS3_HOST(instance)); ret = -EFAULT; } LOG_INFO("hno:%u got semaphore\n", PS3_HOST(instance)); @@ -81,11 +77,9 @@ static inline int ps3_sas_smp_pre_check(struct ps3_instance *instance) } static inline void ps3_sas_linkerror_reqframe_build(struct ps3_cmd *cmd, - struct sas_phy *phy, - unsigned char encl_id) + struct sas_phy *phy, U8 encl_id) { - struct PS3MgrReqFrame *mgrReq = &cmd->req_frame->mgrReq; - + PS3MgrReqFrame_s *mgrReq = &cmd->req_frame->mgrReq; mgrReq->reqHead.timeout = cmd->time_out; mgrReq->reqHead.traceID = cmd->trace_id; mgrReq->reqHead.cmdType = PS3_CMD_SAS_MANAGEMENT; @@ -94,8 +88,8 @@ static inline void ps3_sas_linkerror_reqframe_build(struct ps3_cmd *cmd, mgrReq->reqHead.control = 0; mgrReq->syncFlag = 1; mgrReq->timeout = 0; - mgrReq->sgeOffset = offsetof(struct PS3MgrReqFrame, sgl) >> - PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; + mgrReq->sgeOffset = + offsetof(PS3MgrReqFrame_s, sgl) >> PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; mgrReq->sgeCount = 1; mgrReq->sgl[0].length = cpu_to_le32(sizeof(struct PS3LinkErrInfo)); mgrReq->sgl[0].addr = cpu_to_le64(cmd->ext_buf_phys); @@ -108,11 +102,11 @@ static inline void ps3_sas_linkerror_reqframe_build(struct ps3_cmd *cmd, mgrReq->value.sasMgr.startPhyID = phy->identify.phy_identifier; } -int ps3_sas_linkerrors_get(struct sas_phy *phy) +S32 ps3_sas_linkerrors_get(struct sas_phy *phy) { - int ret = 0; - int send_result = PS3_SUCCESS; - unsigned char encl_id = PS3_SAS_INVALID_ID; + S32 ret = 0; + S32 send_result = PS3_SUCCESS; + U8 encl_id = PS3_SAS_INVALID_ID; struct ps3_cmd *cmd = NULL; struct PS3LinkErrInfo *erroInfo = NULL; struct ps3_instance *instance = phy_to_ps3_instance(phy); @@ -124,24 +118,27 @@ int ps3_sas_linkerrors_get(struct sas_phy *phy) } encl_id = ps3_sas_encl_id_get(instance, phy->identify.sas_address); + INJECT_START(PS3_ERR_IJ_SAS_ENCL_ID_GET_FAILED, &encl_id) if (encl_id == PS3_SAS_INVALID_ID) { LOG_ERROR("hno:%u cannot foud PS3 node by sas_addr[%016llx]\n", - PS3_HOST(instance), phy->identify.sas_address); + PS3_HOST(instance), phy->identify.sas_address); ret = -EINVAL; goto l_no_free_cmd; } ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); + INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { - LOG_WARN_LIM( - "sas_addr[%016llx], hno:%u smp linkerror pre check NOK\n", + LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp linkerror pre check NOK\n", phy->identify.sas_address, PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENXIO; goto l_no_free_cmd; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) if (cmd == NULL) { - LOG_WARN("hno:%u not get a cmd packet\n", PS3_HOST(instance)); + LOG_WARN("hno:%u not get a cmd packet\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENOMEM; goto l_no_free_cmd; @@ -150,35 +147,36 @@ int ps3_sas_linkerrors_get(struct sas_phy *phy) cmd->time_out = PS3_SAS_TIMEOUT_SEC; cmd->is_interrupt = PS3_DRV_FALSE; - LOG_DEBUG( - "hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx] get mgr cmd succeed\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - phy->identify.sas_address); + LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx] get mgr cmd succeed\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, phy->identify.sas_address); ps3_sas_linkerror_reqframe_build(cmd, phy, encl_id); ps3_mgr_cmd_word_build(cmd); + INJECT_START(PS3_ERR_IJ_CMD_POLLING, &cmd) send_result = ps3_cmd_send_sync(instance, cmd); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); + ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret == -PS3_CMD_NO_RESP) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, + ps3_cmd_resp_status(cmd)); ret = -ETIMEDOUT; goto l_no_free_cmd; } if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, + ps3_cmd_resp_status(cmd)); ret = -EFAULT; } else { erroInfo = (struct PS3LinkErrInfo *)cmd->ext_buf; - phy->invalid_dword_count = - le32_to_cpu(erroInfo->invalidDwordCount); + phy->invalid_dword_count = le32_to_cpu(erroInfo->invalidDwordCount); phy->running_disparity_error_count = le32_to_cpu(erroInfo->runningDisparityErrCount); phy->loss_of_dword_sync_count = @@ -189,7 +187,7 @@ int ps3_sas_linkerrors_get(struct sas_phy *phy) } LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], end, ret[%d]\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, ret); + PS3_HOST(instance), cmd->trace_id, cmd->index, ret); ps3_mgr_cmd_free(instance, cmd); l_no_free_cmd: @@ -198,14 +196,13 @@ int ps3_sas_linkerrors_get(struct sas_phy *phy) return ret; } -int ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier) +S32 ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier) { - int ret = 0; + S32 ret = 0; struct ps3_instance *instance = rphy_to_ps3_instance(rphy); *identifier = 0; - LOG_DEBUG( - "hno:%u ----1---ready get encl identifier sas_addr[%016llx]\n", + LOG_DEBUG("hno:%u ----1---ready get encl identifier sas_addr[%016llx]\n", PS3_HOST(instance), rphy->identify.sas_address); ret = ps3_sas_smp_pre_check(instance); @@ -215,10 +212,10 @@ int ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier) } LOG_DEBUG("hno:%u ready get encl identifier sas_addr[%016llx]\n", - PS3_HOST(instance), rphy->identify.sas_address); + PS3_HOST(instance), rphy->identify.sas_address); - *identifier = ps3_sas_rphy_parent_sas_addr_get( - instance, rphy->identify.sas_address); + *identifier = ps3_sas_rphy_parent_sas_addr_get(instance, rphy->identify.sas_address); + INJECT_START(PS3_ERR_IJ_RPHY_PARENT_SAS_ADDR_GET_FAILED,identifier) if (*identifier == PS3_SAS_INVALID_SAS_ADDR) { ret = -ENXIO; *identifier = 0; @@ -226,19 +223,18 @@ int ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier) up(&instance->sas_dev_context.ps3_sas_smp_semaphore); l_out: - LOG_DEBUG( - "hno:%u end get encl identifier sas_addr[%016llx], identifier[%llu]\n", + LOG_DEBUG("hno:%u end get encl identifier sas_addr[%016llx], identifier[%llu]\n", PS3_HOST(instance), rphy->identify.sas_address, *identifier); return ret; } -int ps3_sas_bay_identifier_get(struct sas_rphy *rphy) +S32 ps3_sas_bay_identifier_get(struct sas_rphy *rphy) { - unsigned int solt_id = 0; + U32 solt_id = 0; struct ps3_instance *instance = rphy_to_ps3_instance(rphy); LOG_DEBUG("hno:%u ----1---ready get bay identifier sas_addr[%016llx]\n", - PS3_HOST(instance), rphy->identify.sas_address); + PS3_HOST(instance), rphy->identify.sas_address); if (ps3_sas_smp_pre_check(instance) != PS3_SUCCESS) { solt_id = -ENXIO; @@ -246,27 +242,25 @@ int ps3_sas_bay_identifier_get(struct sas_rphy *rphy) } LOG_DEBUG("hno:%u ready get bay identifier sas_addr[%016llx]\n", - PS3_HOST(instance), rphy->identify.sas_address); + PS3_HOST(instance), rphy->identify.sas_address); - if (ps3_sas_rphy_slot_get(instance, rphy->identify.sas_address, - &solt_id) != PS3_SUCCESS) { + if (ps3_sas_rphy_slot_get(instance, rphy->identify.sas_address, &solt_id) + != PS3_SUCCESS) { solt_id = -ENXIO; } up(&instance->sas_dev_context.ps3_sas_smp_semaphore); l_out: - LOG_DEBUG( - "hno:%u end get bay identifier sas_addr[%016llx], slot_id[%d]\n", + LOG_DEBUG("hno:%u end get bay identifier sas_addr[%016llx], slot_id[%d]\n", PS3_HOST(instance), rphy->identify.sas_address, solt_id); return solt_id; } static inline void ps3_sas_ctrl_reqframe_build(struct ps3_cmd *cmd, - struct sas_phy *phy, - enum PhyCtrl ctrl_code) + struct sas_phy *phy, + enum PhyCtrl ctrl_code) { - struct PS3MgrReqFrame *mgrReq = &cmd->req_frame->mgrReq; - + PS3MgrReqFrame_s *mgrReq = &cmd->req_frame->mgrReq; mgrReq->reqHead.timeout = cmd->time_out; mgrReq->reqHead.traceID = cmd->trace_id; mgrReq->reqHead.cmdType = PS3_CMD_SAS_MANAGEMENT; @@ -277,18 +271,19 @@ static inline void ps3_sas_ctrl_reqframe_build(struct ps3_cmd *cmd, mgrReq->timeout = 0; mgrReq->sgeCount = 0; - mgrReq->value.phySet.sasAddr = cpu_to_le64(phy->identify.sas_address); + mgrReq->value.phySet.sasAddr = + cpu_to_le64(phy->identify.sas_address); mgrReq->value.phySet.phyCtrl = ctrl_code; mgrReq->value.phySet.phyID = phy->identify.phy_identifier; mgrReq->value.phySet.maxLinkRate = phy->maximum_linkrate; mgrReq->value.phySet.minLinkRate = phy->minimum_linkrate; } -static inline int __ps3_sas_phy_ctrl(struct sas_phy *phy, - enum PhyCtrl ctrl_code) +static inline S32 __ps3_sas_phy_ctrl(struct sas_phy *phy, + enum PhyCtrl ctrl_code) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_instance *instance = phy_to_ps3_instance(phy); @@ -298,17 +293,19 @@ static inline int __ps3_sas_phy_ctrl(struct sas_phy *phy, goto l_out; } ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); + INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { - LOG_WARN_LIM( - "sas_addr[%016llx], hno:%u smp phyctrl pre check NOK\n", + LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp phyctrl pre check NOK\n", phy->identify.sas_address, PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENXIO; goto l_no_free_cmd; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) if (cmd == NULL) { - LOG_WARN("hno:%u not get a cmd packet\n", PS3_HOST(instance)); + LOG_WARN("hno:%u not get a cmd packet\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENOMEM; goto l_no_free_cmd; @@ -316,36 +313,38 @@ static inline int __ps3_sas_phy_ctrl(struct sas_phy *phy, cmd->time_out = PS3_SAS_TIMEOUT_SEC; cmd->is_interrupt = PS3_DRV_FALSE; - LOG_DEBUG( - "hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx] ctrl_code[%s] get mgr cmd succeed\n", + LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx] ctrl_code[%s] get mgr cmd succeed\n", PS3_HOST(instance), cmd->trace_id, cmd->index, - phy->identify.sas_address, - namePhyCtrl((enum PhyCtrl)ctrl_code)); + phy->identify.sas_address, namePhyCtrl((enum PhyCtrl)ctrl_code)); ps3_sas_ctrl_reqframe_build(cmd, phy, ctrl_code); ps3_mgr_cmd_word_build(cmd); + INJECT_START(PS3_ERR_IJ_CMD_POLLING, &cmd) send_result = ps3_cmd_send_sync(instance, cmd); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); + ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret == -PS3_CMD_NO_RESP) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, + ps3_cmd_resp_status(cmd)); ret = -ETIMEDOUT; goto l_no_free_cmd; } if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, + ps3_cmd_resp_status(cmd)); ret = -EFAULT; } LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], end, ret[%d]\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, ret); + PS3_HOST(instance), cmd->trace_id, cmd->index, ret); ps3_mgr_cmd_free(instance, cmd); l_no_free_cmd: up(&instance->sas_dev_context.ps3_sas_smp_semaphore); @@ -353,130 +352,98 @@ static inline int __ps3_sas_phy_ctrl(struct sas_phy *phy, return ret; } -int ps3_sas_phy_reset(struct sas_phy *phy, int hard_reset) +S32 ps3_sas_phy_reset(struct sas_phy *phy, int hard_reset) { - int ret = PS3_SUCCESS; enum PhyCtrl ctrl_code = hard_reset ? PS3_SAS_CTRL_RESET_HARD : PS3_SAS_CTRL_RESET; - struct sas_phy *tmp_phy = kcalloc(1, sizeof(struct sas_phy), GFP_KERNEL); - - if (tmp_phy == NULL) { - LOG_ERROR("kcalloc sas_phy fail!\n"); - ret = -ENOMEM; - goto l_out; - } - memcpy(tmp_phy, phy, sizeof(struct sas_phy)); - tmp_phy->maximum_linkrate = 0; - tmp_phy->minimum_linkrate = 0; + struct sas_phy tmp_phy = *phy; + tmp_phy.maximum_linkrate = 0; + tmp_phy.minimum_linkrate = 0; LOG_INFO("enter phy reset, phy sas_addr[%016llx], is_hard[%d]\n", - phy->identify.sas_address, hard_reset); - ret = __ps3_sas_phy_ctrl(tmp_phy, ctrl_code); - kfree(tmp_phy); - tmp_phy = NULL; - -l_out: - return ret; + phy->identify.sas_address, hard_reset); + return __ps3_sas_phy_ctrl(&tmp_phy, ctrl_code); } -int ps3_sas_phy_enable(struct sas_phy *phy, int enable) +S32 ps3_sas_phy_enable(struct sas_phy *phy, int enable) { - int ret = PS3_SUCCESS; enum PhyCtrl ctrl_code = enable ? PS3_SAS_CTRL_RESET : PS3_SAS_CTRL_DISABLE; - struct sas_phy *tmp_phy = kcalloc(1, sizeof(struct sas_phy), GFP_KERNEL); - - if (tmp_phy == NULL) { - LOG_ERROR("kcalloc sas_phy fail!\n"); - ret = -ENOMEM; - goto l_out; - } - memcpy(tmp_phy, phy, sizeof(struct sas_phy)); - tmp_phy->maximum_linkrate = 0; - tmp_phy->minimum_linkrate = 0; + struct sas_phy tmp_phy = *phy; + tmp_phy.maximum_linkrate = 0; + tmp_phy.minimum_linkrate = 0; LOG_INFO("enter phy enable, phy sas_addr[%016llx], is_enable[%d]\n", - phy->identify.sas_address, enable); - ret = __ps3_sas_phy_ctrl(tmp_phy, ctrl_code); - kfree(tmp_phy); - tmp_phy = NULL; - -l_out: - return ret; + phy->identify.sas_address, enable); + return __ps3_sas_phy_ctrl(&tmp_phy, ctrl_code); } -int ps3_sas_update_phy_info(struct sas_phy *phy) +S32 ps3_sas_update_phy_info(struct sas_phy *phy) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct PS3SasMgr sas_req_param; struct ps3_instance *instance = phy_to_ps3_instance(phy); - struct PS3PhyInfo *phy_info = - instance->sas_dev_context.ps3_sas_phy_buff; - unsigned long flags = 0; + struct PS3PhyInfo *phy_info = instance->sas_dev_context.ps3_sas_phy_buff; + ULong flags = 0; - struct ps3_sas_node *sas_node = ps3_sas_find_node_by_sas_addr( + struct ps3_sas_node* sas_node = ps3_sas_find_node_by_sas_addr( instance, phy->identify.sas_address); memset(&sas_req_param, 0, sizeof(sas_req_param)); sas_req_param.enclID = sas_node->encl_id; - sas_req_param.sasAddr = cpu_to_le64(sas_node->sas_address); + sas_req_param.sasAddr =cpu_to_le64(sas_node->sas_address); sas_req_param.startPhyID = phy->identify.phy_identifier; sas_req_param.phyCount = 1; LOG_DEBUG("hno:%u ready get phys[%d] of encl_id[%d] !\n", - PS3_HOST(instance), phy->identify.phy_identifier, - sas_req_param.enclID); + PS3_HOST(instance), phy->identify.phy_identifier, sas_req_param.enclID); memset(phy_info, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_phy_get(instance, &sas_req_param); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u get phy info NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u get phy info NOK\n", + PS3_HOST(instance)); goto l_out; } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); - LOG_INFO_IN_IRQ(instance, - "hno:%u ready update phy %d of encl_id[%d]!\n", - PS3_HOST(instance), phy->identify.phy_identifier, - sas_req_param.enclID); - - ps3_sas_node_phy_update(instance, - &sas_node->phys[phy->identify.phy_identifier], - &phy_info[0]); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, - flags); + LOG_INFO_IN_IRQ(instance, "hno:%u ready update phy %d of encl_id[%d]!\n", + PS3_HOST(instance), phy->identify.phy_identifier, sas_req_param.enclID); + + ps3_sas_node_phy_update(instance, &sas_node->phys[phy->identify.phy_identifier], &phy_info[0]); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); l_out: return ret; } -int ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates) +S32 ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates) { - int ret = PS3_SUCCESS; - unsigned char tmp_min = 0; - unsigned char tmp_max = 0; - - LOG_INFO("enter link rate set, phy sas_addr[%016llx],\n" - "\tminimum_linkrate[%d], maximum_linkrate[%d]\n", - phy->identify.sas_address, rates->minimum_linkrate, - rates->maximum_linkrate); - - if (!rates->minimum_linkrate) + S32 ret = PS3_SUCCESS; + U8 tmp_min = 0; + U8 tmp_max = 0; + LOG_INFO("enter link rate set, phy sas_addr[%016llx]," + "minimum_linkrate[%d], maximum_linkrate[%d]\n", + phy->identify.sas_address, rates->minimum_linkrate, + rates->maximum_linkrate); + + if (!rates->minimum_linkrate) { rates->minimum_linkrate = phy->minimum_linkrate; - else if (rates->minimum_linkrate < phy->minimum_linkrate_hw) + } else if (rates->minimum_linkrate < phy->minimum_linkrate_hw) { rates->minimum_linkrate = phy->minimum_linkrate_hw; + } - if (!rates->maximum_linkrate) + if (!rates->maximum_linkrate) { rates->maximum_linkrate = phy->maximum_linkrate; - else if (rates->maximum_linkrate > phy->maximum_linkrate_hw) + } else if (rates->maximum_linkrate > phy->maximum_linkrate_hw) { rates->maximum_linkrate = phy->maximum_linkrate_hw; + } if (rates->maximum_linkrate < phy->minimum_linkrate || - rates->minimum_linkrate > phy->maximum_linkrate) { - LOG_ERROR( - "linkrate set param NOK, %d phy sas_addr[%016llx],\n" - "\trate minimum_linkrate[%d] > cur maximum_linkrate[%d] or\n" - "\trate maximum_linkrate[%d] < cur minimum_linkrate[%d]\n", + rates->minimum_linkrate> phy->maximum_linkrate) { + LOG_ERROR("linkrate set param NOK, %d phy sas_addr[%016llx]," + "rate minimum_linkrate[%d] > cur maximum_linkrate[%d] or" + "rate maximum_linkrate[%d] < cur minimum_linkrate[%d]\n", phy->identify.phy_identifier, phy->identify.sas_address, rates->minimum_linkrate, phy->maximum_linkrate, rates->maximum_linkrate, phy->minimum_linkrate); @@ -492,10 +459,10 @@ int ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates) ret = __ps3_sas_phy_ctrl(phy, PS3_SAS_CTRL_RESET); if (ret != PS3_SUCCESS) { - LOG_ERROR("linkrate NOK, phy sas_addr[%016llx],\n" - "\tminimum_linkrate[%d], maximum_linkrate[%d]\n", - phy->identify.sas_address, rates->minimum_linkrate, - rates->maximum_linkrate); + LOG_ERROR("linkrate NOK, phy sas_addr[%016llx]," + "minimum_linkrate[%d], maximum_linkrate[%d]\n", + phy->identify.sas_address, rates->minimum_linkrate, + rates->maximum_linkrate); phy->minimum_linkrate = tmp_min; phy->maximum_linkrate = tmp_max; @@ -508,11 +475,9 @@ int ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates) } static inline void ps3_sas_smp_reqframe_build(struct ps3_cmd *cmd, - unsigned long long sas_addr, - unsigned int req_data_len) + U64 sas_addr, U32 req_data_len) { - struct PS3MgrReqFrame *mgrReq = &cmd->req_frame->mgrReq; - + PS3MgrReqFrame_s *mgrReq = &cmd->req_frame->mgrReq; mgrReq->reqHead.timeout = cmd->time_out; mgrReq->reqHead.traceID = cmd->trace_id; mgrReq->reqHead.cmdType = PS3_CMD_SAS_MANAGEMENT; @@ -522,8 +487,8 @@ static inline void ps3_sas_smp_reqframe_build(struct ps3_cmd *cmd, mgrReq->syncFlag = 1; mgrReq->timeout = 0; - mgrReq->sgeOffset = offsetof(struct PS3MgrReqFrame, sgl) >> - PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; + mgrReq->sgeOffset = + offsetof(PS3MgrReqFrame_s, sgl) >> PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; mgrReq->sgeCount = 1; mgrReq->sgl[0].length = cpu_to_le32(cmd->instance->cmd_context.ext_buf_size); @@ -532,19 +497,17 @@ static inline void ps3_sas_smp_reqframe_build(struct ps3_cmd *cmd, mgrReq->sgl[0].ext = 0; mgrReq->value.sasMgr.sasAddr = cpu_to_le64(sas_addr); - mgrReq->value.sasMgr.reqLen = - cpu_to_le16(req_data_len - PS3_SMP_CRC_LEN); + mgrReq->value.sasMgr.reqLen = cpu_to_le16(req_data_len - PS3_SMP_CRC_LEN); } -static inline void show_smp(unsigned char *data, unsigned short len) +static inline void show_smp(U8 *data, U16 len) { - unsigned short i = 0; - char tmp_buf[256] = { 0 }; - char *p_tmp = tmp_buf; - + U16 i = 0; + S8 tmp_buf[256] = {0}; + S8 *p_tmp = tmp_buf; LOG_DEBUG("smp frame data start\n"); while (len != 0) { - memset(tmp_buf, 0, sizeof(char) * 256); + memset(tmp_buf, 0, sizeof(S8) * 256); for (i = 0; i < 32 && len != 0; i++, len--) { snprintf(p_tmp, 4, " %02x", *data++); p_tmp += 3; @@ -556,42 +519,41 @@ static inline void show_smp(unsigned char *data, unsigned short len) LOG_DEBUG("smp frame data end\n"); } -#if defined(PS3_SAS_SMP_RETURN) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,14,0) -static inline unsigned int ps3_sas_req_to_ext_buf(struct ps3_instance *instance, - struct request *req, - void *ext_buf) +static inline U32 ps3_sas_req_to_ext_buf(struct ps3_instance *instance, + struct request *req, void *ext_buf) { -#if defined(PS3_SYPPORT_BIO_ITER) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) struct bio_vec bvec; struct bvec_iter iter; #else struct bio_vec *bvec = NULL; - unsigned int i = 0; + U32 i = 0; #endif - unsigned int req_len = 0; + U32 req_len = 0; + INJECT_START(PS3_ERR_IJ_SAS_REQ_EXT_BUF_INVALLID, req) if (unlikely(blk_rq_bytes(req) > instance->cmd_context.ext_buf_size)) { - LOG_ERROR( - "hno:%u request is too big!(req_len:%d > ext_buf_len:%d\n", + LOG_ERROR("hno:%u request is too big!(req_len:%d > ext_buf_len:%d\n", PS3_HOST(instance), blk_rq_bytes(req), instance->cmd_context.ext_buf_size); goto l_out; } -#if defined(PS3_SYPPORT_BIO_ITER) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) bio_for_each_segment(bvec, req->bio, iter) { - memcpy((unsigned char *)ext_buf + req_len, - page_address(bvec.bv_page) + bvec.bv_offset, - bvec.bv_len); + memcpy((U8*)ext_buf + req_len, + page_address(bvec.bv_page) + bvec.bv_offset, + bvec.bv_len); req_len += bvec.bv_len; } #else bio_for_each_segment(bvec, req->bio, i) { - memcpy((unsigned char *)ext_buf + req_len, - page_address(bvec->bv_page) + bvec->bv_offset, - bvec->bv_len); + memcpy((U8*)ext_buf + req_len, + page_address(bvec->bv_page) + bvec->bv_offset, + bvec->bv_len); req_len += bvec->bv_len; } #endif @@ -600,76 +562,78 @@ static inline unsigned int ps3_sas_req_to_ext_buf(struct ps3_instance *instance, return req_len; } -static inline int ps3_sas_ext_buf_to_rsp(struct ps3_instance *instance, - struct request *req, void *ext_buf) +static inline S32 ps3_sas_ext_buf_to_rsp(struct ps3_instance *instance, + struct request *req, void *ext_buf) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct request *rsp = req->next_rq; -#if defined(PS3_SYPPORT_BIO_ITER) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) struct bio_vec bvec; struct bvec_iter iter; #else struct bio_vec *bvec = NULL; - unsigned int i = 0; + U32 i = 0; #endif - unsigned int offset = 0; - unsigned short rsq_data_len = 0; - unsigned short smp_len = 0; + U32 offset = 0; + U16 rsq_data_len = 0; + U16 smp_len = 0; + INJECT_START(PS3_ERR_IJ_EXT_BUF_TO_RSP_INVALLID, &rsp) if (rsp == NULL) { ret = -PS3_FAILED; LOG_ERROR("hno:%u rsp == NULL\n", PS3_HOST(instance)); goto l_out; } - rsq_data_len = - min(blk_rq_bytes(rsp), instance->cmd_context.ext_buf_size); + rsq_data_len = min(blk_rq_bytes(rsp), instance->cmd_context.ext_buf_size); - smp_len = ((unsigned char *)ext_buf)[3] * 4 + 4; + smp_len = ((U8*)ext_buf)[3] * 4 + 4; rsp->resid_len -= smp_len; LOG_DEBUG("hno:%u smp frame len[%d], rsq_data_len[%d]\n", - PS3_HOST(instance), smp_len, rsq_data_len); + PS3_HOST(instance), smp_len, rsq_data_len); rsq_data_len = min(smp_len, rsq_data_len); - show_smp((unsigned char *)ext_buf, rsq_data_len); -#if defined(PS3_SYPPORT_BIO_ITER) + show_smp((U8*)ext_buf, rsq_data_len); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) bio_for_each_segment(bvec, rsp->bio, iter) { if (rsq_data_len <= bvec.bv_len) { memcpy(page_address(bvec.bv_page) + bvec.bv_offset, - (unsigned char *)ext_buf + offset, rsq_data_len); + (U8*)ext_buf + offset, rsq_data_len); break; + } else { + memcpy(page_address(bvec.bv_page) + bvec.bv_offset, + (U8*)ext_buf + offset, bvec.bv_len); + rsq_data_len -= bvec.bv_len; } - memcpy(page_address(bvec.bv_page) + bvec.bv_offset, - (unsigned char *)ext_buf + offset, bvec.bv_len); - rsq_data_len -= bvec.bv_len; offset += bvec.bv_len; } #else bio_for_each_segment(bvec, rsp->bio, i) { if (rsq_data_len <= bvec->bv_len) { memcpy(page_address(bvec->bv_page) + bvec->bv_offset, - (unsigned char *)ext_buf + offset, rsq_data_len); + (U8*)ext_buf + offset, rsq_data_len); break; + } else { + memcpy(page_address(bvec->bv_page) + bvec->bv_offset, + (U8*)ext_buf + offset, bvec->bv_len); + rsq_data_len -= bvec->bv_len; } - memcpy(page_address(bvec->bv_page) + bvec->bv_offset, - (unsigned char *)ext_buf + offset, bvec->bv_len); - rsq_data_len -= bvec->bv_len; offset += bvec->bv_len; } #endif l_out: return ret; } -int ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, - struct request *req) +S32 ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, + struct request *req) { - int ret = -PS3_FAILED; - int send_result = PS3_SUCCESS; + S32 ret = -PS3_FAILED; + S32 send_result = PS3_SUCCESS; struct ps3_instance *instance = (struct ps3_instance *)shost->hostdata; struct ps3_cmd *cmd = NULL; - unsigned int req_data_len = 0; - unsigned long long sas_addr = 0; + U32 req_data_len = 0; + U64 sas_addr = 0; struct ps3_sas_node *ps3_sas_node = NULL; ret = ps3_sas_smp_pre_check(instance); @@ -678,28 +642,31 @@ int ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, goto l_out; } - sas_addr = (rphy) ? (rphy->identify.sas_address) : - (instance->sas_dev_context.ps3_hba_sas.sas_address); + sas_addr = (rphy) ? (rphy->identify.sas_address) : (instance->sas_dev_context.ps3_hba_sas.sas_address); ps3_sas_node = ps3_sas_find_node_by_sas_addr(instance, sas_addr); + INJECT_START(PS3_ERR_IJ_SAS_NODE_NOT_FOUND, &ps3_sas_node) if (ps3_sas_node == NULL) { - LOG_ERROR("hno:%u cannot find node[%llx] !\n", - PS3_HOST(instance), sas_addr); - up(&instance->sas_dev_context.ps3_sas_smp_semaphore); - ret = -EFAULT; - goto l_out; + LOG_ERROR("hno:%u cannot find node[%llx] !\n", + PS3_HOST(instance), sas_addr); + up(&instance->sas_dev_context.ps3_sas_smp_semaphore); + ret = -EFAULT; + goto l_out; } ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); + INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp pre check NOK\n", - sas_addr, PS3_HOST(instance)); + sas_addr, PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -EFAULT; goto l_no_free_cmd; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) if (cmd == NULL) { - LOG_WARN("hno:%u not get a cmd packet\n", PS3_HOST(instance)); + LOG_WARN("hno:%u not get a cmd packet\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENOMEM; goto l_no_free_cmd; @@ -714,10 +681,8 @@ int ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, goto l_out_failed; } - LOG_DEBUG( - "hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx], len[%u] send smp req\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, sas_addr, - req_data_len); + LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx], len[%u] send smp req\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, sas_addr, req_data_len); ps3_sas_smp_reqframe_build(cmd, sas_addr, req_data_len); ps3_mgr_cmd_word_build(cmd); @@ -725,36 +690,40 @@ int ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); + ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret == -PS3_CMD_NO_RESP) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, + ps3_cmd_resp_status(cmd)); ret = -ETIMEDOUT; goto l_no_free_cmd; } if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, + ps3_cmd_resp_status(cmd)); ret = -ENXIO; - if (ret == -PS3_TIMEOUT) + if (ret == -PS3_TIMEOUT) { ret = -ETIMEDOUT; + } goto l_out_failed; } ret = ps3_sas_ext_buf_to_rsp(instance, req, cmd->ext_buf); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u %d smp response NOK CFID[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID); ret = -EINVAL; goto l_out_failed; } LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], end, ret[%d]\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, ret); + PS3_HOST(instance), cmd->trace_id, cmd->index, ret); l_out_failed: ps3_mgr_cmd_free(instance, cmd); l_no_free_cmd: @@ -764,60 +733,55 @@ int ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, } #else -static inline unsigned int ps3_sas_req_to_ext_buf(struct ps3_instance *instance, - struct bsg_buffer *req_buf, - void *ext_buf) +static inline U32 ps3_sas_req_to_ext_buf(struct ps3_instance *instance, + struct bsg_buffer *req_buf, void *ext_buf) { - unsigned int req_len = 0; + U32 req_len = 0; - if (unlikely(req_buf->payload_len > - instance->cmd_context.ext_buf_size)) { - LOG_ERROR( - "hno:%u request is too big!(req_len:%d > ext_buf_len:%d\n", + if (unlikely(req_buf->payload_len > instance->cmd_context.ext_buf_size)) { + LOG_ERROR("hno:%u request is too big!(req_len:%d > ext_buf_len:%d\n", PS3_HOST(instance), req_buf->payload_len, instance->cmd_context.ext_buf_size); goto l_out; } req_len = sg_copy_to_buffer(req_buf->sg_list, req_buf->sg_cnt, ext_buf, - req_buf->payload_len); + req_buf->payload_len); l_out: return req_len; } -static inline unsigned int ps3_sas_ext_buf_to_rsp(struct ps3_instance *instance, - struct bsg_buffer *rsp_buf, - void *ext_buf) +static inline U32 ps3_sas_ext_buf_to_rsp(struct ps3_instance *instance, + struct bsg_buffer *rsp_buf, void *ext_buf) { - unsigned short rsq_data_len = 0; - unsigned short smp_len = 0; + U16 rsq_data_len = 0; + U16 smp_len = 0; - rsq_data_len = - min(rsp_buf->payload_len, instance->cmd_context.ext_buf_size); + rsq_data_len = min(rsp_buf->payload_len, instance->cmd_context.ext_buf_size); - smp_len = ((unsigned char *)ext_buf)[3] * 4 + 4; + smp_len = ((U8*)ext_buf)[3] * 4 + 4; LOG_DEBUG("hno:%u smp frame len[%d], rsq_data_len[%d]\n", - PS3_HOST(instance), smp_len, rsq_data_len); + PS3_HOST(instance), smp_len, rsq_data_len); rsq_data_len = min(smp_len, rsq_data_len); - show_smp((unsigned char *)ext_buf, rsq_data_len); + show_smp((U8*)ext_buf, rsq_data_len); sg_copy_from_buffer(rsp_buf->sg_list, rsp_buf->sg_cnt, ext_buf, - rsp_buf->payload_len); + rsp_buf->payload_len); return rsq_data_len; } void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, - struct sas_rphy *rphy) + struct sas_rphy *rphy) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_instance *instance = (struct ps3_instance *)shost->hostdata; struct ps3_cmd *cmd = NULL; - unsigned int req_data_len = 0; - unsigned int resp_len = 0; - unsigned long long sas_addr = 0; + U32 req_data_len = 0; + U32 resp_len = 0; + U64 sas_addr = 0; struct ps3_sas_node *ps3_sas_node = NULL; ret = ps3_sas_smp_pre_check(instance); @@ -826,20 +790,19 @@ void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, goto l_out; } - sas_addr = (rphy) ? (rphy->identify.sas_address) : - (instance->sas_dev_context.ps3_hba_sas.sas_address); + sas_addr = (rphy) ? (rphy->identify.sas_address) : (instance->sas_dev_context.ps3_hba_sas.sas_address); ps3_sas_node = ps3_sas_find_node_by_sas_addr(instance, sas_addr); if (ps3_sas_node == NULL) { - LOG_ERROR("hno:%u cannot find node[%llx] !\n", - PS3_HOST(instance), sas_addr); - up(&instance->sas_dev_context.ps3_sas_smp_semaphore); - ret = -EFAULT; - goto l_out; + LOG_ERROR("hno:%u cannot find node[%llx] !\n", + PS3_HOST(instance), sas_addr); + up(&instance->sas_dev_context.ps3_sas_smp_semaphore); + ret = -EFAULT; + goto l_out; } ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp pre check NOK\n", - sas_addr, PS3_HOST(instance)); + sas_addr, PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -EFAULT; goto l_no_free_cmd; @@ -847,7 +810,7 @@ void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, cmd = ps3_mgr_cmd_alloc(instance); if (cmd == NULL) { LOG_WARN("hno:%u Failed to get a cmd packet\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENOMEM; goto l_no_free_cmd; @@ -855,18 +818,15 @@ void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, cmd->time_out = PS3_SAS_TIMEOUT_SEC; cmd->is_interrupt = PS3_DRV_FALSE; - req_data_len = ps3_sas_req_to_ext_buf(instance, &job->request_payload, - cmd->ext_buf); + req_data_len = ps3_sas_req_to_ext_buf(instance, &job->request_payload, cmd->ext_buf); if (req_data_len == 0) { ret = -ENOMEM; ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); goto l_out_failed; } - LOG_DEBUG( - "hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx], len[%u] send smp req\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, sas_addr, - req_data_len); + LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx], len[%u] send smp req\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, sas_addr, req_data_len); ps3_sas_smp_reqframe_build(cmd, sas_addr, req_data_len); ps3_mgr_cmd_word_build(cmd); @@ -874,28 +834,30 @@ void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); + ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret == -PS3_CMD_NO_RESP) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, + ps3_cmd_resp_status(cmd)); ret = -ETIMEDOUT; goto l_no_free_cmd; } if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, + ps3_cmd_resp_status(cmd)); ret = -ENXIO; goto l_out_failed; } - resp_len = ps3_sas_ext_buf_to_rsp(instance, &job->reply_payload, - cmd->ext_buf); + resp_len = ps3_sas_ext_buf_to_rsp(instance, &job->reply_payload, cmd->ext_buf); LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], end, ret[%d]\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, ret); + PS3_HOST(instance), cmd->trace_id, cmd->index, ret); l_out_failed: ps3_mgr_cmd_free(instance, cmd); l_no_free_cmd: @@ -905,32 +867,33 @@ void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, } #endif -int ps3_sas_attach_transport(void) +S32 ps3_sas_attach_transport(void) { - int ret = PS3_SUCCESS; - + S32 ret = PS3_SUCCESS; static struct sas_function_template ps3_sas_transport_functions = { - .get_linkerrors = ps3_sas_linkerrors_get, + .get_linkerrors = ps3_sas_linkerrors_get, .get_enclosure_identifier = ps3_sas_enclosure_identifier_get, - .get_bay_identifier = ps3_sas_bay_identifier_get, - .phy_reset = ps3_sas_phy_reset, - .phy_enable = ps3_sas_phy_enable, - .set_phy_speed = ps3_sas_linkrates_set, - .smp_handler = ps3_sas_smp_handler, + .get_bay_identifier = ps3_sas_bay_identifier_get, + .phy_reset = ps3_sas_phy_reset, + .phy_enable = ps3_sas_phy_enable, + .set_phy_speed = ps3_sas_linkrates_set, + .smp_handler = ps3_sas_smp_handler, }; ps3_sas_transport_template = sas_attach_transport(&ps3_sas_transport_functions); - if (!ps3_sas_transport_template) + if (!ps3_sas_transport_template) { ret = -PS3_FAILED; + } return ret; } void ps3_sas_release_transport(void) { - if (ps3_sas_transport_template != NULL) { + if(ps3_sas_transport_template != NULL) { sas_release_transport(ps3_sas_transport_template); ps3_sas_transport_template = NULL; } } #endif + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.h b/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.h index 01e400d9ced4..5b305d43933f 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.h @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ #ifndef _WINDOWS #ifndef _PS3_SAS_TRANSPORT_H_ @@ -10,35 +8,34 @@ #include #include "ps3_htp.h" -#include "ps3_kernel_version.h" #define PS3_SAS_TIMEOUT_SEC (40) #define PS3_SMP_CRC_LEN (4) struct scsi_transport_template *ps3_sas_transport_get(void); -int ps3_sas_attach_transport(void); +S32 ps3_sas_attach_transport(void); void ps3_sas_release_transport(void); -int ps3_sas_linkerrors_get(struct sas_phy *phy); +S32 ps3_sas_linkerrors_get(struct sas_phy *phy); -int ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier); +S32 ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier); -int ps3_sas_bay_identifier_get(struct sas_rphy *rphy); +S32 ps3_sas_bay_identifier_get(struct sas_rphy *rphy); -int ps3_sas_phy_reset(struct sas_phy *phy, int hard_reset); +S32 ps3_sas_phy_reset(struct sas_phy *phy, int hard_reset); -int ps3_sas_phy_enable(struct sas_phy *phy, int enable); +S32 ps3_sas_phy_enable(struct sas_phy *phy, int enable); -int ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates); +S32 ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates); -#if defined(PS3_SAS_SMP_RETURN) -int ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, - struct request *req); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,14,0) +S32 ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, + struct request *req); #else void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, - struct sas_rphy *rphy); + struct sas_rphy *rphy); #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.c b/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.c index 958c34f486ff..80101b41bf13 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #ifndef _WINDOWS #include #include @@ -30,22 +29,20 @@ #include "ps3_scsih_cmd_parse.h" #include "ps3_module_para.h" #include "ps3_r1x_write_lock.h" -#include "ps3_htp_nvme_spec.h" +#include "ps3_nvme_spec.h" #include "ps3_nvme_resp_to_scsi.h" #include "ps3_scsi_cmd_err.h" #include "ps3_ioc_manager.h" #include "ps3_mgr_channel.h" static void ps3_scsi_sense_print(struct ps3_instance *instance, - const unsigned char *sense_buffer, - unsigned char len, int CFID); + const U8 *sense_buffer, U8 len, S32 CFID); -static void ps3_internal_errcode_to_scsi(struct scsi_cmnd *s_cmd, int err_code, - unsigned int xfer_cnt, - unsigned char is_sata_jbod_mgr_cmd) +static void ps3_internal_errcode_to_scsi(struct scsi_cmnd *s_cmd, S32 err_code, + U32 xfer_cnt, Bool is_sata_jbod_mgr_cmd) { - int host_status = DID_OK; - int status = SCSI_STATUS_GOOD; + S32 host_status = DID_OK; + S32 status = SCSI_STATUS_GOOD; switch (err_code) { case PS3_STATUS_VD_OFFLINE: @@ -67,52 +64,53 @@ static void ps3_internal_errcode_to_scsi(struct scsi_cmnd *s_cmd, int err_code, case PS3_STATUS_ACCESS_BLOCK: host_status = DID_OK; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DRIVER_SENSE) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)) s_cmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS(DRIVER_SENSE); #endif status = SAM_STAT_CHECK_CONDITION; - scsi_build_sense_buffer(0, s_cmd->sense_buffer, ILLEGAL_REQUEST, - 0x20, 0x02); + scsi_build_sense_buffer(0, s_cmd->sense_buffer, + ILLEGAL_REQUEST, 0x20, 0x02); scsi_set_resid(s_cmd, scsi_bufflen(s_cmd)); break; case PS3_STATUS_REQ_ILLEGAL: host_status = DID_OK; -#if defined(PS3_SUPPORT_DRIVER_SENSE) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)) s_cmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS(DRIVER_SENSE); #endif status = SAM_STAT_CHECK_CONDITION; - scsi_build_sense_buffer(0, s_cmd->sense_buffer, ILLEGAL_REQUEST, - 0x20, 0x00); + scsi_build_sense_buffer(0, s_cmd->sense_buffer, + ILLEGAL_REQUEST, 0x20, 0x00); scsi_set_resid(s_cmd, scsi_bufflen(s_cmd)); #else scsi_build_sense_buffer(s_cmd, 0, ILLEGAL_REQUEST, 0x20, 0x02); #endif break; case PS3_STATUS_HOST_NOT_FOUND: - case PS3_STATUS_PCI_RECOVERY: + case PS3_STATUS_PCI_RECOVERY: host_status = DID_NO_CONNECT; break; case PS3_STATUS_VD_MEMBER_OFFLINE: host_status = DID_IMM_RETRY; break; case PS3_STATUS_HOST_RESET: -#if defined(PS3_DID_REQUEUE) - host_status = DID_REQUEUE; -#else - host_status = DID_RESET; -#endif + #if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 7) && (RHEL_MINOR == 3)) || \ + ((LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) && \ + (LINUX_VERSION_CODE < KERNEL_VERSION(4,4,14)))) + host_status = DID_REQUEUE; + #else + host_status = DID_RESET; + #endif break; case PS3_STATUS_UNDERRUN: - if ((scsi_bufflen(s_cmd) < xfer_cnt) && - (!is_sata_jbod_mgr_cmd)) { + if ((scsi_bufflen(s_cmd) < xfer_cnt) + && (!is_sata_jbod_mgr_cmd)) { host_status = DID_SOFT_ERROR; scsi_set_resid(s_cmd, 0); } else if (scsi_bufflen(s_cmd) == xfer_cnt) { host_status = DID_OK; } else { if (scsi_bufflen(s_cmd) > xfer_cnt) { - scsi_set_resid(s_cmd, - scsi_bufflen(s_cmd) - xfer_cnt); + scsi_set_resid(s_cmd, scsi_bufflen(s_cmd) - xfer_cnt); } else { scsi_set_resid(s_cmd, 0); } @@ -120,14 +118,11 @@ static void ps3_internal_errcode_to_scsi(struct scsi_cmnd *s_cmd, int err_code, host_status = DID_SOFT_ERROR; } else if (!xfer_cnt && s_cmd->cmnd[0] == REPORT_LUNS) { host_status = DID_OK; -#if defined(PS3_SUPPORT_DRIVER_SENSE) - s_cmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS( - DRIVER_SENSE); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)) + s_cmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS(DRIVER_SENSE); #endif status = SAM_STAT_CHECK_CONDITION; - scsi_build_sense_buffer(0, s_cmd->sense_buffer, - ILLEGAL_REQUEST, 0x20, - 0x0); + scsi_build_sense_buffer(0, s_cmd->sense_buffer, ILLEGAL_REQUEST, 0x20, 0x0); } else { host_status = DID_OK; } @@ -151,11 +146,11 @@ static void ps3_internal_errcode_to_scsi(struct scsi_cmnd *s_cmd, int err_code, } static void ps3_standard_errcode_to_scsi(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, int err_code, - union PS3RespFrame *resp_frame) + struct scsi_cmnd *s_cmd, S32 err_code, + PS3RespFrame_u *resp_frame) { - int host_status = DID_OK; - int status = SCSI_STATUS_GOOD; + S32 host_status = DID_OK; + S32 status = SCSI_STATUS_GOOD; switch (err_code) { case SCSI_STATUS_GOOD: @@ -167,7 +162,9 @@ static void ps3_standard_errcode_to_scsi(struct ps3_instance *instance, status = err_code; break; case SCSI_STATUS_RESERVATION_CONFLICT: -#if defined(PS3_DID_NEXUS_FAILURE) +#if ((defined(RHEL_MAJOR) && \ + ((RHEL_MAJOR < 9) || (RHEL_MAJOR == 9 && RHEL_MINOR < 3))) || \ + (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 38))) host_status = DID_NEXUS_FAILURE; #endif status = err_code; @@ -176,14 +173,13 @@ static void ps3_standard_errcode_to_scsi(struct ps3_instance *instance, host_status = DID_OK; status = err_code; if (resp_frame != NULL) { - memcpy(s_cmd->sense_buffer, - resp_frame->normalRespFrame.sense, - SCSI_SENSE_BUFFERSIZE); - ps3_scsi_sense_print(instance, s_cmd->sense_buffer, - SCSI_SENSE_BUFFERSIZE, - SCMD_GET_REQUEST(s_cmd)->tag); + memcpy(s_cmd->sense_buffer, resp_frame->normalRespFrame.sense, + SCSI_SENSE_BUFFERSIZE); + ps3_scsi_sense_print(instance, + s_cmd->sense_buffer, + SCSI_SENSE_BUFFERSIZE, SCMD_GET_REQUEST(s_cmd)->tag); } -#if defined(PS3_SUPPORT_DRIVER_SENSE) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)) s_cmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS(DRIVER_SENSE); #endif break; @@ -196,108 +192,92 @@ static void ps3_standard_errcode_to_scsi(struct ps3_instance *instance, } void ps3_errcode_to_scsi_status(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, unsigned int err_code, - union PS3RespFrame *resp_frame, - unsigned int xfer_cnt, struct ps3_cmd *cmd) + struct scsi_cmnd *s_cmd, U32 err_code, + PS3RespFrame_u *resp_frame, U32 xfer_cnt, struct ps3_cmd *cmd) { - unsigned char is_sata_jbod_mgr_cmd = 0; - - if (cmd != NULL) + Bool is_sata_jbod_mgr_cmd = 0; + if (cmd != NULL) { is_sata_jbod_mgr_cmd = ps3_scsih_is_sata_jbod_mgr_cmd(cmd); + } s_cmd->result = SCSI_STATUS_GOOD; if (err_code < PS3_STATUS_DEVICE_NOT_FOUND) { - ps3_standard_errcode_to_scsi(instance, s_cmd, err_code, - resp_frame); + ps3_standard_errcode_to_scsi(instance, + s_cmd, err_code, resp_frame); } else { - ps3_internal_errcode_to_scsi(s_cmd, err_code, xfer_cnt, - is_sata_jbod_mgr_cmd); + ps3_internal_errcode_to_scsi(s_cmd, err_code, xfer_cnt, is_sata_jbod_mgr_cmd); } } -static inline void ps3_err_scsi_errcode_mapping(struct ps3_cmd *cmd, - unsigned short mode, - unsigned char is_sas_direct) +static inline void ps3_err_scsi_errcode_mapping(struct ps3_cmd *cmd, U16 mode, + Bool is_sas_direct) { - unsigned char opcode = 0; - unsigned short sub_opcode = 0; - unsigned int resp_status = 0; - union PS3RespFrame *resp_frame = cmd->resp_frame; - unsigned int xfer_cnt = 0; - struct Ps3SasDirectRespFrameIU *frame = NULL; + U8 opcode = 0; + U16 sub_opcode = 0; + U32 resp_status = 0; + PS3RespFrame_u *resp_frame = cmd->resp_frame; + U32 xfer_cnt = 0; + Ps3SasDirectRespFrameIU_s *frame = NULL; ps3_scsih_cdb_opcode_get(cmd->scmd->cmnd, &opcode, &sub_opcode); - LOG_FILE_INFO("tid:0x%llx hno:%u op:0x%x sub_op:0x%x tag:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), opcode, - sub_opcode, cmd->index); - - if (ps3_err_is_resp_from_direct_cmd(mode) && - (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD)) { - resp_status = - resp_frame->sasRespFrame.status & PS3_SCSI_STATUS_MASK; + LOG_FILE_INFO("tid:0x%llx hno:%u op:0x%x sub_op:0x%x " + "tag:%u\n", cmd->trace_id, PS3_HOST(cmd->instance), + opcode, sub_opcode, cmd->index); + + if (ps3_err_is_resp_from_direct_cmd(mode) + && (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD)) { + resp_status = resp_frame->sasRespFrame.status & PS3_SCSI_STATUS_MASK; } else { - resp_status = resp_frame->normalRespFrame.respStatus & - PS3_SCSI_STATUS_MASK; + resp_status = resp_frame->normalRespFrame.respStatus & PS3_SCSI_STATUS_MASK; } xfer_cnt = ps3_scsih_xfer_cnt_get(cmd); - ps3_errcode_to_scsi_status(cmd->instance, cmd->scmd, resp_status, - resp_frame, xfer_cnt, cmd); + ps3_errcode_to_scsi_status(cmd->instance, cmd->scmd, resp_status, resp_frame, xfer_cnt, cmd); if (is_sas_direct) { frame = &resp_frame->sasRespFrame; - LOG_INFO_IN_IRQ( - cmd->instance, - "tid:0x%llx hno:%u [%u:%u:%u], op:0x%x sub_op:0x%x\n" - "\ttag:%u data_pres:%u resp_status:0x%x scmd status:0x%x\n" - "\tscmd cmd_flags:0x%llx, retries:%d, allowd:%d,\n" - "\txfer_cnt:%u scsi_buflen:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->scmd->device->channel, cmd->scmd->device->id, - cmd->io_attr.disk_id, opcode, sub_opcode, cmd->index, - frame->dataPres, frame->status, cmd->scmd->result, - (unsigned long long)SCMD_GET_REQUEST(cmd->scmd) - ->cmd_flags, - cmd->scmd->retries, cmd->scmd->allowed, xfer_cnt, - scsi_bufflen(cmd->scmd)); + LOG_INFO_IN_IRQ(cmd->instance, + "tid:0x%llx hno:%u [%u:%u:%u], op:0x%x sub_op:0x%x " + "tag:%u data_pres:%u resp_status:0x%x scmd status:0x%x " + "scmd cmd_flags:0x%llx, retries:%d, allowd:%d," + "xfer_cnt:%u scsi_buflen:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->scmd->device->channel, + cmd->scmd->device->id, cmd->io_attr.disk_id, opcode, sub_opcode, + cmd->index, frame->dataPres, frame->status, cmd->scmd->result, + (U64)SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, + cmd->scmd->retries, cmd->scmd->allowed, + xfer_cnt, scsi_bufflen(cmd->scmd)); } else { - LOG_INFO_IN_IRQ( - cmd->instance, - "tid:0x%llx hno:%u [%u:%u:%u], op:0x%x sub_op:0x%x\n" - "\ttag:%u resp_status:0x%x scmd status:0x%x\n" - "\tscmd cmd_flags:0x%llx, retries:%d, allowd:%d,\n" - "\txfer_cnt:%u scsi_buflen:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->scmd->device->channel, cmd->scmd->device->id, - cmd->io_attr.disk_id, opcode, sub_opcode, cmd->index, - resp_frame->normalRespFrame.respStatus, - cmd->scmd->result, - (unsigned long long)SCMD_GET_REQUEST(cmd->scmd) - ->cmd_flags, - cmd->scmd->retries, cmd->scmd->allowed, xfer_cnt, - scsi_bufflen(cmd->scmd)); + LOG_INFO_IN_IRQ(cmd->instance, + "tid:0x%llx hno:%u [%u:%u:%u], op:0x%x sub_op:0x%x " + "tag:%u resp_status:0x%x scmd status:0x%x" + "scmd cmd_flags:0x%llx, retries:%d, allowd:%d, " + "xfer_cnt:%u scsi_buflen:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->scmd->device->channel, + cmd->scmd->device->id, cmd->io_attr.disk_id, opcode, sub_opcode, + cmd->index, resp_frame->normalRespFrame.respStatus, cmd->scmd->result, + (U64)SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, cmd->scmd->retries, + cmd->scmd->allowed, xfer_cnt, scsi_bufflen(cmd->scmd)); } } -static unsigned char -ps3_err_retry_sys_state_check(struct ps3_instance *instance) +static Bool ps3_err_retry_sys_state_check(struct ps3_instance *instance) { - unsigned char ret = PS3_DRV_TRUE; - int cur_state = PS3_INSTANCE_STATE_INIT; + Bool ret = PS3_DRV_TRUE; + S32 cur_state = PS3_INSTANCE_STATE_INIT; if (!instance->state_machine.is_load) { - LOG_WARN_IN_IRQ(instance, "hno:%u instance state not is_load\n", - PS3_HOST(instance)); + LOG_WARN_IN_IRQ(instance, + "hno:%u instance state not is_load\n", PS3_HOST(instance)); ret = PS3_DRV_FALSE; goto l_out; } cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_DEAD || - cur_state == PS3_INSTANCE_STATE_QUIT) { + cur_state == PS3_INSTANCE_STATE_QUIT) { LOG_WARN_IN_IRQ(instance, - "hno:%u instance state is dead/quit\n", - PS3_HOST(instance)); + "hno:%u instance state is dead/quit\n", PS3_HOST(instance)); ret = PS3_DRV_FALSE; goto l_out; } @@ -306,9 +286,9 @@ ps3_err_retry_sys_state_check(struct ps3_instance *instance) return ret; } -static int ps3_is_state_abnormal(struct ps3_instance *instance) +static S32 ps3_is_state_abnormal(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; static unsigned long j; @@ -318,9 +298,8 @@ static int ps3_is_state_abnormal(struct ps3_instance *instance) } if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u host in pci recovery\n", - PS3_HOST(instance)); + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u host in pci recovery\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -328,116 +307,111 @@ static int ps3_is_state_abnormal(struct ps3_instance *instance) return ret; } -static unsigned char ps3_err_code_is_need_change(const struct ps3_cmd *cmd) +static Bool ps3_err_code_is_need_change(const struct ps3_cmd *cmd) { - unsigned int err_code = 0; - union PS3RespFrame *resp_frame = cmd->resp_frame; - unsigned short mode = cmd->reply_word.mode; - unsigned char ret = PS3_TRUE; - struct PS3NvmeCmdStatus status; - struct ps3_nvme_scsi_status cpl; + U32 err_code = 0; + PS3RespFrame_u *resp_frame = cmd->resp_frame; + U16 mode = cmd->reply_word.mode; + Bool ret = PS3_TRUE; + PS3NvmeCmdStatus_s status; + ps3_nvme_scsi_status cpl; if (ps3_err_is_resp_from_direct_cmd(mode)) { if (cmd->reply_word.diskType == PS3_DEV_TYPE_SAS_SATA) { - err_code = resp_frame->sasRespFrame.status & - PS3_SCSI_STATUS_MASK; + err_code = resp_frame->sasRespFrame.status & PS3_SCSI_STATUS_MASK; } else { status.cmdStatus = cmd->reply_word.retStatus; - memset(&cpl, 0, sizeof(struct ps3_nvme_scsi_status)); + memset(&cpl, 0, sizeof(ps3_nvme_scsi_status)); ps3_nvme_error_to_scsi_status(status, &cpl); - err_code = cpl.status; + err_code = cpl.status; } } switch (err_code) { - case SCSI_STATUS_BUSY: - case SCSI_STATUS_TASK_SET_FULL: - case SCSI_STATUS_CONDITION_MET: - case SCSI_STATUS_ACA_ACTIVE: - case PS3_STATUS_OVERRUN: - case PS3_STATUS_UNDERRUN: - ret = PS3_FALSE; - break; - default: - ret = PS3_TRUE; + case SCSI_STATUS_BUSY: + case SCSI_STATUS_TASK_SET_FULL: + case SCSI_STATUS_CONDITION_MET: + case SCSI_STATUS_ACA_ACTIVE: + case PS3_STATUS_OVERRUN: + case PS3_STATUS_UNDERRUN: + ret = PS3_FALSE; + break; + default: + ret = PS3_TRUE; } LOG_DEBUG("tid:0x%llx hno:%u tag:%u status:0x%x %s change\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, err_code, - ret == PS3_TRUE ? "need" : "no need"); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, err_code, + ret == PS3_TRUE?"need":"no need"); return ret; } -static inline unsigned char -ps3_is_need_direct_to_normal(const struct ps3_instance *instance, - const struct ps3_cmd *cmd) +static inline Bool ps3_is_need_direct_to_normal(const struct ps3_instance *instance, + const struct ps3_cmd *cmd) { - return ((instance->ioc_adpter->is_need_direct_to_normal != NULL) && - (instance->ioc_adpter->is_need_direct_to_normal(cmd)) && - (cmd->scmd->allowed != 0)); + return ((instance->ioc_adpter->is_need_direct_to_normal != NULL) + && (instance->ioc_adpter->is_need_direct_to_normal(cmd)) + && (cmd->scmd->allowed != 0)); } -void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, - unsigned char resp_status, - unsigned char cmd_lock); +void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, U8 resp_status, Bool cmd_lock); -int ps3_err_scsi_io_processing(struct ps3_instance *instance, unsigned int id, - unsigned int channel) +S32 ps3_err_scsi_io_processing(struct ps3_instance *instance, + U32 id, U32 channel) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd_context *cmd_context = &instance->cmd_context; struct ps3_cmd *cmd = NULL; - unsigned short idx = 0; + U16 idx = 0; struct scsi_cmnd *s_cmd = NULL; static unsigned long j; - ps3_msleep(ps3_task_reset_delay_time_query()); ps3_atomic_inc(&instance->is_err_scsi_processing); - rmb(); /* in order to force CPU ordering */ + rmb(); ret = ps3_is_state_abnormal(instance); if (ret != PS3_SUCCESS) { - LOG_INFO( - "hno:%u %s [%d:%d] fail, abnormal\n", - PS3_HOST(instance), __func__, channel, id); + LOG_INFO("hno:%u ps3_err_scsi_io_processing [%d:%d] fail, abnormal\n", + PS3_HOST(instance), channel, id); ret = -PS3_FAILED; ps3_atomic_dec(&instance->is_err_scsi_processing); goto l_out; } instance->ioc_adpter->irq_disable(instance); + INJECT_START(PS3_ERR_IJ_WAIT_IOCTL_IN_DEVICE_RESET, instance); #ifndef _WINDOWS ps3_irqs_sync(instance); #endif ps3_all_reply_fifo_complete(instance); - for (idx = 0; idx < cmd_context->max_scsi_cmd_count; idx++) { + for (idx = 0 ; idx < cmd_context->max_scsi_cmd_count; idx++) { cmd = ps3_cmd_find(instance, idx); - if (cmd == NULL) { + if(cmd == NULL) { ret = -PS3_FAILED; break; } - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { continue; + } s_cmd = cmd->scmd; - if (s_cmd == NULL) + if (s_cmd == NULL) { continue; - if (s_cmd->device == NULL) + } + if (s_cmd->device == NULL) { continue; + } if (PS3_SDEV_TARGET(s_cmd->device) == id && - PS3_SDEV_CHANNEL(s_cmd->device) == channel) { + PS3_SDEV_CHANNEL(s_cmd->device) == channel) { #ifndef _WINDOWS scsi_print_command(s_cmd); #endif - LOG_WARN_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u SCSI commands pending to target\n" - "\ttid:0x%llx [%u:%u]: frame_id:%d\n", - PS3_HOST(instance), cmd->trace_id, channel, id, - cmd->index); + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u SCSI commands pending to target" + " tid:0x%llx [%u:%u]: frame_id:%d\n", + PS3_HOST(instance), cmd->trace_id, channel, id, cmd->index); ret = -PS3_FAILED; break; } @@ -454,15 +428,14 @@ int ps3_err_scsi_io_processing(struct ps3_instance *instance, unsigned int id, } static void ps3_err_sas_errcode_mapping_with_sense(struct ps3_cmd *cmd, - union PS3RespFrame *frame) + PS3RespFrame_u *frame) { - unsigned int sense_data_len = 0; + U32 sense_data_len = 0; struct scsi_cmnd *scmd = cmd->scmd; struct ps3_instance *instance = cmd->instance; #ifndef _WINDOWS - int host_status = DID_OK; - struct Ps3SasDirectRespFrameIU frame_sas = frame->sasRespFrame; - + S32 host_status = DID_OK; + Ps3SasDirectRespFrameIU_s frame_sas = frame->sasRespFrame; if (scmd == NULL || scmd->sense_buffer == NULL) { LOG_WARN_IN_IRQ(instance, "scmd is null\n"); goto l_out; @@ -475,23 +448,20 @@ static void ps3_err_sas_errcode_mapping_with_sense(struct ps3_cmd *cmd, goto l_out; } -#if defined(PS3_SUPPORT_DRIVER_SENSE) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)) scmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS(DRIVER_SENSE); #endif - scmd->result |= - PS3_SCSI_RESULT_HOST_STATUS(host_status) | frame_sas.status; + scmd->result |= PS3_SCSI_RESULT_HOST_STATUS(host_status) | frame_sas.status; memset(scmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); - sense_data_len = min_t(unsigned int, SCSI_SENSE_BUFFERSIZE, - sizeof(frame_sas.data)); + sense_data_len = min_t(U32, SCSI_SENSE_BUFFERSIZE, sizeof(frame_sas.data)); if (sense_data_len == 0) { LOG_ERROR_IN_IRQ(instance, "sense_data_len len is zero\n"); goto l_out; } memcpy(scmd->sense_buffer, frame_sas.data, sense_data_len); ps3_scsi_sense_print(instance, scmd->sense_buffer, - SCSI_SENSE_BUFFERSIZE, - SCMD_GET_REQUEST(scmd)->tag); + SCSI_SENSE_BUFFERSIZE, SCMD_GET_REQUEST(scmd)->tag); #else if (frame == NULL) { LOG_ERROR_IN_IRQ(instance, "direct frame is null, retry\n"); @@ -499,197 +469,166 @@ static void ps3_err_sas_errcode_mapping_with_sense(struct ps3_cmd *cmd, goto l_out; } sense_data_len = min(SCSI_SENSE_BUFFERSIZE, sizeof(frame_sas.data)); - if (sense_data_len == 0) { - LOG_ERROR_IN_IRQ(instance, "sense_data_len len is zero\n"); - goto l_out; - } + if (sense_data_len == 0) { + LOG_ERROR_IN_IRQ(instance, "sense_data_len len is zero\n"); + goto l_out; + } - ps3_sense_info_set(scmd, frame_sas.data, - (unsigned short)sense_data_len); + ps3_sense_info_set(scmd, frame_sas.data, (U16)sense_data_len); #endif l_out: return; } -static void ps3_err_sas_errcode_mapping(struct ps3_instance *instance, - struct ps3_cmd *cmd, - unsigned short mode) +static void ps3_err_sas_errcode_mapping(struct ps3_instance *instance, struct ps3_cmd *cmd, U16 mode) { struct scsi_cmnd *scmd = cmd->scmd; - unsigned int channel = 0; - unsigned int id = 0; - unsigned short disk_id = 0; - union PS3RespFrame *frame = cmd->resp_frame; + U32 channel = 0; + U32 id = 0; + U16 disk_id = 0; + PS3RespFrame_u *frame = cmd->resp_frame; static unsigned long j; #ifndef _WINDOWS channel = scmd->device->channel; id = scmd->device->id; disk_id = cmd->io_attr.disk_id; #endif - if (ps3_err_is_resp_from_direct_cmd(mode)) { - struct Ps3SasDirectRespFrameIU frame_sas = frame->sasRespFrame; + if (ps3_err_is_resp_from_direct_cmd(mode)){ + Ps3SasDirectRespFrameIU_s frame_sas = frame->sasRespFrame; switch (frame_sas.dataPres) { - case PS3_SAS_PRES_NO_DATA: - case PS3_SAS_PRES_REPSNSE_DATA: + case PS3_SAS_PRES_NO_DATA: + case PS3_SAS_PRES_REPSNSE_DATA: ps3_err_scsi_errcode_mapping(cmd, mode, PS3_TRUE); break; case PS3_SAS_PRES_SENSE_DATA: - LOG_INFO_IN_IRQ( - instance, + LOG_INFO_IN_IRQ(instance, "tid:0x%llx hno:%u [%u:%u:%u], CFID:%u data_pres:%u status:%u\n", - cmd->trace_id, PS3_HOST(instance), channel, id, - disk_id, cmd->index, - frame->sasRespFrame.dataPres, - frame->sasRespFrame.status); + cmd->trace_id, PS3_HOST(instance), channel, + id, disk_id, cmd->index, + frame->sasRespFrame.dataPres, frame->sasRespFrame.status); ps3_err_sas_errcode_mapping_with_sense(cmd, frame); break; default: #ifndef _WINDOWS scmd->result |= PS3_SCSI_RESULT_HOST_STATUS(DID_ERROR); - LOG_INFO_IN_IRQ( - instance, - "tid:0x%llx hno:%d tag:%u scmd result:%x\n", + LOG_INFO_IN_IRQ(instance, + "tid:0x%llx hno:%d tag:%u scmd result:%x \n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, cmd->scmd->result); #else scsi_cmnd_hoststatus_set(scmd, DID_ERROR); - LOG_INFO_IN_IRQ(instance, "tid:0x%llx hno:%d tag:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->index); + LOG_INFO_IN_IRQ(instance, + "tid:0x%llx hno:%d tag:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); #endif break; } } else { - LOG_WARN_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u [chl:%u, id:%u, devid:%u], CFID:%u respStatus:%u\n", cmd->trace_id, PS3_HOST(instance), channel, id, disk_id, cmd->index, frame->normalRespFrame.respStatus); ps3_err_scsi_errcode_mapping(cmd, mode, PS3_FALSE); } + return; } static void ps3_err_nvme_errcode_mapping(struct ps3_instance *instance, - struct ps3_cmd *cmd, - unsigned short mode) + struct ps3_cmd *cmd, U16 mode) { ps3_nvme_resp_to_scsi_status(cmd); ps3_err_scsi_errcode_mapping(cmd, mode, PS3_FALSE); (void)instance; - LOG_INFO_IN_IRQ(instance, "tid:0x%llx hno:%d tag:%d scmd result:%x\n", - cmd->trace_id, PS3_HOST(instance), cmd->index, - cmd->scmd->result); + LOG_INFO_IN_IRQ(instance, + "tid:0x%llx hno:%d tag:%d scmd result:%x \n", + cmd->trace_id, PS3_HOST(instance), + cmd->index, cmd->scmd->result); } static void ps3_err_protocol_errcode_mapping(struct ps3_instance *instance, - struct ps3_cmd *cmd, - struct PS3ReplyWord *reply_word) + struct ps3_cmd *cmd, struct PS3ReplyWord *reply_word) { - if (reply_word->diskType == PS3_DEV_TYPE_SAS_SATA) + if (reply_word->diskType == PS3_DEV_TYPE_SAS_SATA){ ps3_err_sas_errcode_mapping(instance, cmd, reply_word->mode); - else + } else { ps3_err_nvme_errcode_mapping(instance, cmd, reply_word->mode); + } + return; } -unsigned char ps3_err_is_resp_from_direct_cmd(unsigned short mode) +Bool ps3_err_is_resp_from_direct_cmd(U16 mode) { - return ((mode == PS3_REPLY_WORD_MODE_DIRECT_OK) || - (mode == PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_DIRECT)); + return ((mode == PS3_REPLY_WORD_MODE_DIRECT_OK) + || (mode == PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_DIRECT)); } -int ps3_err_scsi_cmd_fault_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd) +S32 ps3_err_scsi_cmd_fault_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - unsigned short mode = cmd->reply_word.mode; - int ret = PS3_SUCCESS; + U16 mode = cmd->reply_word.mode; + S32 ret = PS3_SUCCESS; - LOG_FILE_INFO( - "tid:0x%llx hno:%u scsi cmd fault proc CFID:%u\n" - "\treply_word info: mode:%d retStatus[%02x], rettype:%d disktype:%d\n", + LOG_FILE_INFO("tid:0x%llx hno:%u scsi cmd fault proc CFID:%u " + "reply_word info: mode:%d retStatus[%02x], rettype:%d disktype:%d\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, mode, - cmd->reply_word.retStatus, cmd->reply_word.retType, - cmd->reply_word.diskType); + cmd->reply_word.retStatus, cmd->reply_word.retType, cmd->reply_word.diskType); - if (cmd->reply_word.retType == 0) { - if ((cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) && - ps3_err_is_resp_from_direct_cmd(mode)) { + if(cmd->reply_word.retType == 0) { + if ((cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) + && ps3_err_is_resp_from_direct_cmd(mode)) { if (ps3_err_retry_sys_state_check(instance)) { - LOG_FILE_INFO( - "hno:%u Direct cmd needs retry!\n" - "\t[scmd cmd_flags:0x%llx, retries:%d, allowd:%d]\n", - PS3_HOST(instance), - (unsigned long long)SCMD_GET_REQUEST( - cmd->scmd) - ->cmd_flags, + LOG_FILE_INFO("hno:%u Direct cmd needs retry!" + " [scmd cmd_flags:0x%llx, retries:%d, allowd:%d]\n", + PS3_HOST(instance), (U64)SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, cmd->scmd->retries, cmd->scmd->allowed); - if ((ps3_is_need_direct_to_normal(instance, - cmd)) && - (ps3_err_code_is_need_change(cmd))) { - cmd->scmd->result = - PS3_SCSI_RESULT_HOST_STATUS( - DID_SOFT_ERROR); + if ((ps3_is_need_direct_to_normal(instance, cmd)) + && (ps3_err_code_is_need_change(cmd))) { + cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR); } else { - ps3_err_protocol_errcode_mapping( - instance, cmd, - &(cmd->reply_word)); + ps3_err_protocol_errcode_mapping(instance, cmd, &(cmd->reply_word)); } } else { - cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS( - DID_NO_CONNECT); + cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); } } else { ps3_err_scsi_errcode_mapping(cmd, mode, PS3_FALSE); } - } else { + }else { if (ps3_err_retry_sys_state_check(instance)) { - LOG_FILE_INFO( - "hno:%u Hil hardware err,need retry!\n" - "\t[scmd cmd_flags:0x%llx, retries:%d, allowd:%d]\n", - PS3_HOST(instance), - SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, + LOG_FILE_INFO("hno:%u Hil hardware err,need retry!" + " [scmd cmd_flags:0x%llx, retries:%d, allowd:%d]\n", + PS3_HOST(instance), SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, cmd->scmd->retries, cmd->scmd->allowed); - if (cmd->reply_word.retStatus == - PS3_NVME_RESP_STATUS_SQ_FULL && - cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - cmd->scmd->result = - PS3_SCSI_RESULT_HOST_STATUS(DID_OK) | - SCSI_STATUS_TASK_SET_FULL; - cmd->scmd->retries = - ((cmd->scmd->retries == 0) ? - 1 : - cmd->scmd->retries); + if (cmd->reply_word.retStatus == PS3_NVME_RESP_STATUS_SQ_FULL && + cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_OK) | SCSI_STATUS_TASK_SET_FULL; + cmd->scmd->retries = ((cmd->scmd->retries == 0) ? 1 : cmd->scmd->retries); } else { - cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS( - DID_SOFT_ERROR); + cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR); } } else { - cmd->scmd->result = - PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); } } if (cmd->scmd->result == SCSI_STATUS_TASK_SET_FULL) { - ps3_qos_adjust_pd_rsc(cmd->scmd->device, instance, - PS3_QOS_QUOTA_ADJUST_QFULL); + ps3_qos_adjust_pd_rsc(cmd->scmd->device, instance, PS3_QOS_QUOTA_ADJUST_QFULL); } return ret; } -void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, - unsigned char resp_status, - unsigned char cmd_lock) +void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, U8 resp_status, Bool cmd_lock) { - struct ps3_instance *instance = cmd->instance; + struct ps3_instance *instance = cmd->instance; struct ps3_scsi_priv_data *data = NULL; if (cmd_lock) { ps3_mutex_lock(&instance->recovery_context->free_cmd_lock); - LOG_INFO( - "hno:%u tid:0x%llx CFID:%u drv reply scsi independently!\n", + LOG_INFO("hno:%u tid:0x%llx CFID:%u drv reply scsi independently!\n", PS3_HOST(instance), cmd->trace_id, cmd->index); } if (likely(cmd->scmd == NULL)) { @@ -703,99 +642,104 @@ void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); - ps3_errcode_to_scsi_status(cmd->instance, s_cmd, resp_status, NULL, 0, - cmd); + ps3_errcode_to_scsi_status(cmd->instance, s_cmd, resp_status, NULL, 0, cmd); -#if defined(PS3_SUPPORT_CMD_SCP) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) s_cmd->SCp.ptr = NULL; #endif ps3_scsi_dma_unmap(cmd); data = (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; - if (likely(data != NULL)) + if(likely(data != NULL)){ ps3_r1x_write_unlock(&data->lock_mgr, cmd); + } if (cmd->r1x_peer_cmd != NULL) { - LOG_DEBUG( - "host_no:%u task repaly r1x scsi write CFID:%d and CFID:%d\n", - PS3_HOST(instance), cmd->index, - cmd->r1x_peer_cmd->index); - if (!ps3_r1x_peer_cmd_free_nolock(cmd->r1x_peer_cmd)) + LOG_DEBUG("host_no:%u task repaly r1x scsi write CFID:%d and CFID:%d\n", + PS3_HOST(instance), cmd->index, cmd->r1x_peer_cmd->index); + if (!ps3_r1x_peer_cmd_free_nolock(cmd->r1x_peer_cmd)) { ps3_scsi_cmd_free(cmd->r1x_peer_cmd); + } - if (!ps3_r1x_peer_cmd_free_nolock(cmd)) + if (!ps3_r1x_peer_cmd_free_nolock(cmd)) { ps3_scsi_cmd_free(cmd); + } } else { ps3_scsi_cmd_free(cmd); } SCMD_IO_DONE(s_cmd); l_out: - if (cmd_lock) + if (cmd_lock) { ps3_mutex_unlock(&instance->recovery_context->free_cmd_lock); + } + return ; } -int ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) +S32 ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) { #ifdef _WINDOWS (void)scmd; #else - int ret = SUCCESS; + S32 ret = SUCCESS; struct ps3_cmd *aborted_cmd = NULL; struct ps3_cmd *aborted_peer_cmd = NULL; - unsigned short cmd_frame_id = 0; + U16 cmd_frame_id = 0; struct ps3_instance *instance = scsi_host_data(scmd); - struct ps3_scsi_priv_data *scsi_priv_data = - scsi_device_private_data(scmd); - unsigned int cmd_flighting_wait_cnt = 0; + struct ps3_scsi_priv_data *scsi_priv_data = scsi_device_private_data(scmd); + U32 cmd_flighting_wait_cnt = 0; - LOG_WARN("hno:%u enter, ready aborted CFID:%u op:0x%x chl:%u id:%u\n", - PS3_HOST(instance), SCMD_GET_REQUEST(scmd)->tag, scmd->cmnd[0], - ps3_scsi_channel_query(scmd), ps3_scsi_target_query(scmd)); + LOG_WARN("hno:%u enter, ready aborted CFID:%u op:0x%x " + "chl:%u id:%u\n", PS3_HOST(instance), SCMD_GET_REQUEST(scmd)->tag, + scmd->cmnd[0], ps3_scsi_channel_query(scmd), + ps3_scsi_target_query(scmd)); + INJECT_START(PS3_ERR_IJ_SCSI_TASK_PRE_CHECK_FAILED, instance) if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { - LOG_WARN("hno:%u pre check NOK!\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pre check NOK!\n", + PS3_HOST(instance)); ret = FAILED; goto l_out; } if (!scsi_priv_data->is_taskmgmt_enable) { - LOG_ERROR("hno:%u task mgmt is disable!\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u task mgmt is disable!\n", + PS3_HOST(instance)); ret = FAILED; goto l_out; } cmd_frame_id = SCMD_GET_REQUEST(scmd)->tag; + INJECT_START(PS3_ERR_IJ_ABORT_PRE1_FORCE_ABORTED_CMD_DONE, scmd) aborted_cmd = ps3_cmd_find(instance, cmd_frame_id); if (aborted_cmd == NULL || aborted_cmd->scmd == NULL) { LOG_INFO("host_no:%u there is no aborted cmd CFID:%u\n", - PS3_HOST(instance), cmd_frame_id); + PS3_HOST(instance), cmd_frame_id); ret = SUCCESS; goto l_out; } + INJECT_START(PS3_ERR_IJ_ABORT_PRE2_FORCE_ABORTED_CMD_DONE, scmd) - LOG_FILE_WARN("tid:0x%llx hno:%u task aborted CFID:%u ready\n", - aborted_cmd->trace_id, PS3_HOST(instance), cmd_frame_id); + LOG_FILE_WARN("tid:0x%llx hno:%u task aborted CFID:%u ready \n", + aborted_cmd->trace_id, PS3_HOST(instance), cmd_frame_id); scsi_priv_data->task_manager_busy = 1; - while (aborted_cmd->flighting && - cmd_flighting_wait_cnt < PS3_ABORT_WAIT_CMD_FLIGHT_END) { + while(aborted_cmd->flighting && + cmd_flighting_wait_cnt < PS3_ABORT_WAIT_CMD_FLIGHT_END) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); cmd_flighting_wait_cnt++; } if (aborted_cmd->flighting) { ret = FAILED; - LOG_WARN( - "task abort wait cmd filghting end NOK. hno:%u tid:0x%llx CFID:%u\n", - PS3_HOST(instance), aborted_cmd->trace_id, - aborted_cmd->index); + LOG_WARN("task abort wait cmd filghting end NOK. hno:%u tid:0x%llx CFID:%u\n", + PS3_HOST(instance), aborted_cmd->trace_id, aborted_cmd->index); goto l_busy_clean_out; } LOG_DEBUG("hno:%u task abort wait flighting cmd end\n", - PS3_HOST(instance)); + PS3_HOST(instance)); if (ps3_r1x_conflict_queue_abort(aborted_cmd, scmd)) { ret = SUCCESS; @@ -809,28 +753,34 @@ int ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) aborted_peer_cmd = aborted_cmd->r1x_peer_cmd; if (aborted_peer_cmd != NULL) { + INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC1, aborted_peer_cmd); ps3_mutex_lock(&instance->task_abort_lock); aborted_peer_cmd->is_aborting = 1; - wmb(); /* in order to force CPU ordering */ + wmb(); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_FREE, aborted_cmd); if (aborted_cmd->r1x_peer_cmd == NULL) { + INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC, aborted_peer_cmd); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC2, aborted_peer_cmd); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_FREE, aborted_peer_cmd); aborted_peer_cmd->is_aborting = 0; + INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC2, aborted_peer_cmd); ps3_mutex_unlock(&instance->task_abort_lock); goto l_busy_clean_out; } ps3_mutex_unlock(&instance->task_abort_lock); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_FREE1, aborted_cmd); + INJECT_START(PS3_ERR_IJ_ABORT_BLOCK1, instance); if (!aborted_peer_cmd->is_r1x_scsi_complete) { ret = ps3_scsi_task_mgr_abort(instance, scsi_priv_data, - aborted_peer_cmd->index, - scmd); + aborted_peer_cmd->index, scmd); ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; aborted_peer_cmd->is_aborting = 0; + INJECT_START(PS3_ERR_IJ_ABORT_BLOCK2, instance); if (ret == SUCCESS) { - LOG_INFO( - "hno:%u task abort peer cmd:%d success !\n", - PS3_HOST(instance), + LOG_INFO("hno:%u task abort peer cmd:%d success !\n", + PS3_HOST(instance), aborted_peer_cmd->index); + aborted_peer_cmd = ps3_cmd_find(instance, aborted_peer_cmd->index); - aborted_peer_cmd = ps3_cmd_find( - instance, aborted_peer_cmd->index); if (unlikely(aborted_peer_cmd == NULL)) { ret = FAILED; goto l_busy_clean_out; @@ -843,22 +793,19 @@ int ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) } } - ret = ps3_scsi_task_mgr_abort(instance, scsi_priv_data, cmd_frame_id, - scmd); + ret = ps3_scsi_task_mgr_abort(instance, scsi_priv_data, + cmd_frame_id, scmd); ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; - if (ret == SUCCESS) { - LOG_INFO("hno:%u task abort cmd success !\n", - PS3_HOST(instance)); + if(ret == SUCCESS) { + LOG_INFO("hno:%u task abort cmd success !\n", PS3_HOST(instance)); aborted_cmd = ps3_cmd_find(instance, cmd_frame_id); if (aborted_cmd == NULL) { ret = FAILED; } else { if (unlikely(aborted_cmd->scmd)) { - LOG_WARN( - "task abort success but scmd is not freed. hno:%u tid:0x%llx CFID:%u\n", - PS3_HOST(instance), - aborted_cmd->trace_id, cmd_frame_id); + LOG_WARN("task abort success but scmd is not freed. hno:%u tid:0x%llx CFID:%u\n", + PS3_HOST(instance), aborted_cmd->trace_id, cmd_frame_id); ret = FAILED; } ps3_can_queue_depth_update(instance); @@ -866,17 +813,15 @@ int ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) } l_busy_clean_out: scsi_priv_data->task_manager_busy = 0; - wmb(); /* in order to force CPU ordering */ + wmb(); l_out: - LOG_WARN("hno:%u quit ret:%#x\n", PS3_HOST(instance), ret); + LOG_WARN("hno:%u quit ret:%#x\n",PS3_HOST(instance), ret); return ret; #endif return -PS3_FAILED; } -void ps3_set_task_manager_busy(struct ps3_instance *instance, - unsigned int channel, unsigned int id, - unsigned int state) +void ps3_set_task_manager_busy(struct ps3_instance *instance, U32 channel, U32 id, U32 state) { struct ps3_scsi_priv_data *scsi_priv_data = NULL; @@ -886,7 +831,7 @@ void ps3_set_task_manager_busy(struct ps3_instance *instance, if (scsi_priv_data == NULL) { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); LOG_ERROR("hno:%u device has been deleted.channel:%u, id:%u!\n", - PS3_HOST(instance), channel, id); + PS3_HOST(instance), channel, id); goto l_out; } scsi_priv_data->task_manager_busy = state; @@ -897,25 +842,26 @@ void ps3_set_task_manager_busy(struct ps3_instance *instance, return; } -int ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) +S32 ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) { - int ret = PS3_SUCCESS; - int send_result = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + S32 send_result = PS3_SUCCESS; struct ps3_instance *instance = scsi_host_data(scmd); struct ps3_scsi_priv_data *scsi_priv_data = NULL; struct ps3_scsi_priv_data pending_priv_data; - struct ps3_cmd *cmd = NULL; + struct ps3_cmd * cmd = NULL; LOG_INFO("hno:%u enter device reset channel:%u id:%u\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(scmd->device), - PS3_SDEV_TARGET(scmd->device)); + PS3_HOST(instance), PS3_SDEV_CHANNEL(scmd->device), + PS3_SDEV_TARGET(scmd->device)); ps3_mutex_lock(&instance->dev_context.dev_priv_lock); + INJECT_START(PS3_ERR_IJ_PRIV_DATA_NULL1, scmd->device) scsi_priv_data = scsi_device_private_data(scmd); - if (scsi_priv_data == NULL) { + if(scsi_priv_data == NULL) { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); LOG_ERROR("hno:%u device has been deleted!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); #ifndef _WINDOWS scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); ret = SUCCESS; @@ -926,15 +872,14 @@ int ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) } LOG_WARN("hno:%u enter ready reset[%u:%u:%u:%#x], CFID:%d\n", - PS3_HOST(instance), - scsi_priv_data->disk_pos.diskDev.ps3Dev.softChan, - scsi_priv_data->disk_pos.diskDev.ps3Dev.devID, - scsi_priv_data->disk_pos.diskDev.ps3Dev.phyDiskID, - scsi_priv_data->disk_pos.diskMagicNum, - SCMD_GET_REQUEST(scmd)->tag); + PS3_HOST(instance), scsi_priv_data->disk_pos.diskDev.ps3Dev.softChan, + scsi_priv_data->disk_pos.diskDev.ps3Dev.devID, + scsi_priv_data->disk_pos.diskDev.ps3Dev.phyDiskID, + scsi_priv_data->disk_pos.diskMagicNum, SCMD_GET_REQUEST(scmd)->tag); if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { - LOG_WARN("hno:%u pre check NOK!\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pre check NOK!\n", + PS3_HOST(instance)); #ifndef _WINDOWS ret = FAILED; #else @@ -945,7 +890,8 @@ int ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) } if (!scsi_priv_data->is_taskmgmt_enable) { - LOG_ERROR("hno:%u task mgmt is disable!\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u task mgmt is disable!\n", + PS3_HOST(instance)); #ifndef _WINDOWS ret = FAILED; #else @@ -955,39 +901,37 @@ int ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) goto l_out; } - LOG_INFO("hno:%u task ready reset[%u:%u:%u]\n", PS3_HOST(instance), - scsi_priv_data->disk_pos.diskDev.ps3Dev.softChan, - scsi_priv_data->disk_pos.diskDev.ps3Dev.devID, - scsi_priv_data->disk_pos.diskDev.ps3Dev.phyDiskID); + LOG_INFO("hno:%u task ready reset[%u:%u:%u] \n",PS3_HOST(instance), + scsi_priv_data->disk_pos.diskDev.ps3Dev.softChan, + scsi_priv_data->disk_pos.diskDev.ps3Dev.devID, + scsi_priv_data->disk_pos.diskDev.ps3Dev.phyDiskID); scsi_priv_data->task_manager_busy = 1; ps3_wait_scsi_cmd_done(instance, PS3_TRUE); - LOG_WARN("hno[%u], task reset wait scsi delivering cmd count[%d] !\n", - PS3_HOST(instance), - ps3_atomic_read(&instance->cmd_statistics.cmd_delivering)); + LOG_WARN("hno[%u], task reset wait scsi delivering cmd count[%d] !\n", PS3_HOST(instance), + ps3_atomic_read(&instance->cmd_statistics.cmd_delivering)); ps3_wait_mgr_cmd_done(instance, PS3_TRUE); - LOG_WARN("hno:%u task reset wait delivering cmd end !\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u task reset wait delivering cmd end !\n", PS3_HOST(instance)); ps3_r1x_conflict_queue_clean(scsi_priv_data, SCSI_STATUS_TASK_ABORTED); - memcpy(&pending_priv_data, scsi_priv_data, - sizeof(struct ps3_scsi_priv_data)); + memcpy(&pending_priv_data, scsi_priv_data, sizeof(struct ps3_scsi_priv_data)); - ps3_qos_device_clean(instance, scsi_priv_data, - SCSI_STATUS_TASK_ABORTED); + ps3_qos_device_clean(instance, scsi_priv_data, SCSI_STATUS_TASK_ABORTED); ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); + INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u mgr reset cmd pre check NOK CFID:%d\n", - PS3_HOST(instance), SCMD_GET_REQUEST(scmd)->tag); + PS3_HOST(instance), SCMD_GET_REQUEST(scmd)->tag); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = FAILED; goto l_err; } cmd = ps3_scsi_task_mgr_reset_build(instance, &pending_priv_data); if (cmd == NULL) { - LOG_ERROR("hno:%u task reset cmd NOK!\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u task reset cmd NOK!\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = FAILED; goto l_err; @@ -997,9 +941,10 @@ int ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); + ret = ps3_mgr_complete_proc(instance, cmd, send_result); LOG_INFO("host_no:%u reset finish CFID:%u t_id:0x%llx!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id); + PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id); if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_task_cmd_free(instance, cmd); @@ -1008,33 +953,36 @@ int ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) if (ret == SUCCESS) { LOG_INFO("hno:%u target reset success !\n", PS3_HOST(instance)); ret = ps3_err_scsi_io_processing(instance, scmd->device->id, - scmd->device->channel); + scmd->device->channel); + INJECT_START(PS3_ERR_IJ_HT_ABNORMAL1, &ret) ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; ps3_can_queue_depth_update(instance); } l_err: ps3_mutex_lock(&instance->dev_context.dev_priv_lock); + INJECT_START(PS3_ERR_IJ_PRIV_DATA_NULL2, scmd->device) scsi_priv_data = scsi_device_private_data(scmd); if (scsi_priv_data == NULL) { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); LOG_ERROR("hno:%u device has been deleted!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } scsi_priv_data->task_manager_busy = 0; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); l_out: - LOG_WARN("hno:%u quit ret:%#x\n", PS3_HOST(instance), ret); + LOG_WARN("hno:%u quit ret:%#x\n",PS3_HOST(instance), ret); return ret; } -int ps3_device_reset_handler(struct scsi_cmnd *scmd) +S32 ps3_device_reset_handler(struct scsi_cmnd *scmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_instance *instance = scsi_host_data(scmd); - LOG_INFO("hno:%u ready device[%u:%u] reset!\n", PS3_HOST(instance), - PS3_SDEV_CHANNEL(scmd->device), PS3_SDEV_TARGET(scmd->device)); + LOG_INFO("hno:%u ready device[%u:%u] reset!\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(scmd->device), + PS3_SDEV_TARGET(scmd->device)); ps3_mutex_lock(&instance->task_mgr_reset_lock); instance->task_manager_host_busy = PS3_TRUE; @@ -1045,98 +993,95 @@ int ps3_device_reset_handler(struct scsi_cmnd *scmd) return ret; } -static int ps3_hard_reset_pre_check(struct ps3_instance *instance) +static S32 ps3_hard_reset_pre_check(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - int cur_state = PS3_INSTANCE_STATE_INIT; - unsigned char is_support_halt = PS3_IOC_STATE_HALT_SUPPORT(instance); - unsigned int hard_reset_enable = ps3_hard_reset_enable_query(); + S32 ret = PS3_SUCCESS; + S32 cur_state = PS3_INSTANCE_STATE_INIT; + Bool is_support_halt = PS3_IOC_STATE_HALT_SUPPORT(instance); + U32 hard_reset_enable = ps3_hard_reset_enable_query(); cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_WARN("hno:%u ready to host reset,instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); - if (is_support_halt && (cur_state != PS3_INSTANCE_STATE_DEAD)) { + PS3_HOST(instance), namePS3InstanceState(cur_state)); + + if(is_support_halt && (cur_state != PS3_INSTANCE_STATE_DEAD)){ ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_DEAD); + PS3_INSTANCE_STATE_DEAD); instance->ioc_adpter->ioc_force_to_halt(instance); LOG_INFO("host_no:%u instance state while support halt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } - cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state == PS3_INSTANCE_STATE_DEAD && - (!hard_reset_enable || is_support_halt || - (!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)))) { + if ((cur_state = ps3_atomic_read(&instance->state_machine.state)) == + PS3_INSTANCE_STATE_DEAD && (!hard_reset_enable || is_support_halt + || (!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)))) { LOG_INFO("hno:%u host reset, instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = -PS3_FAILED; } - LOG_INFO("hno:%u host reset, instance state: %s\n", PS3_HOST(instance), - namePS3InstanceState(cur_state)); + LOG_INFO("hno:%u host reset, instance state: %s\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); return ret; } -static int ps3_host_reset_pre_check(struct ps3_instance *instance) +static S32 ps3_host_reset_pre_check(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - int cur_state = ps3_atomic_read(&instance->state_machine.state); + S32 ret = PS3_SUCCESS; + S32 cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_WARN("hno:%u ready to host reset,instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); if (PS3_DEVICE_IS_SWITCH(instance->dev_id) && - !instance->is_scan_host_finish) { - LOG_INFO( - "host_no:%u instance deviceId:%u is probe, exit failed!\n", + !instance->is_scan_host_finish) { + LOG_INFO("host_no:%u instance deviceId:%u is probe, exit failed!\n", PS3_HOST(instance), instance->dev_id); ret = -PS3_FAILED; goto l_out; } - if (cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_DEAD || - !instance->state_machine.can_hostreset) { + if (cur_state == PS3_INSTANCE_STATE_QUIT || cur_state == PS3_INSTANCE_STATE_DEAD || + !instance->state_machine.can_hostreset) { LOG_ERROR("hno:%u cannot perform host reset due to %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = -PS3_FAILED; } else { LOG_INFO("hno:%u host reset, instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); } l_out: return ret; } -int ps3_wait_for_outstanding_complete(struct ps3_instance *instance) +S32 ps3_wait_for_outstanding_complete(struct ps3_instance *instance) { - unsigned int i = 0; - unsigned int ioc_state = PS3_FW_STATE_UNDEFINED; - int ret = -PS3_FAILED; - unsigned int waittime_for_io_completion = - PS3_WAIT_FOR_OUTSTANDING_IO_COMPLETE; - unsigned int interval = 1000; - unsigned int count = 0; + U32 i = 0; + U32 ioc_state = PS3_FW_STATE_UNDEFINED; + S32 ret = -PS3_FAILED; + U32 waittime_for_io_completion = PS3_WAIT_FOR_OUTSTANDING_IO_COMPLETE; + U32 interval = 1000; + U32 count = 0; for (i = 0; i < waittime_for_io_completion * 10 / interval; i++) { if (!ps3_ioc_state_get_with_check(instance, &ioc_state)) { LOG_ERROR_LIM("host_no:%u get ioc state NOK\n", - PS3_HOST(instance)); - if (count++ < 3) + PS3_HOST(instance)); + if (count++ < 3) { continue; + } goto l_out; } if (ioc_state == PS3_FW_STATE_FAULT || - ioc_state == PS3_FW_STATE_CRITICAL) { + ioc_state == PS3_FW_STATE_CRITICAL) { LOG_WARN("host_no:%u ioc_state:0x%x\n", - PS3_HOST(instance), ioc_state); + PS3_HOST(instance), ioc_state); goto l_out; } - if (atomic_read(&instance->cmd_statistics.io_outstanding) == - 0) { + if(atomic_read(&instance->cmd_statistics.io_outstanding) == 0) { LOG_WARN("host_no:%u io_outstanding is zero\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } @@ -1148,14 +1093,13 @@ int ps3_wait_for_outstanding_complete(struct ps3_instance *instance) return ret; } -int ps3_reset_host(struct ps3_instance *instance) +S32 ps3_reset_host(struct ps3_instance *instance) { - int ret = SUCCESS; - int cur_state = PS3_INSTANCE_STATE_INIT; - + S32 ret = SUCCESS; + S32 cur_state = PS3_INSTANCE_STATE_INIT; LOG_INFO("hno:%u Host reset is requested, IOC outstanding: %d!!\n", - PS3_HOST(instance), - ps3_atomic_read(&instance->cmd_statistics.io_outstanding)); + PS3_HOST(instance), + ps3_atomic_read(&instance->cmd_statistics.io_outstanding)); ps3_atomic_inc(&instance->host_reset_processing); if (ps3_host_reset_pre_check(instance) != PS3_SUCCESS) { ret = FAILED; @@ -1163,58 +1107,49 @@ int ps3_reset_host(struct ps3_instance *instance) } do { if (unlikely(ps3_pci_err_recovery_get(instance))) { - LOG_WARN_LIM( - "hno:%u host in pci recovery during reset request\n", + LOG_WARN_LIM("hno:%u host in pci recovery during reset request\n", PS3_HOST(instance)); } else { ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state == - PS3_HOST_RESET_INIT) { - instance->recovery_context->host_reset_state = - PS3_HOST_RESET_START; + if (instance->recovery_context->host_reset_state == PS3_HOST_RESET_INIT) { + instance->recovery_context->host_reset_state = PS3_HOST_RESET_START; ps3_mutex_unlock(&instance->state_machine.lock); break; } ps3_mutex_unlock(&instance->state_machine.lock); } ps3_msleep(100); - } while (1); + } while(1); ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { - do { + if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + do{ ps3_mutex_unlock(&instance->state_machine.lock); ps3_msleep(100); ps3_mutex_lock(&instance->state_machine.lock); - if (likely(instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE)) { + if (likely(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { continue; } else { ps3_mutex_unlock(&instance->state_machine.lock); - cancel_work_sync(&instance->recovery_context - ->recovery_work); + cancel_work_sync(&instance->recovery_context->recovery_work); goto wait_hard_reset; } - } while (1); - } else if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW) { + }while(1); + } else if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW){ ps3_mutex_unlock(&instance->state_machine.lock); cancel_work_sync(&instance->recovery_context->recovery_work); } else { ps3_mutex_unlock(&instance->state_machine.lock); } ps3_mutex_lock(&instance->state_machine.lock); - if (unlikely(instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE)) { - instance->recovery_context->recovery_state = - PS3_HARD_RECOVERY_FINISH; + if (unlikely(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { + instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_FINISH; } ps3_mutex_unlock(&instance->state_machine.lock); - if (ps3_wait_for_outstanding_complete(instance) == PS3_SUCCESS) { + if(ps3_wait_for_outstanding_complete(instance) == PS3_SUCCESS) { ret = SUCCESS; goto l_out; } @@ -1224,20 +1159,17 @@ int ps3_reset_host(struct ps3_instance *instance) goto l_out; } - if (ps3_hard_reset_pre_check(instance) != PS3_SUCCESS) { + if ((ret = ps3_hard_reset_pre_check(instance) ) != PS3_SUCCESS) { LOG_ERROR("hno:%u hard reset pre check NOK, %s!\n", - PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read( - &instance->state_machine.state))); + PS3_HOST(instance), + namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); ret = FAILED; goto l_wait; } ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state == - PS3_HOST_RESET_HARD_RESET_DONE) { - instance->recovery_context->host_reset_state = - PS3_HOST_RESET_START; + if (instance->recovery_context->host_reset_state == PS3_HOST_RESET_HARD_RESET_DONE) { + instance->recovery_context->host_reset_state = PS3_HOST_RESET_START; } ps3_mutex_unlock(&instance->state_machine.lock); @@ -1245,7 +1177,7 @@ int ps3_reset_host(struct ps3_instance *instance) if (ret != PS3_SUCCESS) { cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_ERROR("hno:%u recovery request NOK, %s!\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = FAILED; goto l_wait; } @@ -1254,75 +1186,71 @@ int ps3_reset_host(struct ps3_instance *instance) ret = ps3_instance_wait_for_hard_reset_flag_done(instance); if (ret == PS3_SUCCESS) { cur_state = ps3_atomic_read(&instance->state_machine.state); - LOG_INFO("hno:%u recovery success, %s!\n", PS3_HOST(instance), - namePS3InstanceState(cur_state)); + LOG_INFO("hno:%u recovery success, %s!\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = SUCCESS; goto l_wait; - } else if (ret == -PS3_RETRY) { + } else if(ret == -PS3_RETRY){ ps3_mutex_lock(&instance->state_machine.lock); - if (unlikely(instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE)) { - instance->recovery_context->recovery_state = - PS3_HARD_RECOVERY_FINISH; + if (unlikely(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { + instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_FINISH; } ps3_mutex_unlock(&instance->state_machine.lock); ret = ps3_hard_recovery_request_with_retry(instance); if (ret != PS3_SUCCESS) { - cur_state = - ps3_atomic_read(&instance->state_machine.state); + cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_ERROR("hno:%u recovery request NOK, %s!\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = FAILED; goto l_wait; } ret = ps3_instance_wait_for_hard_reset_flag_done(instance); if (ret != PS3_SUCCESS) { - cur_state = - ps3_atomic_read(&instance->state_machine.state); - LOG_ERROR( - "hno:%u recovery NOK, %s,host_reset_state:%d!\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state), + cur_state = ps3_atomic_read(&instance->state_machine.state); + LOG_ERROR("hno:%u recovery NOK, %s,host_reset_state:%d!\n", + PS3_HOST(instance),namePS3InstanceState(cur_state), instance->recovery_context->host_reset_state); ret = FAILED; } else { ret = SUCCESS; } - } else { + }else { ret = FAILED; goto l_out; } l_wait: - while (atomic_read(&instance->cmd_statistics.io_outstanding) != 0) + while(atomic_read(&instance->cmd_statistics.io_outstanding) != 0) { ps3_msleep(3000); + } l_out: - if (!instance->state_machine.is_load && !instance->is_suspend) + if (!instance->state_machine.is_load && + !instance->is_suspend) { instance->state_machine.can_hostreset = PS3_FALSE; + } + INJECT_START(PS3_ERR_IJ_BLOCK_HOST_RESET, instance) cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_DEAD && - instance->state_machine.can_hostreset) { - ps3_r1x_conflict_queue_clean_all( - instance, PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), - PS3_TRUE); + instance->state_machine.can_hostreset) { + ps3_r1x_conflict_queue_clean_all(instance, + PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); ps3_qos_waitq_clear_all(instance, PS3_STATUS_HOST_NOT_FOUND); } ps3_mutex_lock(&instance->state_machine.lock); instance->recovery_context->host_reset_state = PS3_HOST_RESET_INIT; ps3_mutex_unlock(&instance->state_machine.lock); ps3_atomic_dec(&instance->host_reset_processing); - LOG_WARN("hno:%u host reset hard recovery %d!\n", PS3_HOST(instance), - ret); + LOG_WARN("hno:%u host reset hard recovery %d!\n", + PS3_HOST(instance), ret); return ret; } -int ps3_err_reset_target(struct scsi_cmnd *scmd) +S32 ps3_err_reset_target(struct scsi_cmnd *scmd) { #ifndef _WINDOWS LOG_WARN("hno:%u enter target reset channel:%u id:%u\n", - PS3_HOST(scsi_host_data(scmd)), PS3_SDEV_CHANNEL(scmd->device), - PS3_SDEV_TARGET(scmd->device)); + PS3_HOST(scsi_host_data(scmd)), + PS3_SDEV_CHANNEL(scmd->device), PS3_SDEV_TARGET(scmd->device)); return ps3_device_reset_handler(scmd); #else @@ -1331,12 +1259,12 @@ int ps3_err_reset_target(struct scsi_cmnd *scmd) #endif } -int ps3_err_reset_host(struct scsi_cmnd *scmd) +S32 ps3_err_reset_host(struct scsi_cmnd *scmd) { - int ret = 0; + S32 ret = 0; #ifndef _WINDOWS struct ps3_instance *instance = - (struct ps3_instance *)scmd->device->host->hostdata; + (struct ps3_instance*)scmd->device->host->hostdata; #else struct ps3_instance *instance = scsi_host_data(scmd); #endif @@ -1345,31 +1273,29 @@ int ps3_err_reset_host(struct scsi_cmnd *scmd) return ret; } -#if defined(PS3_RESET_TIMER) +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 3)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0))) enum scsi_timeout_action ps3_err_reset_timer(struct scsi_cmnd *scmd) #else enum blk_eh_timer_return ps3_err_reset_timer(struct scsi_cmnd *scmd) #endif { struct ps3_instance *instance = NULL; - unsigned long flags = 0; + ULong flags = 0; instance = (struct ps3_instance *)scmd->device->host->hostdata; - if (time_after(jiffies, - scmd->jiffies_at_alloc + - (SCMD_GET_REQUEST(scmd)->timeout * 2))) { - LOG_FILE_WARN( - "reset timer not handled [%u:%u:%u:%llu], tag:%d op:0x%x\n" - "\ttimeout:%u alloc_time:%lu cur_time:%lu\n", + if (time_after(jiffies, scmd->jiffies_at_alloc + + (SCMD_GET_REQUEST(scmd)->timeout * 2))) { + LOG_FILE_WARN("reset timer not handled [%u:%u:%u:%llu], tag:%d op:0x%x " + "timeout:%u alloc_time:%lu cur_time:%lu\n", PS3_HOST(instance), scmd->device->channel, - scmd->device->id, (unsigned long long)scmd->device->lun, - SCMD_GET_REQUEST(scmd)->tag, + scmd->device->id, (U64)scmd->device->lun, SCMD_GET_REQUEST(scmd)->tag, scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff, - SCMD_GET_REQUEST(scmd)->timeout, scmd->jiffies_at_alloc, - jiffies); -#if defined(PS3_BLK_EH_NOT_HANDLED) + SCMD_GET_REQUEST(scmd)->timeout, scmd->jiffies_at_alloc, jiffies); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,16,0) return BLK_EH_NOT_HANDLED; -#elif defined(PS3_RESET_TIMER) +#elif ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 3)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0))) return SCSI_EH_NOT_HANDLED; #else return BLK_EH_DONE; @@ -1377,7 +1303,8 @@ enum blk_eh_timer_return ps3_err_reset_timer(struct scsi_cmnd *scmd) } if (instance->is_support_io_limit && - !instance->fault_context.ioc_busy) { + !instance->fault_context.ioc_busy) { + spin_lock_irqsave(instance->host->host_lock, flags); instance->host->can_queue = instance->cmd_attr.throttle_que_depth; @@ -1387,45 +1314,43 @@ enum blk_eh_timer_return ps3_err_reset_timer(struct scsi_cmnd *scmd) spin_unlock_irqrestore(instance->host->host_lock, flags); } - LOG_FILE_WARN("reset timer [%u:%u:%u:%llu], tag:%d op:0x%x\n" - "\ttimeout:%u alloc_time:%lu cur_time:%lu\n", - PS3_HOST(instance), scmd->device->channel, - scmd->device->id, (unsigned long long)scmd->device->lun, - SCMD_GET_REQUEST(scmd)->tag, - scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff, - SCMD_GET_REQUEST(scmd)->timeout, scmd->jiffies_at_alloc, - jiffies); + LOG_FILE_WARN("reset timer [%u:%u:%u:%llu], tag:%d op:0x%x " + "timeout:%u alloc_time:%lu cur_time:%lu\n", + PS3_HOST(instance), scmd->device->channel, + scmd->device->id, (U64)scmd->device->lun, SCMD_GET_REQUEST(scmd)->tag, + scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff, + SCMD_GET_REQUEST(scmd)->timeout, scmd->jiffies_at_alloc, jiffies); -#if defined(PS3_RESET_TIMER) +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 3)) || \ +(LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0))) return SCSI_EH_RESET_TIMER; #else return BLK_EH_RESET_TIMER; #endif } static void ps3_scsi_sense_print(struct ps3_instance *instance, - const unsigned char *sense_buffer, - unsigned char len, int CFID) + const U8 *sense_buffer, U8 len, S32 CFID) { - struct ps3_scsi_sense_hdr sshdr; - + ps3_scsi_sense_hdr_s sshdr; memset(&sshdr, 0, sizeof(sshdr)); (void)instance; - if (sense_buffer == NULL || len == 0) + if (sense_buffer == NULL || len == 0) { goto l_out; + } sshdr.resp_code = (sense_buffer[0] & PS3_SENSE_RESP_CODE_MASK); if ((sshdr.resp_code & PS3_SENSE_RESP_CODE_VALID_MASK) != - PS3_SENSE_RESP_CODE_VALID_MASK) { - LOG_WARN_IN_IRQ(instance, "CFID:%d sense rcode invalid:0x%x\n", - CFID, sshdr.resp_code); + PS3_SENSE_RESP_CODE_VALID_MASK) { + LOG_WARN_IN_IRQ(instance, + "CFID:%d sense rcode invalid:0x%x\n", CFID, + sshdr.resp_code); goto l_out; } if (sshdr.resp_code >= PS3_SENSE_RESP_CODE_DESC_FORMAT) { if (len > 1) - sshdr.sense_key = - (sense_buffer[1] & PS3_SENSE_KEY_MASK); + sshdr.sense_key = (sense_buffer[1] & PS3_SENSE_KEY_MASK); if (len > 2) sshdr.asc = sense_buffer[2]; if (len > 3) @@ -1434,12 +1359,10 @@ static void ps3_scsi_sense_print(struct ps3_instance *instance, sshdr.additional_len = sense_buffer[7]; } else { if (len > 2) - sshdr.sense_key = - (sense_buffer[2] & PS3_SENSE_KEY_MASK); + sshdr.sense_key = (sense_buffer[2] & PS3_SENSE_KEY_MASK); if (len > 7) { - len = (len < (sense_buffer[7] + 8)) ? - len : - (sense_buffer[7] + 8); + len = (len < (sense_buffer[7] + 8)) ? len : + (sense_buffer[7] + 8); if (len > 12) sshdr.asc = sense_buffer[12]; if (len > 13) @@ -1447,8 +1370,7 @@ static void ps3_scsi_sense_print(struct ps3_instance *instance, } } - LOG_WARN_IN_IRQ( - instance, + LOG_WARN_IN_IRQ(instance, "sense: CFID:%d, rcode:0x%x, key:0x%x, asc:0x%x, ascq:0x%x\n", CFID, sshdr.resp_code, sshdr.sense_key, sshdr.asc, sshdr.ascq); l_out: @@ -1456,7 +1378,9 @@ static void ps3_scsi_sense_print(struct ps3_instance *instance, } void ps3_check_and_wait_host_reset(struct ps3_instance *instance) { - while (ps3_atomic_read(&instance->host_reset_processing) != 0) + while(ps3_atomic_read(&instance->host_reset_processing) != 0){ ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); + } +return; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.h b/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.h index c9518a369cb6..1e84c3252bb0 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_SCSI_CMD_ERR_H_ #define _PS3_SCSI_CMD_ERR_H_ @@ -11,86 +10,83 @@ #include "ps3_htp_def.h" #include "ps3_instance_manager.h" -#include "ps3_kernel_version.h" -#define PS3_SCSI_HOST_SHIFT (16) -#define PS3_SCSI_DRIVER_SHIFT (24) +#define PS3_SCSI_HOST_SHIFT (16) +#define PS3_SCSI_DRIVER_SHIFT (24) -#define PS3_SAS_DATA_PRES_SHIFT (8) -#define PS3_SAS_DATA_PRES_MASK (0x3) -#define PS3_SAS_SENSE_LEN_OFFSET (16) -#define PS3_SAS_RESPDATA_LEN_OFFSET (20) -#define PS3_SAS_SENSE_RESPDATA_LEN_BYTE (4) -#define PS3_SAS_SCSI_STATUS_OFFSET (11) -#define PS3_SAS_RESP_CODE_BYTE (3) +#define PS3_SAS_DATA_PRES_SHIFT (8) +#define PS3_SAS_DATA_PRES_MASK (0x3) +#define PS3_SAS_SENSE_LEN_OFFSET (16) +#define PS3_SAS_RESPDATA_LEN_OFFSET (20) +#define PS3_SAS_SENSE_RESPDATA_LEN_BYTE (4) +#define PS3_SAS_SCSI_STATUS_OFFSET (11) +#define PS3_SAS_RESP_CODE_BYTE (3) -#define PS3_SCSI_STATUS_MASK (0xFF) +#define PS3_SCSI_STATUS_MASK (0xFF) #define PS3_SCSI_RESULT_HOST_STATUS(STATUS) ((STATUS) << PS3_SCSI_HOST_SHIFT) -#define PS3_SCSI_RESULT_DRIVER_STATUS(STATUS) \ - ((STATUS) << PS3_SCSI_DRIVER_SHIFT) +#define PS3_SCSI_RESULT_DRIVER_STATUS(STATUS) ((STATUS) << PS3_SCSI_DRIVER_SHIFT) -#define PS3_SENSE_RESP_CODE_VALID_MASK (0x70) -#define PS3_SENSE_RESP_CODE_DESC_FORMAT (0x72) -#define PS3_SENSE_RESP_CODE_MASK (0x7F) -#define PS3_SENSE_KEY_MASK (0xF) -#define PS3_ABORT_WAIT_CMD_FLIGHT_END 50 -#define PS3_NVME_RESP_STATUS_SQ_FULL (0x102) +#define PS3_SENSE_RESP_CODE_VALID_MASK (0x70) +#define PS3_SENSE_RESP_CODE_DESC_FORMAT (0x72) +#define PS3_SENSE_RESP_CODE_MASK (0x7F) +#define PS3_SENSE_KEY_MASK (0xF) +#define PS3_ABORT_WAIT_CMD_FLIGHT_END 50 +#define PS3_NVME_RESP_STATUS_SQ_FULL (0x102) enum ps3_sas_resp_code { - PS3_SAS_RESP_CODE_TASK_MGR_COMPLETE = 0x0, - PS3_SAS_RESP_CODE_INVALID_FRAME = 0x2, - PS3_SAS_RESP_CODE_TASK_MGR_NOT_SUPPORT = 0x4, - PS3_SAS_RESP_CODE_TASK_MGR_FAILED = 0x5, - PS3_SAS_RESP_CODE_TASK_MGR_SUCCESS = 0x8, - PS3_SAS_RESP_CODE_INCORRECT_LUN = 0x9, - PS3_SAS_RESP_CODE_OVERLAPPED_INIT_PORT = 0xa, + PS3_SAS_RESP_CODE_TASK_MGR_COMPLETE = 0x0, + PS3_SAS_RESP_CODE_INVALID_FRAME = 0x2, + PS3_SAS_RESP_CODE_TASK_MGR_NOT_SUPPORT = 0x4, + PS3_SAS_RESP_CODE_TASK_MGR_FAILED = 0x5, + PS3_SAS_RESP_CODE_TASK_MGR_SUCCESS = 0x8, + PS3_SAS_RESP_CODE_INCORRECT_LUN = 0x9, + PS3_SAS_RESP_CODE_OVERLAPPED_INIT_PORT = 0xa, }; enum ps3_sas_data_pres { - PS3_SAS_PRES_NO_DATA = 0x0, + PS3_SAS_PRES_NO_DATA = 0x0, PS3_SAS_PRES_REPSNSE_DATA = 0x1, - PS3_SAS_PRES_SENSE_DATA = 0x2, - PS3_SAS_PRES_RESERVED = 0x3, + PS3_SAS_PRES_SENSE_DATA = 0x2, + PS3_SAS_PRES_RESERVED = 0x3, }; -struct ps3_scsi_sense_hdr { - unsigned char resp_code; - unsigned char sense_key; - unsigned char asc; - unsigned char ascq; - unsigned char byte4; - unsigned char byte5; - unsigned char byte6; - unsigned char additional_len; -}; +typedef struct ps3_scsi_sense_hdr { + U8 resp_code; + U8 sense_key; + U8 asc; + U8 ascq; + U8 byte4; + U8 byte5; + U8 byte6; + U8 additional_len; +} ps3_scsi_sense_hdr_s; -int ps3_err_scsi_cmd_fault_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd); -int ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd); -int ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd); -int ps3_device_reset_handler(struct scsi_cmnd *scmd); -int ps3_err_reset_target(struct scsi_cmnd *scmd); -int ps3_err_reset_host(struct scsi_cmnd *scmd); -#if defined(PS3_RESET_TIMER) +S32 ps3_err_scsi_cmd_fault_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd); +S32 ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd); +S32 ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd); +S32 ps3_device_reset_handler(struct scsi_cmnd *scmd); +S32 ps3_err_reset_target(struct scsi_cmnd *scmd); +S32 ps3_err_reset_host(struct scsi_cmnd *scmd); +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 3)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0))) enum scsi_timeout_action ps3_err_reset_timer(struct scsi_cmnd *scmd); #else enum blk_eh_timer_return ps3_err_reset_timer(struct scsi_cmnd *scmd); #endif -unsigned char ps3_err_is_resp_from_direct_cmd(unsigned short mode); +Bool ps3_err_is_resp_from_direct_cmd(U16 mode); void ps3_errcode_to_scsi_status(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, unsigned int err_code, - union PS3RespFrame *resp_frame, - unsigned int xfer_cnt, struct ps3_cmd *cmd); + struct scsi_cmnd *s_cmd, U32 err_code, + PS3RespFrame_u *resp_frame, U32 xfer_cnt, struct ps3_cmd *cmd); + +S32 ps3_err_scsi_io_processing(struct ps3_instance *instance, + U32 id, U32 channel); -int ps3_err_scsi_io_processing(struct ps3_instance *instance, unsigned int id, - unsigned int channel); -int ps3_reset_host(struct ps3_instance *instance); +S32 ps3_reset_host(struct ps3_instance *instance); -void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, - unsigned char resp_status, - unsigned char cmd_lock); +void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, U8 resp_status, Bool cmd_lock); void ps3_check_and_wait_host_reset(struct ps3_instance *instance); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih.c b/drivers/scsi/linkdata/ps3stor/ps3_scsih.c index 01dc72566749..f6316f9357a8 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #include "ps3_scsih.h" #ifndef _WINDOWS @@ -14,6 +12,7 @@ #endif #include "ps3_htp.h" +#include "ps3_meta.h" #include "ps3_err_def.h" #include "ps3_instance_manager.h" #include "ps3_cmd_channel.h" @@ -28,40 +27,34 @@ #include "ps3_io_trace.h" #include "ps3_htp_sas.h" -static int ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd); -static int ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, - unsigned short disk_id, - unsigned long long data_addr, - unsigned int sge_count); -static int ps3_scsih_sas_req_frame_build(struct ps3_cmd *cmd); -static int ps3_scsih_sata_req_frame_build(struct ps3_cmd *cmd); -static int ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd); -static inline unsigned short -ps3_scsih_is_use_hard_cmd(const struct ps3_cmd *cmd); -static int ps3_vd_access_policy_check(struct ps3_instance *instance, - unsigned char channel, unsigned short id, - struct scsi_cmnd *s_cmd); -static unsigned short -ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, - struct PS3FrontEndReqFrame *req); +static S32 ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd); +static S32 ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, + U16 disk_id, U64 data_addr, U32 sge_count); +static S32 ps3_scsih_sas_req_frame_build(struct ps3_cmd *cmd); +static S32 ps3_scsih_sata_req_frame_build(struct ps3_cmd *cmd); +static S32 ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd); +static inline U16 ps3_scsih_is_use_hard_cmd(const struct ps3_cmd *cmd); +static S32 ps3_vd_access_policy_check(struct ps3_instance *instance, + U8 channel, U16 id, struct scsi_cmnd *s_cmd); +static U16 ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, + PS3FrontEndReqFrame_s *req); static void ps3_scsih_req_frame_head_build(struct ps3_cmd *cmd, - unsigned char req_frame_format); -static inline void ps3_scsih_print_req_head(struct ps3_cmd *cmd, - unsigned char log_level); -static unsigned int ps3_scsih_datelen_calc(const struct ps3_cmd *cmd); + U8 req_frame_format); +static inline void ps3_scsih_print_req_head(struct ps3_cmd *cmd, U8 log_level); +static U32 ps3_scsih_datelen_calc(const struct ps3_cmd *cmd); #ifdef _WINDOWS static void ps3_scsi_need_remap_check(struct ps3_cmd *cmd); -static int ps3_scsi_remap_sgl(struct ps3_cmd *cmd); +static S32 ps3_scsi_remap_sgl(struct ps3_cmd *cmd); #endif -#define PS3_CMD_WORD_QUE_CALC(vd_id, lba, map_block, que_num) \ - (((vd_id) + (PS3_DIV64_32((lba), (map_block)))) & que_num) +#define PS3_CMD_WORD_QUE_CALC(vd_id, lba, map_block, que_num) \ + (((vd_id) + ((lba) / (map_block))) & que_num) -#define PS3_SCSIH_NOT_SAME_MAPBLOCK(lba, map_block, num_blocks) \ - (((map_block) - (PS3_MOD64((lba), (map_block)))) < (num_blocks)) -#define PS3_LBA(lba_hi, lba_lo) \ - ((((unsigned long long)(lba_hi)) << PS3_SHIFT_DWORD) | (lba_lo)) +#define PS3_SCSIH_NOT_SAME_MAPBLOCK(lba, map_block, num_blocks) \ + (((map_block) - ((lba) % (map_block))) < (num_blocks)) +#define PS3_LBA(lba_hi, lba_lo) \ + ((((U64)(lba_hi)) << PS3_SHIFT_DWORD) | (lba_lo)) #ifndef _WINDOWS #define sg_dma_address_u64(sg) sg_dma_address(sg) @@ -72,19 +65,19 @@ static int ps3_scsi_remap_sgl(struct ps3_cmd *cmd); #define UNMAP_CDB_VALID_LEN (10) static struct disk_type_to_proc_func_table g_req_frame_func_table[] = { - { PS3_DEV_TYPE_VD, ps3_scsih_vd_req_frame_build }, - { PS3_DEV_TYPE_SAS_HDD, ps3_scsih_sas_req_frame_build }, - { PS3_DEV_TYPE_SATA_HDD, ps3_scsih_sata_req_frame_build }, - { PS3_DEV_TYPE_SATA_SSD, ps3_scsih_sata_req_frame_build }, - { PS3_DEV_TYPE_SAS_SSD, ps3_scsih_sas_req_frame_build }, - { PS3_DEV_TYPE_NVME_SSD, ps3_scsih_nvme_req_frame_build }, - { PS3_DEV_TYPE_SES, ps3_scsih_sas_req_frame_build }, - { PS3_DEV_TYPE_VEP, ps3_scsih_sas_req_frame_build } + {PS3_DEV_TYPE_VD, ps3_scsih_vd_req_frame_build}, + {PS3_DEV_TYPE_SAS_HDD, ps3_scsih_sas_req_frame_build}, + {PS3_DEV_TYPE_SATA_HDD, ps3_scsih_sata_req_frame_build}, + {PS3_DEV_TYPE_SATA_SSD, ps3_scsih_sata_req_frame_build}, + {PS3_DEV_TYPE_SAS_SSD, ps3_scsih_sas_req_frame_build}, + {PS3_DEV_TYPE_NVME_SSD, ps3_scsih_nvme_req_frame_build}, + {PS3_DEV_TYPE_SES, ps3_scsih_sas_req_frame_build}, + {PS3_DEV_TYPE_VEP, ps3_scsih_sas_req_frame_build} }; #ifndef _WINDOWS -unsigned char ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) +Bool ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) { struct ps3_scsi_priv_data *data = (struct ps3_scsi_priv_data *)cmd->scmd->device->hostdata; @@ -98,19 +91,18 @@ unsigned char ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) struct ps3_stream_detect *current_sd; u64 lba = 0; u32 len = 0; - unsigned char is_stream = PS3_FALSE; - unsigned int typeIndex; - u32 type = - PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cmd->scmd->cmnd)); - unsigned long flag = 0; - long long value = 0; + Bool is_stream = PS3_FALSE; + U32 typeIndex; + u32 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cmd->scmd->cmnd)); + ULong flag = 0; + S64 value = 0; - if (PS3_IF_QUIT_STREAM_DIRECT_DETECT()) + if (PS3_IF_QUIT_STREAM_DIRECT_DETECT()) { goto l_out; + } - if ((type != PS3_SCSI_CMD_TYPE_READ) && - (type != PS3_SCSI_CMD_TYPE_WRITE)) { + if((type != PS3_SCSI_CMD_TYPE_READ) && (type != PS3_SCSI_CMD_TYPE_WRITE)){ goto l_out; } @@ -123,74 +115,66 @@ unsigned char ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) ps3_scsih_len_parse(cmd->scmd->cmnd, &len); for (index = 0; index < PS3_IO_MAX_STREAMS_TRACKED; ++index) { stream_num = (*track_stream >> - (index << BITS_PER_INDEX_STREAM_SHIFT)) & - STREAM_MASK; + (index << BITS_PER_INDEX_STREAM_SHIFT)) & + STREAM_MASK; current_sd = ¤t_ld_sd->stream_track[stream_num]; value = current_sd->next_seq_lba - IO_STREAM_DETECT_RANGE; if ((((value >= 0) && - (lba >= - current_sd->next_seq_lba - IO_STREAM_DETECT_RANGE) && - (lba <= (current_sd->next_seq_lba + - IO_STREAM_DETECT_RANGE * 2))) || - ((current_sd->next_seq_lba) && - (lba >= current_sd->next_seq_lba) && - (lba <= (current_sd->next_seq_lba + 32)))) && - (type == current_sd->rw_type)) { + (lba >= current_sd->next_seq_lba - IO_STREAM_DETECT_RANGE) && + (lba <= (current_sd->next_seq_lba + IO_STREAM_DETECT_RANGE * 2))) || + ((current_sd->next_seq_lba) && + (lba >= current_sd->next_seq_lba) && + (lba <= (current_sd->next_seq_lba + 32))))&& + (type == current_sd->rw_type)){ is_stream = PS3_TRUE; cmd->io_attr.seq_flag = SCSI_RW_SEQ_CMD; - cmd->req_frame->frontendReq.reqHead.isStream1 = - PS3_TRUE; - current_sd->next_seq_lba = lba + len; + cmd->req_frame->frontendReq.reqHead.isStream1 = PS3_TRUE; + current_sd->next_seq_lba = + lba + len; shifted_values_mask = - (1ULL - << (index << BITS_PER_INDEX_STREAM_SHIFT)) - - 1; + (1ULL << (index << BITS_PER_INDEX_STREAM_SHIFT)) - 1; shifted_values = ((*track_stream & shifted_values_mask) - << BITS_PER_INDEX_STREAM); + << BITS_PER_INDEX_STREAM); index_value_mask = - STREAM_MASK - << (index << BITS_PER_INDEX_STREAM_SHIFT); + STREAM_MASK << (index << BITS_PER_INDEX_STREAM_SHIFT); unshifted_values = - *track_stream & - ~(shifted_values_mask | index_value_mask); + *track_stream & ~(shifted_values_mask | + index_value_mask); *track_stream = unshifted_values | shifted_values | stream_num; goto end; } } - stream_num = (*track_stream >> ((PS3_IO_MAX_STREAMS_TRACKED - 1) - << BITS_PER_INDEX_STREAM_SHIFT)) & - STREAM_MASK; + stream_num = (*track_stream >> ((PS3_IO_MAX_STREAMS_TRACKED - 1) << + BITS_PER_INDEX_STREAM_SHIFT)) & STREAM_MASK; current_sd = ¤t_ld_sd->stream_track[stream_num]; current_sd->rw_type = type; current_sd->next_seq_lba = lba + len; - *track_stream = - (((*track_stream & ZERO_LAST_STREAM) << 4) | stream_num); + *track_stream = (((*track_stream & ZERO_LAST_STREAM) << 4) | stream_num); cmd->io_attr.seq_flag = SCSI_RW_RANDOM_CMD; end: - ps3_spin_unlock_irqrestore(¤t_ld_sd->ps3_sequence_stream_lock, - flag); + ps3_spin_unlock_irqrestore(¤t_ld_sd->ps3_sequence_stream_lock, flag); l_out: + INJECT_START(PS3_ERR_IJ_FORCE_SEQ_CMD, cmd); + INJECT_START(PS3_ERR_IJ_FORCE_STREAM_DETECT_TRUE, &is_stream); + INJECT_START(PS3_ERR_IJ_FORCE_RAND_CMD, cmd); + INJECT_START(PS3_ERR_IJ_FORCE_STREAM_DETECT_FALSE, &is_stream); return is_stream; } -unsigned char ps3_raid_scsih_stream_is_direct(const struct ps3_cmd *cmd) +Bool ps3_raid_scsih_stream_is_direct(const struct ps3_cmd *cmd) { - struct ps3_scsi_priv_data *p_priv_data = - scsi_device_private_data(cmd->scmd); - unsigned char is_direct = PS3_TRUE; + struct ps3_scsi_priv_data *p_priv_data = scsi_device_private_data(cmd->scmd); + Bool is_direct = PS3_TRUE; if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - if (cmd->io_attr.vd_entry->isNvme || - !(cmd->io_attr.vd_entry->isSsd && - (ps3_atomic_read(&p_priv_data->rd_io_outstand) > - PS3_VD_IO_16_OUTSTANDING) && - (cmd->io_attr.num_blocks > - PS3_BLOCK_NUM_OF_32K))) { + if (cmd->io_attr.vd_entry->isNvme || !(cmd->io_attr.vd_entry->isSsd && + (ps3_atomic_read(&p_priv_data->rd_io_outstand) > PS3_VD_IO_16_OUTSTANDING) && + (cmd->io_attr.num_blocks > PS3_BLOCK_NUM_OF_32K))) { is_direct = PS3_FALSE; } } @@ -198,17 +182,16 @@ unsigned char ps3_raid_scsih_stream_is_direct(const struct ps3_cmd *cmd) return is_direct; } -unsigned char ps3_hba_scsih_stream_is_direct(const struct ps3_cmd *cmd) +Bool ps3_hba_scsih_stream_is_direct(const struct ps3_cmd *cmd) { - unsigned char is_direct = PS3_TRUE; - struct ps3_scsi_priv_data *p_priv_data = - scsi_device_private_data(cmd->scmd); + Bool is_direct = PS3_TRUE; + struct ps3_scsi_priv_data *p_priv_data = scsi_device_private_data(cmd->scmd); + if (p_priv_data->dev_type == PS3_DEV_TYPE_VD && - cmd->io_attr.vd_entry->isNvme && - ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - if (ps3_atomic_read(&p_priv_data->rd_io_outstand) > - PS3_VD_IO_16_OUTSTANDING && - cmd->io_attr.num_blocks > PS3_BLOCK_NUM_OF_32K) { + cmd->io_attr.vd_entry->isNvme && + ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { + if (ps3_atomic_read(&p_priv_data->rd_io_outstand) > PS3_VD_IO_16_OUTSTANDING && + cmd->io_attr.num_blocks > PS3_BLOCK_NUM_OF_32K) { is_direct = PS3_FALSE; } } @@ -216,50 +199,45 @@ unsigned char ps3_hba_scsih_stream_is_direct(const struct ps3_cmd *cmd) return is_direct; } -static unsigned char ps3_scsih_sys_state_check(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, - int *scsi_result) +static Bool ps3_scsih_sys_state_check(struct ps3_instance *instance, + struct scsi_cmnd *s_cmd, S32 *scsi_result) { - unsigned char ret = PS3_TRUE; - int cur_state = PS3_INSTANCE_STATE_INIT; + Bool ret = PS3_TRUE; + S32 cur_state = PS3_INSTANCE_STATE_INIT; *scsi_result = PS3_SUCCESS; if (!instance->state_machine.is_load) { - LOG_INFO_LIM("hno:%u instance state not is_load\n", - PS3_HOST(instance)); + LOG_INFO_LIM("hno:%u instance state not is_load\n", PS3_HOST(instance)); goto l_scsi_done; } PS3_IO_START_INC(instance, s_cmd); cur_state = atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_DEAD || - cur_state == PS3_INSTANCE_STATE_QUIT) { + cur_state == PS3_INSTANCE_STATE_QUIT) { PS3_IO_BACK_ERR_INC(instance, s_cmd); - LOG_INFO_LIM("hno:%u instance state is dead/quit\n", - PS3_HOST(instance)); + LOG_INFO_LIM("hno:%u instance state is dead/quit\n", PS3_HOST(instance)); goto l_scsi_done; } - if (instance->recovery_context->host_reset_state != - PS3_HOST_RESET_INIT) { + if (instance->recovery_context->host_reset_state != PS3_HOST_RESET_INIT) { *scsi_result = SCSI_MLQUEUE_HOST_BUSY; ret = PS3_FALSE; PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); LOG_WARN_LIM("hno:%u host_Reset_state:%d\n", PS3_HOST(instance), - instance->recovery_context->host_reset_state); + instance->recovery_context->host_reset_state); goto l_out; } if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { + cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && + cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { *scsi_result = SCSI_MLQUEUE_HOST_BUSY; ret = PS3_FALSE; PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); - LOG_INFO_LIM( - "hno:%u cannot request scsi cmd tag:%d due to %s\n", + LOG_INFO_LIM("hno:%u cannot request scsi cmd tag:%d due to %s\n", PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag, namePS3InstanceState(cur_state)); goto l_out; @@ -269,7 +247,7 @@ static unsigned char ps3_scsih_sys_state_check(struct ps3_instance *instance, l_scsi_done: PS3_DEV_BUSY_DEC(s_cmd); - s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); SCMD_IO_DONE(s_cmd); *scsi_result = PS3_SUCCESS; ret = PS3_FALSE; @@ -278,20 +256,17 @@ static unsigned char ps3_scsih_sys_state_check(struct ps3_instance *instance, return ret; } -static inline unsigned char -ps3_scsih_is_illegel_vd_io(const struct scsi_cmnd *s_cmd, - struct ps3_instance *instance) +static inline Bool ps3_scsih_is_illegel_vd_io(const struct scsi_cmnd *s_cmd, + struct ps3_instance *instance) { - return (!ps3_dev_id_valid_check(instance, s_cmd->device->channel, - s_cmd->device->id, PS3_DISK_TYPE_VD) || - s_cmd->device->lun); + return(!ps3_dev_id_valid_check(instance, s_cmd->device->channel, + s_cmd->device->id, PS3_DISK_TYPE_VD) || s_cmd->device->lun); } -static unsigned char ps3_scsih_device_attr_check(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, - int *scsi_result) +static Bool ps3_scsih_device_attr_check(struct ps3_instance *instance, + struct scsi_cmnd *s_cmd, S32 *scsi_result) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; struct ps3_scsi_priv_data *data = NULL; static unsigned long j; *scsi_result = PS3_SUCCESS; @@ -300,17 +275,14 @@ static unsigned char ps3_scsih_device_attr_check(struct ps3_instance *instance, PS3_DEV_BUSY_DEC(s_cmd); *scsi_result = SCSI_MLQUEUE_DEVICE_BUSY; ret = PS3_FALSE; - LOG_INFO_LIM("hno:%u task_manager_host_busy\n", - PS3_HOST(instance)); + LOG_INFO_LIM("hno:%u task_manager_host_busy\n", PS3_HOST(instance)); goto l_out; } - data = (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; + data = (struct ps3_scsi_priv_data*)s_cmd->device->hostdata; if (unlikely(data == NULL)) { s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u device_priv_data is null s_cmd result:%d\n", + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u device_priv_data is null s_cmd result:%d\n", PS3_HOST(instance), s_cmd->result); goto l_scsi_done; } @@ -326,26 +298,30 @@ static unsigned char ps3_scsih_device_attr_check(struct ps3_instance *instance, if (data->dev_type == PS3_DEV_TYPE_VD) { if (unlikely(ps3_scsih_is_illegel_vd_io(s_cmd, instance))) { - s_cmd->result = - PS3_SCSI_RESULT_HOST_STATUS(DID_BAD_TARGET); - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u dev_type:%s id:%u max_vd_count:%u vd id NOK\n", - PS3_HOST(instance), + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_BAD_TARGET); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u dev_type:%s id:%u " + "max_vd_count:%u vd id NOK\n", PS3_HOST(instance), namePS3DevType((enum PS3DevType)data->dev_type), - s_cmd->device->id, - instance->ctrl_info.maxVdCount); + s_cmd->device->id, instance->ctrl_info.maxVdCount); goto l_scsi_done; } - if (unlikely(ps3_vd_access_policy_check( - instance, s_cmd->device->channel, - s_cmd->device->id, - s_cmd) != PS3_SUCCESS)) { + if (unlikely(ps3_vd_access_policy_check(instance, s_cmd->device->channel, + s_cmd->device->id, s_cmd) != PS3_SUCCESS)) { goto l_scsi_done; } } +#if 0 + if ((s_cmd->cmnd[0] == SYNCHRONIZE_CACHE) && is_vd_io && + !instance->is_support_sync_cache) { + s_cmd->result = DID_OK << PS3_SHIFT_WORD; + LOG_ERROR("hno:%u SYNCHRONIZE_CACHE cmd, return\n", + PS3_HOST(instance)); + goto l_out; + } +#endif + goto l_out; l_scsi_done: @@ -358,61 +334,52 @@ static unsigned char ps3_scsih_device_attr_check(struct ps3_instance *instance, return ret; } -static inline unsigned char -ps3_scsih_dev_type_get(const struct scsi_cmnd *s_cmd) +static inline U8 ps3_scsih_dev_type_get(const struct scsi_cmnd *s_cmd) { struct ps3_scsi_priv_data *data = - (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; + (struct ps3_scsi_priv_data*)s_cmd->device->hostdata; return data->dev_type; } -static inline unsigned char -ps3_scsih_is_vd_scsi_rw_cmd(const struct scsi_cmnd *s_cmd) +static inline Bool ps3_scsih_is_vd_scsi_rw_cmd(const struct scsi_cmnd *s_cmd) { return (ps3_scsih_dev_type_get(s_cmd) == PS3_DEV_TYPE_VD) ? - ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd) : - PS3_DRV_FALSE; + ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd) : PS3_DRV_FALSE; } -static unsigned char ps3_scsih_qos_check(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, - int *scsi_result) +static Bool ps3_scsih_qos_check(struct ps3_instance *instance, + struct scsi_cmnd *s_cmd, S32 *scsi_result) { - unsigned char ret = PS3_DRV_TRUE; - int vd_io_threshold = instance->cmd_attr.vd_io_threshold; - int io_outstand = 0; - int vd_io_outstand = 0; + Bool ret = PS3_DRV_TRUE; + S32 vd_io_threshold = instance->cmd_attr.vd_io_threshold; + S32 io_outstand = 0; + S32 vd_io_outstand = 0; - if (unlikely(!ps3_stat_outstand_switch_is_open(instance))) + if (unlikely(!ps3_stat_outstand_switch_is_open(instance))) { goto l_out; + } - io_outstand = - atomic_inc_return(&instance->cmd_statistics.io_outstanding); + io_outstand = atomic_inc_return(&instance->cmd_statistics.io_outstanding); if (unlikely(io_outstand > instance->host->can_queue)) { PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); *scsi_result = SCSI_MLQUEUE_HOST_BUSY; ret = PS3_FALSE; - LOG_INFO_LIM( - "hno:%u ioc io exceed can_queue:%d io_outstanding:%d\n", - PS3_HOST(instance), instance->host->can_queue, - io_outstand); + LOG_INFO_LIM("hno:%u ioc io exceed can_queue:%d io_outstanding:%d\n", + PS3_HOST(instance), instance->host->can_queue, io_outstand); goto l_dec_io_outstand; } if (unlikely(vd_io_threshold && ps3_scsih_is_vd_scsi_rw_cmd(s_cmd))) { - vd_io_outstand = atomic_inc_return( - &instance->cmd_statistics.vd_io_outstanding); + vd_io_outstand = atomic_inc_return(&instance->cmd_statistics.vd_io_outstanding); if (unlikely(vd_io_outstand > vd_io_threshold)) { PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); *scsi_result = SCSI_MLQUEUE_DEVICE_BUSY; ret = PS3_FALSE; - LOG_INFO_LIM( - "hno:%u vd io exceed vd_io_threshold:%d vd_outstanding:%d\n", - PS3_HOST(instance), vd_io_threshold, - vd_io_outstand); + LOG_INFO_LIM("hno:%u vd io exceed vd_io_threshold:%d vd_outstanding:%d\n", + PS3_HOST(instance), vd_io_threshold, vd_io_outstand); goto l_dec_vd_io_outstand; } } @@ -429,20 +396,21 @@ static unsigned char ps3_scsih_qos_check(struct ps3_instance *instance, return ret; } -static unsigned char ps3_scsih_que_cmd_check(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, - int *scsi_result) +static Bool ps3_scsih_que_cmd_check(struct ps3_instance *instance, + struct scsi_cmnd *s_cmd, S32 *scsi_result) { - unsigned char ret = PS3_TRUE; + Bool ret = PS3_TRUE; s_cmd->result = DID_OK; ret = ps3_scsih_sys_state_check(instance, s_cmd, scsi_result); - if (unlikely(!ret)) + if (unlikely(!ret)) { goto l_out; + } ret = ps3_scsih_device_attr_check(instance, s_cmd, scsi_result); - if (unlikely(!ret)) + if (unlikely(!ret)) { goto l_out; + } ret = ps3_scsih_qos_check(instance, s_cmd, scsi_result); @@ -451,40 +419,34 @@ static unsigned char ps3_scsih_que_cmd_check(struct ps3_instance *instance, } #else -unsigned char ps3_scsih_sys_state_check(struct ps3_instance *instance, - int *host_status) +Bool ps3_scsih_sys_state_check(struct ps3_instance *instance, S32 *host_status) { - unsigned char ret = PS3_DRV_TRUE; - int cur_state = PS3_INSTANCE_STATE_INIT; + Bool ret = PS3_DRV_TRUE; + S32 cur_state = PS3_INSTANCE_STATE_INIT; static unsigned long j; - if (!instance->state_machine.is_load) { LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u instance state not is_load\n", - PS3_HOST(instance)); + "hno:%u instance state not is_load\n", PS3_HOST(instance)); *host_status = DID_ERROR; goto l_out; } cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_DEAD || - cur_state == PS3_INSTANCE_STATE_QUIT) { + cur_state == PS3_INSTANCE_STATE_QUIT) { LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u instance state is dead/quit\n", - PS3_HOST(instance)); + "hno:%u instance state is dead/quit\n", PS3_HOST(instance)); *host_status = DID_BAD_TARGET; goto l_out; } if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { + cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && + cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { ret = PS3_DRV_FALSE; *host_status = DID_BUS_BUSY; - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u cannot request scsi cmd due to %s\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state)); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u cannot request scsi cmd due to %s\n", + PS3_HOST(instance), namePS3InstanceState(cur_state)); goto l_out; } @@ -492,23 +454,30 @@ unsigned char ps3_scsih_sys_state_check(struct ps3_instance *instance, return ret; } -unsigned char ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) +Bool ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) { (void)cmd; return PS3_FALSE; } #endif +#if 0 +static Bool ps3_synchronize_cache_filter(struct scsi_cmnd *s_cmd) +{ + (void)s_cmd; + return PS3_DRV_FALSE; +} +#endif + #ifndef _WINDOWS -int ps3_scsih_queue_command(struct Scsi_Host *s_host, struct scsi_cmnd *s_cmd) +S32 ps3_scsih_queue_command(struct Scsi_Host *s_host, + struct scsi_cmnd *s_cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_instance *instance = NULL; - struct ps3_scsi_priv_data *data = - (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; + struct ps3_scsi_priv_data *data = (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; static unsigned long j; - instance = (struct ps3_instance *)s_host->hostdata; if (unlikely(instance == NULL)) { s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); @@ -516,24 +485,26 @@ int ps3_scsih_queue_command(struct Scsi_Host *s_host, struct scsi_cmnd *s_cmd) goto l_scsi_done; } - LOG_DEBUG("hno:%u tag:%d op:0x%x cmd_len:%d chl:%u id:%u timeout:%u\n", - s_host->host_no, SCMD_GET_REQUEST(s_cmd)->tag, s_cmd->cmnd[0], - s_cmd->cmd_len, s_cmd->device->channel, s_cmd->device->id, - SCMD_GET_REQUEST(s_cmd)->timeout); + LOG_DEBUG("hno:%u tag:%d op:0x%x cmd_len:%d chl:%u " + "id:%u timeout:%u\n", s_host->host_no, SCMD_GET_REQUEST(s_cmd)->tag, + s_cmd->cmnd[0], s_cmd->cmd_len, s_cmd->device->channel, + s_cmd->device->id, SCMD_GET_REQUEST(s_cmd)->timeout); PS3_DEV_BUSY_INC(s_cmd); - if (unlikely(!ps3_scsih_que_cmd_check(instance, s_cmd, &ret))) + if (unlikely(!ps3_scsih_que_cmd_check(instance, s_cmd, &ret))) { goto l_out; + } + INJECT_START(PS3_ERR_IJ_CMD_BLOCK_BEFORE_DELIVER_CNT, instance); if (unlikely(s_cmd->cmd_len > PS3_FRAME_CDB_BUFLEN)) { - LOG_ERROR("hno:%u cmd len %u check NOK\n", PS3_HOST(instance), - s_cmd->cmd_len); + LOG_ERROR("hno:%u cmd len %u check NOK\n", PS3_HOST(instance), s_cmd->cmd_len); PS3_BUG(); s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_ERROR); goto l_scsi_done; } ps3_scsi_cmd_deliver_get(instance); + INJECT_START(PS3_ERR_IJ_CMD_SEND_INSTANCE_RECOVERY, instance); if (unlikely(!ps3_is_instance_state_normal(instance, PS3_TRUE))) { ret = SCSI_MLQUEUE_HOST_BUSY; goto l_cmd_stat_dec; @@ -541,10 +512,8 @@ int ps3_scsih_queue_command(struct Scsi_Host *s_host, struct scsi_cmnd *s_cmd) cmd = ps3_scsi_cmd_alloc(instance, SCMD_GET_REQUEST(s_cmd)->tag); if (unlikely(cmd == NULL)) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u tag:%d ps3_cmd_get NOK ret:%d\n", - PS3_HOST(instance), - SCMD_GET_REQUEST(s_cmd)->tag, ret); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tag:%d ps3_cmd_get NOK ret:%d\n", + PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag, ret); PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_IO_OUTSTAND_DEC(instance, s_cmd); PS3_VD_OUTSTAND_DEC(instance, s_cmd); @@ -554,11 +523,10 @@ int ps3_scsih_queue_command(struct Scsi_Host *s_host, struct scsi_cmnd *s_cmd) goto l_scsi_done; } + INJECT_START(PS3_ERR_IJ_CMD_BLOCK_BEFORE_SEND_TO_IOC, instance); if (cmd->scmd != NULL) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u CFID:%u cmd is exist\n", - PS3_HOST(instance), - SCMD_GET_REQUEST(s_cmd)->tag); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u CFID:%u cmd is exist\n", + PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag); PS3_BUG(); s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); goto l_cmd_stat_dec; @@ -569,53 +537,51 @@ int ps3_scsih_queue_command(struct Scsi_Host *s_host, struct scsi_cmnd *s_cmd) ret = instance->ioc_adpter->io_cmd_build(cmd); if (unlikely(ret != PS3_SUCCESS)) { switch (ret) { - case -PS3_IO_CONFLICT: - ps3_errcode_to_scsi_status(instance, s_cmd, - SCSI_STATUS_BUSY, NULL, 0, - cmd); - ret = SCSI_MLQUEUE_DEVICE_BUSY; - goto l_cmd_release; - case -PS3_IO_REQUEUE: - s_cmd->result = - PS3_SCSI_RESULT_HOST_STATUS(DID_REQUEUE); - break; - case -PS3_IO_CONFLICT_IN_Q: - LOG_DEBUG("tid:0x%llx hno:%u tag:%d conflict in queue,\n" - "\ttimeout:%u alloc_time:%lu cur_time:%lu\n", - cmd->trace_id, PS3_HOST(instance), - SCMD_GET_REQUEST(s_cmd)->tag, - SCMD_GET_REQUEST(s_cmd)->timeout, - s_cmd->jiffies_at_alloc, jiffies); - ret = PS3_SUCCESS; - cmd->flighting = PS3_FALSE; - wmb(); /* in order to force CPU ordering */ - ps3_scsi_cmd_deliver_put(instance); - goto l_out; - case -PS3_IN_QOS_Q: - ret = PS3_SUCCESS; - cmd->flighting = PS3_FALSE; - wmb(); /* in order to force CPU ordering */ - ps3_scsi_cmd_deliver_put(instance); - goto l_out; - case -PS3_RETRY: - ret = SCSI_MLQUEUE_DEVICE_BUSY; - goto l_cmd_release; - case -PS3_RECOVERED: - case SCSI_MLQUEUE_HOST_BUSY: - ret = SCSI_MLQUEUE_HOST_BUSY; - goto l_cmd_release; - default: - s_cmd->result = - PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - break; + case -PS3_IO_CONFLICT: + ps3_errcode_to_scsi_status(instance, s_cmd, SCSI_STATUS_BUSY, NULL, 0, cmd); + ret = SCSI_MLQUEUE_DEVICE_BUSY; + goto l_cmd_release; + break; + case -PS3_IO_REQUEUE: + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_REQUEUE); + break; + case -PS3_IO_CONFLICT_IN_Q: + LOG_DEBUG("tid:0x%llx hno:%u tag:%d conflict in queue, " + "timeout:%u alloc_time:%lu cur_time:%lu\n", + cmd->trace_id, PS3_HOST(instance), + SCMD_GET_REQUEST(s_cmd)->tag, + SCMD_GET_REQUEST(s_cmd)->timeout, + s_cmd->jiffies_at_alloc, jiffies); + ret = PS3_SUCCESS; + cmd->flighting = PS3_FALSE; + wmb(); + ps3_scsi_cmd_deliver_put(instance); + goto l_out; + break; + case -PS3_IN_QOS_Q: + ret = PS3_SUCCESS; + cmd->flighting = PS3_FALSE; + wmb(); + ps3_scsi_cmd_deliver_put(instance); + goto l_out; + case -PS3_RETRY: + ret = SCSI_MLQUEUE_DEVICE_BUSY; + goto l_cmd_release; + case -PS3_RECOVERED: + case SCSI_MLQUEUE_HOST_BUSY: + ret = SCSI_MLQUEUE_HOST_BUSY; + goto l_cmd_release; + default: + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + break; } LOG_DEBUG("tid:0x%llx hno:%u tag:%d cmd build err ret:%d\n", - cmd->trace_id, PS3_HOST(instance), - SCMD_GET_REQUEST(s_cmd)->tag, ret); + cmd->trace_id, PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag, ret); ret = PS3_SUCCESS; goto l_cmd_release; } + INJECT_START(PS3_ERR_IJ_CMD_SEND_WAIT_RECOVERY_END, instance); ret = ps3_scsi_cmd_send(instance, cmd, PS3_TRUE); if (unlikely(ret != PS3_SUCCESS)) { ps3_qos_cmd_update(instance, cmd); @@ -624,14 +590,12 @@ int ps3_scsih_queue_command(struct Scsi_Host *s_host, struct scsi_cmnd *s_cmd) } else if (ret == -PS3_RETRY) { ret = SCSI_MLQUEUE_DEVICE_BUSY; } else { - s_cmd->result = - PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); ret = PS3_SUCCESS; } LOG_ERROR_LIM("tid:0x%llx hno:%u tag:%d cmd send NOK ret:%d\n", - cmd->trace_id, PS3_HOST(instance), - SCMD_GET_REQUEST(s_cmd)->tag, ret); - PS3_DEV_IO_START_ERR_INC(instance, cmd); + cmd->trace_id, PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag, ret); + PS3_DEV_IO_START_ERR_INC(instance, cmd); goto l_cmd_release; } @@ -653,29 +617,30 @@ int ps3_scsih_queue_command(struct Scsi_Host *s_host, struct scsi_cmnd *s_cmd) PS3_DEV_BUSY_DEC(s_cmd); ps3_scsi_cmd_deliver_put(instance); l_scsi_done: - if (ret != SCSI_MLQUEUE_HOST_BUSY && ret != SCSI_MLQUEUE_DEVICE_BUSY) + if (ret != SCSI_MLQUEUE_HOST_BUSY && ret != SCSI_MLQUEUE_DEVICE_BUSY) { SCMD_IO_DONE(s_cmd); + } l_out: return ret; } #endif -static inline unsigned char -ps3_is_need_build_hw_req_frame(const struct ps3_cmd *cmd) +static inline Bool ps3_is_need_build_hw_req_frame(const struct ps3_cmd *cmd) { return ps3_scsih_is_use_hard_cmd(cmd) == PS3_CMDWORD_FORMAT_HARDWARE; } -unsigned char ps3_is_r1x_write_cmd(const struct ps3_cmd *cmd) +Bool ps3_is_r1x_write_cmd(const struct ps3_cmd *cmd) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; - switch (cmd->io_attr.vd_entry->raidLevel) { + switch(cmd->io_attr.vd_entry->raidLevel) { case RAID1: case RAID10: case RAID1E: - if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) + if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) { ret = PS3_TRUE; + } break; default: ret = PS3_FALSE; @@ -685,11 +650,11 @@ unsigned char ps3_is_r1x_write_cmd(const struct ps3_cmd *cmd) return ret; } -static unsigned char direct_cmd_is_raidlevel_support(struct ps3_cmd *cmd) +static Bool direct_cmd_is_raidlevel_support(struct ps3_cmd *cmd) { - unsigned char ret = PS3_DRV_TRUE; + Bool ret = PS3_DRV_TRUE; - switch (cmd->io_attr.vd_entry->raidLevel) { + switch(cmd->io_attr.vd_entry->raidLevel) { case RAID0: case RAID00: break; @@ -698,7 +663,7 @@ static unsigned char direct_cmd_is_raidlevel_support(struct ps3_cmd *cmd) case RAID1E: if (cmd->instance->cmd_context.max_r1x_cmd_count > 0) { if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_READ || - cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) { + cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) { ret = PS3_TRUE; } else { ret = PS3_FALSE; @@ -711,8 +676,9 @@ static unsigned char direct_cmd_is_raidlevel_support(struct ps3_cmd *cmd) case RAID6: case RAID50: case RAID60: - if (cmd->io_attr.rw_flag != PS3_SCSI_CMD_TYPE_READ) + if (cmd->io_attr.rw_flag != PS3_SCSI_CMD_TYPE_READ) { ret = PS3_FALSE; + } break; default: ret = PS3_FALSE; @@ -722,52 +688,48 @@ static unsigned char direct_cmd_is_raidlevel_support(struct ps3_cmd *cmd) return ret; } -static unsigned char -direct_cmd_is_plba_sector_aligned(struct ps3_cmd *cmd, - const struct ps3_pd_entry *pd) +static Bool direct_cmd_is_plba_sector_aligned(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd) { const struct PS3VDEntry *vd = cmd->io_attr.vd_entry; - unsigned char ret = PS3_DRV_FALSE; + Bool ret = PS3_DRV_FALSE; if (unlikely(pd->sector_size == 0)) { LOG_FILE_ERROR("pd chl:%u id:%u sector_size is 0\n", - PS3_CHANNEL(&pd->disk_pos), - PS3_TARGET(&pd->disk_pos)); + PS3_CHANNEL(&pd->disk_pos), + PS3_TARGET(&pd->disk_pos)); goto l_out; } #ifndef _WINDOWS - if (PS3_MOD64((cmd->io_attr.plba << ilog2(vd->sectorSize)), - pd->sector_size)) { + if ((cmd->io_attr.plba << ilog2(vd->sectorSize)) % pd->sector_size) { #else if ((cmd->io_attr.plba * vd->sectorSize) % pd->sector_size) { #endif LOG_DEBUG("pd chl:%u id:%u plba:0x%llx pd sector_size:%u\n", - PS3_CHANNEL(&pd->disk_pos), PS3_TARGET(&pd->disk_pos), - cmd->io_attr.plba, pd->sector_size); + PS3_CHANNEL(&pd->disk_pos), PS3_TARGET(&pd->disk_pos), + cmd->io_attr.plba, pd->sector_size); goto l_out; } #ifndef _WINDOWS - if ((cmd->io_attr.num_blocks << ilog2(vd->sectorSize)) % - pd->sector_size) { + if ((cmd->io_attr.num_blocks << ilog2(vd->sectorSize)) % pd->sector_size) { #else if ((cmd->io_attr.num_blocks * vd->sectorSize) % pd->sector_size) { #endif LOG_DEBUG("num_blocks:%u pd sector_size:%u vd sector_size:%u\n", - cmd->io_attr.num_blocks, pd->sector_size, - vd->sectorSize); + cmd->io_attr.num_blocks, pd->sector_size, vd->sectorSize); goto l_out; } ret = PS3_DRV_TRUE; l_out: return ret; } -unsigned char -ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, - const struct ps3_pd_entry *pd_entry) +Bool ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd_entry) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; - if (cmd == NULL || cmd->instance == NULL || pd_entry == NULL) { + if (cmd == NULL || cmd->instance == NULL || + pd_entry == NULL) { LOG_ERROR_LIM("sata direct support judge parameter NOK\n"); goto l_out; } @@ -787,17 +749,16 @@ ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, return ret; } -static inline unsigned char -ps3_scsih_datelen_buflen_is_match(const struct ps3_cmd *cmd) +static inline Bool ps3_scsih_datelen_buflen_is_match(const struct ps3_cmd *cmd) { - unsigned char ret = PS3_FALSE; - unsigned int data_len = 0; + Bool ret = PS3_FALSE; + U32 data_len = 0; data_len = ps3_scsih_datelen_calc(cmd); - if (data_len != scsi_bufflen(cmd->scmd)) { - LOG_INFO("data_len:%u not equal to bufflen:%u\n", data_len, - scsi_bufflen(cmd->scmd)); + if(data_len != scsi_bufflen(cmd->scmd)) { + LOG_INFO("data_len:%u not equal to bufflen:%u\n", + data_len, scsi_bufflen(cmd->scmd)); goto l_out; } ret = PS3_TRUE; @@ -806,17 +767,15 @@ ps3_scsih_datelen_buflen_is_match(const struct ps3_cmd *cmd) return ret; } -static unsigned int ps3_scsih_datelen_calc(const struct ps3_cmd *cmd) +static U32 ps3_scsih_datelen_calc(const struct ps3_cmd *cmd) { - unsigned short sector_size = 0; - unsigned int num_blocks = 0; - unsigned int date_len = 0; + U16 sector_size = 0; + U32 num_blocks = 0; + U32 date_len = 0; static unsigned long j; - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { if (cmd->io_attr.vd_entry == NULL) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "host parameter NOK\n"); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "host parameter NOK\n"); goto l_out; } sector_size = cmd->io_attr.vd_entry->sectorSize; @@ -825,8 +784,7 @@ static unsigned int ps3_scsih_datelen_calc(const struct ps3_cmd *cmd) sector_size = cmd->io_attr.pd_entry->sector_size; } if (sector_size == 0) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "host parameter NOK\n"); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "host parameter NOK\n"); goto l_out; } num_blocks = cmd->io_attr.num_blocks; @@ -836,25 +794,25 @@ static unsigned int ps3_scsih_datelen_calc(const struct ps3_cmd *cmd) return date_len; } -unsigned char ps3_scsih_sata_direct_is_need(struct ps3_cmd *cmd) +Bool ps3_scsih_sata_direct_is_need(struct ps3_cmd *cmd) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; if (cmd->scmd->cmd_len == 32) { LOG_DEBUG("read32 or write32 no need direct\n"); goto l_out; } - if (ps3_scsih_datelen_buflen_is_match(cmd) != PS3_TRUE) + if(ps3_scsih_datelen_buflen_is_match(cmd) != PS3_TRUE) { goto l_out; + } if (ps3_scsih_cdb_opts_parse(cmd) == PS3_SUCCESS) { if (likely(cmd->io_attr.cdb_opts.protect == 0 && - cmd->io_attr.cdb_opts.fua == 0)) { + cmd->io_attr.cdb_opts.fua == 0)) { ret = PS3_TRUE; } else { - LOG_DEBUG("SATA cdb_opts is 0x%x\n", - cmd->io_attr.cdb_opts.option); + LOG_DEBUG("SATA cdb_opts is 0x%x\n", cmd->io_attr.cdb_opts.option); } } else { LOG_DEBUG("SATA options parse failure\n"); @@ -863,19 +821,17 @@ unsigned char ps3_scsih_sata_direct_is_need(struct ps3_cmd *cmd) return ret; } -static inline unsigned char -ps3_scsih_sas_direct_is_need(const struct ps3_cmd *cmd) +static inline Bool ps3_scsih_sas_direct_is_need(const struct ps3_cmd *cmd) { (void)cmd; return PS3_TRUE; } -static inline unsigned char ps3_scsih_nvme_direct_is_need(struct ps3_cmd *cmd) +static inline Bool ps3_scsih_nvme_direct_is_need(struct ps3_cmd *cmd) { if (ps3_scsih_cdb_opts_parse(cmd) == PS3_SUCCESS) { if (likely(cmd->io_attr.cdb_opts.protect != 0)) { - LOG_DEBUG("NVMe protect is 0x%x\n", - cmd->io_attr.cdb_opts.protect); + LOG_DEBUG("NVMe protect is 0x%x\n", cmd->io_attr.cdb_opts.protect); return PS3_FALSE; } } else { @@ -886,46 +842,43 @@ static inline unsigned char ps3_scsih_nvme_direct_is_need(struct ps3_cmd *cmd) return (ps3_scsih_datelen_buflen_is_match(cmd) == PS3_TRUE); } -static unsigned char -ps3_scsih_direct_cmd_is_supported_logic(struct ps3_cmd *cmd, - const struct ps3_pd_entry *pd_entry) +static Bool ps3_scsih_direct_cmd_is_supported_logic(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd_entry) { - unsigned char ret = PS3_FALSE; - + Bool ret = PS3_FALSE; if (pd_entry == NULL) { PS3_BUG(); goto l_out; } - switch (pd_entry->dev_type) { - case PS3_DEV_TYPE_SATA_SSD: - case PS3_DEV_TYPE_SATA_HDD: - ret = ps3_scsih_sata_direct_is_need(cmd); - break; - case PS3_DEV_TYPE_SAS_SSD: - case PS3_DEV_TYPE_SAS_HDD: - ret = ps3_scsih_sas_direct_is_need(cmd); - break; - case PS3_DEV_TYPE_NVME_SSD: - ret = ps3_scsih_nvme_direct_is_need(cmd); - break; - default: - ret = PS3_FALSE; - break; + switch (pd_entry->dev_type) + { + case PS3_DEV_TYPE_SATA_SSD: + case PS3_DEV_TYPE_SATA_HDD: + ret = ps3_scsih_sata_direct_is_need(cmd); + break; + case PS3_DEV_TYPE_SAS_SSD: + case PS3_DEV_TYPE_SAS_HDD: + ret = ps3_scsih_sas_direct_is_need(cmd); + break; + case PS3_DEV_TYPE_NVME_SSD: + ret = ps3_scsih_nvme_direct_is_need(cmd); + break; + default: + ret = PS3_FALSE; + break; } l_out: return ret; } -static unsigned char -direct_cmd_is_supported_device(struct ps3_cmd *cmd, - const struct ps3_pd_entry *pd_entry) +static Bool direct_cmd_is_supported_device(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd_entry) { - unsigned char ret = PS3_FALSE; - + Bool ret = PS3_FALSE; if (pd_entry == NULL) { LOG_ERROR("tid:0x%llx hno:%u CFID:%d pd entry is NULL\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); PS3_BUG(); return ret; } @@ -933,92 +886,85 @@ direct_cmd_is_supported_device(struct ps3_cmd *cmd, LOG_DEBUG("Direct is disable\n"); return ret; } - switch (pd_entry->dev_type) { - case PS3_DEV_TYPE_SATA_SSD: - case PS3_DEV_TYPE_SATA_HDD: - ret = ps3_scsih_sata_direct_is_support(cmd, pd_entry); - break; - case PS3_DEV_TYPE_SAS_SSD: - case PS3_DEV_TYPE_SAS_HDD: - ret = PS3_TRUE; - break; - case PS3_DEV_TYPE_NVME_SSD: - ret = ps3_scsih_is_protocal_rw(cmd->scmd->cmnd); - break; - default: - ret = PS3_FALSE; - break; + switch (pd_entry->dev_type) + { + case PS3_DEV_TYPE_SATA_SSD: + case PS3_DEV_TYPE_SATA_HDD: + ret = ps3_scsih_sata_direct_is_support(cmd, pd_entry); + break; + case PS3_DEV_TYPE_SAS_SSD: + case PS3_DEV_TYPE_SAS_HDD: + ret = PS3_TRUE; + break; + case PS3_DEV_TYPE_NVME_SSD: + ret = ps3_scsih_is_protocal_rw(cmd->scmd->cmnd); + break; + default: + ret = PS3_FALSE; + break; } return ret; } -static inline int ps3_scsih_is_valid_vlba(struct ps3_cmd *cmd) +static inline S32 ps3_scsih_is_valid_vlba(struct ps3_cmd *cmd) { return ((U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) + - cmd->io_attr.num_blocks) > cmd->io_attr.vd_entry->capacity) ? - -PS3_FAILED : - PS3_SUCCESS; + cmd->io_attr.num_blocks) > cmd->io_attr.vd_entry->capacity) ? + -PS3_FAILED : PS3_SUCCESS; } -static inline unsigned char -ps3_scsih_is_direct_to_normal(const struct ps3_instance *instance, - const struct ps3_cmd *cmd) +static inline Bool ps3_scsih_is_direct_to_normal(const struct ps3_instance *instance, + const struct ps3_cmd *cmd) { return (instance->ioc_adpter->is_need_direct_to_normal != NULL && instance->ioc_adpter->is_need_direct_to_normal(cmd)); } -static inline unsigned char ps3_scsih_is_sas_jbod_cmd(const struct ps3_cmd *cmd) +static inline Bool ps3_scsih_is_sas_jbod_cmd(const struct ps3_cmd *cmd) { return cmd->io_attr.dev_type == PS3_DEV_TYPE_SAS_HDD || - cmd->io_attr.dev_type == PS3_DEV_TYPE_SAS_SSD; + cmd->io_attr.dev_type == PS3_DEV_TYPE_SAS_SSD; } -static inline unsigned char -ps3_scsih_is_sata_jbod_cmd(const struct ps3_cmd *cmd) +static inline Bool ps3_scsih_is_sata_jbod_cmd(const struct ps3_cmd *cmd) { return cmd->io_attr.dev_type == PS3_DEV_TYPE_SATA_HDD || - cmd->io_attr.dev_type == PS3_DEV_TYPE_SATA_SSD; + cmd->io_attr.dev_type == PS3_DEV_TYPE_SATA_SSD; } -unsigned char ps3_scsih_is_sata_jbod_mgr_cmd(const struct ps3_cmd *cmd) +Bool ps3_scsih_is_sata_jbod_mgr_cmd(const struct ps3_cmd *cmd) { - return (ps3_scsih_is_sata_jbod_cmd(cmd)) && - (!ps3_scsih_cdb_is_rw_cmd(cmd->scmd->cmnd)); + return (ps3_scsih_is_sata_jbod_cmd(cmd)) + && (!ps3_scsih_cdb_is_rw_cmd(cmd->scmd->cmnd)); } -unsigned int ps3_scsih_xfer_cnt_get(const struct ps3_cmd *cmd) +U32 ps3_scsih_xfer_cnt_get(const struct ps3_cmd *cmd) { - unsigned int xfer_cnt = 0; + U32 xfer_cnt = 0; - union PS3RespFrame *resp_frame = cmd->resp_frame; - unsigned short mode = cmd->reply_word.mode; + PS3RespFrame_u *resp_frame = cmd->resp_frame; + U16 mode = cmd->reply_word.mode; - if (ps3_err_is_resp_from_direct_cmd(mode) && - (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD)) { + if (ps3_err_is_resp_from_direct_cmd(mode) + && (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD)) { xfer_cnt = resp_frame->sasRespFrame.xfer_cnt; } else { xfer_cnt = resp_frame->normalRespFrame.respDetail.xfer_cnt; } return xfer_cnt; } -static inline unsigned char -ps3_scsih_hdd_vd_direct_check(const struct ps3_cmd *cmd) +static inline Bool ps3_scsih_hdd_vd_direct_check(const struct ps3_cmd *cmd) { - unsigned char is_direct = PS3_TRUE; - struct ps3_scsi_priv_data *p_priv_data = - scsi_device_private_data(cmd->scmd); + Bool is_direct = PS3_TRUE; + struct ps3_scsi_priv_data *p_priv_data = scsi_device_private_data(cmd->scmd); if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { - if (!cmd->io_attr.vd_entry->isNvme && - !cmd->io_attr.vd_entry->isSsd) { + if (!cmd->io_attr.vd_entry->isNvme && !cmd->io_attr.vd_entry->isSsd) { if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag) && - (ps3_atomic_read(&p_priv_data->wr_io_outstand) != - PS3_VD_IO_1_OUTSTANDING)) { - is_direct = PS3_FALSE; - } else if (ps3_scsih_is_read_cmd( - cmd->io_attr.rw_flag)) { + (ps3_atomic_read(&p_priv_data->wr_io_outstand) != PS3_VD_IO_1_OUTSTANDING)) { + is_direct = PS3_FALSE; + } else if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { is_direct = PS3_FALSE; } } @@ -1028,84 +974,83 @@ ps3_scsih_hdd_vd_direct_check(const struct ps3_cmd *cmd) static void ps3_scsih_build_direct_cmd(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - unsigned long long lba = 0; + S32 ret = PS3_SUCCESS; + U64 lba = 0; struct ps3_cmd_attr_context *cmd_attr = &cmd->instance->cmd_attr; - if (!cmd_attr->is_support_direct_cmd) + if (!cmd_attr->is_support_direct_cmd) { goto l_out; + } - if (cmd->io_attr.is_force_normal) + if (cmd->io_attr.is_force_normal) { goto l_out; + } - if (!ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) + if (!ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { goto l_out; + } if ((!ps3_scsih_is_protocal_rw(cmd->scmd->cmnd)) && - ps3_scsih_is_sas_jbod_cmd(cmd)) { + ps3_scsih_is_sas_jbod_cmd(cmd)) { goto l_out; } if (unlikely(cmd->io_attr.num_blocks == 0)) { LOG_DEBUG("tid:0x%llx hno:%u num blocks is zero\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } if (unlikely(cmd->io_attr.is_retry_cmd && - ps3_scsih_is_direct_to_normal(cmd->instance, cmd))) { - LOG_FILE_WARN("tid:0x%llx hno:%u is_retry_cmd\n", - cmd->trace_id, PS3_HOST(cmd->instance)); - goto l_out; + ps3_scsih_is_direct_to_normal(cmd->instance, cmd))) { + LOG_FILE_WARN("tid:0x%llx hno:%u is_retry_cmd \n", + cmd->trace_id, PS3_HOST(cmd->instance)); + goto l_out; } if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { if (cmd->instance->ioc_adpter->scsih_stream_is_detect != NULL && - cmd->instance->ioc_adpter->scsih_stream_is_detect(cmd)) { - LOG_DEBUG( - "hno[%u], cmd index[%u], tid[0x%llx], detected it is sequential io\n", - PS3_HOST(cmd->instance), cmd->index, - cmd->trace_id); - if (cmd->instance->ioc_adpter->scsih_stream_is_direct != - NULL && - !cmd->instance->ioc_adpter->scsih_stream_is_direct( - cmd)) { - goto l_out; + cmd->instance->ioc_adpter->scsih_stream_is_detect(cmd)) { + + LOG_DEBUG("hno[%u], cmd index[%u], tid[0x%llx], detected it is sequential io\n", + PS3_HOST(cmd->instance), cmd->index, cmd->trace_id); + if (cmd->instance->ioc_adpter->scsih_stream_is_direct != NULL && \ + !cmd->instance->ioc_adpter->scsih_stream_is_direct(cmd)) { + goto l_out; } } if (unlikely(!cmd->io_attr.vd_entry->isDirectEnable)) { LOG_DEBUG("tid:0x%llx hno:%u direct disable\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } if (cmd->instance->ioc_adpter->write_direct_enable != NULL && - !cmd->instance->ioc_adpter->write_direct_enable(cmd)) { + !cmd->instance->ioc_adpter->write_direct_enable(cmd)) { LOG_DEBUG("tid:0x%llx hno:%u write direct disable\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } if (unlikely(ps3_scsih_is_valid_vlba(cmd) != PS3_SUCCESS)) { - LOG_ERROR_LIM( - "hno:%u tid:%#llx lba:0x%llx\n" - "\tnum_blks:0x%x vd capacity:%llu cmd out of range\n", + LOG_ERROR_LIM("hno:%u tid:%#llx lba:0x%llx " + "num_blks:0x%x vd capacity:%llu cmd out of range\n", PS3_HOST(cmd->instance), cmd->trace_id, - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, - cmd->io_attr.lba_lo), - cmd->io_attr.num_blocks, - cmd->io_attr.vd_entry->capacity); + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo), + cmd->io_attr.num_blocks, cmd->io_attr.vd_entry->capacity); goto l_out; } - if (!direct_cmd_is_raidlevel_support(cmd)) + if (!direct_cmd_is_raidlevel_support(cmd)) { goto l_out; + } - if (!ps3_scsih_is_protocal_rw(cmd->scmd->cmnd)) + if (!ps3_scsih_is_protocal_rw(cmd->scmd->cmnd)) { goto l_out; + } - if (cmd->io_attr.vd_entry->raidLevel == RAID1) { + if ((cmd->io_attr.vd_entry->raidLevel == RAID1)) { if (cmd->io_attr.vd_entry->mapBlock == 0) { PS3_BUG(); goto l_out; @@ -1113,37 +1058,26 @@ static void ps3_scsih_build_direct_cmd(struct ps3_cmd *cmd) if (cmd->instance->is_raid1_direct_skip_mapblock_check) { LOG_DEBUG("hba raid1, skip MapBlock check\n"); } else { - lba = PS3_LBA(cmd->io_attr.lba_hi, - cmd->io_attr.lba_lo); - if (PS3_SCSIH_NOT_SAME_MAPBLOCK( - lba, - cmd->io_attr.vd_entry->mapBlock, - cmd->io_attr.num_blocks)) { - LOG_DEBUG( - "hno:%u map_block:%llu lba:0x%llx num_blks:0x%x not same map block\n", - PS3_HOST(cmd->instance), - cmd->io_attr.vd_entry->mapBlock, + lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + if (PS3_SCSIH_NOT_SAME_MAPBLOCK(lba, cmd->io_attr.vd_entry->mapBlock, + cmd->io_attr.num_blocks)) { + LOG_DEBUG("hno:%u map_block:%llu lba:0x%llx num_blks:0x%x not same map block\n", + PS3_HOST(cmd->instance), cmd->io_attr.vd_entry->mapBlock, lba, cmd->io_attr.num_blocks); goto l_out; } } } else { - if ((cmd->instance - ->is_single_disk_raid0_direct_skip_strip_check) && - (cmd->io_attr.vd_entry->raidLevel == RAID0) && - (cmd->io_attr.vd_entry->physDrvCnt == 1)) { - LOG_DEBUG( - "hba raid0 with single disk, skip strip check\n"); + if ((cmd->instance->is_single_disk_raid0_direct_skip_strip_check) && + (cmd->io_attr.vd_entry->raidLevel == RAID0) && + (cmd->io_attr.vd_entry->physDrvCnt == 1)) { + LOG_DEBUG("hba raid0 with single disk, skip strip check\n"); } else { - if (!ps3_scsih_is_same_strip( - cmd->io_attr.vd_entry, - cmd->io_attr.lba_lo, - cmd->io_attr.num_blocks)) { - LOG_DEBUG( - "not same strip lba:0x%x num_blks:0x%x\n", - cmd->io_attr.lba_lo, - cmd->io_attr.num_blocks); + if ( !ps3_scsih_is_same_strip(cmd->io_attr.vd_entry, + cmd->io_attr.lba_lo, cmd->io_attr.num_blocks) ) { + LOG_DEBUG("not same strip lba:0x%x num_blks:0x%x\n", + cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); goto l_out; } } @@ -1151,118 +1085,107 @@ static void ps3_scsih_build_direct_cmd(struct ps3_cmd *cmd) ret = ps3_scsih_vd_rw_io_to_pd_calc(cmd); if (ret != PS3_SUCCESS) { - LOG_DEBUG("cmd index:%u vlba to plba fail\n", - cmd->index); + LOG_DEBUG("cmd index:%u vlba to plba fail\n", cmd->index); goto l_out; } - if (!direct_cmd_is_supported_device(cmd, - cmd->io_attr.pd_entry)) { - LOG_DEBUG( - "tid:0x%llx hno:%u not support to direct for this cmd\n", + if (!direct_cmd_is_supported_device(cmd, cmd->io_attr.pd_entry)) { + LOG_DEBUG("tid:0x%llx hno:%u not support to direct for this cmd\n", cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } - if (ps3_scsih_direct_cmd_is_supported_logic( - cmd, cmd->io_attr.pd_entry) != PS3_TRUE) { - LOG_DEBUG( - "tid:0x%llx hno:%u not need to direct for this cmd\n", + if (ps3_scsih_direct_cmd_is_supported_logic(cmd, cmd->io_attr.pd_entry) != PS3_TRUE) { + LOG_DEBUG("tid:0x%llx hno:%u not need to direct for this cmd\n", cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } if (!direct_cmd_is_plba_sector_aligned(cmd, - cmd->io_attr.pd_entry)) { + cmd->io_attr.pd_entry)) { goto l_out; } if (ps3_is_r1x_write_cmd(cmd)) { - if (!direct_cmd_is_supported_device( - cmd, cmd->io_attr.peer_pd_entry)) { - LOG_DEBUG( - "tid:0x%llx hno:%u peer_pd[%u:%u:%u] not\n" - "\tsupport to direct for this cmd\n", - cmd->trace_id, PS3_HOST(cmd->instance), - PS3_CHANNEL(&cmd->io_attr.peer_pd_entry - ->disk_pos), - PS3_TARGET(&cmd->io_attr.peer_pd_entry - ->disk_pos), - PS3_PDID(&cmd->io_attr.peer_pd_entry - ->disk_pos)); + if (!direct_cmd_is_supported_device(cmd, + cmd->io_attr.peer_pd_entry)) { + LOG_DEBUG("tid:0x%llx hno:%u peer_pd[%u:%u:%u] not " + "support to direct for this cmd\n", + cmd->trace_id, + PS3_HOST(cmd->instance), + PS3_CHANNEL(&cmd->io_attr.peer_pd_entry->disk_pos), + PS3_TARGET(&cmd->io_attr.peer_pd_entry->disk_pos), + PS3_PDID(&cmd->io_attr.peer_pd_entry->disk_pos)); goto l_out; } - if (ps3_scsih_direct_cmd_is_supported_logic( - cmd, cmd->io_attr.peer_pd_entry) != - PS3_TRUE) { + if (ps3_scsih_direct_cmd_is_supported_logic(cmd, + cmd->io_attr.peer_pd_entry) != PS3_TRUE) { goto l_out; } - if (!direct_cmd_is_plba_sector_aligned( - cmd, cmd->io_attr.peer_pd_entry)) { + if (!direct_cmd_is_plba_sector_aligned(cmd, + cmd->io_attr.peer_pd_entry)) { goto l_out; } } - if (!ps3_scsih_hdd_vd_direct_check(cmd)) + if (!ps3_scsih_hdd_vd_direct_check(cmd)) { goto l_out; - cmd->io_attr.direct_flag = - (unsigned char)PS3_CMDWORD_DIRECT_ADVICE; + } + cmd->io_attr.direct_flag = (U8)PS3_CMDWORD_DIRECT_ADVICE; } else { - if (!direct_cmd_is_supported_device(cmd, - cmd->io_attr.pd_entry)) { + if (!direct_cmd_is_supported_device(cmd, cmd->io_attr.pd_entry)) { goto l_out; } - if (ps3_scsih_direct_cmd_is_supported_logic( - cmd, cmd->io_attr.pd_entry) != PS3_TRUE) { - LOG_DEBUG( - "tid:0x%llx hno:%u not need to direct for this cmd\n", + if (ps3_scsih_direct_cmd_is_supported_logic(cmd, cmd->io_attr.pd_entry) != PS3_TRUE) { + LOG_DEBUG("tid:0x%llx hno:%u not need to direct for this cmd\n", cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } - cmd->io_attr.direct_flag = (unsigned char)PS3_CMDWORD_DIRECT_OK; - cmd->io_attr.plba = - PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + cmd->io_attr.direct_flag = (U8)PS3_CMDWORD_DIRECT_OK; + cmd->io_attr.plba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); } l_out: - return; + return ; } -static inline unsigned char ps3_scsih_is_invalid_dev(unsigned char type) +static inline Bool ps3_scsih_is_invalid_dev(U8 type) { return (type <= PS3_DEV_TYPE_UNKNOWN || type >= PS3_DEV_TYPE_COUNT); } static inline void ps3_scsih_use_frontend_prp_check(struct ps3_cmd *cmd) { - if (!cmd->instance->is_use_frontend_prp) + if (!cmd->instance->is_use_frontend_prp) { goto l_out; + } if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - if (!cmd->io_attr.vd_entry->isNvme) + if (!cmd->io_attr.vd_entry->isNvme) { goto l_out; + } } else { - if (cmd->io_attr.pd_entry->dev_type != PS3_DEV_TYPE_NVME_SSD) + if (cmd->io_attr.pd_entry->dev_type != PS3_DEV_TYPE_NVME_SSD) { goto l_out; + } } - cmd->io_attr.is_use_frontend_prp = - ps3_scsih_is_protocal_rw(cmd->scmd->cmnd); + cmd->io_attr.is_use_frontend_prp = ps3_scsih_is_protocal_rw(cmd->scmd->cmnd); l_out: - return; + return ; } -static unsigned char ps3_unmap_check_block_valid(struct ps3_cmd *cmd) +static Bool ps3_unmap_check_block_valid(struct ps3_cmd *cmd) { - unsigned char ret = PS3_FALSE; - unsigned char umap_xbuf[32] = { 0 }; - unsigned int *p_umap_unmblk = &cmd->io_attr.num_blocks; - unsigned short payload_len = 0; - unsigned short desc_len = 0; + Bool ret = PS3_FALSE; + U8 umap_xbuf[32] = {0}; + U32 *p_umap_unmblk = &cmd->io_attr.num_blocks; + U16 payload_len = 0; + U16 desc_len = 0; if (cmd->scmd->cmnd[0] != UNMAP) { ret = PS3_TRUE; @@ -1272,16 +1195,15 @@ static unsigned char ps3_unmap_check_block_valid(struct ps3_cmd *cmd) payload_len = ps3_get_unaligned_be16(&cmd->scmd->cmnd[7]); if (unlikely(payload_len != scsi_bufflen(cmd->scmd))) { LOG_DEBUG("hno:%u. unmap: buf len:%u != cdb:%u\n", - PS3_HOST(cmd->instance), scsi_bufflen(cmd->scmd), - payload_len); + PS3_HOST(cmd->instance), scsi_bufflen(cmd->scmd), + payload_len); goto l_out; } - if (unlikely(scsi_bufflen(cmd->scmd) > - (UNMAP_PARAM_LEN + UNMAP_DESCRIPTOR_LEN))) { + if (unlikely(scsi_bufflen(cmd->scmd) > (UNMAP_PARAM_LEN + UNMAP_DESCRIPTOR_LEN))) { LOG_DEBUG("hno:%u. unmap: buf len:%u > %u\n", - PS3_HOST(cmd->instance), scsi_bufflen(cmd->scmd), - (UNMAP_PARAM_LEN + UNMAP_DESCRIPTOR_LEN)); + PS3_HOST(cmd->instance), scsi_bufflen(cmd->scmd), + (UNMAP_PARAM_LEN + UNMAP_DESCRIPTOR_LEN)); goto l_out; } @@ -1289,26 +1211,25 @@ static unsigned char ps3_unmap_check_block_valid(struct ps3_cmd *cmd) if (ps3_get_unaligned_be16(&umap_xbuf[0]) != (payload_len - 2)) { LOG_DEBUG("hno:%u. unmap data len: :%u > payload:%u\n", - PS3_HOST(cmd->instance), - ps3_get_unaligned_be16(&umap_xbuf[0]), - payload_len - 2); + PS3_HOST(cmd->instance), ps3_get_unaligned_be16(&umap_xbuf[0]), + payload_len - 2); goto l_out; } desc_len = ps3_get_unaligned_be16(&umap_xbuf[2]); if ((desc_len >> 4) > cmd->io_attr.vd_entry->umapBlkDescCnt) { LOG_DEBUG("hno:%u. unmap: desc len:%u > desc cnt:%u*16\n", - PS3_HOST(cmd->instance), desc_len, - cmd->io_attr.vd_entry->umapBlkDescCnt); + PS3_HOST(cmd->instance), desc_len, + cmd->io_attr.vd_entry->umapBlkDescCnt); goto l_out; } ps3_scsih_unmap_desc_parse(&umap_xbuf[UNMAP_PARAM_LEN], p_umap_unmblk, - &cmd->io_attr.lba_lo, &cmd->io_attr.lba_hi); + &cmd->io_attr.lba_lo, &cmd->io_attr.lba_hi); if (*p_umap_unmblk > cmd->io_attr.vd_entry->umapNumblk) { LOG_DEBUG("hno:%u. unmap: numblk:%u > limit %u\n", - PS3_HOST(cmd->instance), *p_umap_unmblk, - cmd->io_attr.vd_entry->umapNumblk); + PS3_HOST(cmd->instance), *p_umap_unmblk, + cmd->io_attr.vd_entry->umapNumblk); goto l_out; } @@ -1317,7 +1238,7 @@ static unsigned char ps3_unmap_check_block_valid(struct ps3_cmd *cmd) return ret; } -static inline void ps3_req_frame_head_init(struct PS3ReqFrameHead *req_head) +static inline void ps3_req_frame_head_init(PS3ReqFrameHead_s *req_head) { req_head->cmdType = 0; req_head->cmdSubType = 0; @@ -1333,9 +1254,9 @@ static inline void ps3_req_frame_head_init(struct PS3ReqFrameHead *req_head) req_head->traceID = 0; } -static inline unsigned int ps3_hw_vd_max_io_size_get(unsigned char enum_size) +static inline U32 ps3_hw_vd_max_io_size_get(U8 enum_size) { - unsigned int max_size = PS3_HW_VD_MAX_IO_SIZE_1M; + U32 max_size = PS3_HW_VD_MAX_IO_SIZE_1M; switch (enum_size) { case PS3_ENUM_HW_VD_MAX_IO_SIZE_1M: @@ -1345,33 +1266,31 @@ static inline unsigned int ps3_hw_vd_max_io_size_get(unsigned char enum_size) return max_size; } -static int ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) +static S32 ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - int dma_map_ret = 0; - unsigned char is_need_split = PS3_FALSE; + S32 ret = PS3_SUCCESS; + S32 dma_map_ret = 0; + Bool is_need_split = PS3_FALSE; struct ps3_scsi_priv_data *data = scsi_device_private_data(cmd->scmd); - unsigned int hw_vd_max_num_blk = 0; - unsigned int hw_vd_max_io_size = 0; + U32 hw_vd_max_num_blk = 0; + U32 hw_vd_max_io_size = 0; cmd->io_attr.dev_type = data->dev_type; if (cmd->is_inserted_c_q == 0) { dma_map_ret = ps3_scsi_dma_map(cmd); if (unlikely(dma_map_ret < 0)) { LOG_WARN_LIM("hno:%u. cfid[%u] dma_map NOK:%d\n", - PS3_HOST(cmd->instance), cmd->index, - dma_map_ret); + PS3_HOST(cmd->instance), cmd->index, dma_map_ret); ret = -PS3_ENOMEM; goto l_out; } } if (unlikely(ps3_scsih_is_invalid_dev(cmd->io_attr.dev_type))) { - LOG_ERROR_LIM( - "hno:%u get dev type NOK :%d dev_type:%s\n", + LOG_ERROR_LIM("hno:%u get dev type NOK :%d dev_type:%s\n", PS3_HOST(cmd->instance), cmd->index, namePS3DevType((enum PS3DevType)cmd->io_attr.dev_type)); - ret = -PS3_DEV_UNKNOWN; + ret = -PS3_DEV_TYPE_UNKOWN; goto l_out; } @@ -1381,47 +1300,36 @@ static int ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) #ifndef _WINDOWS cmd->io_attr.is_retry_cmd = (cmd->scmd->retries != 0); #endif - cmd->io_attr.direct_flag = (unsigned char)PS3_CMDWORD_DIRECT_NORMAL; - cmd->io_attr.rw_type = - ps3_scsih_cdb_rw_type_get(scsi_cmnd_cdb(cmd->scmd)); + cmd->io_attr.direct_flag = (U8)PS3_CMDWORD_DIRECT_NORMAL; + cmd->io_attr.rw_type = ps3_scsih_cdb_rw_type_get(scsi_cmnd_cdb(cmd->scmd)); if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { - ps3_scsih_cdb_parse(scsi_cmnd_cdb(cmd->scmd), - &cmd->io_attr.num_blocks, - &cmd->io_attr.lba_lo, &cmd->io_attr.lba_hi, - &is_need_split); + ps3_scsih_cdb_parse(scsi_cmnd_cdb(cmd->scmd), &cmd->io_attr.num_blocks, + &cmd->io_attr.lba_lo, &cmd->io_attr.lba_hi, &is_need_split); } if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - cmd->io_attr.vd_entry = ps3_dev_mgr_lookup_vd_info_by_id( - cmd->instance, cmd->io_attr.disk_id); + cmd->io_attr.vd_entry = ps3_dev_mgr_lookup_vd_info_by_id(cmd->instance, + cmd->io_attr.disk_id); if (unlikely(cmd->io_attr.vd_entry == NULL)) { ret = -PS3_ENODEV; goto l_out; } - if (unlikely(cmd->io_attr.num_blocks > - cmd->io_attr.vd_entry->maxIOSize)) { + if (unlikely(cmd->io_attr.num_blocks > cmd->io_attr.vd_entry->maxIOSize)) { LOG_DEBUG("hno:%u. numblk:%u > maxio:%u\n", - PS3_HOST(cmd->instance), - cmd->io_attr.num_blocks, - cmd->io_attr.vd_entry->maxIOSize); + PS3_HOST(cmd->instance), cmd->io_attr.num_blocks, + cmd->io_attr.vd_entry->maxIOSize); cmd->io_attr.is_force_normal = PS3_TRUE; } - hw_vd_max_io_size = ps3_hw_vd_max_io_size_get( - cmd->instance->ctrl_info.hwVdMaxIOSize); - hw_vd_max_num_blk = hw_vd_max_io_size >> - ps3_blocksize_to_shift( - cmd->io_attr.vd_entry->sectorSize); + hw_vd_max_io_size = ps3_hw_vd_max_io_size_get(cmd->instance->ctrl_info.hwVdMaxIOSize); + hw_vd_max_num_blk = hw_vd_max_io_size >> ps3_blocksize_to_shift(cmd->io_attr.vd_entry->sectorSize); if (unlikely(cmd->io_attr.num_blocks > hw_vd_max_num_blk && - cmd->io_attr.num_blocks > - cmd->io_attr.vd_entry->maxIOSize)) { - LOG_DEBUG( - "hno:%u. numblk:%u > max size, hw max numblk:%u maxIOSize:%u\n", - PS3_HOST(cmd->instance), - cmd->io_attr.num_blocks, hw_vd_max_num_blk, - cmd->io_attr.vd_entry->maxIOSize); + cmd->io_attr.num_blocks > cmd->io_attr.vd_entry->maxIOSize)) { + LOG_DEBUG("hno:%u. numblk:%u > max size, hw max numblk:%u maxIOSize:%u\n", + PS3_HOST(cmd->instance), cmd->io_attr.num_blocks, + hw_vd_max_num_blk, cmd->io_attr.vd_entry->maxIOSize); goto l_skip_r1x_write_lock; } @@ -1431,11 +1339,12 @@ static int ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) } ret = ps3_r1x_write_lock(&data->lock_mgr, cmd); - if (unlikely(ret != PS3_SUCCESS)) + if(unlikely(ret != PS3_SUCCESS)){ goto l_out; + } } else { - cmd->io_attr.pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( - cmd->instance, cmd->io_attr.disk_id); + cmd->io_attr.pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(cmd->instance, + cmd->io_attr.disk_id); if (unlikely(cmd->io_attr.pd_entry == NULL)) { ret = -PS3_ENODEV; goto l_out; @@ -1454,11 +1363,11 @@ static int ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) return ret; } -static int ps3_scsih_req_frame_build(struct ps3_cmd *cmd) +static S32 ps3_scsih_req_frame_build(struct ps3_cmd *cmd) { - int ret = -PS3_FAILED; - unsigned int table_size = ARRAY_SIZE(g_req_frame_func_table); - unsigned int i = 0; + S32 ret = -PS3_FAILED; + U32 table_size = ARRAY_SIZE(g_req_frame_func_table); + U32 i = 0; #ifdef _WINDOWS ps3_scsi_need_remap_check(cmd); if (cmd->scmd->is_remap_databuff) { @@ -1480,9 +1389,9 @@ static int ps3_scsih_req_frame_build(struct ps3_cmd *cmd) } static void ps3_scsih_vd_cmd_word_devid_build(struct ps3_cmd *cmd, - const struct PS3VDEntry *vd_info) + const struct PS3VDEntry *vd_info) { - cmd->cmd_word.virtDiskID = (unsigned char)PS3_VDID(&vd_info->diskPos); + cmd->cmd_word.virtDiskID = (U8)PS3_VDID(&vd_info->diskPos); switch (cmd->io_attr.direct_flag) { case PS3_CMDWORD_DIRECT_OK: @@ -1497,23 +1406,25 @@ static void ps3_scsih_vd_cmd_word_devid_build(struct ps3_cmd *cmd, break; } + return; } -static unsigned char ps3_is_no_calc_mapblocks(const struct PS3VDEntry *vd_info, - const struct ps3_cmd *cmd) +static Bool ps3_is_no_calc_mapblocks(const struct PS3VDEntry *vd_info, + const struct ps3_cmd *cmd) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; (void)vd_info; if (ps3_scsih_is_sync_cache(scsi_cmnd_cdb(cmd->scmd))) { LOG_DEBUG("hno:%u is SYNCHRONIZE_CACHE\n", - PS3_HOST(cmd->instance)); + PS3_HOST(cmd->instance)); ret = PS3_FALSE; goto l_out; } if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag) == PS3_FALSE) { - LOG_DEBUG("hno:%u not rw cmd\n", PS3_HOST(cmd->instance)); + LOG_DEBUG("hno:%u not rw cmd\n", + PS3_HOST(cmd->instance)); ret = PS3_TRUE; goto l_out; } @@ -1522,30 +1433,28 @@ static unsigned char ps3_is_no_calc_mapblocks(const struct PS3VDEntry *vd_info, return ret; } -static int ps3_scsih_vd_cmd_word_cpu_set(struct ps3_cmd *cmd, - const struct PS3VDEntry *vd_info) +static S32 ps3_scsih_vd_cmd_word_cpu_set(struct ps3_cmd *cmd, + const struct PS3VDEntry *vd_info) { - int ret = PS3_SUCCESS; - unsigned int num_blocks = cmd->io_attr.num_blocks; - unsigned int lba_lo = cmd->io_attr.lba_lo; - unsigned int lba_hi = cmd->io_attr.lba_hi; - unsigned long long lba = 0; - unsigned char que_offset = 0; - struct PS3ReqFrameHead *req_head = &cmd->req_frame->frontendReq.reqHead; + S32 ret = PS3_SUCCESS; + U32 num_blocks = cmd->io_attr.num_blocks; + U32 lba_lo = cmd->io_attr.lba_lo; + U32 lba_hi = cmd->io_attr.lba_hi; + U64 lba = 0; + U8 que_offset = 0; + PS3ReqFrameHead_s *req_head= &cmd->req_frame->frontendReq.reqHead; cmd->cmd_word.qMask = 0; req_head->mapBlockVer = PS3_CMDWORD_VER_INVALID; - lba = ((unsigned long long)lba_hi << PS3_SHIFT_DWORD) | lba_lo; + lba = ((U64)lba_hi << PS3_SHIFT_DWORD) | lba_lo; - LOG_DEBUG( - "tid:0x%llx hno:%u CFID:%d lba:0x%llx map_block[%lld], num_blks:0x%x\n", + LOG_DEBUG("tid:0x%llx hno:%u CFID:%d lba:0x%llx map_block[%lld], num_blks:0x%x\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, lba, vd_info->mapBlock, num_blocks); if (ps3_is_no_calc_mapblocks(vd_info, cmd)) { - LOG_DEBUG( - "tid:0x%llx hno:%u CFID:%u lba:0x%llx map_block[%lld], num_blks:0x%x\n", + LOG_DEBUG("tid:0x%llx hno:%u CFID:%u lba:0x%llx map_block[%lld], num_blks:0x%x\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, lba, vd_info->mapBlock, num_blocks); goto l_out; @@ -1559,43 +1468,44 @@ static int ps3_scsih_vd_cmd_word_cpu_set(struct ps3_cmd *cmd, goto l_out; } - if (vd_info->isSsd && - cmd->instance->ioc_adpter->ssd_vd_qmask_calculate != NULL) { + if (vd_info->isSsd && cmd->instance->ioc_adpter->ssd_vd_qmask_calculate != NULL) { if (cmd->instance->ioc_adpter->ssd_vd_qmask_calculate(cmd)) goto l_hba_ssd_vd; } - que_offset = PS3_CMD_WORD_QUE_CALC( - vd_info->diskPos.diskDev.ps3Dev.virtDiskID, lba, + que_offset = PS3_CMD_WORD_QUE_CALC(vd_info->diskPos.diskDev.ps3Dev.virtDiskID, lba, vd_info->mapBlock, (cmd->instance->ctrl_info.vdQueueNum - 1)); cmd->cmd_word.qMask = 1 << que_offset; - if ((PS3_SCSIH_NOT_SAME_MAPBLOCK(lba, vd_info->mapBlock, num_blocks)) && - (cmd->instance->ioc_adpter->rw_cmd_is_need_split != NULL) && - (cmd->instance->ioc_adpter->rw_cmd_is_need_split(cmd))) { - if (que_offset == (cmd->instance->ctrl_info.vdQueueNum - 1)) + if ((PS3_SCSIH_NOT_SAME_MAPBLOCK(lba, vd_info->mapBlock, num_blocks)) + && (cmd->instance->ioc_adpter->rw_cmd_is_need_split != NULL) + && (cmd->instance->ioc_adpter->rw_cmd_is_need_split(cmd))) { + + if (que_offset == (cmd->instance->ctrl_info.vdQueueNum - 1)) { cmd->cmd_word.qMask |= 0x1; - else + } else { cmd->cmd_word.qMask |= 1 << (que_offset + 1); + } req_head->mapBlockVer = PS3_CMDWORD_VER_INVALID; LOG_DEBUG("hno:%u map_block:%llu not same map block qMask 0x:%x\n", - PS3_HOST(cmd->instance), vd_info->mapBlock, - cmd->cmd_word.qMask); + PS3_HOST(cmd->instance), vd_info->mapBlock, cmd->cmd_word.qMask); } l_hba_ssd_vd: - LOG_DEBUG("tid:0x%llx hno:%u CFID:%d que:%d ver:%u\n", cmd->trace_id, - PS3_HOST(cmd->instance), cmd->index, cmd->cmd_word.qMask, - req_head->mapBlockVer); + LOG_DEBUG("tid:0x%llx hno:%u CFID:%d que:%d ver:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, + cmd->cmd_word.qMask, req_head->mapBlockVer); l_out: return ret; + } -static int ps3_scsih_cmd_word_type_set(struct ps3_cmd *cmd) +static S32 ps3_scsih_cmd_word_type_set(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; + INJECT_START(PS3_ERR_IJ_IO_RW_FLAG_SET_UNKOWN, cmd); switch (cmd->io_attr.rw_flag) { case PS3_SCSI_CMD_TYPE_READ: @@ -1612,38 +1522,34 @@ static int ps3_scsih_cmd_word_type_set(struct ps3_cmd *cmd) default: cmd->cmd_word.type = PS3_CMDWORD_TYPE_MGR; ret = -PS3_FAILED; - LOG_ERROR_LIM( - "hno:%u cmd word set type NOK CFID:%d ret:%d rw_flag:%d\n", - PS3_HOST(cmd->instance), cmd->index, ret, - cmd->io_attr.rw_flag); + LOG_ERROR_LIM("hno:%u cmd word set type NOK CFID:%d ret:%d rw_flag:%d\n", + PS3_HOST(cmd->instance), cmd->index, ret, cmd->io_attr.rw_flag); break; } return ret; } -static inline unsigned short -ps3_scsih_is_use_hard_cmd(const struct ps3_cmd *cmd) +static inline U16 ps3_scsih_is_use_hard_cmd(const struct ps3_cmd *cmd) { return ((cmd->cmd_word.direct == PS3_CMDWORD_DIRECT_OK) || (cmd->cmd_word.direct == PS3_CMDWORD_DIRECT_ADVICE)) ? - PS3_CMDWORD_FORMAT_HARDWARE : - PS3_CMDWORD_FORMAT_FRONTEND; + PS3_CMDWORD_FORMAT_HARDWARE : PS3_CMDWORD_FORMAT_FRONTEND; } -static int ps3_scsih_vd_cmd_word_build(struct ps3_cmd *cmd) +static S32 ps3_scsih_vd_cmd_word_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; const struct PS3VDEntry *vd_info = cmd->io_attr.vd_entry; memset(&cmd->cmd_word, 0, sizeof(cmd->cmd_word)); ret = ps3_scsih_cmd_word_type_set(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_LIM("tid:0x%llx hno:%u set cmd word fail\n" - "\tcmd:%d chl:%u id:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->index, PS3_SDEV_CHANNEL(cmd->scmd->device), - PS3_SDEV_TARGET(cmd->scmd->device)); + LOG_ERROR_LIM("tid:0x%llx hno:%u set cmd word fail " + "cmd:%d chl:%u id:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, + PS3_SDEV_CHANNEL(cmd->scmd->device), + PS3_SDEV_TARGET(cmd->scmd->device)); ret = -PS3_FAILED; goto l_out; } @@ -1664,15 +1570,16 @@ static int ps3_scsih_vd_cmd_word_build(struct ps3_cmd *cmd) return ret; } -static int ps3_scsih_pd_cmd_word_build(struct ps3_cmd *cmd) +static S32 ps3_scsih_pd_cmd_word_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_scsi_priv_data *priv_data = NULL; cmd->cmd_word.direct = cmd->io_attr.direct_flag; ret = ps3_scsih_cmd_word_type_set(cmd); - if (ret != PS3_SUCCESS) + if (ret != PS3_SUCCESS) { goto l_out; + } #ifndef _WINDOWS cmd->cmd_word.isrSN = ps3_msix_index_get(cmd, 1); @@ -1685,8 +1592,8 @@ static int ps3_scsih_pd_cmd_word_build(struct ps3_cmd *cmd) cmd->cmd_word.phyDiskID = priv_data->disk_pos.diskDev.ps3Dev.phyDiskID; cmd->cmd_word.virtDiskID = PS3_INVALID_DEV_ID; - if ((cmd->cmd_word.type == PS3_CMDWORD_TYPE_READ) || - (cmd->cmd_word.type == PS3_CMDWORD_TYPE_WRITE)) { + if ((cmd->cmd_word.type == PS3_CMDWORD_TYPE_READ) + || (cmd->cmd_word.type == PS3_CMDWORD_TYPE_WRITE)){ cmd->cmd_word.qMask = 0x1; } @@ -1694,172 +1601,153 @@ static int ps3_scsih_pd_cmd_word_build(struct ps3_cmd *cmd) return ret; } -static int ps3_scsih_cmd_word_build(struct ps3_cmd *cmd) +static S32 ps3_scsih_cmd_word_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { ret = ps3_scsih_vd_cmd_word_build(cmd); - else + } else { ret = ps3_scsih_pd_cmd_word_build(cmd); + } if (unlikely(ret != PS3_SUCCESS)) { LOG_ERROR_LIM("tid:0x%llx hno:%u CFID:%d cmd word build NOK!\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->index); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); } return ret; } -static inline const char *ps3_scsih_print_rw_type(unsigned char rw_flag) +static inline const char *ps3_scsih_print_rw_type(U8 rw_flag) { - static const char *const rw_type_table[] = { - [PS3_SCSI_CMD_TYPE_UNKNOWN] = "SCMD_T_UNKNOWN", - [PS3_SCSI_CMD_TYPE_READ] = "SCMD_T_R", - [PS3_SCSI_CMD_TYPE_WRITE] = "SCMD_T_W", - [PS3_SCSI_CMD_TYPE_RW] = "SCMD_T_RW", - [PS3_SCSI_CMD_TYPE_UNMAP] = "SCMD_T_UNMAP", - [PS3_SCSI_CMD_TYPE_NORW] = "SCMD_T_NORW", - [PS3_SCSI_CMD_TYPE_COUNT] = "SCMD_T_CNT" + static const char *rw_type_table[] = { + [PS3_SCSI_CMD_TYPE_UNKOWN] = "SCMD_T_UNKOWN", + [PS3_SCSI_CMD_TYPE_READ] ="SCMD_T_R", + [PS3_SCSI_CMD_TYPE_WRITE] ="SCMD_T_W", + [PS3_SCSI_CMD_TYPE_RW] ="SCMD_T_RW", + [PS3_SCSI_CMD_TYPE_UNMAP] ="SCMD_T_UNMAP", + [PS3_SCSI_CMD_TYPE_NORW] ="SCMD_T_NORW", + [PS3_SCSI_CMD_TYPE_COUNT] ="SCMD_T_CNT" }; - if (rw_flag >= PS3_SCSI_CMD_TYPE_COUNT) - return rw_type_table[PS3_SCSI_CMD_TYPE_UNKNOWN]; - - return rw_type_table[rw_flag]; -} - -static void ps3_scsih_print_cdb(const unsigned char *cdb) -{ - LOG_DEBUG("CDB: %02x %02x %02x %02x %02x %02x %02x %02x\n" - "\t%02x %02x %02x %02x %02x %02x %02x %02x\n" - "\t%02x %02x %02x %02x %02x %02x %02x %02x\n" - "\t%02x %02x %02x %02x %02x %02x %02x %02x\n", - cdb[0], cdb[1], cdb[2], cdb[3], cdb[4], cdb[5], cdb[6], - cdb[7], cdb[8], cdb[9], cdb[10], cdb[11], cdb[12], cdb[13], - cdb[14], cdb[15], cdb[16], cdb[17], cdb[18], cdb[19], cdb[20], - cdb[21], cdb[22], cdb[23], cdb[24], cdb[25], cdb[26], cdb[27], - cdb[28], cdb[29], cdb[30], cdb[31]); -} - -static inline void ps3_scsih_print_req_head(struct ps3_cmd *cmd, - unsigned char log_level) -{ - if (cmd->req_frame->frontendReq.reqHead.reqFrameFormat == - PS3_REQFRAME_FORMAT_FRONTEND) { - struct PS3ReqFrameHead reqHead = - cmd->req_frame->frontendReq.reqHead; - - LOG_LEVEL( - log_level, - "tid:0x%llx hno:%u fe head cmd_t:%d\n" - "\tstype:%d CFID:%d ctrl:0x%x dev id:0x%x noReplyWord:%d\n" - "\tdataFormat:%d reqFrameFormat:%d mapBlockVer:%d isWrite:%d\n" - "\tvirtDiskSeq:%d\n", - reqHead.traceID, PS3_HOST(cmd->instance), - reqHead.cmdType, reqHead.cmdSubType, reqHead.cmdFrameID, - reqHead.control, reqHead.devID.diskID, - reqHead.noReplyWord, reqHead.dataFormat, - reqHead.reqFrameFormat, reqHead.mapBlockVer, - reqHead.isWrite, reqHead.virtDiskSeq); - } else { - struct PS3ReqFrameHead reqHead = cmd->req_frame->hwReq.reqHead; + if (rw_flag >= PS3_SCSI_CMD_TYPE_COUNT) { + return rw_type_table[PS3_SCSI_CMD_TYPE_UNKOWN]; + } - LOG_LEVEL( - log_level, - "tid:0x%llx hno:%u fe head cmd_t:%d\n" - "\tstype:%d CFID:%d ctrl:0x%x dev id:0x%x noReplyWord:%d\n" - "\tdataFormat:%d reqFrameFormat:%d mapBlockVer:%d isWrite:%d\n" - "\tvirtDiskSeq:%d\n", - reqHead.traceID, PS3_HOST(cmd->instance), - reqHead.cmdType, reqHead.cmdSubType, reqHead.cmdFrameID, - reqHead.control, reqHead.devID.diskID, - reqHead.noReplyWord, reqHead.dataFormat, - reqHead.reqFrameFormat, reqHead.mapBlockVer, - reqHead.isWrite, reqHead.virtDiskSeq); + return rw_type_table[rw_flag]; +} + +static void ps3_scsih_print_cdb(const U8 *cdb) +{ + LOG_DEBUG("CDB: %02x %02x %02x %02x %02x %02x %02x %02x" + " %02x %02x %02x %02x %02x %02x %02x %02x" + " %02x %02x %02x %02x %02x %02x %02x %02x" + " %02x %02x %02x %02x %02x %02x %02x %02x\n", + cdb[0], cdb[1], cdb[2], cdb[3], cdb[4], + cdb[5], cdb[6], cdb[7], cdb[8], cdb[9], + cdb[10], cdb[11], cdb[12], cdb[13], cdb[14], + cdb[15], cdb[16], cdb[17], cdb[18], cdb[19], + cdb[20], cdb[21], cdb[22], cdb[23], cdb[24], + cdb[25], cdb[26], cdb[27], cdb[28], cdb[29], + cdb[30], cdb[31]); +} + +static inline void ps3_scsih_print_req_head(struct ps3_cmd *cmd, U8 log_level) +{ + if (cmd->req_frame->frontendReq.reqHead.reqFrameFormat == PS3_REQFRAME_FORMAT_FRONTEND){ + PS3ReqFrameHead_s reqHead = cmd->req_frame->frontendReq.reqHead; + LOG_LEVEL(log_level, "tid:0x%llx hno:%u fe head cmd_t:%d" + " stype:%d CFID:%d ctrl:0x%x dev id:0x%x noReplyWord:%d" + "dataFormat:%d reqFrameFormat:%d mapBlockVer:%d isWrite:%d" + "virtDiskSeq:%d\n", + reqHead.traceID, PS3_HOST(cmd->instance), reqHead.cmdType, + reqHead.cmdSubType, reqHead.cmdFrameID, reqHead.control, + reqHead.devID.diskID, reqHead.noReplyWord, reqHead.dataFormat, + reqHead.reqFrameFormat, reqHead.mapBlockVer, reqHead.isWrite, + reqHead.virtDiskSeq); + } else { + PS3ReqFrameHead_s reqHead = cmd->req_frame->hwReq.reqHead; + LOG_LEVEL(log_level, "tid:0x%llx hno:%u fe head cmd_t:%d" + " stype:%d CFID:%d ctrl:0x%x dev id:0x%x noReplyWord:%d" + "dataFormat:%d reqFrameFormat:%d mapBlockVer:%d isWrite:%d" + "virtDiskSeq:%d\n", + reqHead.traceID, PS3_HOST(cmd->instance), reqHead.cmdType, + reqHead.cmdSubType, reqHead.cmdFrameID, reqHead.control, + reqHead.devID.diskID, reqHead.noReplyWord, reqHead.dataFormat, + reqHead.reqFrameFormat, reqHead.mapBlockVer, reqHead.isWrite, + reqHead.virtDiskSeq); } } -static void ps3_scsih_print_hw_req(struct ps3_cmd *cmd, unsigned char log_level) +static void ps3_scsih_print_hw_req(struct ps3_cmd *cmd, U8 log_level) { - struct IODT_V1 *req = NULL; - struct ps3_pd_entry *pd_entry = - (struct ps3_pd_entry *)cmd->io_attr.pd_entry; - if (pd_entry == NULL) + IODT_V1_s *req = NULL; + struct ps3_pd_entry * pd_entry = (struct ps3_pd_entry *)cmd->io_attr.pd_entry; + if (pd_entry == NULL) { return; + } ps3_scsih_print_req_head(cmd, log_level); switch (pd_entry->dev_type) { case PS3_DEV_TYPE_SAS_HDD: case PS3_DEV_TYPE_SAS_SSD: req = &cmd->req_frame->hwReq.sasReqFrame; - LOG_LEVEL(log_level, - "hno:%u cmdProto:%d cmdType:%d\n" - "\tcmdLen:%d dataAddr:0x%llx sgeMode:%d\n" - "\tdirect:%d function:%d phyDiskID:%d\n" - "\treqFrameID:%d CmdWordType:%d cmdDir:%d\n" - "\tdataBufLenDWAlign:0x%x iuSrc:%d sataCtl:%d\n", - PS3_HOST(cmd->instance), req->protocolType, - req->frameType, le32_to_cpu(req->cmdLen), - le64_to_cpu(req->dataBaseAddr), req->dmaCfg.sgMode, - req->commonWord.direct, req->commonWord.function, - le16_to_cpu(req->commonWord.phyDiskID), - le16_to_cpu(req->commonWord.reqFrameID), - req->commonWord.type, req->cmdDir, - le32_to_cpu(req->dataBufLenDWAlign), req->iuSrc, - req->sasCtl); + LOG_LEVEL(log_level, "hno:%u cmdProto:%d cmdType:%d " + "cmdLen:%d dataAddr:0x%llx sgeMode:%d " + "direct:%d function:%d phyDiskID:%d " + "reqFrameID:%d CmdWordType:%d cmdDir:%d " + "dataBufLenDWAlign:0x%x iuSrc:%d sataCtl:%d\n", + PS3_HOST(cmd->instance), req->protocolType, req->frameType, + le32_to_cpu(req->cmdLen), le64_to_cpu(req->dataBaseAddr), + req->dmaCfg.sgMode, req->commonWord.direct, req->commonWord.function, + le16_to_cpu(req->commonWord.phyDiskID), + le16_to_cpu(req->commonWord.reqFrameID), + req->commonWord.type, req->cmdDir, le32_to_cpu(req->dataBufLenDWAlign), + req->iuSrc, req->sasCtl); ps3_scsih_print_cdb(req->B.cdb); break; case PS3_DEV_TYPE_SATA_HDD: case PS3_DEV_TYPE_SATA_SSD: req = &cmd->req_frame->hwReq.sasReqFrame; - LOG_LEVEL(log_level, - "hno:%u cmdProto:%d cmdType:%d\n" - "\tdataAddr:0x%llx sgeMode:%d\n" - "\tdirect:%d function:%d phyDiskID:%d\n" - "\treqFrameID:%d CmdWordType:%d cmdDir:%d\n" - "\tdataBufLenDWAlign:0x%x lba:0x%llx\n" - "\topCode:0x%llx iuSrc:%d sataCtl:%d\n", - PS3_HOST(cmd->instance), req->protocolType, - req->frameType, le64_to_cpu(req->dataBaseAddr), - req->dmaCfg.sgMode, req->commonWord.direct, - req->commonWord.function, - le16_to_cpu(req->commonWord.phyDiskID), - le16_to_cpu(req->commonWord.reqFrameID), - req->commonWord.type, req->cmdDir, - le32_to_cpu(req->dataBufLenDWAlign), - le64_to_cpu(req->C.lba), - (unsigned long long)req->C.opCode, req->iuSrc, - req->sataCtl); + LOG_LEVEL(log_level, "hno:%u cmdProto:%d cmdType:%d " + "dataAddr:0x%llx sgeMode:%d " + "direct:%d function:%d phyDiskID:%d " + "reqFrameID:%d CmdWordType:%d cmdDir:%d " + "dataBufLenDWAlign:0x%x lba:0x%llx " + "opCode:0x%llx iuSrc:%d sataCtl:%d\n", + PS3_HOST(cmd->instance), req->protocolType, req->frameType, + le64_to_cpu(req->dataBaseAddr), req->dmaCfg.sgMode, + req->commonWord.direct, req->commonWord.function, + le16_to_cpu(req->commonWord.phyDiskID), + le16_to_cpu(req->commonWord.reqFrameID), req->commonWord.type, + req->cmdDir, le32_to_cpu(req->dataBufLenDWAlign), + le64_to_cpu(req->C.lba), (U64)req->C.opCode, req->iuSrc, req->sataCtl); break; case PS3_DEV_TYPE_NVME_SSD: break; - default: + default : LOG_LEVEL(log_level, "hno:%u dev_type:%d\n", - PS3_HOST(cmd->instance), pd_entry->dev_type); + PS3_HOST(cmd->instance), pd_entry->dev_type); break; } } -static void ps3_scsih_print_frontend_req(struct ps3_cmd *cmd, - unsigned char log_level) +static void ps3_scsih_print_frontend_req(struct ps3_cmd *cmd, U8 log_level) { ps3_scsih_print_req_head(cmd, log_level); - LOG_LEVEL(log_level, - "cmd sge_cnt:%d sge_of:%d data_len:%d isStream:%d\n" - "\tnum_blks:0x%x\n", - cmd->req_frame->frontendReq.sgeCount, - cmd->req_frame->frontendReq.sgeOffset, - cmd->req_frame->frontendReq.dataXferLen, - cmd->req_frame->frontendReq.vdAccAttr.isStream, - cmd->io_attr.num_blocks); + LOG_LEVEL(log_level, "cmd sge_cnt:%d sge_of:%d data_len:%d isStream:%d" + " num_blks:0x%x\n", + cmd->req_frame->frontendReq.sgeCount, + cmd->req_frame->frontendReq.sgeOffset, + cmd->req_frame->frontendReq.dataXferLen, + cmd->req_frame->frontendReq.vdAccAttr.isStream, + cmd->io_attr.num_blocks); ps3_scsih_print_cdb(cmd->req_frame->frontendReq.cdb); } -void ps3_scsih_print_req(struct ps3_cmd *cmd, unsigned char log_level) +void ps3_scsih_print_req(struct ps3_cmd *cmd, U8 log_level) { - if (cmd->req_frame->frontendReq.reqHead.reqFrameFormat == - PS3_REQFRAME_FORMAT_FRONTEND) { + if (cmd->req_frame->frontendReq.reqHead.reqFrameFormat == PS3_REQFRAME_FORMAT_FRONTEND) { ps3_scsih_print_frontend_req(cmd, log_level); } else { ps3_scsih_print_hw_req(cmd, log_level); @@ -1868,81 +1756,65 @@ void ps3_scsih_print_req(struct ps3_cmd *cmd, unsigned char log_level) static void ps3_scsih_print_io_cmd(struct ps3_cmd *cmd) { - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + if(cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { if (cmd->io_attr.pd_entry != NULL) { - LOG_DEBUG( - "tid:0x%llx hno:%u cmd CFID:%d, dev_t:%s [%d:%d:%d]\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->index, - namePS3DevType((enum PS3DevType)cmd->io_attr - .pd_entry->dev_type), - cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev - .softChan, - cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev - .devID, - cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev - .phyDiskID); - } - } - - LOG_DEBUG( - "tid:0x%llx hno:%u print CMD: CFID:%u\n" - "\tdev_t:%s outstand:%u is_retry_cmd:%d\n" - "\tdirect_f:%d rw_f:%s CMD_WORD: type:%d direct:%d\n" - "\tqmask:0x%x CFID:%d isr_sn:%d vid:%d pid:%d\n" - "\tlba:0x%llx opcode:0x%x\n", + LOG_DEBUG("tid:0x%llx hno:%u cmd CFID:%d, dev_t:%s [%d:%d:%d]\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, + namePS3DevType((enum PS3DevType)cmd->io_attr.pd_entry->dev_type), + cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev.softChan, + cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev.devID, + cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev.phyDiskID); + } + } + + LOG_DEBUG("tid:0x%llx hno:%u print CMD: CFID:%u" + " dev_t:%s outstand:%u is_retry_cmd:%d " + "direct_f:%d rw_f:%s CMD_WORD: type:%d direct:%d" + " qmask:0x%x CFID:%d isr_sn:%d vid:%d pid:%d" + " lba:0x%llx opcode:0x%x\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, namePS3DevType((enum PS3DevType)cmd->io_attr.dev_type), ps3_atomic_read(&cmd->instance->cmd_statistics.io_outstanding), cmd->io_attr.is_retry_cmd, cmd->io_attr.direct_flag, ps3_scsih_print_rw_type(cmd->io_attr.rw_flag), - cmd->cmd_word.type, cmd->cmd_word.direct, cmd->cmd_word.qMask, - cmd->cmd_word.cmdFrameID, cmd->cmd_word.isrSN, - cmd->cmd_word.virtDiskID, cmd->cmd_word.phyDiskID, - ((((unsigned long long)(cmd->io_attr.lba_hi)) << 32) + - (cmd->io_attr.lba_lo)), + cmd->cmd_word.type, cmd->cmd_word.direct, + cmd->cmd_word.qMask, cmd->cmd_word.cmdFrameID, + cmd->cmd_word.isrSN, cmd->cmd_word.virtDiskID, + cmd->cmd_word.phyDiskID, + ((((U64)(cmd->io_attr.lba_hi)) << 32) + (cmd->io_attr.lba_lo)), cmd->scmd->cmnd[0]); ps3_scsih_print_req(cmd, LEVEL_DEBUG); } -int ps3_scsih_cmd_build(struct ps3_cmd *cmd) +S32 ps3_scsih_cmd_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; static unsigned long j; - ret = ps3_scsih_cmd_build_prepare(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_DEBUG( - "tid:0x%llx hno:%u cmd_word build prepare fail CFID:%d ret:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - ret); + LOG_DEBUG("tid:0x%llx hno:%u cmd_word build prepare fail CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); ret = ((-PS3_IO_CONFLICT == ret || -PS3_IO_REQUEUE == ret || -PS3_IO_CONFLICT_IN_Q == ret) ? - ret : - SCSI_MLQUEUE_HOST_BUSY); + ret : SCSI_MLQUEUE_HOST_BUSY); goto l_out; } ret = ps3_scsih_cmd_word_build(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - ret); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); ret = SCSI_MLQUEUE_HOST_BUSY; goto l_out; } ret = ps3_scsih_req_frame_build(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "tid:0x%llx hno:%u req_frame NOK CFID:%d ret:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - ret); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u req_frame NOK CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); ret = SCSI_MLQUEUE_HOST_BUSY; goto l_out; } @@ -1950,49 +1822,43 @@ int ps3_scsih_cmd_build(struct ps3_cmd *cmd) ps3_scsih_print_io_cmd(cmd); PS3_IO_TRACE(cmd, PS3_IO_TRACE_DIRECT_SEND); - ret = ps3_qos_decision(cmd); + ret = ps3_qos_decision(cmd); l_out: return ret; } -static inline union PS3DiskDev -ps3_scsih_dev_id_get(const struct scsi_cmnd *s_cmd) +static inline union PS3DiskDev ps3_scsih_dev_id_get(const struct scsi_cmnd *s_cmd) { struct ps3_scsi_priv_data *data = scsi_device_private_data(s_cmd); - return data->disk_pos.diskDev; } -static inline unsigned char ps3_scsih_is_vd_accelerate(struct ps3_cmd *cmd) +static inline Bool ps3_scsih_is_vd_accelerate(struct ps3_cmd *cmd) { return ps3_scsih_vd_acc_att_build(cmd); } static inline void ps3_sas_cdb_build(struct ps3_cmd *cmd) { - unsigned int blocks = 0; + U32 blocks = 0; memset(cmd->io_attr.cdb, 0, PS3_FRAME_CDB_BUFLEN); memcpy(cmd->io_attr.cdb, cmd->scmd->cmnd, cmd->scmd->cmd_len); #ifndef _WINDOWS - blocks = cmd->io_attr.num_blocks - << ilog2(cmd->io_attr.vd_entry->sectorSize); + blocks = cmd->io_attr.num_blocks << ilog2(cmd->io_attr.vd_entry->sectorSize); #else blocks = cmd->io_attr.num_blocks * cmd->io_attr.vd_entry->sectorSize; #endif - blocks = blocks >> - ps3_blocksize_to_shift(cmd->io_attr.pd_entry->sector_size); + blocks = blocks >> ps3_blocksize_to_shift(cmd->io_attr.pd_entry->sector_size); ps3_scsih_cdb_rebuild(cmd->io_attr.cdb, cmd->scmd->cmd_len, blocks, - (unsigned int)cmd->io_attr.plba, - (unsigned int)(cmd->io_attr.plba >> - PS3_SHIFT_DWORD)); + (U32)cmd->io_attr.plba, (U32)(cmd->io_attr.plba >> PS3_SHIFT_DWORD)); } -int ps3_vd_direct_req_frame_build(struct ps3_cmd *cmd) +S32 ps3_vd_direct_req_frame_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - switch (cmd->io_attr.pd_entry->dev_type) { + switch(cmd->io_attr.pd_entry->dev_type) { case PS3_DEV_TYPE_SAS_SSD: case PS3_DEV_TYPE_SAS_HDD: ps3_sas_cdb_build(cmd); @@ -2013,222 +1879,199 @@ int ps3_vd_direct_req_frame_build(struct ps3_cmd *cmd) return ret; } -static inline unsigned int -ps3_scsih_data_direction_build(const struct ps3_cmd *cmd) +static inline U32 ps3_scsih_data_direction_build(const struct ps3_cmd *cmd) { - unsigned int ret; + U32 ret; static unsigned long j; - - if ((cmd->scmd->sc_data_direction == DMA_BIDIRECTIONAL) || - (cmd->scmd->sc_data_direction == DMA_TO_DEVICE)) { + if((cmd->scmd->sc_data_direction == DMA_BIDIRECTIONAL) + || (cmd->scmd->sc_data_direction == DMA_TO_DEVICE)){ ret = PS3_DATA_DIRECTION_WRITE; - } else if ((cmd->scmd->sc_data_direction == DMA_FROM_DEVICE) || - (cmd->scmd->sc_data_direction == DMA_NONE)) { + } else if((cmd->scmd->sc_data_direction == DMA_FROM_DEVICE) + || (cmd->scmd->sc_data_direction == DMA_NONE)){ ret = PS3_DATA_DIRECTION_READ; } else { - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u tid:0x%llx date direction:%d check NOK", - PS3_HOST(cmd->instance), cmd->trace_id, - cmd->scmd->sc_data_direction); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tid:0x%llx date direction:%d check NOK", + PS3_HOST(cmd->instance),cmd->trace_id, cmd->scmd->sc_data_direction); ret = PS3_DATA_DIRECTION_WRITE; } return ret; } -static int ps3_scsih_vd_frontend_req_build(struct ps3_cmd *cmd, - struct PS3FrontEndReqFrame *req, - unsigned short sge_count) +static S32 ps3_scsih_vd_frontend_req_build(struct ps3_cmd *cmd, + PS3FrontEndReqFrame_s *req, U16 sge_count) { - int ret = PS3_SUCCESS; - struct ps3_scsi_priv_data *p_priv_data = - scsi_device_private_data(cmd->scmd); + S32 ret = PS3_SUCCESS; + struct ps3_scsi_priv_data *p_priv_data = scsi_device_private_data(cmd->scmd); ps3_scsih_req_frame_head_build(cmd, PS3_REQFRAME_FORMAT_FRONTEND); memcpy(req->cdb, cmd->scmd->cmnd, cmd->scmd->cmd_len); req->dataXferLen = cmd->io_attr.sgl_buf_len; req->sgeCount = sge_count; - req->sgeOffset = offsetof(struct PS3FrontEndReqFrame, sgl) >> 2; - if (cmd->io_attr.seq_flag == SCSI_RW_UNUSED_CMD && - cmd->instance->ioc_adpter->scsih_stream_is_detect != NULL) { + req->sgeOffset = offsetof(PS3FrontEndReqFrame_s, sgl) >> 2; + if(cmd->io_attr.seq_flag == SCSI_RW_UNUSED_CMD && + cmd->instance->ioc_adpter->scsih_stream_is_detect != NULL) { cmd->instance->ioc_adpter->scsih_stream_is_detect(cmd); } - req->vdAccAttr.isStream = - ((cmd->io_attr.seq_flag == SCSI_RW_SEQ_CMD) ? (1) : (0)); + req->vdAccAttr.isStream = ((cmd->io_attr.seq_flag == SCSI_RW_SEQ_CMD)?(1):(0)); if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - req->vdAccAttr.ioOutStandingCnt = - (unsigned short)ps3_atomic_read( - &p_priv_data->rd_io_outstand); + req->vdAccAttr.ioOutStandingCnt = (U16)ps3_atomic_read(&p_priv_data->rd_io_outstand); } if (ps3_scsih_is_vd_accelerate(cmd)) { - LOG_DEBUG("tid:0x%llx hno:%u cmd_type:%d CFID:%d\n" - "\tret:%d vlba->plba:0x%llx\n", - cmd->trace_id, PS3_HOST(cmd->instance), - req->reqHead.cmdType, cmd->index, ret, - cmd->io_attr.plba); + LOG_DEBUG("tid:0x%llx hno:%u cmd_type:%d CFID:%d " + "ret:%d vlba->plba:0x%llx\n", + cmd->trace_id, PS3_HOST(cmd->instance), + req->reqHead.cmdType, cmd->index, ret, cmd->io_attr.plba); } return ret; } -static inline void ps3_align_16bytes_check(unsigned long long addr) +static inline void ps3_align_16bytes_check(U64 addr) { - if (unlikely(addr & PS3_SCSI_ALINNMENT_MASK)) + if (unlikely(addr & PS3_SCSI_ALINNMENT_MASK)) { LOG_ERROR_LIM("addr:0x%llx not align\n", addr); + } } -static inline void ps3_align_4bytes_check(unsigned long long addr) +static inline void ps3_align_4bytes_check(U64 addr) { - if (unlikely(addr & PS3_SCSI_ALINNMENT_MASK)) + if (unlikely(addr & PS3_SCSI_ALINNMENT_MASK)) { LOG_ERROR_LIM("addr:0x%llx not align\n", addr); + } } -static inline unsigned char -ps3_is_invalid_ossgl_count(unsigned short valid_os_sge_count, - unsigned short max_drv_sge_count) +static inline Bool ps3_is_invalid_ossgl_count(U16 valid_os_sge_count, + U16 max_drv_sge_count) { return (max_drv_sge_count < valid_os_sge_count + 1); } static inline void ps3_last_sge_build(struct PS3Sge *sgl_ptr, - const struct scatterlist *os_sgl) + const ps3_scatter_gather_element *os_sgl) { - sgl_ptr->length = cpu_to_le32(sg_dma_len(os_sgl)); - sgl_ptr->addr = cpu_to_le64(sg_dma_address_u64(os_sgl)); - sgl_ptr->lastSge = 1; - sgl_ptr->ext = 0; + sgl_ptr->length = cpu_to_le32(sg_dma_len(os_sgl)); + sgl_ptr->addr = cpu_to_le64(sg_dma_address_u64(os_sgl)); + sgl_ptr->lastSge = 1; + sgl_ptr->ext = 0; + return ; } -static inline unsigned char ps3_is_last_sge(int sgl_idx, - unsigned short os_sge_count) +static inline Bool ps3_is_last_sge(S32 sgl_idx, U16 os_sge_count) { return ((sgl_idx + 1) == os_sge_count); } -static inline unsigned char ps3_is_list_sge(int sgl_idx, - unsigned short frame_sge_count) +static inline Bool ps3_is_list_sge(S32 sgl_idx, U16 frame_sge_count) { return ((sgl_idx + 1) == frame_sge_count); } static inline void ps3_list_sge_build(struct PS3Sge *sgl_ptr, - const struct ps3_cmd *cmd, - unsigned short ext_sge_size) + const struct ps3_cmd *cmd, U16 ext_sge_size) { - sgl_ptr->length = ext_sge_size; - sgl_ptr->addr = cpu_to_le64(cmd->ext_buf_phys); + sgl_ptr->length = ext_sge_size; + sgl_ptr->addr = cpu_to_le64(cmd->ext_buf_phys); sgl_ptr->lastSge = 0; - sgl_ptr->ext = 1; + sgl_ptr->ext = 1; + return; } -static unsigned int ps3_scsih_data_buf_len(struct ps3_cmd *cmd, - unsigned int os_sge_count) +static U32 ps3_scsih_data_buf_len(struct ps3_cmd *cmd, U32 os_sge_count) { struct scsi_cmnd *scp = cmd->scmd; - struct scatterlist *os_sgl = NULL; - unsigned int index = 0; + ps3_scatter_gather_element *os_sgl = NULL; + U32 index = 0; cmd->io_attr.sgl_buf_len = 0; scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { cmd->io_attr.sgl_buf_len += sg_dma_len(os_sgl); - mb(); /* in order to force CPU ordering */ + mb(); } if (scsi_bufflen(scp) != cmd->io_attr.sgl_buf_len) { - LOG_INFO("data_buf:%u buf_len:%u mismatch\n", scsi_bufflen(scp), - cmd->io_attr.sgl_buf_len); + LOG_INFO("data_buf:%u buf_len:%u mismatch\n", + scsi_bufflen(scp), cmd->io_attr.sgl_buf_len); } return cmd->io_attr.sgl_buf_len; } -static inline unsigned short -ps3_drv_max_sge_count(const struct ps3_cmd *cmd, unsigned short frame_sge_count) +static inline U16 ps3_drv_max_sge_count(const struct ps3_cmd *cmd, + U16 frame_sge_count) { - unsigned short count = 0; + U16 count = 0; if (cmd->instance->cmd_context.sgl_mode_support) { - count = ((unsigned short)cmd->instance->cmd_context - .ext_sge_frame_count + - frame_sge_count); + count = ((U16)cmd->instance->cmd_context.ext_sge_frame_count + + frame_sge_count); } else { - count = PS3_MAX((unsigned short)cmd->instance->cmd_context - .ext_sge_frame_count + - 1, - frame_sge_count); + count = PS3_MAX((U16)cmd->instance->cmd_context.ext_sge_frame_count + 1, + frame_sge_count); } return count; } -static inline unsigned short -ps3_scsih_frame_ext_sge_pos(const struct ps3_cmd *cmd, - unsigned short frame_sge_count, - unsigned short os_sge_count) +static inline U16 ps3_scsih_frame_ext_sge_pos(const struct ps3_cmd *cmd, + U16 frame_sge_count, U16 os_sge_count) { - unsigned short pos = 0; + U16 pos = 0; - if (cmd->instance->cmd_context.sgl_mode_support) + if (cmd->instance->cmd_context.sgl_mode_support) { pos = frame_sge_count; - else + } else { pos = (os_sge_count <= frame_sge_count) ? 0 : 1; + } return pos; } -static inline unsigned short -ps3_scsih_ext_sge_size_calc(unsigned short ext_sge_pos, - unsigned short frame_sge_count, - unsigned short os_sge_count) +static inline U16 ps3_scsih_ext_sge_size_calc(U16 ext_sge_pos, + U16 frame_sge_count, U16 os_sge_count) { - unsigned short cnt = 0; + U16 cnt = 0; - if (ext_sge_pos == 0) + if (ext_sge_pos == 0) { cnt = 0; - else if (ext_sge_pos == 1) + } else if (ext_sge_pos == 1) { cnt = os_sge_count; - else + } else { cnt = os_sge_count - frame_sge_count + 1; + } return cnt * sizeof(struct PS3Sge); } -static unsigned short ps3_scsih_sgl_build(struct ps3_cmd *cmd, - struct PS3Sge *sge, - unsigned char frame_sge_count) +static U16 ps3_scsih_sgl_build(struct ps3_cmd *cmd, struct PS3Sge *sge, + U8 frame_sge_count) { - int index = 0; - unsigned short max_drv_sge_count = 0; - unsigned short os_sge_count = cmd->os_sge_map_count; + S32 index = 0; + U16 max_drv_sge_count = 0; + U16 os_sge_count = cmd->os_sge_map_count; struct scsi_cmnd *scp = cmd->scmd; - struct scatterlist *os_sgl = NULL; + ps3_scatter_gather_element *os_sgl = NULL; struct PS3Sge *sge_ptr = sge; - unsigned short ret_sge_count = 0; - unsigned short ext_sge_pos = 0; - unsigned short ext_sge_size = 0; + U16 ret_sge_count = 0; + U16 ext_sge_pos = 0; + U16 ext_sge_size = 0; static unsigned long j; - cmd->io_attr.sgl_buf_len = 0; max_drv_sge_count = ps3_drv_max_sge_count(cmd, frame_sge_count); if (unlikely(ps3_is_invalid_ossgl_count(os_sge_count, - max_drv_sge_count))) { - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "tid:0x%llx hno:%u CFID:%u io is\n" - "\ttoo huge max_drv_sge_count:%d os_sge_count:%u\n", + max_drv_sge_count))) { + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u CFID:%u io is " + "too huge max_drv_sge_count:%d os_sge_count:%u\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - max_drv_sge_count, os_sge_count); + max_drv_sge_count , os_sge_count); goto l_out; } - memset(&cmd->req_frame->hwReq.sgl, 0, - sizeof(cmd->req_frame->hwReq.sgl)); - ext_sge_pos = - ps3_scsih_frame_ext_sge_pos(cmd, frame_sge_count, os_sge_count); + memset(&cmd->req_frame->hwReq.sgl, 0, sizeof(cmd->req_frame->hwReq.sgl)); + ext_sge_pos = ps3_scsih_frame_ext_sge_pos(cmd, frame_sge_count, os_sge_count); ext_sge_size = ps3_scsih_ext_sge_size_calc(ext_sge_pos, frame_sge_count, - os_sge_count); + os_sge_count); ret_sge_count = os_sge_count; scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { @@ -2237,13 +2080,13 @@ static unsigned short ps3_scsih_sgl_build(struct ps3_cmd *cmd, cmd->io_attr.sgl_buf_len += sge_ptr->length; ps3_align_4bytes_check(sge_ptr->addr); LOG_DEBUG("sgl addr:0x%llx len:%d\n", sge_ptr->addr, - sge_ptr->length); + sge_ptr->length); break; } if (ps3_is_list_sge(index, ext_sge_pos)) { ps3_list_sge_build(sge_ptr, cmd, ext_sge_size); - sge_ptr = (struct PS3Sge *)cmd->ext_buf; + sge_ptr = (struct PS3Sge*)cmd->ext_buf; ret_sge_count += 1; } @@ -2260,11 +2103,11 @@ static unsigned short ps3_scsih_sgl_build(struct ps3_cmd *cmd, return ret_sge_count; } -static int ps3_vd_normal_req_frame_build(struct ps3_cmd *cmd) +static S32 ps3_vd_normal_req_frame_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - struct PS3FrontEndReqFrame *req = &cmd->req_frame->frontendReq; - unsigned short sge_count = 0; + S32 ret = PS3_SUCCESS; + PS3FrontEndReqFrame_s *req = &cmd->req_frame->frontendReq; + U16 sge_count = 0; static unsigned long j; memset(&req->reserved, 0, sizeof(req->reserved)); @@ -2278,45 +2121,38 @@ static int ps3_vd_normal_req_frame_build(struct ps3_cmd *cmd) sge_count = ps3_scsih_frontend_data_buf_build(cmd, req); if (sge_count == 0 && cmd->os_sge_map_count != 0) { ret = -PS3_FAILED; - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u tid:0x%llx drv_sge_count:%u os_sge_count:%u\n", - PS3_HOST(cmd->instance), - cmd->trace_id, sge_count, - cmd->os_sge_map_count); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tid:0x%llx drv_sge_count:%u " + "os_sge_count:%u\n", PS3_HOST(cmd->instance), + cmd->trace_id, sge_count, cmd->os_sge_map_count); goto l_out; } } ret = ps3_scsih_vd_frontend_req_build(cmd, req, sge_count); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u CFID:%d ret:%d frondend build NOK\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - ret); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); } l_out: return ret; } -static inline int ps3_vd_adv_to_normal_req_frame_rebuild(struct ps3_cmd *cmd) +static inline S32 ps3_vd_adv_to_normal_req_frame_rebuild(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; static unsigned long j; - cmd->io_attr.direct_flag = PS3_CMDWORD_DIRECT_NORMAL; cmd->io_attr.is_use_frontend_prp = PS3_FALSE; - memset((void *)&cmd->cmd_word, 0, sizeof(struct PS3CmdWord)); + memset((void *) &cmd->cmd_word, 0, sizeof(struct PS3CmdWord)); memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); ret = ps3_scsih_vd_cmd_word_build(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - ret); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); ret = -PS3_FAILED; goto l_out; } @@ -2327,23 +2163,20 @@ static inline int ps3_vd_adv_to_normal_req_frame_rebuild(struct ps3_cmd *cmd) return ret; } -static int ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd) +static S32 ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; static unsigned long j; - if ((cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) || - (cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_ADVICE)) { + (cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_ADVICE)) { ret = ps3_vd_direct_req_frame_build(cmd); - if ((ret != PS3_SUCCESS) && (cmd->io_attr.pd_entry->dev_type == - PS3_DEV_TYPE_NVME_SSD)) { - LOG_WARN_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "tid:0x%llx hno:%u advice direct NVMe vd NOK, to normal\n" - "\tis_use_frontend_prp:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->io_attr.is_use_frontend_prp); + if ((ret != PS3_SUCCESS) && + (cmd->io_attr.pd_entry->dev_type == PS3_DEV_TYPE_NVME_SSD) ) { + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u advice direct NVMe vd NOK, to normal" + "is_use_frontend_prp:%d\n", cmd->trace_id, + PS3_HOST(cmd->instance), cmd->io_attr.is_use_frontend_prp); ret = ps3_vd_adv_to_normal_req_frame_rebuild(cmd); } } else { @@ -2352,33 +2185,30 @@ static int ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd) return ret; } -static int ps3_software_zone_build(struct ps3_cmd *cmd, - unsigned long long virtDiskLba, - unsigned char type, unsigned short sge_count) +static S32 ps3_software_zone_build(struct ps3_cmd *cmd, + U64 virtDiskLba, U8 type, U16 sge_count) { - struct PS3SoftwareZone *zone = NULL; - unsigned int num_blocks = cmd->io_attr.num_blocks; - int ret = PS3_SUCCESS; + PS3SoftwareZone_s *zone = NULL; + U32 num_blocks = cmd->io_attr.num_blocks; + S32 ret = PS3_SUCCESS; static unsigned long j; - - if (unlikely((type < PS3_DEV_TYPE_SAS_HDD) || - (type >= PS3_DEV_TYPE_COUNT))) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "tid:0x%llx hno:%u type:%d\n", cmd->trace_id, - PS3_HOST(cmd->instance), type); + INJECT_START(PS3_ERR_IJ_SOFT_ZONE_TYPE_SET_UNKOWN, &type); + if(unlikely((type < PS3_DEV_TYPE_SAS_HDD) || + (type >= PS3_DEV_TYPE_COUNT))) { + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u type:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), type); ret = -PS3_FAILED; goto l_ret; } zone = &cmd->req_frame->hwReq.softwareZone; - ps3_scsih_cdb_opcode_get(cmd->scmd->cmnd, &zone->opcode, - &zone->subOpcode); + ps3_scsih_cdb_opcode_get(cmd->scmd->cmnd, &zone->opcode, &zone->subOpcode); zone->virtDiskLba = cpu_to_le64(virtDiskLba); zone->numBlocks = cpu_to_le32(num_blocks); zone->sgeCount = sge_count; - if (type == PS3_DEV_TYPE_NVME_SSD) { + if( type == PS3_DEV_TYPE_NVME_SSD) { zone->sglOffset = offsetof(struct PS3NvmeCmdDw0_9, dPtr) >> 2; zone->sglFormat = 1; } else { @@ -2391,28 +2221,31 @@ static int ps3_software_zone_build(struct ps3_cmd *cmd, return ret; } -static unsigned char ps3_prp_build_check(struct ps3_cmd *cmd, - unsigned int data_len) +static Bool ps3_prp_build_check(struct ps3_cmd *cmd, U32 data_len) { struct scsi_cmnd *scmd = cmd->scmd; - unsigned char prp_convert_support = PS3_TRUE; - int index = 0; - unsigned short total_sge_count = cmd->os_sge_map_count; - unsigned int nvme_page_size = cmd->instance->cmd_attr.nvme_page_size; - struct scatterlist *sge_ptr = scsi_sglist(scmd); - unsigned long long sge_addr = 0; - unsigned int first_prp_len = 0; - unsigned int nvme_page_size_mask = nvme_page_size - 1; + Bool prp_convert_support = PS3_TRUE; + S32 index = 0; + U16 total_sge_count = cmd->os_sge_map_count; + U32 nvme_page_size = cmd->instance->cmd_attr.nvme_page_size; + ps3_scatter_gather_element *sge_ptr = scsi_sglist(scmd); + U64 sge_addr = 0; + U32 first_prp_len = 0; + U32 nvme_page_size_mask = nvme_page_size - 1; static unsigned long j; (void)data_len; - LOG_DEBUG("hno:%u CFID:%u sge_count:%u\n", PS3_HOST(cmd->instance), - cmd->index, total_sge_count); + LOG_DEBUG("hno:%u CFID:%u sge_count:%u\n", + PS3_HOST(cmd->instance), cmd->index, total_sge_count); scsi_for_each_sg(scmd, sge_ptr, total_sge_count, index) { sge_addr = sg_dma_address(sge_ptr); +#if 0 + LOG_DEBUG("hno:%u CFID:%u index:%u sge_addr:0x%llx len:%u\n", + PS3_HOST(cmd->instance), cmd->index, index, sge_addr, + sg_dma_len(sge_ptr)); +#endif if (index == 0) { - first_prp_len = nvme_page_size - - (sge_addr & nvme_page_size_mask); + first_prp_len = nvme_page_size - (sge_addr & nvme_page_size_mask); if (first_prp_len >= sg_dma_len(sge_ptr)) { prp_convert_support = PS3_TRUE; break; @@ -2421,49 +2254,35 @@ static unsigned char ps3_prp_build_check(struct ps3_cmd *cmd, if (total_sge_count <= 1) { prp_convert_support = PS3_TRUE; break; - } else if (ps3_utility_mod64( - sge_addr + sg_dma_len(sge_ptr), - nvme_page_size)) { + } else if (ps3_utility_mod64(sge_addr + sg_dma_len(sge_ptr), + nvme_page_size)) { prp_convert_support = PS3_FALSE; - LOG_WARN_TIME_LIM(&j, - PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u CFID:%u index:%u\n" - "\tsge_addr:0x%llx len:%u\n", - PS3_HOST(cmd->instance), - cmd->index, index, sge_addr, - sg_dma_len(sge_ptr)); + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u CFID:%u index:%u " + "sge_addr:0x%llx len:%u\n", + PS3_HOST(cmd->instance), cmd->index, + index, sge_addr, sg_dma_len(sge_ptr)); break; } } else { - if ((total_sge_count > 1) && - (index == (total_sge_count - 1))) { - if (ps3_utility_mod64(sge_addr, - nvme_page_size)) { - LOG_WARN_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u CFID:%u index:%u\n" - "\tsge_addr:0x%llx len:%u\n", - PS3_HOST(cmd->instance), - cmd->index, index, sge_addr, - sg_dma_len(sge_ptr)); + if ((total_sge_count > 1) && (index == (total_sge_count - 1))) { + if (ps3_utility_mod64(sge_addr, nvme_page_size)) { + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u CFID:%u index:%u " + "sge_addr:0x%llx len:%u\n", + PS3_HOST(cmd->instance), cmd->index, + index, sge_addr, sg_dma_len(sge_ptr)); prp_convert_support = PS3_FALSE; break; } } - if ((total_sge_count > 1) && - (index != (total_sge_count - 1))) { - if (ps3_utility_mod64(sg_dma_len(sge_ptr), - nvme_page_size) || - ps3_utility_mod64(sge_addr, - nvme_page_size)) { - LOG_WARN_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "middle hno:%u CFID:%u index:%u\n" - "\tsge_addr:0x%llx len:%u\n", - PS3_HOST(cmd->instance), - cmd->index, index, sge_addr, - sg_dma_len(sge_ptr)); + if ((total_sge_count > 1) && (index != (total_sge_count - 1))) { + if (ps3_utility_mod64(sg_dma_len(sge_ptr), nvme_page_size) || + ps3_utility_mod64(sge_addr, nvme_page_size)) { + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "middle hno:%u CFID:%u index:%u " + "sge_addr:0x%llx len:%u\n", + PS3_HOST(cmd->instance), cmd->index, + index, sge_addr, sg_dma_len(sge_ptr)); prp_convert_support = PS3_FALSE; break; } @@ -2474,44 +2293,37 @@ static unsigned char ps3_prp_build_check(struct ps3_cmd *cmd, return prp_convert_support; } -static unsigned short ps3_scsih_prp_build(struct ps3_cmd *cmd, - unsigned long long *prp_ptr, - unsigned char frame_prp_count, - unsigned int data_len, - unsigned char is_need_clean_sgl) +static U16 ps3_scsih_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, + U8 frame_prp_count, U32 data_len, Bool is_need_clean_sgl) { struct scsi_cmnd *scp = cmd->scmd; - struct scatterlist *sge_scmd = scsi_sglist(scp); - unsigned int page_size = cmd->instance->cmd_attr.nvme_page_size; - unsigned int nvme_page_size_mask = page_size - 1; - unsigned int sge_len = sg_dma_len(sge_scmd); - unsigned long long sge_addr = sg_dma_address_u64(sge_scmd); - unsigned int first_prp_len = 0; - unsigned short prp_entry_count = 0; + ps3_scatter_gather_element *sge_scmd = scsi_sglist(scp); + U32 page_size = cmd->instance->cmd_attr.nvme_page_size; + U32 nvme_page_size_mask = page_size - 1; + U32 sge_len = sg_dma_len(sge_scmd); + U64 sge_addr = sg_dma_address_u64(sge_scmd); + U32 first_prp_len = 0; + U16 prp_entry_count = 0; static unsigned long j; - if (is_need_clean_sgl) { - memset(&cmd->req_frame->hwReq.sgl, 0, - sizeof(cmd->req_frame->hwReq.sgl)); - } + if (is_need_clean_sgl) + memset(&cmd->req_frame->hwReq.sgl, 0, sizeof(cmd->req_frame->hwReq.sgl)); *prp_ptr = sge_addr; prp_entry_count++; first_prp_len = page_size - (sge_addr & nvme_page_size_mask); - LOG_DEBUG("hno:%u CFID:%u sge0_addr:0x%llx data_len:%u sge_len:%u\n" - "\tfirst_max_prp_len:%u\n", - PS3_HOST(cmd->instance), cmd->index, sge_addr, data_len, - sge_len, first_prp_len); + LOG_DEBUG("hno:%u CFID:%u sge0_addr:0x%llx data_len:%u sge_len:%u" + "first_max_prp_len:%u\n", PS3_HOST(cmd->instance), + cmd->index, sge_addr, data_len, sge_len, first_prp_len); - data_len = (data_len > first_prp_len) ? (data_len - first_prp_len) : 0; - if (data_len <= 0) + data_len = (data_len > first_prp_len)? (data_len - first_prp_len) : 0; + if (data_len <= 0) { goto l_out; + } if (sge_len > first_prp_len) { sge_addr += first_prp_len; - sge_len = (sge_len > first_prp_len) ? - (sge_len - first_prp_len) : - 0; + sge_len = (sge_len > first_prp_len) ? (sge_len - first_prp_len) : 0 ; } else { sge_scmd = sg_next(sge_scmd); sge_len = sg_dma_len(sge_scmd); @@ -2522,15 +2334,11 @@ static unsigned short ps3_scsih_prp_build(struct ps3_cmd *cmd, frame_prp_count--; for (;;) { - if (prp_entry_count > - cmd->instance->cmd_context.max_prp_count) { - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "tid:0x%llx hno:%u CFID:%u prp_entry_count:%u\n" - "\tmax_prp_count:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->index, prp_entry_count, - cmd->instance->cmd_context.max_prp_count); + if (prp_entry_count > cmd->instance->cmd_context.max_prp_count) { + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u CFID:%u prp_entry_count:%u " + "max_prp_count:%u\n", cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index, prp_entry_count, cmd->instance->cmd_context.max_prp_count); prp_entry_count = 0; goto l_out; } @@ -2538,7 +2346,7 @@ static unsigned short ps3_scsih_prp_build(struct ps3_cmd *cmd, if (frame_prp_count == 1) { if (data_len > page_size) { *prp_ptr = cmd->ext_buf_phys; - prp_ptr = (unsigned long long *)cmd->ext_buf; + prp_ptr = (U64*)cmd->ext_buf; prp_entry_count++; } frame_prp_count--; @@ -2549,24 +2357,22 @@ static unsigned short ps3_scsih_prp_build(struct ps3_cmd *cmd, sge_len = (sge_len > page_size) ? (sge_len - page_size) : 0; data_len = (data_len > page_size) ? (data_len - page_size) : 0; - if (frame_prp_count > 0) + if (frame_prp_count > 0) { frame_prp_count--; + } if (data_len <= 0) { - LOG_DEBUG( - "end hno:%u CFID:%u data_len:%u prp_entry:0x%llx\n" - "\tsge_addr:0x%llx sge_len:%u prp_entry_count:%u\n", - PS3_HOST(cmd->instance), cmd->index, data_len, - *prp_ptr, sge_addr, sge_len, prp_entry_count); + LOG_DEBUG("end hno:%u CFID:%u data_len:%u prp_entry:0x%llx " + "sge_addr:0x%llx sge_len:%u prp_entry_count:%u\n", + PS3_HOST(cmd->instance), cmd->index, data_len, *prp_ptr, + sge_addr, sge_len, prp_entry_count); break; } if (unlikely(cmd->instance->is_print_special_log)) { - LOG_DEBUG( - "end hno:%u CFID:%u data_len:%u prp_entry:0x%llx\n" - "\tsge_addr:0x%llx sge_len:%u\n", - PS3_HOST(cmd->instance), cmd->index, data_len, - *prp_ptr, sge_addr, sge_len); + LOG_DEBUG("end hno:%u CFID:%u data_len:%u prp_entry:0x%llx " + "sge_addr:0x%llx sge_len:%u\n", PS3_HOST(cmd->instance), + cmd->index, data_len, *prp_ptr, sge_addr, sge_len); } prp_ptr++; @@ -2584,23 +2390,20 @@ static unsigned short ps3_scsih_prp_build(struct ps3_cmd *cmd, return prp_entry_count; } -static void ps3_scsih_frontend_prp_build(struct ps3_cmd *cmd, - unsigned long long *prp_ptr, - unsigned int data_len, - unsigned short prp_count) +static void ps3_scsih_frontend_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, + U32 data_len, U16 prp_count) { struct scsi_cmnd *scp = cmd->scmd; - struct scatterlist *sge_scmd = scsi_sglist(scp); + ps3_scatter_gather_element *sge_scmd = scsi_sglist(scp); struct PS3Sge *sge_ptr = (struct PS3Sge *)prp_ptr; - unsigned int page_size = cmd->instance->cmd_attr.nvme_page_size; - unsigned int nvme_page_size_mask = page_size - 1; - unsigned int first_prp_len = 0; - unsigned int sge_len = sg_dma_len(sge_scmd); - unsigned long long sge_addr = sg_dma_address_u64(sge_scmd); + U32 page_size = cmd->instance->cmd_attr.nvme_page_size; + U32 nvme_page_size_mask = page_size - 1; + U32 first_prp_len = 0; + U32 sge_len = sg_dma_len(sge_scmd); + U64 sge_addr = sg_dma_address_u64(sge_scmd); - first_prp_len = page_size - - (sg_dma_address_u64(sge_scmd) & nvme_page_size_mask); - data_len = (data_len > first_prp_len) ? (data_len - first_prp_len) : 0; + first_prp_len = page_size - (sg_dma_address_u64(sge_scmd) & nvme_page_size_mask); + data_len = (data_len > first_prp_len)? (data_len - first_prp_len) : 0; sge_ptr->length = first_prp_len; sge_ptr->addr = sge_addr; @@ -2609,17 +2412,15 @@ static void ps3_scsih_frontend_prp_build(struct ps3_cmd *cmd, ps3_align_16bytes_check(sge_ptr->addr); LOG_DEBUG("hno:%u CFID:%u sge0_addr:0x%llx sge_len:%u\n", - PS3_HOST(cmd->instance), cmd->index, sge_ptr->addr, - sge_ptr->length); + PS3_HOST(cmd->instance), cmd->index, sge_ptr->addr, sge_ptr->length); - if (data_len <= 0) + if(data_len <= 0){ goto l_out; + } if (sge_len > first_prp_len) { sge_addr += first_prp_len; - sge_len = (sge_len > first_prp_len) ? - (sge_len - first_prp_len) : - 0; + sge_len = (sge_len > first_prp_len) ? (sge_len - first_prp_len) : 0 ; } else { sge_scmd = sg_next(sge_scmd); sge_len = sg_dma_len(sge_scmd); @@ -2636,64 +2437,52 @@ static void ps3_scsih_frontend_prp_build(struct ps3_cmd *cmd, ps3_align_16bytes_check(sge_ptr->addr); goto l_out; } else { - sge_ptr->length = (prp_count - PS3_FRAME_REQ_PRP_NUM_FE) * - sizeof(unsigned long long); + sge_ptr->length = (prp_count - PS3_FRAME_REQ_PRP_NUM_FE) * sizeof(U64); sge_ptr->addr = cmd->ext_buf_phys; sge_ptr->lastSge = 0; sge_ptr->ext = 1; sge_ptr = (struct PS3Sge *)prp_ptr; sge_ptr = sge_ptr + PS3_FRAME_REQ_SGE_NUM_FE - 1; - sge_ptr->length = (prp_count - PS3_FRAME_REQ_PRP_NUM_FE) * - sizeof(unsigned long long); + sge_ptr->length = (prp_count - PS3_FRAME_REQ_PRP_NUM_FE) * sizeof(U64); sge_ptr->addr = cmd->ext_buf_phys; sge_ptr->lastSge = 0; sge_ptr->ext = 1; } LOG_DEBUG("hno:%u CFID:%u sge1_addr:0x%llx sge_len:%u sge_ext:%d\n", - PS3_HOST(cmd->instance), cmd->index, sge_ptr->addr, - sge_ptr->length, sge_ptr->ext); + PS3_HOST(cmd->instance), cmd->index, sge_ptr->addr, sge_ptr->length, sge_ptr->ext); l_out: - return; + return ; } -static inline int ps3_scsih_prp_len_check(struct ps3_cmd *cmd, - unsigned int data_len) +static inline S32 ps3_scsih_prp_len_check(struct ps3_cmd *cmd, U32 data_len) { - int ret = PS3_SUCCESS; - unsigned int max_prp_count = cmd->instance->cmd_context.max_prp_count; - unsigned long long max_nvme_data_size = - (unsigned long long)(max_prp_count - - (unsigned int)PS3_FRAME_REQ_PRP_NUM_FE - - 1) * + S32 ret = PS3_SUCCESS; + U32 max_prp_count = cmd->instance->cmd_context.max_prp_count; + U64 max_nvme_data_size = (U64)(max_prp_count - (U32)PS3_FRAME_REQ_PRP_NUM_FE - 1) * cmd->instance->cmd_attr.nvme_page_size; static unsigned long j; - if (unlikely(max_nvme_data_size < data_len)) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "tid:0x%llx hno:%u io is too huge\n" - "\t[max_nvme_data_size:%llu][data_len:%d]\n", - cmd->trace_id, PS3_HOST(cmd->instance), - max_nvme_data_size, data_len); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u io is too huge " + "[max_nvme_data_size:%llu][data_len:%d]\n", + cmd->trace_id, PS3_HOST(cmd->instance), + max_nvme_data_size , data_len); ret = -PS3_FAILED; } return ret; } -static unsigned short -ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, - struct PS3FrontEndReqFrame *req) + +static U16 ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, + PS3FrontEndReqFrame_s *req) { - unsigned short sge_count = 0; - unsigned int data_len = 0; + U16 sge_count = 0; + U32 data_len = 0; static unsigned long j; - if (cmd->io_attr.is_use_frontend_prp) { if (cmd->os_sge_map_count == 0) { - LOG_WARN_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u CFID:%u os_sge_map_count==0\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->index); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); sge_count = 0; goto l_out; } @@ -2704,36 +2493,30 @@ ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, } if (ps3_prp_build_check(cmd, data_len)) { - sge_count = - ps3_scsih_prp_build(cmd, &req->prp.prp1, - PS3_FRAME_REQ_PRP_NUM_FE, - data_len, PS3_TRUE); + sge_count = ps3_scsih_prp_build(cmd, &req->prp.prp1, + PS3_FRAME_REQ_PRP_NUM_FE, data_len, PS3_TRUE); ps3_scsih_frontend_prp_build(cmd, &req->prp.prp1, - data_len, sge_count); + data_len, sge_count); } else { - LOG_WARN_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u CFID:%u nvme prp change to sgl\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->index); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); sge_count = 0; } } else { - sge_count = ps3_scsih_sgl_build(cmd, req->sgl, - PS3_FRAME_REQ_SGE_NUM_FE); + sge_count = ps3_scsih_sgl_build(cmd, req->sgl, PS3_FRAME_REQ_SGE_NUM_FE); } l_out: return sge_count; } -static int ps3_scsih_pd_frontend_req_build(struct ps3_cmd *cmd) +static S32 ps3_scsih_pd_frontend_req_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - struct PS3FrontEndReqFrame *req = &cmd->req_frame->frontendReq; + S32 ret = PS3_SUCCESS; + PS3FrontEndReqFrame_s *req = &cmd->req_frame->frontendReq; static unsigned long j; - ps3_scsih_req_frame_head_build(cmd, PS3_REQFRAME_FORMAT_FRONTEND); memset(&req->reserved, 0, sizeof(req->reserved)); @@ -2748,30 +2531,26 @@ static int ps3_scsih_pd_frontend_req_build(struct ps3_cmd *cmd) req->sgeCount = ps3_scsih_frontend_data_buf_build(cmd, req); if (req->sgeCount == 0 && cmd->os_sge_map_count != 0) { ret = -PS3_FAILED; - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u tid:0x%llx drv_sge_count:%u\n" - "\tos_sge_count:%u\n", - PS3_HOST(cmd->instance), - cmd->trace_id, req->sgeCount, - cmd->os_sge_map_count); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tid:0x%llx drv_sge_count:%u " + "os_sge_count:%u\n", PS3_HOST(cmd->instance), + cmd->trace_id, req->sgeCount, cmd->os_sge_map_count); goto l_out; } } memcpy(req->cdb, cmd->scmd->cmnd, cmd->scmd->cmd_len); - req->sgeOffset = offsetof(struct PS3FrontEndReqFrame, sgl) >> 2; + req->sgeOffset = offsetof(PS3FrontEndReqFrame_s, sgl) >> 2; req->dataXferLen = cmd->io_attr.sgl_buf_len; l_out: return ret; } -static unsigned short ps3_scsi_cmd_timeout_get(struct ps3_cmd *cmd) +static U16 ps3_scsi_cmd_timeout_get(struct ps3_cmd *cmd) { - unsigned int time_s = SCMD_GET_REQUEST(cmd->scmd)->timeout / HZ; - unsigned short timeout = 0; - + U32 time_s = SCMD_GET_REQUEST(cmd->scmd)->timeout / HZ; + U16 timeout = 0; if (time_s > 0xfffe) { timeout = 0; return timeout; @@ -2780,66 +2559,54 @@ static unsigned short ps3_scsi_cmd_timeout_get(struct ps3_cmd *cmd) return timeout; } -static void ps3_scsih_req_frame_head_build(struct ps3_cmd *cmd, - unsigned char req_frame_format) +static void ps3_scsih_req_frame_head_build(struct ps3_cmd *cmd, U8 req_frame_format) { - struct PS3ReqFrameHead *req_head = &cmd->req_frame->hwReq.reqHead; + PS3ReqFrameHead_s *req_head= &cmd->req_frame->hwReq.reqHead; static unsigned long j; - req_head->reqFrameFormat = req_frame_format; req_head->cmdSubType = 0; req_head->cmdFrameID = cmd->index; req_head->noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; - req_head->dataFormat = - cmd->io_attr.is_use_frontend_prp || - req_frame_format == PS3_REQFRAME_FORMAT_NVME ? - PS3_PRP : - PS3_SGL; + req_head->dataFormat = cmd->io_attr.is_use_frontend_prp || req_frame_format == PS3_REQFRAME_FORMAT_NVME ? \ + PS3_PRP : PS3_SGL; req_head->isWrite = ps3_scsih_data_direction_build(cmd); req_head->timeout = ps3_scsi_cmd_timeout_get(cmd); req_head->traceID = cmd->trace_id; if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { req_head->devID = cmd->io_attr.vd_entry->diskPos.diskDev; if (unlikely(req_head->devID.diskID == 0)) { - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u chl:%u id:%u dev id:0x%x NOK\n", - cmd->trace_id, PS3_HOST(cmd->instance), - PS3_SDEV_CHANNEL(cmd->scmd->device), - PS3_SDEV_TARGET(cmd->scmd->device), - req_head->devID.diskID); + cmd->trace_id, PS3_HOST(cmd->instance), PS3_SDEV_CHANNEL(cmd->scmd->device), + PS3_SDEV_TARGET(cmd->scmd->device), req_head->devID.diskID); } req_head->cmdType = ps3_scsih_is_rw_type(cmd->io_attr.rw_flag) ? - PS3_CMD_VD_SCSI_IO_RW : - PS3_CMD_VD_SCSI_IO_NORW; + PS3_CMD_VD_SCSI_IO_RW : PS3_CMD_VD_SCSI_IO_NORW; req_head->virtDiskSeq = cmd->io_attr.vd_entry->virtDiskSeq; - } else { - req_head->devID.diskID = - PS3_DISKID(&cmd->io_attr.pd_entry->disk_pos); + }else { + req_head->devID.diskID = PS3_DISKID(&cmd->io_attr.pd_entry->disk_pos); req_head->mapBlockVer = PS3_CMDWORD_VER_INVALID; req_head->cmdType = ps3_scsih_is_rw_type(cmd->io_attr.rw_flag) ? - PS3_CMD_PD_SCSI_IO_RW : - PS3_CMD_PD_SCSI_IO_NORW; + PS3_CMD_PD_SCSI_IO_RW : PS3_CMD_PD_SCSI_IO_NORW; } + return; } -static inline unsigned long long -ps3_scsih_direct_sgl_base_addr(const struct ps3_cmd *cmd, - unsigned short sge_count) +static inline U64 ps3_scsih_direct_sgl_base_addr(const struct ps3_cmd *cmd, + U16 sge_count) { - unsigned long long data_base = 0; + U64 data_base = 0; if (sge_count == PS3_SGL_MODE_SGE_COUNT_DIRECT) { data_base = cmd->req_frame->hwReq.sgl[0].addr; } else if ((sge_count > PS3_FRAME_REQ_SGE_NUM_HW) && - (!cmd->instance->cmd_context.sgl_mode_support)) { - data_base = cmd->ext_buf_phys; - ps3_align_16bytes_check(data_base); + (!cmd->instance->cmd_context.sgl_mode_support)) { + data_base = cmd->ext_buf_phys; + ps3_align_16bytes_check(data_base); } else { - data_base = cmd->req_frame_phys + - offsetof(struct PS3HwReqFrame, sgl); + data_base = cmd->req_frame_phys + offsetof(PS3HwReqFrame_s, sgl); ps3_align_16bytes_check(data_base); } @@ -2847,19 +2614,17 @@ ps3_scsih_direct_sgl_base_addr(const struct ps3_cmd *cmd, } static inline void ps3_scsih_sata_iodt_data_build(struct ps3_cmd *cmd, - unsigned int sge_count, - unsigned long long data_addr) + U32 sge_count, U64 data_addr) { - struct IODT_V1 *iodt = &cmd->req_frame->hwReq.sasReqFrame; + IODT_V1_s *iodt = &cmd->req_frame->hwReq.sasReqFrame; struct ps3_scsi_io_attr *cmd_io_attr = &cmd->io_attr; - unsigned short sector_size = cmd_io_attr->pd_entry->sector_size; + U16 sector_size = cmd_io_attr->pd_entry->sector_size; #ifndef _WINDOWS - unsigned int data_buf_len = cmd_io_attr->num_blocks - << ilog2(sector_size); + U32 data_buf_len = cmd_io_attr->num_blocks << ilog2(sector_size); #else - unsigned int data_buf_len = cmd_io_attr->num_blocks * sector_size; + U32 data_buf_len = cmd_io_attr->num_blocks * sector_size; #endif - switch (sge_count) { + switch(sge_count) { case PS3_SGL_MODE_SGE_COUNT_NO_DATA: iodt->dataBufLenDWAlign = 0; iodt->dataBaseAddr = 0; @@ -2867,30 +2632,27 @@ static inline void ps3_scsih_sata_iodt_data_build(struct ps3_cmd *cmd, break; case PS3_SGL_MODE_SGE_COUNT_DIRECT: iodt->dataBaseAddr = cpu_to_le64(data_addr); - iodt->dataBufLenDWAlign = - cpu_to_le32(ENCODE_CCS_XFERLEN(data_buf_len)); + iodt->dataBufLenDWAlign = cpu_to_le32(ENCODE_CCS_XFERLEN(data_buf_len)); iodt->dmaCfg.sgMode = IODT_SGEMODE_DIRECT; break; default: iodt->dataBaseAddr = cpu_to_le64(data_addr); - iodt->dataBufLenDWAlign = - cpu_to_le32(ENCODE_CCS_XFERLEN(data_buf_len)); + iodt->dataBufLenDWAlign = cpu_to_le32(ENCODE_CCS_XFERLEN(data_buf_len)); iodt->dmaCfg.sgMode = IODT_SGEMODE_SGL; break; } + return; } -static int ps3_scsih_sata_hw_req_frame_build(struct ps3_cmd *cmd, - unsigned short sge_count, - unsigned long long data_addr) +static S32 ps3_scsih_sata_hw_req_frame_build(struct ps3_cmd *cmd, U16 sge_count, U64 data_addr) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct ps3_scsi_io_attr *cmd_io_attr = &cmd->io_attr; - struct IODT_V1 *iodt = &cmd->req_frame->hwReq.sasReqFrame; - struct PS3ReqFrameHead *req_head = &cmd->req_frame->hwReq.reqHead; - unsigned char req_frame_format = PS3_REQFRAME_FORMAT_SATA; + IODT_V1_s *iodt = &cmd->req_frame->hwReq.sasReqFrame; + PS3ReqFrameHead_s *req_head = &cmd->req_frame->hwReq.reqHead; + U8 req_frame_format = PS3_REQFRAME_FORMAT_SATA; - memset(iodt, 0, sizeof(struct IODT_V1)); + memset(iodt, 0, sizeof(IODT_V1_s)); ps3_scsih_req_frame_head_build(cmd, req_frame_format); @@ -2921,25 +2683,23 @@ static int ps3_scsih_sata_hw_req_frame_build(struct ps3_cmd *cmd, return ret; } -static int ps3_scsih_sata_req_frame_build(struct ps3_cmd *cmd) +static S32 ps3_scsih_sata_req_frame_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - unsigned long long lba = 0; - unsigned long long data_addr = 0; - unsigned short sge_count = 0; + S32 ret = PS3_SUCCESS; + U64 lba = 0; + U64 data_addr = 0; + U16 sge_count = 0; if (ps3_is_need_build_hw_req_frame(cmd)) { sge_count = ps3_scsih_sgl_build(cmd, cmd->req_frame->hwReq.sgl, - PS3_FRAME_REQ_SGE_NUM_HW); + PS3_FRAME_REQ_SGE_NUM_HW); data_addr = ps3_scsih_direct_sgl_base_addr(cmd, sge_count); - ret = ps3_scsih_sata_hw_req_frame_build(cmd, sge_count, - data_addr); + ret = ps3_scsih_sata_hw_req_frame_build(cmd, sge_count, data_addr); if (likely(ret == PS3_SUCCESS)) { cmd->req_frame->hwReq.reqHead.traceID = cmd->trace_id; lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); - ret = ps3_software_zone_build( - cmd, lba, cmd->io_attr.pd_entry->dev_type, - sge_count); + ret = ps3_software_zone_build(cmd, lba, + cmd->io_attr.pd_entry->dev_type, sge_count); } } else { ret = ps3_scsih_pd_frontend_req_build(cmd); @@ -2949,12 +2709,10 @@ static int ps3_scsih_sata_req_frame_build(struct ps3_cmd *cmd) } static inline void ps3_scsih_sas_iodt_data_build(struct ps3_cmd *cmd, - unsigned long long data_addr, - unsigned int sge_count) + U64 data_addr, U32 sge_count) { - struct IODT_V1 *iodt = &cmd->req_frame->hwReq.sasReqFrame; - - switch (sge_count) { + IODT_V1_s *iodt = &cmd->req_frame->hwReq.sasReqFrame; + switch(sge_count) { case PS3_SGL_MODE_SGE_COUNT_NO_DATA: iodt->dataBufLenDWAlign = 0; iodt->dataBaseAddr = 0; @@ -2962,35 +2720,33 @@ static inline void ps3_scsih_sas_iodt_data_build(struct ps3_cmd *cmd, break; case PS3_SGL_MODE_SGE_COUNT_DIRECT: - iodt->dataBufLenDWAlign = cpu_to_le32( - ENCODE_CCS_XFERLEN(cmd->io_attr.sgl_buf_len)); + iodt->dataBufLenDWAlign = cpu_to_le32(ENCODE_CCS_XFERLEN(cmd->io_attr.sgl_buf_len)); iodt->dataBaseAddr = cpu_to_le64(data_addr); iodt->dmaCfg.sgMode = IODT_SGEMODE_DIRECT; break; default: - iodt->dataBufLenDWAlign = cpu_to_le32( - ENCODE_CCS_XFERLEN(cmd->io_attr.sgl_buf_len)); + iodt->dataBufLenDWAlign = cpu_to_le32(ENCODE_CCS_XFERLEN(cmd->io_attr.sgl_buf_len)); iodt->dataBaseAddr = cpu_to_le64(data_addr); iodt->dmaCfg.sgMode = IODT_SGEMODE_SGL; break; } + return; } -static int ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, - unsigned short disk_id, - unsigned long long data_addr, - unsigned int sge_count) +static S32 ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, U16 disk_id, + U64 data_addr, U32 sge_count) { - struct IODT_V1 *iodt = &cmd->req_frame->hwReq.sasReqFrame; - unsigned char *cdb = cmd->scmd->cmnd; - int ret = PS3_SUCCESS; - struct PS3ReqFrameHead *req_head = &cmd->req_frame->hwReq.reqHead; - unsigned char req_frame_format = PS3_REQFRAME_FORMAT_SAS; + IODT_V1_s *iodt = &cmd->req_frame->hwReq.sasReqFrame; + U8 *cdb = cmd->scmd->cmnd; + S32 ret = PS3_SUCCESS; + PS3ReqFrameHead_s *req_head = &cmd->req_frame->hwReq.reqHead; + U8 req_frame_format = PS3_REQFRAME_FORMAT_SAS; - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) + if(cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { cdb = cmd->io_attr.cdb; - memset(iodt, 0, sizeof(struct IODT_V1)); + } + memset(iodt, 0, sizeof(IODT_V1_s)); ps3_scsih_req_frame_head_build(cmd, req_frame_format); @@ -2998,10 +2754,11 @@ static int ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, iodt->frameType = FRAMETYPE_DIRECT; iodt->iuSrc = IU_SRC_IODT; - if (cmd->scmd->cmd_len != CMD_LEN_THR) + if(cmd->scmd->cmd_len != CMD_LEN_THR) { iodt->cmdLen = CMD_LEN_S; - else + } else { iodt->cmdLen = CMD_LEN_L; + } memcpy(iodt->B.cdb, cdb, CMD_LEN_THR); @@ -3009,12 +2766,13 @@ static int ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, iodt->sasCtl = 0; - if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_READ) + if(cmd->cmd_word.type == PS3_CMDWORD_TYPE_READ) { iodt->commonWord.type = PS3_CMDWORD_TYPE_READ; - else + } else { iodt->commonWord.type = PS3_CMDWORD_TYPE_WRITE; + } - iodt->commonWord.direct = DIRECT_FLAG_DIRECT; + iodt->commonWord.direct = DIRECT_FLAG_DIRECT; iodt->commonWord.function = ps3_get_pci_function(cmd->instance->pdev); iodt->commonWord.phyDiskID = disk_id; iodt->commonWord.reqFrameID = req_head->cmdFrameID; @@ -3023,27 +2781,24 @@ static int ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, return ret; } -static int ps3_scsih_sas_req_frame_build(struct ps3_cmd *cmd) +static S32 ps3_scsih_sas_req_frame_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - unsigned short sge_count = 0; - unsigned long long data_addr = 0; - unsigned long long lba = 0; + S32 ret = PS3_SUCCESS; + U16 sge_count = 0; + U64 data_addr = 0; + U64 lba = 0; if (ps3_is_need_build_hw_req_frame(cmd)) { - sge_count = ps3_scsih_sgl_build(cmd, cmd->req_frame->hwReq.sgl, - PS3_FRAME_REQ_SGE_NUM_HW); + sge_count = ps3_scsih_sgl_build(cmd, + cmd->req_frame->hwReq.sgl, PS3_FRAME_REQ_SGE_NUM_HW); data_addr = ps3_scsih_direct_sgl_base_addr(cmd, sge_count); - ret = ps3_scsih_sas_hw_req_frame_build( - cmd, PS3_PDID(&cmd->io_attr.pd_entry->disk_pos), + ret = ps3_scsih_sas_hw_req_frame_build(cmd, + PS3_PDID(&cmd->io_attr.pd_entry->disk_pos), data_addr, sge_count); if (likely(ret == PS3_SUCCESS)) { - lba = (unsigned long long)cmd->io_attr.lba_hi - << PS3_SHIFT_DWORD | - cmd->io_attr.lba_lo; - ret = ps3_software_zone_build( - cmd, lba, cmd->io_attr.pd_entry->dev_type, - sge_count); + lba = (U64)cmd->io_attr.lba_hi << PS3_SHIFT_DWORD | cmd->io_attr.lba_lo; + ret = ps3_software_zone_build(cmd, lba, + cmd->io_attr.pd_entry->dev_type, sge_count); } } else { ret = ps3_scsih_pd_frontend_req_build(cmd); @@ -3052,128 +2807,108 @@ static int ps3_scsih_sas_req_frame_build(struct ps3_cmd *cmd) } static void ps3_hw_nvme_req_frame_build(struct ps3_cmd *cmd, - struct PS3HwReqFrame *hw_reqframe) + PS3HwReqFrame_s *hw_reqframe) { - struct PS3NvmeRWCmd *rwReqFrame = &hw_reqframe->nvmeReqFrame.rwReqFrame; - + PS3NvmeRWCmd_s *rwReqFrame = &hw_reqframe->nvmeReqFrame.rwReqFrame; rwReqFrame->numLba = cpu_to_le32(cmd->io_attr.num_blocks - 1); - rwReqFrame->numLba |= - (unsigned int)((unsigned int)cmd->io_attr.cdb_opts.fua << 30); + rwReqFrame->numLba |= (U32)((U32)cmd->io_attr.cdb_opts.fua << 30); - rwReqFrame->sLbaHi = cpu_to_le32( - (unsigned int)(cmd->io_attr.plba >> PS3_SHIFT_DWORD)); - rwReqFrame->sLbaLo = cpu_to_le32((unsigned int)(cmd->io_attr.plba)); + rwReqFrame->sLbaHi = cpu_to_le32((U32)(cmd->io_attr.plba >> PS3_SHIFT_DWORD)); + rwReqFrame->sLbaLo = cpu_to_le32((U32)(cmd->io_attr.plba)); rwReqFrame->cDW0_9.cID = cpu_to_le16(cmd->index); rwReqFrame->cDW0_9.psdt = 0; rwReqFrame->cDW0_9.nsID = 1; - if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_READ) + if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_READ) { rwReqFrame->cDW0_9.opcode = 0x02; - else if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) + } else if(cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) { rwReqFrame->cDW0_9.opcode = 0x01; + } else { + } - LOG_DEBUG("hno:%u cid:%d, op:%d, nsid:%d, prp1:0x%llx,\n" - "\tprp2:0x%llx, numLb:%d, LbaHi:0x%x, LbaLo:0x%x, dw13:0x%x,\n" - "\tdw13:0x%x, dw13:0x%x\n", - PS3_HOST(cmd->instance), rwReqFrame->cDW0_9.cID, - rwReqFrame->cDW0_9.opcode, rwReqFrame->cDW0_9.nsID, - rwReqFrame->cDW0_9.dPtr.prp.prp1, - rwReqFrame->cDW0_9.dPtr.prp.prp2, rwReqFrame->numLba, - rwReqFrame->sLbaHi, rwReqFrame->sLbaLo, rwReqFrame->cDW13, - rwReqFrame->cDW14, rwReqFrame->cDW15); + LOG_DEBUG("hno:%u cid:%d, op:%d, nsid:%d, prp1:0x%llx, " + "prp2:0x%llx, numLb:%d, LbaHi:0x%x, LbaLo:0x%x, dw13:0x%x, " + "dw13:0x%x, dw13:0x%x\n", + PS3_HOST(cmd->instance), rwReqFrame->cDW0_9.cID, + rwReqFrame->cDW0_9.opcode, rwReqFrame->cDW0_9.nsID, + rwReqFrame->cDW0_9.dPtr.prp.prp1, + rwReqFrame->cDW0_9.dPtr.prp.prp2, + rwReqFrame->numLba, rwReqFrame->sLbaHi, rwReqFrame->sLbaLo, + rwReqFrame->cDW13, rwReqFrame->cDW14, rwReqFrame->cDW15); + return ; } -static void ps3_hw_nvme_ext_fill(struct ps3_cmd *cmd, unsigned short prp_count) +static void ps3_hw_nvme_ext_fill(struct ps3_cmd *cmd, U16 prp_count) { if (prp_count > PS3_FRAME_REQ_PRP_NUM_HW) { cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].length = - (prp_count - PS3_FRAME_REQ_PRP_NUM_HW) * - sizeof(unsigned long long); + (prp_count - PS3_FRAME_REQ_PRP_NUM_HW) * sizeof(U64); cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].addr = cmd->ext_buf_phys; - cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].lastSge = - 0; + cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].lastSge = 0; cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].ext = 1; } else { - if (cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1] - .ext != 0) { - cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1] - .ext = 0; - } + if (cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].ext != 0) + cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].ext = 0; } } -static int ps3_scsih_nvme_hw_req_frame_build(struct ps3_cmd *cmd) +static S32 ps3_scsih_nvme_hw_req_frame_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - unsigned long long *prp_ptr = NULL; - struct PS3HwReqFrame *hw_reqframe = NULL; - unsigned char pd_dev_type = PS3_DEV_TYPE_COUNT; - unsigned long long lba = 0; - unsigned short prp_count = 0; - unsigned int data_len = - ps3_scsih_data_buf_len(cmd, cmd->os_sge_map_count); + S32 ret = PS3_SUCCESS; + U64 * prp_ptr = NULL; + PS3HwReqFrame_s *hw_reqframe = NULL; + U8 pd_dev_type = PS3_DEV_TYPE_COUNT; + U64 lba = 0; + U16 prp_count = 0; + U32 data_len = ps3_scsih_data_buf_len(cmd, cmd->os_sge_map_count); static unsigned long j; - hw_reqframe = &cmd->req_frame->hwReq; - memset(&hw_reqframe->nvmeReqFrame, 0, sizeof(union PS3NvmeReqFrame)); + memset(&hw_reqframe->nvmeReqFrame, 0, sizeof(PS3NvmeReqFrame_u)); prp_ptr = &hw_reqframe->nvmeReqFrame.rwReqFrame.cDW0_9.dPtr.prp.prp1; ps3_scsih_req_frame_head_build(cmd, PS3_REQFRAME_FORMAT_NVME); - if (cmd->io_attr.pd_entry != NULL) + if (cmd->io_attr.pd_entry != NULL) { pd_dev_type = cmd->io_attr.pd_entry->dev_type; + } if (ps3_prp_build_check(cmd, data_len)) { - prp_count = ps3_scsih_prp_build(cmd, prp_ptr, - PS3_FRAME_REQ_PRP_NUM_HW, - data_len, PS3_FALSE); + prp_count = ps3_scsih_prp_build(cmd, prp_ptr, PS3_FRAME_REQ_PRP_NUM_HW, data_len, PS3_FALSE); ps3_hw_nvme_ext_fill(cmd, prp_count); ps3_hw_nvme_req_frame_build(cmd, hw_reqframe); cmd->req_frame->hwReq.reqHead.traceID = cmd->trace_id; - lba = (unsigned long long)cmd->io_attr.lba_hi - << PS3_SHIFT_DWORD | - cmd->io_attr.lba_lo; + lba = (U64)cmd->io_attr.lba_hi << PS3_SHIFT_DWORD | cmd->io_attr.lba_lo; ret = ps3_software_zone_build(cmd, lba, pd_dev_type, prp_count); } else { - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "tid:0x%llx hno:%u this io don't support prp!\n", + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u this io don't support prp!\n", cmd->trace_id, PS3_HOST(cmd->instance)); ret = -PS3_FAILED; } return ret; } -static int ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd) +static S32 ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; static unsigned long j; - if (ps3_is_need_build_hw_req_frame(cmd)) { ret = ps3_scsih_nvme_hw_req_frame_build(cmd); if (ret != PS3_SUCCESS) { - LOG_WARN_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "tid:0x%llx hno:%u direct NVMe NOK, to normal\n" - "\tis_use_frontend_prp:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->io_attr.is_use_frontend_prp); + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u direct NVMe NOK, to normal " + "is_use_frontend_prp:%d\n", cmd->trace_id, + PS3_HOST(cmd->instance), cmd->io_attr.is_use_frontend_prp); cmd->io_attr.direct_flag = PS3_CMDWORD_DIRECT_NORMAL; cmd->io_attr.is_use_frontend_prp = PS3_FALSE; - memset((void *)&cmd->cmd_word, 0, - sizeof(struct PS3CmdWord)); - memset((void *)cmd->req_frame, 0, - sizeof(union PS3ReqFrame)); - memset(cmd->ext_buf, 0, - cmd->instance->cmd_context.ext_buf_size); + memset((void *) &cmd->cmd_word, 0, sizeof(struct PS3CmdWord)); + memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); + memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); ret = ps3_scsih_pd_cmd_word_build(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->index, ret); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); ret = -PS3_FAILED; goto l_out; } @@ -3187,8 +2922,7 @@ static int ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd) return ret; } -static inline void ps3_scsih_cmd_back_stat(struct ps3_cmd *cmd, - unsigned char reply_flags) +static inline void ps3_scsih_cmd_back_stat(struct ps3_cmd *cmd, U8 reply_flags) { PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd, reply_flags); PS3_DEV_IO_OUTSTAND_DEC(cmd->instance, cmd); @@ -3203,81 +2937,72 @@ static inline void ps3_scsih_cmd_back_stat(struct ps3_cmd *cmd, static inline void ps3_scsih_overrun_underrun_verify(struct ps3_cmd *cmd) { - if ((ps3_scsih_is_sas_jbod_cmd(cmd)) || - (ps3_scsih_is_sata_jbod_cmd(cmd) && - ps3_scsih_cdb_is_rw_cmd(cmd->scmd->cmnd))) { + if ((ps3_scsih_is_sas_jbod_cmd(cmd)) + || (ps3_scsih_is_sata_jbod_cmd(cmd) + && ps3_scsih_cdb_is_rw_cmd(cmd->scmd->cmnd))) { if (cmd->io_attr.sgl_buf_len > scsi_bufflen(cmd->scmd)) { scsi_set_resid(cmd->scmd, 0); - cmd->scmd->result = - PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR); - LOG_DEBUG( - "cmd overrun, CFID:%u op:0x%x data_len:%u scsi_buf_len:%u\n", - cmd->index, cmd->scmd->cmnd[0], - cmd->io_attr.sgl_buf_len, - scsi_bufflen(cmd->scmd)); + cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR); + LOG_DEBUG("cmd overrun, CFID:%u op:0x%x data_len:%u scsi_buf_len:%u\n", + cmd->index, cmd->scmd->cmnd[0], cmd->io_attr.sgl_buf_len, scsi_bufflen(cmd->scmd)); } } + return; } -static inline void ps3_r1x_read_dec(struct ps3_cmd *cmd, - struct ps3_r1x_read_balance_info *rb_info) +static inline void ps3_r1x_read_dec(struct ps3_cmd *cmd, struct ps3_r1x_read_balance_info *rb_info) { if (rb_info != NULL && cmd->r1x_read_pd > 0) { if (cmd->r1x_read_pd > PS3_MAX_PD_NUM_ONE_VD) { PS3_BUG(); return; } - ps3_atomic_dec( - &rb_info->scsi_outstanding_cmds[cmd->r1x_read_pd]); + ps3_atomic_dec(&rb_info->scsi_outstanding_cmds[cmd->r1x_read_pd]); } } -int ps3_scsih_io_done(struct ps3_cmd *cmd, unsigned short reply_flags) +S32 ps3_scsih_io_done(struct ps3_cmd *cmd, U16 reply_flags) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; struct scsi_cmnd *s_cmd = cmd->scmd; struct ps3_scsi_priv_data *data = NULL; struct ps3_cmd *err_cmd = cmd; struct ps3_cmd *peer_cmd = NULL; if (unlikely(s_cmd == NULL)) { - LOG_ERROR_IN_IRQ(cmd->instance, "hno:%u CFID:%d scmd is null\n", - PS3_HOST(cmd->instance), cmd->index); + LOG_ERROR_IN_IRQ(cmd->instance, + "hno:%u CFID:%d scmd is null\n", + PS3_HOST(cmd->instance), cmd->index); goto l_out; } if (cmd->r1x_peer_cmd != NULL) { - LOG_DEBUG( - "hno:%u CFID:%d one of the r1x write scmd is return, rflag:%d\n", + LOG_DEBUG("hno:%u CFID:%d one of the r1x write scmd is return, rflag:%d\n", PS3_HOST(cmd->instance), cmd->index, reply_flags); cmd->r1x_reply_flag = reply_flags; cmd->is_r1x_scsi_complete = PS3_TRUE; if (!cmd->r1x_peer_cmd->is_r1x_scsi_complete) { - PS3_IOC_DRV2IOC_BACK_INC( - cmd->instance, cmd->r1x_peer_cmd, reply_flags); - LOG_DEBUG( - "hno:%u CFID:%d r1x write peer cmd:%d is not return\n", + PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd->r1x_peer_cmd, reply_flags); + LOG_DEBUG("hno:%u CFID:%d r1x write peer cmd:%d is not return\n", PS3_HOST(cmd->instance), cmd->index, cmd->r1x_peer_cmd->index); goto l_out; } - if (cmd->r1x_peer_cmd->r1x_reply_flag != - PS3_REPLY_WORD_FLAG_SUCCESS) { + if (cmd->r1x_peer_cmd->r1x_reply_flag != PS3_REPLY_WORD_FLAG_SUCCESS) { err_cmd = cmd->r1x_peer_cmd; reply_flags = cmd->r1x_peer_cmd->r1x_reply_flag; } - if (cmd->index >= - (unsigned int)cmd->instance->cmd_attr.cur_can_que) + if (cmd->index >= (U32)cmd->instance->cmd_attr.cur_can_que) { cmd = cmd->r1x_peer_cmd; + } } data = scsi_device_private_data(s_cmd); - LOG_DEBUG( - "tid:0x%llx hno:%u scsi cmd reply cb CFID:%u rep_f:%u\n" - "\top:0x%x chl:%u id:%u data_len:%u scsi_buflen:%u dev_type:%s\n", + LOG_DEBUG("tid:0x%llx hno:%u scsi cmd reply cb CFID:%u rep_f:%u" + " op:0x%x chl:%u id:%u data_len:%u scsi_buflen:%u dev_type:%s\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, reply_flags, s_cmd->cmnd[0], PS3_SDEV_CHANNEL(cmd->scmd->device), PS3_SDEV_TARGET(cmd->scmd->device), cmd->io_attr.sgl_buf_len, @@ -3293,14 +3018,13 @@ int ps3_scsih_io_done(struct ps3_cmd *cmd, unsigned short reply_flags) } else { ps3_scsih_overrun_underrun_verify(cmd); if (cmd->scmd->result == DID_OK) { - ps3_qos_adjust_pd_rsc(s_cmd->device, cmd->instance, - PS3_QOS_QUOTA_ADJUST_UP); + ps3_qos_adjust_pd_rsc(s_cmd->device, cmd->instance, PS3_QOS_QUOTA_ADJUST_UP); } } ps3_r1x_read_dec(cmd, data->r1x_rb_info); -#if defined(PS3_SUPPORT_CMD_SCP) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) s_cmd->SCp.ptr = NULL; #endif ps3_scsi_dma_unmap(cmd); @@ -3309,14 +3033,14 @@ int ps3_scsih_io_done(struct ps3_cmd *cmd, unsigned short reply_flags) ps3_r1x_write_unlock(&data->lock_mgr, cmd); peer_cmd = cmd->r1x_peer_cmd; + INJECT_START(PS3_ERR_IJ_WAIT_ABORT_FLAG, peer_cmd); PS3_IO_OUTSTAND_DEC(cmd->instance, s_cmd); PS3_VD_OUTSTAND_DEC(cmd->instance, s_cmd); ps3_scsi_cmd_free(cmd); if (peer_cmd != NULL) { - LOG_DEBUG( - "host_no:%u r1x scsi write done CFID:%d and CFID:%d\n", - PS3_HOST(peer_cmd->instance), - peer_cmd->r1x_peer_cmd->index, peer_cmd->index); + LOG_DEBUG("host_no:%u r1x scsi write done CFID:%d and CFID:%d\n", + PS3_HOST(peer_cmd->instance), peer_cmd->r1x_peer_cmd->index, + peer_cmd->index); ps3_r1x_peer_cmd_free_nolock(peer_cmd); } SCMD_IO_DONE(s_cmd); @@ -3325,27 +3049,28 @@ int ps3_scsih_io_done(struct ps3_cmd *cmd, unsigned short reply_flags) return ret; } -void ps3_scsih_direct_to_normal_req_frame_rebuild(struct ps3_cmd *cmd) +void ps3_scsih_direct_to_normal_req_frame_rebuild( + struct ps3_cmd *cmd) { ps3_vd_adv_to_normal_req_frame_rebuild(cmd); } #ifdef _WINDOWS -static unsigned char ps3_scsi_sge_remap_check(struct ps3_cmd *cmd, - struct scatterlist *os_sgl, - int index) +static Bool ps3_scsi_sge_remap_check(struct ps3_cmd *cmd, + ps3_scatter_gather_element *os_sgl, S32 index) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; struct scsi_cmnd *scp = cmd->scmd; - unsigned short os_sge_count = - (unsigned short)scp->scatterlist->NumberOfElements; + U16 os_sge_count = (U16)scp->scatterlist->NumberOfElements; - if (index != 0 && index != os_sge_count - 1) + if (index != 0 && index != os_sge_count-1) { goto l_check; + } - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - if (cmd->io_attr.vd_entry->isNvme) + if ( cmd->io_attr.dev_type == PS3_DEV_TYPE_VD ) { + if (cmd->io_attr.vd_entry->isNvme) { goto l_nvme_check; + } } else if (cmd->io_attr.dev_type == PS3_DEV_TYPE_NVME_SSD) { goto l_nvme_check; } else { @@ -3354,21 +3079,20 @@ static unsigned char ps3_scsi_sge_remap_check(struct ps3_cmd *cmd, goto l_check; l_nvme_check: if (index == 0) { - if (os_sgl->PhysicalAddress.QuadPart & - PS3_SCSI_ALINNMENT_MASK) { + if (os_sgl->PhysicalAddress.QuadPart & PS3_SCSI_ALINNMENT_MASK) { ret = PS3_TRUE; } } else { if (os_sgl->PhysicalAddress.QuadPart & - scp->dma_addr_alignment_mask) { + scp->dma_addr_alignment_mask) { ret = PS3_TRUE; } } goto l_out; l_check: - if ((os_sgl->PhysicalAddress.QuadPart & scp->dma_addr_alignment_mask) || - (os_sgl->Length & scp->dma_len_alignment_mask)) { + if ((os_sgl->PhysicalAddress.QuadPart & scp->dma_addr_alignment_mask) + || (os_sgl->Length & scp->dma_len_alignment_mask)) { ret = PS3_TRUE; } l_out: @@ -3377,18 +3101,16 @@ static unsigned char ps3_scsi_sge_remap_check(struct ps3_cmd *cmd, static void ps3_scsi_dma_algin_calc(struct ps3_cmd *cmd) { - unsigned int dma_addr_alignment = 0; - unsigned int dma_len_alignment = 0; + U32 dma_addr_alignment = 0; + U32 dma_len_alignment = 0; struct scsi_cmnd *scp = cmd->scmd; if ((cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) && - (ps3_scsih_is_use_hard_cmd(cmd) != PS3_CMDWORD_FORMAT_HARDWARE)) { + (ps3_scsih_is_use_hard_cmd(cmd) != PS3_CMDWORD_FORMAT_HARDWARE)) { dma_addr_alignment = cmd->io_attr.vd_entry->dmaAddrAlignShift; dma_len_alignment = cmd->io_attr.vd_entry->dmaLenAlignShift; - dma_addr_alignment = - dma_addr_alignment ? 1 << dma_addr_alignment : 0; - dma_len_alignment = - dma_len_alignment ? 1 << dma_len_alignment : 0; + dma_addr_alignment = dma_addr_alignment ? 1 << dma_addr_alignment : 0; + dma_len_alignment = dma_len_alignment ? 1 << dma_len_alignment : 0; } else { dma_addr_alignment = cmd->io_attr.pd_entry->dma_addr_alignment; dma_len_alignment = cmd->io_attr.pd_entry->dma_len_alignment; @@ -3396,49 +3118,53 @@ static void ps3_scsi_dma_algin_calc(struct ps3_cmd *cmd) scp->dma_addr_alignment_mask = PS3_SCSI_ALINNMENT_MASK; scp->dma_len_alignment_mask = 0; - if (dma_addr_alignment) + if (dma_addr_alignment) { scp->dma_addr_alignment_mask = dma_addr_alignment - 1; + } - if (dma_len_alignment) + if(dma_len_alignment){ scp->dma_len_alignment_mask = dma_len_alignment - 1; + } - if (((cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) && - (cmd->io_attr.vd_entry->isNvme)) || - (cmd->io_attr.dev_type == PS3_DEV_TYPE_NVME_SSD)) { + if (( (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) && + (cmd->io_attr.vd_entry->isNvme)) || + (cmd->io_attr.dev_type == PS3_DEV_TYPE_NVME_SSD) ) { scp->dma_addr_alignment_mask = PS3_SCSI_4K_ALINNMENT_MASK; scp->dma_len_alignment_mask = PS3_SCSI_4K_ALINNMENT_MASK; } - LOG_DEBUG( - "tid:0x%llx hno:%u align[addr:%d,len:%d][addr_mask:%x,len_mask:%x]\n", - cmd->trace_id, PS3_HOST(cmd->instance), dma_addr_alignment, - dma_len_alignment, scp->dma_addr_alignment_mask, + LOG_DEBUG("tid:0x%llx hno:%u align[addr:%d,len:%d][addr_mask:%x,len_mask:%x]\n", + cmd->trace_id, PS3_HOST(cmd->instance), + dma_addr_alignment, + dma_len_alignment, + scp->dma_addr_alignment_mask, scp->dma_len_alignment_mask); } static void ps3_scsi_need_remap_check(struct ps3_cmd *cmd) { - int index = 0; - unsigned short os_sge_count = 0; + S32 index = 0; + U16 os_sge_count = 0; struct scsi_cmnd *scp = cmd->scmd; - struct scatterlist *os_sgl = NULL; - + ps3_scatter_gather_element *os_sgl = NULL; scp->is_remap_databuff = PS3_FALSE; - if (scp->scatterlist == NULL) + if (scp->scatterlist == NULL) { goto l_out; + } if (!ps3_scsih_cdb_is_rw_cmd(scp->cmnd) && - (cmd->io_attr.dev_type == PS3_DEV_TYPE_NVME_SSD)) { + (cmd->io_attr.dev_type == PS3_DEV_TYPE_NVME_SSD)) { goto l_out; } ps3_scsi_dma_algin_calc(cmd); - os_sge_count = (unsigned short)scp->scatterlist->NumberOfElements; + os_sge_count = (U16)scp->scatterlist->NumberOfElements; scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { - if (os_sgl == NULL) + if (os_sgl == NULL) { break; + } if (ps3_scsi_sge_remap_check(cmd, os_sgl, index)) { scp->is_remap_databuff = PS3_TRUE; @@ -3446,79 +3172,88 @@ static void ps3_scsi_need_remap_check(struct ps3_cmd *cmd) } } l_out: - if (scp->is_remap_databuff) { - LOG_DEBUG( - "tid:0x%llx hno:%u unalign[addr_mask:%x,len_mask:%x]\n" - "\tsgl addr:0x%llx len:%d or SAS sge num:%d > %d, index:%d\n", + if(scp->is_remap_databuff) { + LOG_DEBUG("tid:0x%llx hno:%u unalign[addr_mask:%x,len_mask:%x] " + "sgl addr:0x%llx len:%d or SAS sge num:%d > %d, index:%d\n", cmd->trace_id, PS3_HOST(cmd->instance), scp->dma_addr_alignment_mask, scp->dma_len_alignment_mask, - os_sgl->PhysicalAddress.QuadPart, os_sgl->Length, + os_sgl->PhysicalAddress.QuadPart, + os_sgl->Length, scp->scatterlist->NumberOfElements, - PS3_FRAME_REQ_SGE_NUM_HW, index); + PS3_FRAME_REQ_SGE_NUM_HW, + index); } + return; } -static int ps3_scsi_remap_sgl(struct ps3_cmd *cmd) +static S32 ps3_scsi_remap_sgl(struct ps3_cmd *cmd) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct scsi_cmnd *scp = cmd->scmd; void *srb_data_buff = SrbGetDataBuffer(cmd->srb); - if (srb_data_buff == NULL) + if (srb_data_buff == NULL) { goto l_out; + } scp->remap_databuff_length = scp->data_transfer_length; if (scp->data_transfer_length & scp->dma_len_alignment_mask) { scp->remap_databuff_length = - (scp->data_transfer_length + - scp->dma_len_alignment_mask + 1) & - (~(unsigned long long)scp->dma_len_alignment_mask); + (scp->data_transfer_length + scp->dma_len_alignment_mask + 1) & + (~(U64)scp->dma_len_alignment_mask); } - scp->remap_databuff = ps3_dma_alloc_coherent( - cmd->instance, scp->remap_databuff_length, - (unsigned long long *)&scp->remap_databuff_phy); - if (scp->remap_databuff == NULL) + scp->remap_databuff = ps3_dma_alloc_coherent(cmd->instance, + scp->remap_databuff_length, + &scp->remap_databuff_phy); + if (scp->remap_databuff == NULL) { goto l_out; + } cmd->os_sge_map_count = 1; memset(&scp->remap_sgl, 0, sizeof(scp->remap_sgl)); - scp->scatterlist = (STOR_SCATTER_GATHER_LIST *)&scp->remap_sgl; + scp->scatterlist = (STOR_SCATTER_GATHER_LIST*)&scp->remap_sgl; scp->scatterlist->NumberOfElements = 1; scp->scatterlist->List[0].Length = scp->remap_databuff_length; - scp->scatterlist->List[0].PhysicalAddress.QuadPart = - (LONGLONG)scp->remap_databuff_phy; - RtlMoveMemory(scp->remap_databuff, srb_data_buff, - scp->data_transfer_length); + scp->scatterlist->List[0].PhysicalAddress.QuadPart = (LONGLONG)scp->remap_databuff_phy; + RtlMoveMemory(scp->remap_databuff, + srb_data_buff, + scp->data_transfer_length); LOG_DEBUG("remap io,%p, data_len:%d, remap_len:%d, addr:0x%llx\n", - srb_data_buff, scp->data_transfer_length, - scp->remap_databuff_length, scp->remap_databuff_phy); + srb_data_buff, + scp->data_transfer_length, + scp->remap_databuff_length, + scp->remap_databuff_phy); ret = PS3_SUCCESS; l_out: return ret; } -static int ps3_scsi_unremap_sgl(struct ps3_cmd *cmd) +static S32 ps3_scsi_unremap_sgl(struct ps3_cmd *cmd) { - int ret = -PS3_FAILED; + S32 ret = -PS3_FAILED; struct scsi_cmnd *scp = cmd->scmd; void *srb_data_buff = SrbGetDataBuffer(cmd->srb); - if (srb_data_buff == NULL) + if (srb_data_buff == NULL) { goto l_out; + } if (scp->remap_databuff != NULL) { - RtlMoveMemory(srb_data_buff, scp->remap_databuff, - scp->data_transfer_length); - - LOG_DEBUG("unremap io,%p, len:%d\n", srb_data_buff, - scp->data_transfer_length); - - ps3_dma_free_coherent(cmd->instance, scp->remap_databuff_length, - scp->remap_databuff, - scp->remap_databuff_phy); + RtlMoveMemory(srb_data_buff, + scp->remap_databuff, + scp->data_transfer_length); + + LOG_DEBUG("unremap io,%p, len:%d \n", + srb_data_buff, + scp->data_transfer_length); + + ps3_dma_free_coherent(cmd->instance, + scp->remap_databuff_length, + scp->remap_databuff, + scp->remap_databuff_phy ); scp->remap_databuff = NULL; scp->is_remap_databuff = PS3_FALSE; cmd->os_sge_map_count = 0; @@ -3530,12 +3265,12 @@ static int ps3_scsi_unremap_sgl(struct ps3_cmd *cmd) } #endif -int ps3_scsi_dma_map(struct ps3_cmd *cmd) +S32 ps3_scsi_dma_map(struct ps3_cmd *cmd) { - int index = 0; - int os_sge_count = 0; + S32 index = 0; + S32 os_sge_count = 0; struct scsi_cmnd *scp = cmd->scmd; - struct scatterlist *os_sgl = NULL; + ps3_scatter_gather_element *os_sgl = NULL; os_sge_count = scsi_dma_map(scp); if (unlikely(os_sge_count <= 0)) { @@ -3544,25 +3279,22 @@ int ps3_scsi_dma_map(struct ps3_cmd *cmd) } scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { - if (os_sgl == NULL) + if (os_sgl == NULL) { break; - if (index == 0 && cmd->instance->page_mode_change && - (sg_dma_address_u64(os_sgl) & - cmd->instance->page_mode_addr_mask)) { - cmd->instance->page_mode_addr_mask = - PS3_PAGE_MODE_ABOVE_4_ADDR_MASK; - if (sg_dma_address_u64(os_sgl) & - PS3_PAGE_MODE_ABOVE_4_ADDR_MASK) { + } + INJECT_START(PS3_ERR_IJ_SGL_ADDR_PAGE_MODE_5, &(sg_dma_address_u64(os_sgl))); + if (index == 0 && cmd->instance->page_mode_change + && (sg_dma_address_u64(os_sgl) & cmd->instance->page_mode_addr_mask)) { + cmd->instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_4_ADDR_MASK; + if (sg_dma_address_u64(os_sgl) & PS3_PAGE_MODE_ABOVE_4_ADDR_MASK) cmd->instance->page_mode_change = PS3_FALSE; - } - dev_info( - &cmd->instance->pdev->dev, + dev_info(&cmd->instance->pdev->dev, "page mode change, addr:0x%llx\n", - (unsigned long long)sg_dma_address_u64(os_sgl)); + sg_dma_address_u64(os_sgl)); } - sg_dma_address(os_sgl) = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - cmd->instance->dma_addr_bit_pos, - sg_dma_address_u64(os_sgl)); + INJECT_START(PS3_ERR_IJ_SGL_ADDR_RESTORE, &(sg_dma_address_u64(os_sgl))); + sg_dma_address(os_sgl) = + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(cmd->instance->dma_addr_bit_pos, sg_dma_address_u64(os_sgl)); } cmd->os_sge_map_count = os_sge_count; @@ -3572,80 +3304,77 @@ int ps3_scsi_dma_map(struct ps3_cmd *cmd) void ps3_scsi_dma_unmap(struct ps3_cmd *cmd) { - int index = 0; - unsigned short os_sge_count = 0; + S32 index = 0; + U16 os_sge_count = 0; struct scsi_cmnd *scp = NULL; - struct scatterlist *os_sgl = NULL; + ps3_scatter_gather_element *os_sgl = NULL; - if (cmd == NULL) + if (cmd == NULL) { goto l_out; + } os_sge_count = cmd->os_sge_map_count; scp = cmd->scmd; - if (os_sge_count == 0) + if (os_sge_count == 0) { goto l_out; + } scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { - if (os_sgl == NULL) + if (os_sgl == NULL) { break; - sg_dma_address(os_sgl) = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( - cmd->instance->dma_addr_bit_pos, + } + sg_dma_address(os_sgl) = + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(cmd->instance->dma_addr_bit_pos, sg_dma_address_u64(os_sgl)); } - if (scp->sdb.table.sgl) + if (scp->sdb.table.sgl) { scsi_dma_unmap(scp); + } cmd->os_sge_map_count = 0; l_out: return; } -static int ps3_vd_access_policy_check(struct ps3_instance *instance, - unsigned char channel, unsigned short id, - struct scsi_cmnd *s_cmd) +static S32 ps3_vd_access_policy_check(struct ps3_instance *instance, + U8 channel, U16 id, struct scsi_cmnd *s_cmd) { - int ret = PS3_SUCCESS; - unsigned char opcode = 0; - unsigned short sub_opcode = 0; - struct PS3VDEntry *entry = - ps3_dev_mgr_lookup_vd_info(instance, channel, id); + S32 ret = PS3_SUCCESS; + U8 opcode = 0; + U16 sub_opcode = 0; + struct PS3VDEntry *entry = ps3_dev_mgr_lookup_vd_info(instance, channel, id); static unsigned long j; - if (unlikely(entry == NULL)) { #ifndef _WINDOWS s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_BAD_TARGET); #else scsi_cmnd_hoststatus_set(s_cmd, DID_BAD_TARGET); #endif - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "hno:%u chl:%u id:%u\n", PS3_HOST(instance), - channel, id); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u chl:%u id:%u\n", + PS3_HOST(instance), channel, id); ret = -PS3_ENODEV; goto l_out; } if (unlikely((entry->accessPolicy == VD_ACCESS_POLICY_BLOCK) && - ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd))) { - ps3_errcode_to_scsi_status(instance, s_cmd, - PS3_STATUS_ACCESS_BLOCK, NULL, 0, - NULL); + ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd))) { + ps3_errcode_to_scsi_status(instance, s_cmd, PS3_STATUS_ACCESS_BLOCK, NULL, 0, NULL); ps3_scsih_cdb_opcode_get(s_cmd->cmnd, &opcode, &sub_opcode); - LOG_DEBUG("hno:%u chl:%u id:%u vd_access_policy:%u op:0x%x sub_op:0x%x block io\n", - PS3_HOST(instance), channel, id, entry->accessPolicy, - opcode, sub_opcode); + LOG_DEBUG("hno:%u chl:%u id:%u vd_access_policy:%u" + "op:0x%x sub_op:0x%x block io\n", + PS3_HOST(instance), channel, id, entry->accessPolicy, + opcode, sub_opcode); ret = -PS3_IO_BLOCK; goto l_out; - } else if (unlikely((entry->accessPolicy == - VD_ACCESS_POLICY_READ_ONLY) && - ps3_scsih_cdb_is_write_cmd(s_cmd->cmnd))) { - ps3_errcode_to_scsi_status(instance, s_cmd, - PS3_STATUS_ACCESS_BLOCK, NULL, 0, - NULL); + } else if (unlikely((entry->accessPolicy == VD_ACCESS_POLICY_READ_ONLY) && + ps3_scsih_cdb_is_write_cmd(s_cmd->cmnd))) { + ps3_errcode_to_scsi_status(instance, s_cmd, PS3_STATUS_ACCESS_BLOCK, NULL, 0, NULL); ps3_scsih_cdb_opcode_get(s_cmd->cmnd, &opcode, &sub_opcode); - LOG_DEBUG("hno:%u chl:%u id:%u vd_access_policy:%u op:0x%x sub_op:0x%x write io\n", - PS3_HOST(instance), channel, id, entry->accessPolicy, - opcode, sub_opcode); + LOG_DEBUG("hno:%u chl:%u id:%u vd_access_policy:%u" + "op:0x%x sub_op:0x%x block write io\n", + PS3_HOST(instance), channel, id, entry->accessPolicy, + opcode, sub_opcode); ret = -PS3_IO_BLOCK; goto l_out; } @@ -3653,41 +3382,41 @@ static int ps3_vd_access_policy_check(struct ps3_instance *instance, return ret; } -int ps3_get_requeue_or_reset(void) +S32 ps3_get_requeue_or_reset(void) { -#if defined(PS3_DID_REQUEUE) +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 7) && (RHEL_MINOR == 3)) || \ +((LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) && \ +(LINUX_VERSION_CODE < KERNEL_VERSION(4,4,14)))) return PS3_SCSI_RESULT_HOST_STATUS(DID_REQUEUE); #else return PS3_SCSI_RESULT_HOST_STATUS(DID_RESET); #endif } -unsigned char ps3_write_direct_enable(struct ps3_cmd *cmd) +Bool ps3_write_direct_enable(struct ps3_cmd *cmd) { - unsigned char result = PS3_TRUE; - + Bool result = PS3_TRUE; if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag) && - !cmd->io_attr.vd_entry->isWriteDirectEnable) { + !cmd->io_attr.vd_entry->isWriteDirectEnable) { result = PS3_FALSE; } return result; } -unsigned char ps3_ssd_vd_qmask_calculate_hba(struct ps3_cmd *cmd) +Bool ps3_ssd_vd_qmask_calculate_hba(struct ps3_cmd *cmd) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; struct ps3_scsi_priv_data *device_priv_data = NULL; device_priv_data = PS3_SDEV_PRI_DATA(cmd->scmd->device); if (device_priv_data != NULL) { - cmd->cmd_word.qMask = - 1 << (device_priv_data->qmask_count & - (cmd->instance->ctrl_info.vdQueueNum - 1)); + cmd->cmd_word.qMask = 1 << + (device_priv_data->qmask_count & (cmd->instance->ctrl_info.vdQueueNum - 1)); device_priv_data->qmask_count++; ret = PS3_TRUE; - ; } return ret; } + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih.h b/drivers/scsi/linkdata/ps3stor/ps3_scsih.h index 30fe859f3f51..26cc1979b455 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_SCSIH_H_ #define _PS3_SCSIH_H_ @@ -12,133 +11,139 @@ #include "ps3_htp_def.h" #include "ps3_inner_data.h" -#include "ps3_kernel_version.h" #define PS3_HW_VD_MAX_IO_SIZE_1M (1ULL << 20) #define PS3_PAGE_MODE_ABOVE_3_ADDR_MASK 0xFFFFFF8000000000ULL #define PS3_PAGE_MODE_ABOVE_4_ADDR_MASK 0xFFFF000000000000ULL -#define PS3_IS_R0J1(raidlevel) \ - ((raidlevel) == RAID0 || (raidlevel) == RAID1 || \ - (raidlevel) == RAID10 || (raidlevel) == RAID1E || \ - (raidlevel) == RAID00) +#define PS3_IS_R0J1(raidlevel) \ + ((raidlevel) == RAID0 || (raidlevel) == RAID1 || \ + (raidlevel) == RAID10 || (raidlevel) == RAID1E || \ + (raidlevel) == RAID00) -#if defined(PS3_SCMD_GET_REQUEST) -#define SCMD_GET_REQUEST(scmd) scsi_cmd_to_rq(scmd) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)) +#define SCMD_GET_REQUEST(scmd) scsi_cmd_to_rq(scmd) #else -#define SCMD_GET_REQUEST(scmd) scmd->request +#define SCMD_GET_REQUEST(scmd) scmd->request #endif -#if defined(PS3_SCMD_IO_DONE) -#define SCMD_IO_DONE(scmd) scsi_done(scmd) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)) +#define SCMD_IO_DONE(scmd) scsi_done(scmd) #else -#define SCMD_IO_DONE(scmd) scmd->scsi_done(scmd) +#define SCMD_IO_DONE(scmd) scmd->scsi_done(scmd) +#endif + +#if 0 +#define PS3_IF_QUIT_STREAM_DIRECT_DETECT(raidlevel) \ + ((ps3_direct_check_stream_query() == PS3_FALSE) && PS3_IS_R0J1(raidlevel)) #endif -#define PS3_IF_QUIT_STREAM_DIRECT_DETECT() \ +#define PS3_IF_QUIT_STREAM_DIRECT_DETECT() \ (ps3_direct_check_stream_query() == PS3_FALSE) +typedef S32 (*dev_type_to_proc_func)(struct ps3_cmd*); struct disk_type_to_proc_func_table { - unsigned char type; - int (*func)(struct ps3_cmd *cmd); + U8 type; + dev_type_to_proc_func func; }; -#define CMND_LEN16 (16) -#define FRAME_CMD_MASK_SHIFT (0x1) -#define FRAME_CMD_MASK_BITS (0x07) +#define CMND_LEN16 (16) +#define FRAME_CMD_MASK_SHIFT (0x1) +#define FRAME_CMD_MASK_BITS (0x07) enum PS3_FRAME_CMD_TYPE { - SCSI_FRAME_CMD = 0, - SAS_FRAME_CMD = 1, - SATA_FRAME_CMD = 2, - NVME_FRAME_CMD = 3, + SCSI_FRAME_CMD = 0, + SAS_FRAME_CMD = 1, + SATA_FRAME_CMD = 2, + NVME_FRAME_CMD = 3, UNKNOWN_FRAME_CMD, }; enum PS3_RW_CMD_TYPE { - SCSI_RW_UNUSED_CMD = 0, - SCSI_RW_SEQ_CMD = 1, - SCSI_RW_RANDOM_CMD = 2, + SCSI_RW_UNUSED_CMD = 0, + SCSI_RW_SEQ_CMD = 1, + SCSI_RW_RANDOM_CMD = 2, }; struct scsi_cmd_parse_table { - unsigned char cmd_type; - unsigned char rw_attr; + U8 cmd_type; + U8 rw_attr; }; -static inline void ps3_put_unaligned_be64(unsigned char *p, unsigned int val_hi, - unsigned int val_lo) +static inline void ps3_put_unaligned_be64(U8 *p, U32 val_hi, U32 val_lo) { - p[0] = (unsigned char)(val_hi >> PS3_SHIFT_3BYTE) & 0xff; - p[1] = (unsigned char)(val_hi >> PS3_SHIFT_WORD) & 0xff; - p[2] = (unsigned char)(val_hi >> PS3_SHIFT_BYTE) & 0xff; - p[3] = (unsigned char)val_hi & 0xff; - - p[4] = (unsigned char)(val_lo >> PS3_SHIFT_3BYTE) & 0xff; - p[5] = (unsigned char)(val_lo >> PS3_SHIFT_WORD) & 0xff; - p[6] = (unsigned char)(val_lo >> PS3_SHIFT_BYTE) & 0xff; - p[7] = (unsigned char)val_lo & 0xff; + p[0] = (U8) (val_hi >> PS3_SHIFT_3BYTE) & 0xff; + p[1] = (U8) (val_hi >> PS3_SHIFT_WORD) & 0xff; + p[2] = (U8) (val_hi >> PS3_SHIFT_BYTE) & 0xff; + p[3] = (U8) val_hi & 0xff; + + p[4] = (U8) (val_lo >> PS3_SHIFT_3BYTE) & 0xff; + p[5] = (U8) (val_lo >> PS3_SHIFT_WORD) & 0xff; + p[6] = (U8) (val_lo >> PS3_SHIFT_BYTE) & 0xff; + p[7] = (U8) val_lo & 0xff; } -static inline void ps3_put_unaligned_be32(unsigned char *p, unsigned int val) +static inline void ps3_put_unaligned_be32(U8 *p, U32 val) { - p[0] = (unsigned char)(val >> PS3_SHIFT_3BYTE) & 0xff; - p[1] = (unsigned char)(val >> PS3_SHIFT_WORD) & 0xff; - p[2] = (unsigned char)(val >> PS3_SHIFT_BYTE) & 0xff; - p[3] = (unsigned char)val & 0xff; + p[0] = (U8) (val >> PS3_SHIFT_3BYTE) & 0xff; + p[1] = (U8) (val >> PS3_SHIFT_WORD) & 0xff; + p[2] = (U8) (val >> PS3_SHIFT_BYTE) & 0xff; + p[3] = (U8) val & 0xff; } -static inline void ps3_put_unaligned_be16(unsigned char *p, unsigned short val) +static inline void ps3_put_unaligned_be16(U8 *p, U16 val) { - p[0] = (unsigned char)(val >> PS3_SHIFT_BYTE) & 0xff; - p[1] = (unsigned char)val & 0xff; + p[0] = (U8) (val >> PS3_SHIFT_BYTE) & 0xff; + p[1] = (U8) val & 0xff; } -static inline unsigned short ps3_get_unaligned_be16(unsigned char *p) +static inline U16 ps3_get_unaligned_be16(U8 *p) { - return (unsigned short)((p[0] << PS3_SHIFT_BYTE) | p[1]); + return (U16)((p[0] << PS3_SHIFT_BYTE) | p[1]); } #ifndef _WINDOWS -int ps3_scsih_queue_command(struct Scsi_Host *s_host, struct scsi_cmnd *s_cmd); +typedef struct scatterlist ps3_scatter_gather_element; + +S32 ps3_scsih_queue_command(struct Scsi_Host *s_host, + struct scsi_cmnd *s_cmd); #else -unsigned char ps3_scsih_sys_state_check(struct ps3_instance *instance, - int *host_status); +Bool ps3_scsih_sys_state_check(struct ps3_instance *instance, S32 *host_status); #endif -int ps3_scsih_cmd_build(struct ps3_cmd *cmd); +S32 ps3_scsih_cmd_build(struct ps3_cmd *cmd); -void ps3_scsih_direct_to_normal_req_frame_rebuild(struct ps3_cmd *cmd); +void ps3_scsih_direct_to_normal_req_frame_rebuild( + struct ps3_cmd *cmd); -int ps3_scsih_io_done(struct ps3_cmd *cmd, unsigned short reply_flags); +S32 ps3_scsih_io_done(struct ps3_cmd *cmd, U16 reply_flags); void ps3_scsi_dma_unmap(struct ps3_cmd *cmd); -int ps3_scsi_dma_map(struct ps3_cmd *cmd); +S32 ps3_scsi_dma_map(struct ps3_cmd *cmd); -unsigned char -ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, - const struct ps3_pd_entry *pd_entry); +Bool ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd_entry); -unsigned char ps3_scsih_stream_is_detect(struct ps3_cmd *cmd); -unsigned char ps3_raid_scsih_stream_is_direct(const struct ps3_cmd *cmd); -unsigned char ps3_hba_scsih_stream_is_direct(const struct ps3_cmd *cmd); +Bool ps3_scsih_stream_is_detect(struct ps3_cmd * cmd); +Bool ps3_raid_scsih_stream_is_direct(const struct ps3_cmd * cmd); +Bool ps3_hba_scsih_stream_is_direct(const struct ps3_cmd * cmd); -void ps3_scsih_print_req(struct ps3_cmd *cmd, unsigned char log_level); +void ps3_scsih_print_req(struct ps3_cmd *cmd, U8 log_level); -int ps3_get_requeue_or_reset(void); +S32 ps3_get_requeue_or_reset(void); -unsigned char ps3_scsih_sata_direct_is_need(struct ps3_cmd *cmd); +Bool ps3_scsih_sata_direct_is_need(struct ps3_cmd *cmd); -unsigned char ps3_scsih_is_sata_jbod_mgr_cmd(const struct ps3_cmd *cmd); +Bool ps3_scsih_is_sata_jbod_mgr_cmd(const struct ps3_cmd *cmd); -unsigned int ps3_scsih_xfer_cnt_get(const struct ps3_cmd *cmd); +U32 ps3_scsih_xfer_cnt_get(const struct ps3_cmd *cmd); -unsigned char ps3_is_r1x_write_cmd(const struct ps3_cmd *cmd); +Bool ps3_is_r1x_write_cmd(const struct ps3_cmd *cmd); -int ps3_vd_direct_req_frame_build(struct ps3_cmd *cmd); +S32 ps3_vd_direct_req_frame_build(struct ps3_cmd *cmd); -unsigned char ps3_write_direct_enable(struct ps3_cmd *cmd); +Bool ps3_write_direct_enable(struct ps3_cmd *cmd); -unsigned char ps3_ssd_vd_qmask_calculate_hba(struct ps3_cmd *cmd); +Bool ps3_ssd_vd_qmask_calculate_hba(struct ps3_cmd *cmd); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.c b/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.c index 28e1648b712e..01343852e627 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.c @@ -1,5 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ + #ifndef _WINDOWS #include #include "ps3_scsih.h" @@ -11,7 +10,6 @@ #include "ps3_inner_data.h" #include "ps3_instance_manager.h" #include "ps3_driver_log.h" -#include "ps3_kernel_version.h" #define PS3_WRITE_VERIFY_16 (0x8e) #define PS3_WRITE_VERIFY_32 (0x0C) @@ -29,9 +27,9 @@ #define WRITE_STREAM_32 (0x10) #define WRITE_LONG_16 (0x11) -unsigned char ps3_scsih_is_rw_type(unsigned char type) +Bool ps3_scsih_is_rw_type(U8 type) { - unsigned char is_rw_type = PS3_FALSE; + Bool is_rw_type = PS3_FALSE; switch (type) { case PS3_SCSI_CMD_TYPE_READ: @@ -48,34 +46,32 @@ unsigned char ps3_scsih_is_rw_type(unsigned char type) return is_rw_type; } -unsigned char ps3_scsih_rw_cmd_is_need_split_hba(struct ps3_cmd *cmd) +Bool ps3_scsih_rw_cmd_is_need_split_hba(struct ps3_cmd *cmd) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; (void)cmd; return ret; } -unsigned char ps3_scsih_rw_cmd_is_need_split_raid(struct ps3_cmd *cmd) +Bool ps3_scsih_rw_cmd_is_need_split_raid(struct ps3_cmd *cmd) { - unsigned char is_need_split = PS3_FALSE; - unsigned int num_blocks = 0; - unsigned int lba_lo = 0; - unsigned int lba_hi = 0; + Bool is_need_split = PS3_FALSE; + U32 num_blocks = 0; + U32 lba_lo = 0; + U32 lba_hi = 0; - ps3_scsih_cdb_parse(cmd->scmd->cmnd, &num_blocks, &lba_lo, &lba_hi, - &is_need_split); + ps3_scsih_cdb_parse(cmd->scmd->cmnd, &num_blocks, &lba_lo, &lba_hi, &is_need_split); return is_need_split; } -static unsigned char -ps3_scsih_service_action32_rw_type_get(const unsigned char *cdb) +static U8 ps3_scsih_service_action32_rw_type_get(const U8 *cdb) { - enum ps3_scsi_cmd_type rw_type = PS3_SCSI_CMD_TYPE_UNKNOWN; - unsigned short cmd_type = PS3_SERVICE_ACTION32(cdb); + enum ps3_scsi_cmd_type rw_type = PS3_SCSI_CMD_TYPE_UNKOWN; + U16 cmd_type = PS3_SERVICE_ACTION32(cdb); switch (cmd_type) { case READ_32: rw_type = PS3_SCSI_CMD_TYPE_READ; @@ -85,9 +81,7 @@ ps3_scsih_service_action32_rw_type_get(const unsigned char *cdb) case PS3_WRITE_VERIFY_32: case ORWRITE_32: case WRITE_ATOMIC_32: - rw_type = (enum ps3_scsi_cmd_type)( - (unsigned char)PS3_SCSI_CMD_TYPE_WRITE | - PS3_SCSI_CONFLICT_CHECK); + rw_type = (enum ps3_scsi_cmd_type)((U8)PS3_SCSI_CMD_TYPE_WRITE | PS3_SCSI_CONFLICT_CHECK); break; case VERIFY_32: case WRITE_SAME_32: @@ -101,15 +95,14 @@ ps3_scsih_service_action32_rw_type_get(const unsigned char *cdb) break; } - return (unsigned char)rw_type; + return (U8)rw_type; } -static inline unsigned char -ps3_service_action16_rw_type_get(const unsigned char *cdb) +static inline U8 ps3_service_action16_rw_type_get(const U8 *cdb) { - enum ps3_scsi_cmd_type rw_type = PS3_SCSI_CMD_TYPE_UNKNOWN; - unsigned char cmd_type = cdb[1] & 0x1f; + enum ps3_scsi_cmd_type rw_type = PS3_SCSI_CMD_TYPE_UNKOWN; + U8 cmd_type = cdb[1] & 0x1f; switch (cmd_type) { case WRITE_LONG_16: case WRITE_SCATTERED_16: @@ -120,31 +113,30 @@ ps3_service_action16_rw_type_get(const unsigned char *cdb) break; } - return (unsigned char)rw_type; + return (U8)rw_type; } -static inline void -ps3_scsih_cdb_options_get(const unsigned char *cdb, - union ps3_scsi_cdb_option *cdb_opts) +static inline void ps3_scsih_cdb_options_get(const U8 *cdb, + ps3_scsi_cdb_opts_u *cdb_opts) { - union ps3_scsi_cdb_option *pRead = (union ps3_scsi_cdb_option *)(cdb); + ps3_scsi_cdb_opts_u *pRead = (ps3_scsi_cdb_opts_u *)(cdb); cdb_opts->fua = pRead->fua; cdb_opts->protect = pRead->protect; cdb_opts->dpo = pRead->dpo; } -int ps3_scsih_cdb_opts_parse(struct ps3_cmd *cmd) +S32 ps3_scsih_cdb_opts_parse(struct ps3_cmd *cmd) { - union ps3_scsi_cdb_option *cdb_opts = &cmd->io_attr.cdb_opts; + ps3_scsi_cdb_opts_u *cdb_opts = &cmd->io_attr.cdb_opts; #ifndef _WINDOWS - const unsigned char *cdb = cmd->scmd->cmnd; + const U8 *cdb = cmd->scmd->cmnd; #else - const unsigned char *cdb = scsi_cmnd_cdb(cmd->scmd); + const U8 *cdb = scsi_cmnd_cdb(cmd->scmd); #endif - unsigned short sub_cmd_type = 0; - int ret = PS3_SUCCESS; + U16 sub_cmd_type = 0; + S32 ret = PS3_SUCCESS; switch (cdb[0]) { case READ_10: @@ -181,10 +173,10 @@ int ps3_scsih_cdb_opts_parse(struct ps3_cmd *cmd) return ret; } -unsigned char ps3_scsih_is_protocal_rw(const unsigned char *cdb) +Bool ps3_scsih_is_protocal_rw(const U8 *cdb) { - unsigned char ret = PS3_DRV_FALSE; - unsigned short sub_cmd_type = 0; + Bool ret = PS3_DRV_FALSE; + U16 sub_cmd_type = 0; switch (cdb[0]) { case READ_6: @@ -215,9 +207,9 @@ unsigned char ps3_scsih_is_protocal_rw(const unsigned char *cdb) return ret; } -unsigned char ps3_scsih_cdb_rw_type_get(const unsigned char *cdb) +U8 ps3_scsih_cdb_rw_type_get(const U8 *cdb) { - unsigned char rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_UNKNOWN; + U8 rw_type = (U8)PS3_SCSI_CMD_TYPE_UNKOWN; switch (cdb[0]) { case READ_6: @@ -226,7 +218,7 @@ unsigned char ps3_scsih_cdb_rw_type_get(const unsigned char *cdb) case READ_16: case PRE_FETCH: case PRE_FETCH_16: - rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_READ; + rw_type = (U8)PS3_SCSI_CMD_TYPE_READ; break; case WRITE_6: @@ -238,8 +230,7 @@ unsigned char ps3_scsih_cdb_rw_type_get(const unsigned char *cdb) case ORWRITE_16: case WRITE_ATOMIC_16: case PS3_WRITE_VERIFY_16: - rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_WRITE | - PS3_SCSI_CONFLICT_CHECK; + rw_type = (U8)PS3_SCSI_CMD_TYPE_WRITE | PS3_SCSI_CONFLICT_CHECK; break; case VERIFY: case WRITE_SAME: @@ -250,20 +241,18 @@ unsigned char ps3_scsih_cdb_rw_type_get(const unsigned char *cdb) case SYNCHRONIZE_CACHE_16: case WRITE_STREAM_16: case WRITE_LONG: - rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_WRITE; + rw_type = (U8)PS3_SCSI_CMD_TYPE_WRITE; break; case VARIABLE_LENGTH_CMD: rw_type = ps3_scsih_service_action32_rw_type_get(cdb); break; case UNMAP: - rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_UNMAP | - PS3_SCSI_CONFLICT_CHECK; + rw_type = (U8)PS3_SCSI_CMD_TYPE_UNMAP | PS3_SCSI_CONFLICT_CHECK; break; case COMPARE_AND_WRITE: - rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_RW | - PS3_SCSI_CONFLICT_CHECK; + rw_type = (U8)PS3_SCSI_CMD_TYPE_RW | PS3_SCSI_CONFLICT_CHECK; break; case SERVICE_ACTION_OUT_16: @@ -271,81 +260,73 @@ unsigned char ps3_scsih_cdb_rw_type_get(const unsigned char *cdb) break; default: - rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_NORW; + rw_type = (U8)PS3_SCSI_CMD_TYPE_NORW; break; } return rw_type; } -static inline void ps3_scsih_cdb_rw6_rebuild(unsigned char *cdb, - unsigned int num_blocks, - unsigned int lba_lo) +static inline void ps3_scsih_cdb_rw6_rebuild(U8 *cdb, U32 num_blocks, + U32 lba_lo) { cdb[1] &= ~(0x1f); - cdb[1] |= (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0x1f; - cdb[2] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[3] = (unsigned char)lba_lo & 0xff; + cdb[1] |= (U8) (lba_lo >> PS3_SHIFT_WORD) & 0x1f; + cdb[2] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[3] = (U8) lba_lo & 0xff; - cdb[4] = (num_blocks == 256) ? 0 : ((unsigned char)num_blocks & 0xff); + cdb[4] = (256 == num_blocks ) ? 0 : ((U8) num_blocks & 0xff); } -static inline void ps3_scsih_cdb_rw10_rebuild(unsigned char *cdb, - unsigned int num_blocks, - unsigned int lba_lo) +static inline void ps3_scsih_cdb_rw10_rebuild(U8 *cdb, U32 num_blocks, + U32 lba_lo) { - cdb[2] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (unsigned char)lba_lo & 0xff; + cdb[2] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (U8) lba_lo & 0xff; - cdb[7] = (unsigned char)(num_blocks >> PS3_SHIFT_BYTE) & 0xff; - cdb[8] = (unsigned char)num_blocks & 0xff; + cdb[7] = (U8) (num_blocks >> PS3_SHIFT_BYTE) & 0xff; + cdb[8] = (U8) num_blocks & 0xff; } -static inline void ps3_scsih_cdb_rw12_rebuild(unsigned char *cdb, - unsigned int num_blocks, - unsigned int lba_lo) +static inline void ps3_scsih_cdb_rw12_rebuild(U8 *cdb, U32 num_blocks, + U32 lba_lo) { - cdb[2] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (unsigned char)lba_lo & 0xff; - - cdb[6] = (unsigned char)(num_blocks >> PS3_SHIFT_3BYTE) & 0xff; - cdb[7] = (unsigned char)(num_blocks >> PS3_SHIFT_WORD) & 0xff; - cdb[8] = (unsigned char)(num_blocks >> PS3_SHIFT_BYTE) & 0xff; - cdb[9] = (unsigned char)num_blocks & 0xff; + cdb[2] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (U8) lba_lo & 0xff; + + cdb[6] = (U8) (num_blocks >> PS3_SHIFT_3BYTE) & 0xff; + cdb[7] = (U8) (num_blocks >> PS3_SHIFT_WORD) & 0xff; + cdb[8] = (U8) (num_blocks >> PS3_SHIFT_BYTE) & 0xff; + cdb[9] = (U8) num_blocks & 0xff; } -static inline void ps3_scsih_cdb_rw16_rebuild(unsigned char *cdb, - unsigned int num_blocks, - unsigned int lba_lo, - unsigned int lba_hi) +static inline void ps3_scsih_cdb_rw16_rebuild(U8 *cdb, U32 num_blocks, + U32 lba_lo, U32 lba_hi) { - cdb[2] = (unsigned char)(lba_hi >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (unsigned char)(lba_hi >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (unsigned char)(lba_hi >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (unsigned char)lba_hi & 0xff; - - cdb[6] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[7] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[8] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[9] = (unsigned char)lba_lo & 0xff; - - cdb[10] = (unsigned char)(num_blocks >> PS3_SHIFT_3BYTE) & 0xff; - cdb[11] = (unsigned char)(num_blocks >> PS3_SHIFT_WORD) & 0xff; - cdb[12] = (unsigned char)(num_blocks >> PS3_SHIFT_BYTE) & 0xff; - cdb[13] = (unsigned char)num_blocks & 0xff; + cdb[2] = (U8) (lba_hi >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (U8) (lba_hi >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (U8) (lba_hi >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (U8) lba_hi & 0xff; + + cdb[6] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[7] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[8] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[9] = (U8) lba_lo & 0xff; + + cdb[10] = (U8) (num_blocks >> PS3_SHIFT_3BYTE) & 0xff; + cdb[11] = (U8) (num_blocks >> PS3_SHIFT_WORD) & 0xff; + cdb[12] = (U8) (num_blocks >> PS3_SHIFT_BYTE) & 0xff; + cdb[13] = (U8) num_blocks & 0xff; } -static inline void ps3_scsih_cdb_rw32_rebuild(unsigned char *cdb, - unsigned int num_blocks, - unsigned int lba_lo, - unsigned int lba_hi) +static inline void ps3_scsih_cdb_rw32_rebuild(U8 *cdb, U32 num_blocks, + U32 lba_lo, U32 lba_hi) { - unsigned short cmd_type = PS3_SERVICE_ACTION32(cdb); - + U16 cmd_type = PS3_SERVICE_ACTION32(cdb); LOG_DEBUG("[ps3]VARIABLE_LENGTH_CMD :0x%x!\n", cmd_type); switch (cmd_type) { @@ -357,80 +338,75 @@ static inline void ps3_scsih_cdb_rw32_rebuild(unsigned char *cdb, case ORWRITE_32: case WRITE_ATOMIC_32: case WRITE_STREAM_32: - cdb[12] = (unsigned char)(lba_hi >> PS3_SHIFT_3BYTE) & 0xff; - cdb[13] = (unsigned char)(lba_hi >> PS3_SHIFT_WORD) & 0xff; - cdb[14] = (unsigned char)(lba_hi >> PS3_SHIFT_BYTE) & 0xff; - cdb[15] = (unsigned char)lba_hi & 0xff; - - cdb[16] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[17] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[18] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[19] = (unsigned char)lba_lo & 0xff; - cdb[20] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[21] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[22] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[23] = (unsigned char)lba_lo & 0xff; - cdb[28] = (unsigned char)(num_blocks >> PS3_SHIFT_3BYTE) & 0xff; - cdb[29] = (unsigned char)(num_blocks >> PS3_SHIFT_WORD) & 0xff; - cdb[30] = (unsigned char)(num_blocks >> PS3_SHIFT_BYTE) & 0xff; - cdb[31] = (unsigned char)num_blocks & 0xff; + cdb[12] = (U8) (lba_hi >> PS3_SHIFT_3BYTE) & 0xff; + cdb[13] = (U8) (lba_hi >> PS3_SHIFT_WORD) & 0xff; + cdb[14] = (U8) (lba_hi >> PS3_SHIFT_BYTE) & 0xff; + cdb[15] = (U8) lba_hi & 0xff; + + cdb[16] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[17] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[18] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[19] = (U8) lba_lo & 0xff; + + cdb[20] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[21] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[22] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[23] = (U8) lba_lo & 0xff; + + cdb[28] = (U8) (num_blocks >> PS3_SHIFT_3BYTE) & 0xff; + cdb[29] = (U8) (num_blocks >> PS3_SHIFT_WORD) & 0xff; + cdb[30] = (U8) (num_blocks >> PS3_SHIFT_BYTE) & 0xff; + cdb[31] = (U8) num_blocks & 0xff; break; - default: + default : break; } } -static inline void ps3_scsih_cdb_write_long10_rebuild(unsigned char *cdb, - unsigned int lba_lo) +static inline void ps3_scsih_cdb_write_long10_rebuild(U8 *cdb,U32 lba_lo) { - cdb[2] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (unsigned char)lba_lo & 0xff; + cdb[2] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (U8) lba_lo & 0xff; } -static inline void ps3_cdb_comp_and_write_rebuild(unsigned char *cdb, - unsigned int num_blocks, - unsigned int lba_lo, - unsigned int lba_hi) +static inline void ps3_cdb_comp_and_write_rebuild(U8 *cdb, + U32 num_blocks, U32 lba_lo, U32 lba_hi) { - cdb[2] = (unsigned char)(lba_hi >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (unsigned char)(lba_hi >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (unsigned char)(lba_hi >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (unsigned char)lba_hi & 0xff; + cdb[2] = (U8) (lba_hi >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (U8) (lba_hi >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (U8) (lba_hi >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (U8) lba_hi & 0xff; - cdb[6] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[7] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[8] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[9] = (unsigned char)lba_lo & 0xff; + cdb[6] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[7] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[8] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[9] = (U8) lba_lo & 0xff; - cdb[13] = (unsigned char)num_blocks & 0xff; + cdb[13] = (U8) num_blocks & 0xff; } -static inline void ps3_scsih_service_16_rebuild(unsigned char *cdb, - unsigned int lba_lo, - unsigned int lba_hi) +static inline void ps3_scsih_service_16_rebuild(U8 *cdb, + U32 lba_lo, U32 lba_hi) { - unsigned char cmd_type = cdb[1] & 0x1f; - + U8 cmd_type = cdb[1] & 0x1f; LOG_DEBUG("[ps3] CMD :0x%x!\n", cmd_type); - if (cmd_type == WRITE_LONG_16) { - cdb[2] = (unsigned char)(lba_hi >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (unsigned char)(lba_hi >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (unsigned char)(lba_hi >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (unsigned char)lba_hi & 0xff; + if (WRITE_LONG_16 == cmd_type) { + cdb[2] = (U8) (lba_hi >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (U8) (lba_hi >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (U8) (lba_hi >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (U8) lba_hi & 0xff; - cdb[6] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[7] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[8] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[9] = (unsigned char)lba_lo & 0xff; + cdb[6] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[7] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[8] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[9] = (U8) lba_lo & 0xff; } } -static inline void ps3_scsih_atomic_stream_16_rebuild(unsigned char *cdb, - unsigned int num_blocks, - unsigned int lba_lo, - unsigned int lba_hi) +static inline void ps3_scsih_atomic_stream_16_rebuild(U8 *cdb, + U32 num_blocks, U32 lba_lo, U32 lba_hi) { cdb[2] = (lba_hi >> PS3_SHIFT_3BYTE) & 0xff; cdb[3] = (lba_hi >> PS3_SHIFT_WORD) & 0xff; @@ -446,77 +422,61 @@ static inline void ps3_scsih_atomic_stream_16_rebuild(unsigned char *cdb, cdb[13] = num_blocks & 0xff; } -static inline void ps3_scsih_cdb_rw6_parse(const unsigned char *cdb, - unsigned int *num_blocks, - unsigned int *lba_lo, - unsigned int *lba_hi) +static inline void ps3_scsih_cdb_rw6_parse(const U8 *cdb, U32 *num_blocks, + U32 *lba_lo, U32 *lba_hi) { - const unsigned int default_num_blocks = 256; + const U32 default_num_blocks = 256; (void)lba_hi; - *lba_lo = (unsigned int)(((cdb[1] & 0x1f) << PS3_SHIFT_WORD) | - (cdb[2] << PS3_SHIFT_BYTE) | cdb[3]); - *num_blocks = ((unsigned int)cdb[4] == 0) ? default_num_blocks : - (unsigned int)cdb[4]; + *lba_lo = (U32)(((cdb[1] & 0x1f) << PS3_SHIFT_WORD) | + (cdb[2] << PS3_SHIFT_BYTE) | cdb[3]); + *num_blocks = ((U32)cdb[4] == 0) ? default_num_blocks : (U32)cdb[4]; + return; } -static inline void ps3_scsih_cdb_rw10_parse(const unsigned char *cdb, - unsigned int *num_blocks, - unsigned int *lba_lo, - unsigned int *lba_hi) +static inline void ps3_scsih_cdb_rw10_parse(const U8 *cdb, U32 *num_blocks, + U32 *lba_lo, U32 *lba_hi) { (void)lba_hi; - *lba_lo = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[5]; - *num_blocks = ((unsigned int)cdb[8] | - ((unsigned int)cdb[7] << PS3_SHIFT_BYTE)); + *lba_lo = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | + ((U32)cdb[3] << PS3_SHIFT_WORD) | + ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; + *num_blocks = ((U32)cdb[8] | ((U32)cdb[7] << PS3_SHIFT_BYTE)); + return; } -static inline void ps3_scsih_cdb_rw12_parse(const unsigned char *cdb, - unsigned int *num_blocks, - unsigned int *lba_lo, - unsigned int *lba_hi) +static inline void ps3_scsih_cdb_rw12_parse(const U8 *cdb, U32 *num_blocks, + U32 *lba_lo, U32 *lba_hi) { (void)lba_hi; - *lba_lo = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[5]; - *num_blocks = ((unsigned int)cdb[6] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[7] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[8] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[9]; + *lba_lo = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | + ((U32)cdb[3] << PS3_SHIFT_WORD) | + ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; + *num_blocks = ((U32)cdb[6] << PS3_SHIFT_3BYTE) | + ((U32)cdb[7] << PS3_SHIFT_WORD) | + ((U32)cdb[8] << PS3_SHIFT_BYTE) | (U32)cdb[9]; + return; } -static inline void ps3_scsih_cdb_rw16_parse(const unsigned char *cdb, - unsigned int *num_blocks, - unsigned int *lba_lo, - unsigned int *lba_hi) +static inline void ps3_scsih_cdb_rw16_parse(const U8 *cdb, U32 *num_blocks, + U32 *lba_lo, U32 *lba_hi) { - *lba_lo = ((unsigned int)cdb[6] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[7] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[8] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[9]; - *lba_hi = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[5]; - *num_blocks = ((unsigned int)cdb[10] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[11] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[12] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[13]; + *lba_lo = ((U32)cdb[6] << PS3_SHIFT_3BYTE) | + ((U32)cdb[7] << PS3_SHIFT_WORD) | + ((U32) cdb[8] << PS3_SHIFT_BYTE) | (U32)cdb[9]; + *lba_hi = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | + ((U32)cdb[3] << PS3_SHIFT_WORD) | + ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; + *num_blocks = ((U32)cdb[10] << PS3_SHIFT_3BYTE) | + ((U32)cdb[11] << PS3_SHIFT_WORD) | + ((U32)cdb[12] << PS3_SHIFT_BYTE) | (U32)cdb[13]; + return; } -static inline void ps3_scsih_cdb_rw32_parse(const unsigned char *cdb, - unsigned int *num_blocks, - unsigned int *lba_lo, - unsigned int *lba_hi, - unsigned char *is_need_split) +static inline void ps3_scsih_cdb_rw32_parse(const U8 *cdb, + U32 *num_blocks, U32 *lba_lo, U32 *lba_hi, Bool *is_need_split) { - unsigned short cmd_type = PS3_SERVICE_ACTION32(cdb); - + U16 cmd_type = PS3_SERVICE_ACTION32(cdb); LOG_DEBUG("[ps3]VARIABLE_LENGTH_CMD :0x%x!\n", cmd_type); *is_need_split = PS3_FALSE; @@ -525,7 +485,7 @@ static inline void ps3_scsih_cdb_rw32_parse(const unsigned char *cdb, case WRITE_32: case PS3_WRITE_VERIFY_32: *is_need_split = PS3_TRUE; -#if defined(PS3_FALLTHROUGH) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) fallthrough; #endif case VERIFY_32: @@ -533,18 +493,15 @@ static inline void ps3_scsih_cdb_rw32_parse(const unsigned char *cdb, case ORWRITE_32: case WRITE_ATOMIC_32: case WRITE_STREAM_32: - *lba_lo = ((unsigned int)cdb[16] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[17] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[18] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[19]; - *lba_hi = ((unsigned int)cdb[12] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[13] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[14] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[15]; - *num_blocks = ((unsigned int)cdb[28] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[29] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[30] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[31]; + *lba_lo = ((U32)cdb[16] << PS3_SHIFT_3BYTE) | + ((U32)cdb[17] << PS3_SHIFT_WORD) | + ((U32) cdb[18] << PS3_SHIFT_BYTE) | (U32)cdb[19]; + *lba_hi = ((U32)cdb[12] << PS3_SHIFT_3BYTE) | + ((U32)cdb[13] << PS3_SHIFT_WORD) | + ((U32)cdb[14] << PS3_SHIFT_BYTE) | (U32)cdb[15]; + *num_blocks = ((U32)cdb[28] << PS3_SHIFT_3BYTE) | + ((U32)cdb[29] << PS3_SHIFT_WORD) | + ((U32)cdb[30] << PS3_SHIFT_BYTE) | (U32)cdb[31]; break; case WRITE_SCATTERED_32: @@ -556,56 +513,45 @@ static inline void ps3_scsih_cdb_rw32_parse(const unsigned char *cdb, break; } + return; } -static inline void ps3_cdb_write_long10_parse(const unsigned char *cdb, - unsigned int *num_blocks, - unsigned int *lba_lo, - unsigned int *lba_hi) +static inline void ps3_cdb_write_long10_parse(const U8 *cdb, + U32 *num_blocks, U32 *lba_lo, U32 *lba_hi) { (void)lba_hi; - *lba_lo = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[5]; - *num_blocks = 1; + *lba_lo = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | + ((U32)cdb[3] << PS3_SHIFT_WORD) | + ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; + *num_blocks =1; } -static inline void ps3_cdb_comp_and_write_parse(const unsigned char *cdb, - unsigned int *num_blocks, - unsigned int *lba_lo, - unsigned int *lba_hi) +static inline void ps3_cdb_comp_and_write_parse(const U8 *cdb, + U32 *num_blocks, U32 *lba_lo, U32 *lba_hi) { - *lba_lo = ((unsigned int)cdb[6] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[7] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[8] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[9]; - *lba_hi = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[5]; - *num_blocks = (unsigned int)cdb[13]; + *lba_lo = ((U32)cdb[6] << PS3_SHIFT_3BYTE) | + ((U32)cdb[7] << PS3_SHIFT_WORD) | + ((U32) cdb[8] << PS3_SHIFT_BYTE) | (U32)cdb[9]; + *lba_hi = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | + ((U32)cdb[3] << PS3_SHIFT_WORD) | + ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; + *num_blocks = (U32)cdb[13]; } -static inline void ps3_scsih_service_16_parse(const unsigned char *cdb, - unsigned int *num_blocks, - unsigned int *lba_lo, - unsigned int *lba_hi) +static inline void ps3_scsih_service_16_parse(const U8 *cdb, + U32 *num_blocks, U32 *lba_lo, U32 *lba_hi) { - unsigned char cmd_type = cdb[1] & 0x1f; - + U8 cmd_type = cdb[1] & 0x1f; LOG_DEBUG("[ps3] CMD :0x%x!\n", cmd_type); switch (cmd_type) { case WRITE_LONG_16: - *lba_lo = ((unsigned int)cdb[6] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[7] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[8] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[9]; - *lba_hi = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[5]; + *lba_lo = ((U32)cdb[6] << PS3_SHIFT_3BYTE) | + ((U32)cdb[7] << PS3_SHIFT_WORD) | + ((U32) cdb[8] << PS3_SHIFT_BYTE) | (U32)cdb[9]; + *lba_hi = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | + ((U32)cdb[3] << PS3_SHIFT_WORD) | + ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; *num_blocks = 1; break; @@ -618,11 +564,11 @@ static inline void ps3_scsih_service_16_parse(const unsigned char *cdb, break; } + return; } -void ps3_scsih_cdb_parse(const unsigned char *cdb, unsigned int *num_blocks, - unsigned int *lba_lo, unsigned int *lba_hi, - unsigned char *is_need_split) +void ps3_scsih_cdb_parse(const U8 *cdb, U32 *num_blocks, + U32 *lba_lo, U32 *lba_hi, Bool *is_need_split) { *num_blocks = 0; *lba_lo = 0; @@ -640,7 +586,7 @@ void ps3_scsih_cdb_parse(const unsigned char *cdb, unsigned int *num_blocks, case WRITE_10: case WRITE_VERIFY: *is_need_split = PS3_TRUE; -#if defined(PS3_FALLTHROUGH) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) fallthrough; #endif case VERIFY: @@ -654,7 +600,7 @@ void ps3_scsih_cdb_parse(const unsigned char *cdb, unsigned int *num_blocks, case WRITE_12: case WRITE_VERIFY_12: *is_need_split = PS3_TRUE; -#if defined(PS3_FALLTHROUGH) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) fallthrough; #endif case VERIFY_12: @@ -665,7 +611,7 @@ void ps3_scsih_cdb_parse(const unsigned char *cdb, unsigned int *num_blocks, case WRITE_16: case PS3_WRITE_VERIFY_16: *is_need_split = PS3_TRUE; -#if defined(PS3_FALLTHROUGH) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) fallthrough; #endif case VERIFY_16: @@ -682,8 +628,7 @@ void ps3_scsih_cdb_parse(const unsigned char *cdb, unsigned int *num_blocks, break; case VARIABLE_LENGTH_CMD: - ps3_scsih_cdb_rw32_parse(cdb, num_blocks, lba_lo, lba_hi, - is_need_split); + ps3_scsih_cdb_rw32_parse(cdb, num_blocks, lba_lo, lba_hi, is_need_split); break; case COMPARE_AND_WRITE: @@ -692,16 +637,13 @@ void ps3_scsih_cdb_parse(const unsigned char *cdb, unsigned int *num_blocks, case WRITE_ATOMIC_16: case WRITE_STREAM_16: - *lba_lo = ((unsigned int)cdb[6] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[7] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[8] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[9]; - *lba_hi = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | - ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | - ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[5]; - *num_blocks = ((unsigned int)cdb[12] << PS3_SHIFT_BYTE) | - (unsigned int)cdb[13]; + *lba_lo = ((U32)cdb[6] << PS3_SHIFT_3BYTE) | + ((U32)cdb[7] << PS3_SHIFT_WORD) | + ((U32) cdb[8] << PS3_SHIFT_BYTE) | (U32)cdb[9]; + *lba_hi = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | + ((U32)cdb[3] << PS3_SHIFT_WORD) | + ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; + *num_blocks = ((U32)cdb[12] << PS3_SHIFT_BYTE) | (U32)cdb[13]; break; case WRITE_LONG: @@ -716,17 +658,14 @@ void ps3_scsih_cdb_parse(const unsigned char *cdb, unsigned int *num_blocks, break; } + return; } -static inline void ps3_convert_to_cdb16(unsigned char *cdb, - unsigned short cdb_len, - unsigned int num_blocks, - unsigned int lba_lo, - unsigned int lba_hi) +static inline void ps3_convert_to_cdb16(U8 *cdb, U16 cdb_len, U32 num_blocks, U32 lba_lo, U32 lba_hi) { - unsigned char opcode = 0; - unsigned char flagvals = 0; - unsigned char groupnum = 0; - unsigned char control = 0; + U8 opcode = 0; + U8 flagvals = 0; + U8 groupnum = 0; + U8 control = 0; switch (cdb_len) { case 6: @@ -734,13 +673,15 @@ static inline void ps3_convert_to_cdb16(unsigned char *cdb, control = cdb[5]; break; case 10: - opcode = cdb[0] == READ_10 ? READ_16 : WRITE_16; + opcode = + cdb[0] == READ_10 ? READ_16 : WRITE_16; flagvals = cdb[1]; groupnum = cdb[6]; control = cdb[9]; break; case 12: - opcode = cdb[0] == READ_12 ? READ_16 : WRITE_16; + opcode = + cdb[0] == READ_12 ? READ_16 : WRITE_16; flagvals = cdb[1]; groupnum = cdb[10]; control = cdb[11]; @@ -753,27 +694,26 @@ static inline void ps3_convert_to_cdb16(unsigned char *cdb, cdb[1] = flagvals; cdb[14] = groupnum; cdb[15] = control; - cdb[9] = (unsigned char)(lba_lo & 0xff); - cdb[8] = (unsigned char)((lba_lo >> PS3_SHIFT_BYTE) & 0xff); - cdb[7] = (unsigned char)((lba_lo >> PS3_SHIFT_WORD) & 0xff); - cdb[6] = (unsigned char)((lba_lo >> PS3_SHIFT_3BYTE) & 0xff); - cdb[5] = (unsigned char)(lba_hi & 0xff); - cdb[4] = (unsigned char)((lba_hi >> PS3_SHIFT_BYTE) & 0xff); - cdb[3] = (unsigned char)((lba_hi >> PS3_SHIFT_WORD) & 0xff); - cdb[2] = (unsigned char)((lba_hi >> PS3_SHIFT_3BYTE) & 0xff); - cdb[13] = (unsigned char)(num_blocks & 0xff); - cdb[12] = (unsigned char)((num_blocks >> PS3_SHIFT_BYTE) & 0xff); - cdb[11] = (unsigned char)((num_blocks >> PS3_SHIFT_WORD) & 0xff); - cdb[10] = (unsigned char)((num_blocks >> PS3_SHIFT_3BYTE) & 0xff); + + cdb[9] = (U8)(lba_lo & 0xff); + cdb[8] = (U8)((lba_lo >> PS3_SHIFT_BYTE) & 0xff); + cdb[7] = (U8)((lba_lo >> PS3_SHIFT_WORD) & 0xff); + cdb[6] = (U8)((lba_lo >> PS3_SHIFT_3BYTE) & 0xff); + cdb[5] = (U8)(lba_hi & 0xff); + cdb[4] = (U8)((lba_hi >> PS3_SHIFT_BYTE) & 0xff); + cdb[3] = (U8)((lba_hi >> PS3_SHIFT_WORD) & 0xff); + cdb[2] = (U8)((lba_hi >> PS3_SHIFT_3BYTE) & 0xff); + + cdb[13] = (U8)(num_blocks & 0xff); + cdb[12] = (U8)((num_blocks >> PS3_SHIFT_BYTE) & 0xff); + cdb[11] = (U8)((num_blocks >> PS3_SHIFT_WORD) & 0xff); + cdb[10] = (U8)((num_blocks >> PS3_SHIFT_3BYTE) & 0xff); } -void ps3_scsih_cdb_rebuild(unsigned char *cdb, unsigned short cdb_len, - unsigned int num_blocks, unsigned int lba_lo, - unsigned int lba_hi) +void ps3_scsih_cdb_rebuild(U8 *cdb, U16 cdb_len, U32 num_blocks, + U32 lba_lo, U32 lba_hi) { - if (unlikely((cdb_len < 16) && - (((unsigned long long)lba_hi << PS3_SHIFT_DWORD | lba_lo) > - 0xffffffff))) { + if (unlikely((cdb_len < 16) && (((U64)lba_hi << PS3_SHIFT_DWORD | lba_lo) > 0xffffffff))) { ps3_convert_to_cdb16(cdb, cdb_len, num_blocks, lba_lo, lba_hi); goto l_out; } @@ -781,7 +721,7 @@ void ps3_scsih_cdb_rebuild(unsigned char *cdb, unsigned short cdb_len, switch (cdb[0]) { case READ_6: case WRITE_6: - ps3_scsih_cdb_rw6_rebuild(cdb, num_blocks, lba_lo); + ps3_scsih_cdb_rw6_rebuild( cdb, num_blocks, lba_lo); break; case READ_10: @@ -791,14 +731,14 @@ void ps3_scsih_cdb_rebuild(unsigned char *cdb, unsigned short cdb_len, case WRITE_SAME: case PRE_FETCH: case SYNCHRONIZE_CACHE: - ps3_scsih_cdb_rw10_rebuild(cdb, num_blocks, lba_lo); + ps3_scsih_cdb_rw10_rebuild( cdb, num_blocks, lba_lo); break; case READ_12: case WRITE_12: case VERIFY_12: case WRITE_VERIFY_12: - ps3_scsih_cdb_rw12_rebuild(cdb, num_blocks, lba_lo); + ps3_scsih_cdb_rw12_rebuild( cdb, num_blocks, lba_lo); break; case READ_16: @@ -809,7 +749,7 @@ void ps3_scsih_cdb_rebuild(unsigned char *cdb, unsigned short cdb_len, case ORWRITE_16: case PRE_FETCH_16: case SYNCHRONIZE_CACHE_16: - ps3_scsih_cdb_rw16_rebuild(cdb, num_blocks, lba_lo, lba_hi); + ps3_scsih_cdb_rw16_rebuild( cdb, num_blocks, lba_lo, lba_hi); break; case VARIABLE_LENGTH_CMD: @@ -822,8 +762,7 @@ void ps3_scsih_cdb_rebuild(unsigned char *cdb, unsigned short cdb_len, case WRITE_ATOMIC_16: case WRITE_STREAM_16: - ps3_scsih_atomic_stream_16_rebuild(cdb, num_blocks, lba_lo, - lba_hi); + ps3_scsih_atomic_stream_16_rebuild(cdb, num_blocks, lba_lo, lba_hi); break; case WRITE_LONG: @@ -841,24 +780,25 @@ void ps3_scsih_cdb_rebuild(unsigned char *cdb, unsigned short cdb_len, return; } -void ps3_scsih_lba_parse(const unsigned char *cdb, unsigned long long *lba) +void ps3_scsih_lba_parse(const U8 *cdb, U64 *lba) { - unsigned int num_blocks = 0; - unsigned int lba_lo = 0; - unsigned int lba_hi = 0; - unsigned char is_need_split = PS3_FALSE; + U32 num_blocks = 0; + U32 lba_lo = 0; + U32 lba_hi = 0; + Bool is_need_split = PS3_FALSE; ps3_scsih_cdb_parse(cdb, &num_blocks, &lba_lo, &lba_hi, &is_need_split); - *lba = ((unsigned long long)lba_hi << PS3_SHIFT_DWORD) | lba_lo; + *lba = ((U64)lba_hi << PS3_SHIFT_DWORD) | lba_lo; } -void ps3_scsih_len_parse(const unsigned char *cdb, unsigned int *len) +void ps3_scsih_len_parse(const U8 *cdb, U32 *len) { - unsigned int num_blocks = 0; - unsigned int lba_lo = 0; - unsigned int lba_hi = 0; - unsigned char is_need_split = PS3_FALSE; + U32 num_blocks = 0; + U32 lba_lo = 0; + U32 lba_hi = 0; + Bool is_need_split = PS3_FALSE; ps3_scsih_cdb_parse(cdb, &num_blocks, &lba_lo, &lba_hi, &is_need_split); *len = num_blocks; } + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.h b/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.h index 808e979dd489..030005b50196 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.h @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ #ifndef _PS3_SCSIH_CMD_PARSE_H_ #define _PS3_SCSIH_CMD_PARSE_H_ @@ -12,53 +10,53 @@ #include #else -#define VARIABLE_LENGTH_CMD 0x7f -#define SYNCHRONIZE_CACHE_16 0x91 -#define SYNCHRONIZE_CACHE 0x35 - -#define FORMAT_UNIT 0x04 -#define REASSIGN_BLOCKS 0x07 -#define READ_6 0x08 -#define WRITE_6 0x0a -#define READ_10 0x28 -#define WRITE_10 0x2a -#define WRITE_VERIFY 0x2e -#define VERIFY 0x2f -#define PRE_FETCH 0x34 -#define SYNCHRONIZE_CACHE 0x35 -#define WRITE_LONG 0x3f -#define WRITE_SAME 0x41 -#define UNMAP 0x42 -#define VARIABLE_LENGTH_CMD 0x7f -#define READ_12 0xa8 -#define WRITE_12 0xaa -#define WRITE_VERIFY_12 0xae -#define VERIFY_12 0xaf -#define EXTENDED_COPY 0x83 -#define READ_16 0x88 -#define COMPARE_AND_WRITE 0x89 -#define WRITE_16 0x8a -#define WRITE_ATTRIBUTE 0x8d -#define PS3_WRITE_VERIFY_16 0x8e -#define VERIFY_16 0x8f -#define SYNCHRONIZE_CACHE_16 0x91 -#define WRITE_SAME_16 0x93 -#define SERVICE_ACTION_IN_16 0x9e +#define VARIABLE_LENGTH_CMD 0x7f +#define SYNCHRONIZE_CACHE_16 0x91 +#define SYNCHRONIZE_CACHE 0x35 + +#define FORMAT_UNIT 0x04 +#define REASSIGN_BLOCKS 0x07 +#define READ_6 0x08 +#define WRITE_6 0x0a +#define READ_10 0x28 +#define WRITE_10 0x2a +#define WRITE_VERIFY 0x2e +#define VERIFY 0x2f +#define PRE_FETCH 0x34 +#define SYNCHRONIZE_CACHE 0x35 +#define WRITE_LONG 0x3f +#define WRITE_SAME 0x41 +#define UNMAP 0x42 +#define VARIABLE_LENGTH_CMD 0x7f +#define READ_12 0xa8 +#define WRITE_12 0xaa +#define WRITE_VERIFY_12 0xae +#define VERIFY_12 0xaf +#define EXTENDED_COPY 0x83 +#define READ_16 0x88 +#define COMPARE_AND_WRITE 0x89 +#define WRITE_16 0x8a +#define WRITE_ATTRIBUTE 0x8d +#define PS3_WRITE_VERIFY_16 0x8e +#define VERIFY_16 0x8f +#define SYNCHRONIZE_CACHE_16 0x91 +#define WRITE_SAME_16 0x93 +#define SERVICE_ACTION_IN_16 0x9e #define SERVICE_ACTION_OUT_16 0x9f -#define READ_32 0x09 -#define VERIFY_32 0x0a -#define WRITE_32 0x0b -#define PS3_WRITE_VERIFY_32 0x0c -#define WRITE_SAME_32 0x0d +#define READ_32 0x09 +#define VERIFY_32 0x0a +#define WRITE_32 0x0b +#define PS3_WRITE_VERIFY_32 0x0c +#define WRITE_SAME_32 0x0d #endif -#define PS3_SCSI_CONFLICT_CHECK 0x80 -#define PS3_SCSI_CONFLICT_CHECK_TEST(type) ((type)&PS3_SCSI_CONFLICT_CHECK) -#define PS3_SCSI_CMD_TYPE(type) ((type)&0x7F) +#define PS3_SCSI_CONFLICT_CHECK 0x80 +#define PS3_SCSI_CONFLICT_CHECK_TEST(type) ((type) & PS3_SCSI_CONFLICT_CHECK) +#define PS3_SCSI_CMD_TYPE(type) ((type) & 0x7F) enum ps3_scsi_cmd_type { - PS3_SCSI_CMD_TYPE_UNKNOWN, + PS3_SCSI_CMD_TYPE_UNKOWN, PS3_SCSI_CMD_TYPE_READ, PS3_SCSI_CMD_TYPE_WRITE, PS3_SCSI_CMD_TYPE_RW, @@ -69,7 +67,7 @@ enum ps3_scsi_cmd_type { enum { PS3_ATA_OPC_READ_FPDMA = 0x60, - PS3_ATA_OPC_WRITE_FPDMA = 0x61, + PS3_ATA_OPC_WRITE_FPDMA =0x61, PS3_SATA_DEV_REG_DEFAULT = 0x40, PS3_NCQ_FUA_OFFSET_IN_DEVICE_REG = 7, }; @@ -77,19 +75,17 @@ enum { #define PS3_SERVICE_ACTION32(cdb) (*(cdb + 9) | (*(cdb + 8) << PS3_SHIFT_BYTE)) #define PS3_SERVICE_ACTION16_TO_OPCODE(cdb) (*(cdb + 1) & 0x1f) -static inline void ps3_scsih_cdb_opcode_get(const unsigned char *cdb, - unsigned char *opcode, - unsigned short *sub_opcode) +static inline void ps3_scsih_cdb_opcode_get(const U8 *cdb, + U8 *opcode, U16 *sub_opcode) { *opcode = cdb[0]; - switch (cdb[0]) { + switch(cdb[0]) { case VARIABLE_LENGTH_CMD: *sub_opcode = PS3_SERVICE_ACTION32(cdb); break; case SERVICE_ACTION_IN_16: case SERVICE_ACTION_OUT_16: - *sub_opcode = - (unsigned short)PS3_SERVICE_ACTION16_TO_OPCODE(cdb); + *sub_opcode = (U16)PS3_SERVICE_ACTION16_TO_OPCODE(cdb); break; default: *sub_opcode = 0; @@ -98,35 +94,34 @@ static inline void ps3_scsih_cdb_opcode_get(const unsigned char *cdb, } #ifndef U32_HIGH_LOW_TO_U64 -#define U32_HIGH_LOW_TO_U64(u64_high, u64_low) \ - (((unsigned long long)(u64_high) << 32) | (u64_low)) +#define U32_HIGH_LOW_TO_U64(u64_high, u64_low) \ + (((U64)(u64_high) << 32) | (u64_low)) #endif -unsigned char ps3_scsih_is_rw_type(unsigned char type); +Bool ps3_scsih_is_rw_type(U8 type); -unsigned char ps3_scsih_cdb_rw_type_get(const unsigned char *cdb); +U8 ps3_scsih_cdb_rw_type_get(const U8 *cdb); -void ps3_scsih_cdb_parse(const unsigned char *cdb, unsigned int *num_blocks, - unsigned int *lba_lo, unsigned int *lba_hi, - unsigned char *is_need_split); +void ps3_scsih_cdb_parse(const U8 *cdb, U32 *num_blocks, + U32 *lba_lo, U32 *lba_hi, Bool *is_need_split); -static inline unsigned char ps3_scsih_cdb_is_rw_cmd(const unsigned char *cdb) +static inline Bool ps3_scsih_cdb_is_rw_cmd(const U8 *cdb) { - unsigned char type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); - + U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); return ps3_scsih_is_rw_type(type); } -static inline unsigned char ps3_scsih_is_read_cmd(unsigned char type) +static inline Bool ps3_scsih_is_read_cmd(U8 type) { return (type == PS3_SCSI_CMD_TYPE_READ); } -static inline unsigned char ps3_scsih_is_write_cmd(unsigned char type) +static inline Bool ps3_scsih_is_write_cmd(U8 type) { - unsigned char ret = PS3_FALSE; + Bool ret = PS3_FALSE; - switch (type) { + switch (type) + { case PS3_SCSI_CMD_TYPE_WRITE: case PS3_SCSI_CMD_TYPE_UNMAP: case PS3_SCSI_CMD_TYPE_RW: @@ -139,58 +134,50 @@ static inline unsigned char ps3_scsih_is_write_cmd(unsigned char type) l_out: return ret; } -static inline unsigned char ps3_scsih_is_sync_cache(const unsigned char *cdb) +static inline Bool ps3_scsih_is_sync_cache(const U8 *cdb) { return cdb[0] == SYNCHRONIZE_CACHE || cdb[0] == SYNCHRONIZE_CACHE_16; } -void ps3_scsih_lba_parse(const unsigned char *cdb, unsigned long long *lba); +void ps3_scsih_lba_parse(const U8 *cdb, U64 *lba); -void ps3_scsih_len_parse(const unsigned char *cdb, unsigned int *len); +void ps3_scsih_len_parse(const U8 *cdb, U32 *len); -int ps3_scsih_cdb_opts_parse(struct ps3_cmd *cmd); +S32 ps3_scsih_cdb_opts_parse(struct ps3_cmd *cmd); -void ps3_scsih_cdb_rebuild(unsigned char *cdb, unsigned short cdb_len, - unsigned int num_blocks, unsigned int lba_lo, - unsigned int lba_hi); +void ps3_scsih_cdb_rebuild(U8 *cdb, U16 cdb_len, U32 num_blocks, U32 lba_lo, U32 lba_hi); -static inline unsigned char ps3_scsih_cdb_is_read_cmd(const unsigned char *cdb) +static inline Bool ps3_scsih_cdb_is_read_cmd(const U8 *cdb) { - unsigned char type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); - + U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); return ps3_scsih_is_read_cmd(type); } -static inline unsigned char ps3_scsih_cdb_is_write_cmd(const unsigned char *cdb) +static inline Bool ps3_scsih_cdb_is_write_cmd(const U8 *cdb) { - unsigned char type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); - + U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); return ps3_scsih_is_write_cmd(type); } -unsigned char ps3_scsih_is_protocal_rw(const unsigned char *cdb); +Bool ps3_scsih_is_protocal_rw(const U8 *cdb); -unsigned char ps3_scsih_rw_cmd_is_need_split_hba(struct ps3_cmd *cmd); +Bool ps3_scsih_rw_cmd_is_need_split_hba(struct ps3_cmd *cmd); -unsigned char ps3_scsih_rw_cmd_is_need_split_raid(struct ps3_cmd *cmd); +Bool ps3_scsih_rw_cmd_is_need_split_raid(struct ps3_cmd *cmd); -static inline void ps3_scsih_unmap_desc_parse(const unsigned char *desc, - unsigned int *num_blocks, - unsigned int *lba_lo, - unsigned int *lba_hi) +static inline void ps3_scsih_unmap_desc_parse(const U8 *desc, U32 *num_blocks, + U32 *lba_lo, U32 *lba_hi) { - *lba_lo = ((unsigned int)desc[4] << PS3_SHIFT_3BYTE) | - ((unsigned int)desc[5] << PS3_SHIFT_WORD) | - ((unsigned int)desc[6] << PS3_SHIFT_BYTE) | - (unsigned int)desc[7]; - *lba_hi = ((unsigned int)desc[0] << PS3_SHIFT_3BYTE) | - ((unsigned int)desc[1] << PS3_SHIFT_WORD) | - ((unsigned int)desc[2] << PS3_SHIFT_BYTE) | - (unsigned int)desc[3]; - *num_blocks = ((unsigned int)desc[8] << PS3_SHIFT_3BYTE) | - ((unsigned int)desc[9] << PS3_SHIFT_WORD) | - ((unsigned int)desc[10] << PS3_SHIFT_BYTE) | - (unsigned int)desc[11]; + *lba_lo = ((U32)desc[4] << PS3_SHIFT_3BYTE) | + ((U32)desc[5] << PS3_SHIFT_WORD) | + ((U32) desc[6] << PS3_SHIFT_BYTE) | (U32)desc[7]; + *lba_hi = ((U32)desc[0] << PS3_SHIFT_3BYTE) | + ((U32)desc[1] << PS3_SHIFT_WORD) | + ((U32)desc[2] << PS3_SHIFT_BYTE) | (U32)desc[3]; + *num_blocks = ((U32)desc[8] << PS3_SHIFT_3BYTE) | + ((U32)desc[9] << PS3_SHIFT_WORD) | + ((U32)desc[10] << PS3_SHIFT_BYTE) | (U32)desc[11]; + return; } #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.c b/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.c index 8dd14dcf114a..6a1feaf7b74b 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.c @@ -1,6 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ -#ifndef _WINDOWS + +#ifndef _WINDOWS #include #include #else @@ -9,40 +8,36 @@ #include "ps3_scsih_raid_engine.h" #include "ps3_instance_manager.h" -#include "ps3_htp_meta.h" +#include "ps3_meta.h" #include "ps3_scsih_cmd_parse.h" #include "ps3_driver_log.h" #include "ps3_util.h" #include "ps3_module_para.h" #include "ps3_scsih.h" -#define LBA_TO_STRIPE_INDEX(u64_lba, u32_stripe_data_size, u64_stripe_idx) \ - ((u64_stripe_idx) = (PS3_DIV64_32((u64_lba), (u32_stripe_data_size)))) +#define LBA_TO_STRIPE_INDEX(u64_lba, u32_stripe_data_size, u64_stripe_idx) \ + (u64_stripe_idx) = (u64_lba) / (u32_stripe_data_size) #define LBA_TO_STRIPE_OFFSET(u64_lba, u32_stripe_data_size, u32_stripe_offset) \ - ((u32_stripe_offset) = (PS3_MOD64((u64_lba), (u32_stripe_data_size)))) - -#define SPANNO_DISKIDX_TO_PHYDISKID(vd_entry, span_idx, span_disk_idx) \ - ((vd_entry) \ - ->span[(span_idx)] \ - .extent[(span_disk_idx)] \ - .phyDiskID.ps3Dev.phyDiskID) - -#define VD_SPAN_PD_NUM(vd_entry, span_idx) \ - ((vd_entry)->span[(span_idx)].spanPdNum) - -#define STRIP_SIZE_MASK(strip_size) ((strip_size)-1) - -#define RAID660_GET_PQ_SPINDLENO(stripe_idx, phy_disk_count, q_disk_idx) \ - do { \ - if (ps3_is_power_of_2(phy_disk_count)) { \ - (q_disk_idx) = (stripe_idx) & ((phy_disk_count)-1); \ - } else { \ - (q_disk_idx) = \ - PS3_MOD64((stripe_idx), (phy_disk_count)); \ - } \ - (q_disk_idx) = (phy_disk_count) - (q_disk_idx)-1; \ - } while (0) + (u32_stripe_offset) = (u64_lba) % (u32_stripe_data_size) + +#define SPANNO_DISKIDX_TO_PHYDISKID(vd_entry, span_idx, span_disk_idx) \ + (vd_entry)->span[(span_idx)].extent[(span_disk_idx)].phyDiskID.ps3Dev.phyDiskID + +#define VD_SPAN_PD_NUM(vd_entry, span_idx) \ + (vd_entry)->span[(span_idx)].spanPdNum + +#define STRIP_SIZE_MASK(strip_size) ((strip_size) - 1) + +#define RAID660_GET_PQ_SPINDLENO(stripe_idx, phy_disk_count, q_disk_idx) \ +do { \ + if (ps3_is_power_of_2(phy_disk_count)){ \ + (q_disk_idx) = (stripe_idx) & ((phy_disk_count) - 1); \ + } else { \ + (q_disk_idx) = (stripe_idx) % (phy_disk_count); \ + } \ + (q_disk_idx) = (phy_disk_count) - (q_disk_idx) - 1; \ +} while (0); #define PS3_R1X_HDD_MAX_SWAP_CNT_1 (64) #define PS3_R1X_HDD_MAX_SWAP_CNT_2 (32) @@ -50,20 +45,19 @@ #define PS3_R1X_SSD_MAX_SWAP_CNT_2 (16) #define PS3_R1X_SWAP_VD_MEMBER_CNT (8) #define PS3_R1X_RB_DIFF_CMDS_DEFAULT (4) -#define ABS_DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) -#define PS3_R1X_RB_INFO_INDEX(span, span_disk_idx) \ - ((span) * PS3_MAX_PD_COUNT_IN_SPAN + (span_disk_idx) + 1) -unsigned int g_ps3_r1x_rb_diff_cmds = PS3_R1X_RB_DIFF_CMDS_DEFAULT; +#define ABS_DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) +#define PS3_R1X_RB_INFO_INDEX(span, span_disk_idx) \ + ((span) * PS3_MAX_PD_COUNT_IN_SPAN + (span_disk_idx) + 1) +U32 g_ps3_r1x_rb_diff_cmds = PS3_R1X_RB_DIFF_CMDS_DEFAULT; -static inline unsigned char ps3_is_power_of_2(unsigned int n) +static inline Bool ps3_is_power_of_2(U32 n) { - return (unsigned char)(n != 0 && ((n & (n - 1)) == 0)); + return (Bool)(n != 0 && ((n & (n - 1)) == 0)); } -static inline unsigned char -ps3_vd_entry_valid_check(const struct PS3VDEntry *vd_entry) +static inline Bool ps3_vd_entry_valid_check(const struct PS3VDEntry *vd_entry) { - unsigned char ret = PS3_DRV_TRUE; + Bool ret = PS3_DRV_TRUE; if (unlikely(vd_entry == NULL)) { ret = PS3_DRV_FALSE; @@ -83,156 +77,133 @@ ps3_vd_entry_valid_check(const struct PS3VDEntry *vd_entry) return ret; } -unsigned char ps3_scsih_is_same_strip(const struct PS3VDEntry *vd_entry, - unsigned int vlba_lo, - unsigned int lba_length) +Bool ps3_scsih_is_same_strip(const struct PS3VDEntry *vd_entry, U32 vlba_lo, U32 lba_length) { - if (unlikely(!ps3_vd_entry_valid_check(vd_entry))) + if (unlikely(!ps3_vd_entry_valid_check(vd_entry))) { return PS3_DRV_FALSE; + } - if ((vd_entry->stripSize - - (vlba_lo & STRIP_SIZE_MASK(vd_entry->stripSize))) >= lba_length) { + if ( (vd_entry->stripSize - (vlba_lo & STRIP_SIZE_MASK(vd_entry->stripSize)) ) + >= lba_length ) { return PS3_DRV_TRUE; - } else { + } else { return PS3_DRV_FALSE; } } static void ps3_r0_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; - cmd->io_attr.plba = - vd_entry->startLBA + (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = vd_entry->startLBA + + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); cmd->io_attr.span_idx = 0; - cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; + cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; } -static void ps3_r1x_rand_read_target_pd_calc(struct ps3_cmd *cmd, - unsigned int span_idx, - unsigned int span_pd_idx, - unsigned int span_pd_back_idx) +static void ps3_r1x_rand_read_target_pd_calc(struct ps3_cmd *cmd, U32 span_idx, + U32 span_pd_idx, U32 span_pd_back_idx) { struct ps3_r1x_read_balance_info *rb_info = NULL; struct ps3_scsi_priv_data *priv_data = NULL; - unsigned long long vlba = 0; - unsigned int outstanding0 = 0; - unsigned int outstanding1 = 0; - unsigned long long diff0 = 0; - unsigned long long diff1 = 0; - unsigned int pd0 = 0; - unsigned int pd1 = 0; - unsigned int target_pd = 0; + U64 vlba = 0; + U32 outstanding0 = 0; + U32 outstanding1 = 0; + U64 diff0 = 0; + U64 diff1 = 0; + U32 pd0 = 0; + U32 pd1 = 0; + U32 target_pd = 0; if (!cmd->r1x_read_pd) { priv_data = scsi_device_private_data(cmd->scmd); rb_info = priv_data->r1x_rb_info; - vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, - cmd->io_attr.lba_lo); + vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); pd0 = PS3_R1X_RB_INFO_INDEX(span_idx, span_pd_idx); pd1 = PS3_R1X_RB_INFO_INDEX(span_idx, span_pd_back_idx); - outstanding0 = - ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd0]); - outstanding1 = - ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd1]); + outstanding0 = ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd0]); + outstanding1 = ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd1]); if (outstanding0 > outstanding1 + g_ps3_r1x_rb_diff_cmds) { target_pd = pd1; - } else if (outstanding1 > - outstanding0 + g_ps3_r1x_rb_diff_cmds) { + } else if (outstanding1 > outstanding0 + g_ps3_r1x_rb_diff_cmds) { target_pd = pd0; } else { - diff0 = ABS_DIFF(vlba, - rb_info->last_accessed_block[pd0]); - diff1 = ABS_DIFF(vlba, - rb_info->last_accessed_block[pd1]); + diff0 = ABS_DIFF(vlba, rb_info->last_accessed_block[pd0]); + diff1 = ABS_DIFF(vlba, rb_info->last_accessed_block[pd1]); target_pd = (diff0 <= diff1 ? pd0 : pd1); } if (target_pd == pd0) { - cmd->io_attr.span_pd_idx = (unsigned char)span_pd_idx; - cmd->io_attr.span_pd_idx_p = - (unsigned char)span_pd_back_idx; + cmd->io_attr.span_pd_idx = (U8)span_pd_idx; + cmd->io_attr.span_pd_idx_p = (U8)span_pd_back_idx; } else { - cmd->io_attr.span_pd_idx = - (unsigned char)span_pd_back_idx; - cmd->io_attr.span_pd_idx_p = (unsigned char)span_pd_idx; + cmd->io_attr.span_pd_idx = (U8)span_pd_back_idx; + cmd->io_attr.span_pd_idx_p = (U8)span_pd_idx; } cmd->r1x_read_pd = target_pd; - rb_info->last_accessed_block[target_pd] = - vlba + cmd->io_attr.num_blocks; + rb_info->last_accessed_block[target_pd] = vlba + cmd->io_attr.num_blocks; ps3_atomic_inc(&rb_info->scsi_outstanding_cmds[target_pd]); } } -static void ps3_r1x_seq_read_target_pd_calc(struct ps3_cmd *cmd, - unsigned int span_idx, - unsigned int span_pd_idx, - unsigned int span_pd_back_idx) +static void ps3_r1x_seq_read_target_pd_calc(struct ps3_cmd *cmd, U32 span_idx, + U32 span_pd_idx, U32 span_pd_back_idx) { struct ps3_r1x_read_balance_info *rb_info = NULL; struct ps3_scsi_priv_data *priv_data = NULL; - unsigned long long vlba = 0; - unsigned int outstanding0 = 0; - unsigned int outstanding1 = 0; - unsigned long long diff0 = 0; - unsigned long long diff1 = 0; - unsigned int pd0 = 0; - unsigned int pd1 = 0; - unsigned int target_pd = 0; + U64 vlba = 0; + U32 outstanding0 = 0; + U32 outstanding1 = 0; + U64 diff0 = 0; + U64 diff1 = 0; + U32 pd0 = 0; + U32 pd1 = 0; + U32 target_pd = 0; if (!cmd->r1x_read_pd) { priv_data = scsi_device_private_data(cmd->scmd); rb_info = priv_data->r1x_rb_info; - vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, - cmd->io_attr.lba_lo); + vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); pd0 = PS3_R1X_RB_INFO_INDEX(span_idx, span_pd_idx); pd1 = PS3_R1X_RB_INFO_INDEX(span_idx, span_pd_back_idx); - outstanding0 = - ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd0]); - outstanding1 = - ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd1]); + outstanding0 = ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd0]); + outstanding1 = ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd1]); - if (outstanding0 == 0 && outstanding1 != 0) { + if (outstanding0 == 0 && outstanding1 != 0) { target_pd = pd0; } else if (outstanding0 != 0 && outstanding1 == 0) { target_pd = pd1; } else { - diff0 = ABS_DIFF(vlba, - rb_info->last_accessed_block[pd0]); - diff1 = ABS_DIFF(vlba, - rb_info->last_accessed_block[pd1]); + diff0 = ABS_DIFF(vlba, rb_info->last_accessed_block[pd0]); + diff1 = ABS_DIFF(vlba, rb_info->last_accessed_block[pd1]); target_pd = (diff0 <= diff1 ? pd0 : pd1); } if (target_pd == pd0) { - cmd->io_attr.span_pd_idx = (unsigned char)span_pd_idx; - cmd->io_attr.span_pd_idx_p = - (unsigned char)span_pd_back_idx; + cmd->io_attr.span_pd_idx = (U8)span_pd_idx; + cmd->io_attr.span_pd_idx_p = (U8)span_pd_back_idx; } else { - cmd->io_attr.span_pd_idx = - (unsigned char)span_pd_back_idx; - cmd->io_attr.span_pd_idx_p = (unsigned char)span_pd_idx; + cmd->io_attr.span_pd_idx = (U8)span_pd_back_idx; + cmd->io_attr.span_pd_idx_p = (U8)span_pd_idx; } cmd->r1x_read_pd = target_pd; - rb_info->last_accessed_block[target_pd] = - vlba + cmd->io_attr.num_blocks; + rb_info->last_accessed_block[target_pd] = vlba + cmd->io_attr.num_blocks; ps3_atomic_inc(&rb_info->scsi_outstanding_cmds[target_pd]); } } @@ -240,39 +211,36 @@ static void ps3_r1x_seq_read_target_pd_calc(struct ps3_cmd *cmd, static void ps3_r1_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); cmd->io_attr.plba = vd_entry->startLBA + vlba; cmd->io_attr.span_idx = 0; cmd->io_attr.plba_back = cmd->io_attr.plba; if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - if (cmd->io_attr.seq_flag == SCSI_RW_RANDOM_CMD) + if (cmd->io_attr.seq_flag == SCSI_RW_RANDOM_CMD) { ps3_r1x_rand_read_target_pd_calc(cmd, 0, 0, 1); - else + } else { ps3_r1x_seq_read_target_pd_calc(cmd, 0, 0, 1); + } } else { cmd->io_attr.span_pd_idx = 0; cmd->io_attr.span_pd_idx_p = 1; } - LOG_DEBUG( - "hno:%u chl:%u id:%u rw=%u, span_pd_idx=%u, span_pd_idx_p=%u\n", - PS3_HOST(cmd->instance), cmd->scmd->device->channel, - cmd->scmd->device->id, cmd->io_attr.rw_flag, - cmd->io_attr.span_pd_idx, cmd->io_attr.span_pd_idx_p); + LOG_DEBUG("hno:%u chl:%u id:%u rw=%u, span_pd_idx=%u, span_pd_idx_p=%u\n", + PS3_HOST(cmd->instance), cmd->scmd->device->channel, cmd->scmd->device->id, + cmd->io_attr.rw_flag, cmd->io_attr.span_pd_idx, cmd->io_attr.span_pd_idx_p); } static void ps3_r5_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_parity_disk_idx = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_parity_disk_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -280,227 +248,209 @@ static void ps3_r5_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) if (ps3_is_power_of_2(vd_entry->physDrvCnt)) { span_parity_disk_idx = stripe_idx & (vd_entry->physDrvCnt - 1); } else { - span_parity_disk_idx = - PS3_MOD64(stripe_idx, vd_entry->physDrvCnt); + span_parity_disk_idx = stripe_idx % vd_entry->physDrvCnt; } span_parity_disk_idx = vd_entry->physDrvCnt - span_parity_disk_idx - 1; - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_parity_disk_idx + span_data_disk_idx + 1; - if (span_data_disk_idx >= vd_entry->physDrvCnt) + if ( span_data_disk_idx >= vd_entry->physDrvCnt) { span_data_disk_idx -= vd_entry->physDrvCnt; + } - cmd->io_attr.plba = - vd_entry->startLBA + (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = vd_entry->startLBA + + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); cmd->io_attr.span_idx = 0; - cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; - cmd->io_attr.span_pd_idx_p = (unsigned char)span_parity_disk_idx; - LOG_DEBUG("vlba:0x%llx plba:0x%llx startLBA:0x%llx stripe_idx:%llu\n" - "\tstrip_size_shift:%u stripe_offset:%u span_pd_indx:%u\n", - vlba, cmd->io_attr.plba, vd_entry->startLBA, stripe_idx, - strip_size_shift, stripe_offset, cmd->io_attr.span_pd_idx); + cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; + cmd->io_attr.span_pd_idx_p = (U8)span_parity_disk_idx; + LOG_DEBUG("vlba:0x%llx plba:0x%llx startLBA:0x%llx stripe_idx:%llu" + "strip_size_shift:%u stripe_offset:%u span_pd_indx:%u\n", + vlba, cmd->io_attr.plba, vd_entry->startLBA, stripe_idx, + strip_size_shift, stripe_offset, cmd->io_attr.span_pd_idx); } static void ps3_r6_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_q_disk_idx = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_q_disk_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); - RAID660_GET_PQ_SPINDLENO(stripe_idx, vd_entry->physDrvCnt, - span_q_disk_idx); + RAID660_GET_PQ_SPINDLENO(stripe_idx, vd_entry->physDrvCnt, span_q_disk_idx); - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx + span_q_disk_idx + 1; - if (span_data_disk_idx >= vd_entry->physDrvCnt) + if ( span_data_disk_idx >= vd_entry->physDrvCnt) { span_data_disk_idx -= vd_entry->physDrvCnt; + } - cmd->io_attr.plba = - vd_entry->startLBA + (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = vd_entry->startLBA + + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); cmd->io_attr.span_idx = 0; - cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; - cmd->io_attr.span_pd_idx_q = (unsigned char)span_q_disk_idx; - if (span_q_disk_idx != 0) + cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; + cmd->io_attr.span_pd_idx_q = (U8)span_q_disk_idx; + if(0 != span_q_disk_idx){ cmd->io_attr.span_pd_idx_p = span_q_disk_idx - 1; - else + } else{ cmd->io_attr.span_pd_idx_p = vd_entry->physDrvCnt - 1; - + } } static void ps3_r10_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_data_disk_back_idx = 0; - unsigned int span_idx = 0; - unsigned char span_pd_num = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_data_disk_back_idx = 0; + U32 span_idx = 0; + U8 span_pd_num = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); - while (stripe_offset >= vd_entry->span[span_idx].spanStripeDataSize) { + while(stripe_offset >= vd_entry->span[span_idx].spanStripeDataSize) { stripe_offset -= vd_entry->span[span_idx].spanStripeDataSize; span_idx++; } - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx << 1; span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); - if (span_data_disk_idx > span_pd_num) { + if ( span_data_disk_idx > span_pd_num ) { span_data_disk_idx -= span_pd_num; span_data_disk_back_idx = - ((span_data_disk_idx + 1) == span_pd_num) ? - 0 : - (span_data_disk_idx + 1); + ((span_data_disk_idx+1) == span_pd_num)? + 0 :(span_data_disk_idx+1); stripe_idx = (stripe_idx << 1) + 1; } else { if (span_pd_num & 1) { stripe_idx = stripe_idx << 1; span_data_disk_back_idx = - ((span_data_disk_idx + 1) == span_pd_num) ? - 0 : - (span_data_disk_idx + 1); + ((span_data_disk_idx+1) == span_pd_num)? + 0 :(span_data_disk_idx+1); } else { span_data_disk_back_idx = span_data_disk_idx + 1; } } - cmd->io_attr.plba = - vd_entry->startLBA + (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = vd_entry->startLBA + + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); cmd->io_attr.plba_back = cmd->io_attr.plba; - if (span_data_disk_back_idx == 0) + if (span_data_disk_back_idx == 0) { cmd->io_attr.plba_back += vd_entry->stripSize; - cmd->io_attr.span_idx = (unsigned char)span_idx; + } + cmd->io_attr.span_idx = (U8)span_idx; if (!(span_pd_num & 1) && ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { if (cmd->io_attr.seq_flag == SCSI_RW_RANDOM_CMD) { - ps3_r1x_rand_read_target_pd_calc( - cmd, span_idx, span_data_disk_idx, - span_data_disk_back_idx); + ps3_r1x_rand_read_target_pd_calc(cmd, span_idx, + span_data_disk_idx, span_data_disk_back_idx); } else { - ps3_r1x_seq_read_target_pd_calc( - cmd, span_idx, span_data_disk_idx, - span_data_disk_back_idx); + ps3_r1x_seq_read_target_pd_calc(cmd, span_idx, + span_data_disk_idx, span_data_disk_back_idx); } } else { - cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; - cmd->io_attr.span_pd_idx_p = - (unsigned char)span_data_disk_back_idx; + cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; + cmd->io_attr.span_pd_idx_p = (U8)span_data_disk_back_idx; } - LOG_DEBUG( - "hno:%u tid:0x%llx chl:%u id:%u\n" - "\todd physDrvCnt:%d rw=%u span_pd_idx=%u-plba:0x%llx\n" - "\tspan_pd_idx_p=%u-bplba:0x%llx stripe_offset=0x%x\n", + LOG_DEBUG("hno:%u tid:0x%llx chl:%u id:%u " + "odd physDrvCnt:%d rw=%u span_pd_idx=%u-plba:0x%llx span_pd_idx_p=%u-bplba:0x%llx stripe_offset=0x%x\n", PS3_HOST(cmd->instance), cmd->trace_id, cmd->scmd->device->channel, cmd->scmd->device->id, - vd_entry->physDrvCnt & 1, cmd->io_attr.rw_flag, - cmd->io_attr.span_pd_idx, cmd->io_attr.plba, - cmd->io_attr.span_pd_idx_p, cmd->io_attr.plba_back, - stripe_offset); + vd_entry->physDrvCnt & 1, + cmd->io_attr.rw_flag, cmd->io_attr.span_pd_idx, + cmd->io_attr.plba, cmd->io_attr.span_pd_idx_p, + cmd->io_attr.plba_back, stripe_offset); } static void ps3_r1e_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_data_disk_back_idx = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_data_disk_back_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx << 1; - if (span_data_disk_idx > vd_entry->physDrvCnt) { + if ( span_data_disk_idx > vd_entry->physDrvCnt ) { span_data_disk_idx -= vd_entry->physDrvCnt; span_data_disk_back_idx = - ((span_data_disk_idx + 1) == vd_entry->physDrvCnt) ? - 0 : - (span_data_disk_idx + 1); + ((span_data_disk_idx+1) == vd_entry->physDrvCnt)? + 0 :(span_data_disk_idx+1) ; stripe_idx = (stripe_idx << 1) + 1; } else { if (vd_entry->physDrvCnt & 1) { stripe_idx = stripe_idx << 1; span_data_disk_back_idx = - ((span_data_disk_idx + 1) == - vd_entry->physDrvCnt) ? - 0 : - (span_data_disk_idx + 1); + ((span_data_disk_idx+1) == vd_entry->physDrvCnt)? + 0 :(span_data_disk_idx+1) ; } else { span_data_disk_back_idx = span_data_disk_idx + 1; } } - cmd->io_attr.plba = - vd_entry->startLBA + (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = vd_entry->startLBA + + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); cmd->io_attr.plba_back = cmd->io_attr.plba; - if (span_data_disk_back_idx == 0) + if (span_data_disk_back_idx == 0) { cmd->io_attr.plba_back += vd_entry->stripSize; + } cmd->io_attr.span_idx = 0; - if (!(vd_entry->physDrvCnt & 1) && - ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { + if (!(vd_entry->physDrvCnt & 1) && ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { if (cmd->io_attr.seq_flag == SCSI_RW_RANDOM_CMD) { - ps3_r1x_rand_read_target_pd_calc( - cmd, 0, span_data_disk_idx, - span_data_disk_back_idx); + ps3_r1x_rand_read_target_pd_calc(cmd, 0, span_data_disk_idx, span_data_disk_back_idx); } else { - ps3_r1x_seq_read_target_pd_calc( - cmd, 0, span_data_disk_idx, - span_data_disk_back_idx); + ps3_r1x_seq_read_target_pd_calc(cmd, 0, span_data_disk_idx, span_data_disk_back_idx); } } else { - cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; - cmd->io_attr.span_pd_idx_p = - (unsigned char)span_data_disk_back_idx; + cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; + cmd->io_attr.span_pd_idx_p = (U8)span_data_disk_back_idx; } - LOG_DEBUG("hno:%u chl:%u id:%u odd physDrvCnt:%d rw=%u, span_pd_idx=%u, span_pd_idx_p=%u\n", - PS3_HOST(cmd->instance), cmd->scmd->device->channel, - cmd->scmd->device->id, vd_entry->physDrvCnt & 1, - cmd->io_attr.rw_flag, cmd->io_attr.span_pd_idx, - cmd->io_attr.span_pd_idx_p); + LOG_DEBUG("hno:%u chl:%u id:%u " + "odd physDrvCnt:%d rw=%u, span_pd_idx=%u, span_pd_idx_p=%u\n", + PS3_HOST(cmd->instance), cmd->scmd->device->channel, cmd->scmd->device->id, + vd_entry->physDrvCnt & 1, cmd->io_attr.rw_flag, + cmd->io_attr.span_pd_idx, cmd->io_attr.span_pd_idx_p); } static void ps3_r00_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_idx = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -510,28 +460,27 @@ static void ps3_r00_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) span_idx++; } - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; - cmd->io_attr.plba = - vd_entry->startLBA + (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = vd_entry->startLBA + + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); - cmd->io_attr.span_idx = (unsigned char)span_idx; - cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; + cmd->io_attr.span_idx = (U8)span_idx; + cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; } static void ps3_r50_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_parity_disk_idx = 0; - unsigned int span_idx = 0; - unsigned char span_pd_num = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_parity_disk_idx = 0; + U32 span_idx = 0; + U8 span_pd_num = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -542,39 +491,39 @@ static void ps3_r50_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) } span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); - if (ps3_is_power_of_2(span_pd_num)) + if (ps3_is_power_of_2(span_pd_num)) { span_parity_disk_idx = stripe_idx & (span_pd_num - 1); - else - span_parity_disk_idx = PS3_MOD64(stripe_idx, span_pd_num); - + } else { + span_parity_disk_idx = stripe_idx % span_pd_num; + } span_parity_disk_idx = span_pd_num - span_parity_disk_idx - 1; - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_parity_disk_idx + span_data_disk_idx + 1; - if (span_data_disk_idx >= span_pd_num) + if ( span_data_disk_idx >= span_pd_num) { span_data_disk_idx -= span_pd_num; + } - cmd->io_attr.plba = - vd_entry->startLBA + (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = vd_entry->startLBA + + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); - cmd->io_attr.span_idx = (unsigned char)span_idx; - cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; - cmd->io_attr.span_pd_idx_p = (unsigned char)span_parity_disk_idx; + cmd->io_attr.span_idx = (U8)span_idx; + cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; + cmd->io_attr.span_pd_idx_p = (U8)span_parity_disk_idx; } static void ps3_r60_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_q_disk_idx = 0; - unsigned int span_idx = 0; - unsigned char span_pd_num = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_q_disk_idx = 0; + U32 span_idx = 0; + U8 span_pd_num = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -587,48 +536,50 @@ static void ps3_r60_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); RAID660_GET_PQ_SPINDLENO(stripe_idx, span_pd_num, span_q_disk_idx); - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx + span_q_disk_idx + 1; - if (span_data_disk_idx >= span_pd_num) + if ( span_data_disk_idx >= span_pd_num) { span_data_disk_idx -= span_pd_num; + } - cmd->io_attr.plba = - vd_entry->startLBA + (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = vd_entry->startLBA + + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); - cmd->io_attr.span_idx = (unsigned char)span_idx; - cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; - cmd->io_attr.span_pd_idx_q = (unsigned char)span_q_disk_idx; - if (span_q_disk_idx != 0) + cmd->io_attr.span_idx = (U8)span_idx; + cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; + cmd->io_attr.span_pd_idx_q = (U8)span_q_disk_idx; + if(0 != span_q_disk_idx){ cmd->io_attr.span_pd_idx_p = span_q_disk_idx - 1; - else + } else{ cmd->io_attr.span_pd_idx_p = span_pd_num - 1; + } } -static int ps3_convert_to_pd_info(struct ps3_cmd *cmd) +static S32 ps3_convert_to_pd_info(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - const struct PS3Extent *extent = - &(vd_entry->span[cmd->io_attr.span_idx] - .extent[cmd->io_attr.span_pd_idx]); + const struct PS3Extent *extent = &(vd_entry->span[cmd->io_attr.span_idx]. + extent[cmd->io_attr.span_pd_idx]); if (extent->state != MIC_PD_STATE_ONLINE) { LOG_DEBUG("cmd :%u direct check pd:%u state:%s != ONLINE\n", - cmd->index, extent->phyDiskID.ps3Dev.phyDiskID, - getPdStateName((enum MicPdState)extent->state, - cmd->instance->is_raid)); + cmd->index, extent->phyDiskID.ps3Dev.phyDiskID, + getPdStateName((MicPdState_e)extent->state, cmd->instance->is_raid)); ret = -PS3_ENODEV; goto l_out; } - cmd->io_attr.pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( - cmd->instance, extent->phyDiskID.ps3Dev.phyDiskID); + cmd->io_attr.pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(cmd->instance, + extent->phyDiskID.ps3Dev.phyDiskID); if (unlikely(cmd->io_attr.pd_entry == NULL)) { - LOG_FILE_ERROR( - "host_no:%u trace_id:0x%llx idspan_id:%d span_pd_idx:%d pd[%u:%u:%u], pd_entry == NULL\n", - PS3_HOST(cmd->instance), cmd->trace_id, - cmd->io_attr.span_idx, cmd->io_attr.span_pd_idx, + LOG_FILE_ERROR("host_no:%u trace_id:0x%llx idspan_id:%d " + "span_pd_idx:%d pd[%u:%u:%u], pd_entry == NULL\n", + PS3_HOST(cmd->instance), + cmd->trace_id, + cmd->io_attr.span_idx, + cmd->io_attr.span_pd_idx, extent->phyDiskID.ps3Dev.softChan, extent->phyDiskID.ps3Dev.devID, extent->phyDiskID.ps3Dev.phyDiskID); @@ -636,17 +587,17 @@ static int ps3_convert_to_pd_info(struct ps3_cmd *cmd) goto l_out; } - if (!ps3_is_r1x_write_cmd(cmd)) + if (!ps3_is_r1x_write_cmd(cmd)) { goto l_out; + } - extent = &(vd_entry->span[cmd->io_attr.span_idx] - .extent[cmd->io_attr.span_pd_idx_p]); + extent = &(vd_entry->span[cmd->io_attr.span_idx]. + extent[cmd->io_attr.span_pd_idx_p]); if (extent->state != MIC_PD_STATE_ONLINE) { LOG_DEBUG("cmd :%u direct check pd:%u state:%s != ONLINE\n", - cmd->index, extent->phyDiskID.ps3Dev.phyDiskID, - getPdStateName((enum MicPdState)extent->state, - cmd->instance->is_raid)); + cmd->index, extent->phyDiskID.ps3Dev.phyDiskID, + getPdStateName((MicPdState_e)extent->state, cmd->instance->is_raid)); ret = -PS3_ENODEV; goto l_out; } @@ -654,10 +605,12 @@ static int ps3_convert_to_pd_info(struct ps3_cmd *cmd) cmd->io_attr.peer_pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( cmd->instance, extent->phyDiskID.ps3Dev.phyDiskID); if (unlikely(cmd->io_attr.peer_pd_entry == NULL)) { - LOG_ERROR_LIM( - "host_no:%u trace_id:0x%llx idspan_id:%d span_pd_idx:%d peer_pd[%u:%u:%u], pd_entry == NULL\n", - PS3_HOST(cmd->instance), cmd->trace_id, - cmd->io_attr.span_idx, cmd->io_attr.span_pd_idx, + LOG_ERROR_LIM("host_no:%u trace_id:0x%llx idspan_id:%d " + "span_pd_idx:%d peer_pd[%u:%u:%u], pd_entry == NULL\n", + PS3_HOST(cmd->instance), + cmd->trace_id, + cmd->io_attr.span_idx, + cmd->io_attr.span_pd_idx, extent->phyDiskID.ps3Dev.softChan, extent->phyDiskID.ps3Dev.devID, extent->phyDiskID.ps3Dev.phyDiskID); @@ -669,19 +622,18 @@ static int ps3_convert_to_pd_info(struct ps3_cmd *cmd) return ret; } -int ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd) +S32 ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; - if (unlikely(!ps3_vd_entry_valid_check(cmd->io_attr.vd_entry))) { + if ( unlikely(!ps3_vd_entry_valid_check(cmd->io_attr.vd_entry)) ) { ret = -PS3_FAILED; - LOG_ERROR_LIM( - "trace_id:0x%llx host_no:%u vd entry is invalid\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + LOG_ERROR_LIM("trace_id:0x%llx host_no:%u vd entry is invalid\n", + cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } - switch (cmd->io_attr.vd_entry->raidLevel) { + switch(cmd->io_attr.vd_entry->raidLevel) { case RAID0: ps3_r0_convert_vlba_to_pd_attr(cmd); break; @@ -711,9 +663,8 @@ int ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd) break; default: ret = -PS3_FAILED; - LOG_ERROR_LIM( - "trace_id:0x%llx host_no:%u vd level:%d is illegal\n", - cmd->trace_id, PS3_HOST(cmd->instance), + LOG_ERROR_LIM("trace_id:0x%llx host_no:%u vd level:%d is illegal\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->io_attr.vd_entry->raidLevel); goto l_out; } @@ -722,17 +673,15 @@ int ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd) return ret; } -unsigned char ps3_scsih_vd_acc_att_build(struct ps3_cmd *cmd) +Bool ps3_scsih_vd_acc_att_build(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; - struct PS3VDAccAttr *acc_attr = &cmd->req_frame->frontendReq.vdAccAttr; + S32 ret = PS3_SUCCESS; + PS3VDAccAttr_s *acc_attr = &cmd->req_frame->frontendReq.vdAccAttr; static unsigned long j; - ret = ps3_scsih_vlba_to_pd_calc(cmd); if (ret != PS3_SUCCESS) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "trace_id:0x%llx host_no:%u vlba calc NOK\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "trace_id:0x%llx host_no:%u vlba calc NOK\n", + cmd->trace_id, PS3_HOST(cmd->instance)); acc_attr->isAccActive = 0; goto l_out; } @@ -747,14 +696,14 @@ unsigned char ps3_scsih_vd_acc_att_build(struct ps3_cmd *cmd) return (acc_attr->isAccActive == 1); } -int ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd) +S32 ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; ret = ps3_scsih_vlba_to_pd_calc(cmd); if (ret != PS3_SUCCESS) { LOG_WARN_LIM("trace_id:0x%llx host_no:%u vlba calc NOK\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } @@ -764,30 +713,26 @@ int ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd) return ret; } -static void ps3_update_cmd_target_pd(struct ps3_cmd *cmd, - unsigned short disk_id) +static void ps3_update_cmd_target_pd(struct ps3_cmd *cmd, U16 disk_id) { - unsigned short i = 0; + U16 i = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_instance *instance = cmd->instance; - if (unlikely(cmd->target_pd_count >= PS3_QOS_MAX_PD_IN_VD)) { - LOG_INFO( - "host_no:%u CFID:%u did:%u target pd count %u check NOK\n", - PS3_HOST(instance), cmd->index, disk_id, - cmd->target_pd_count); + LOG_INFO("host_no:%u CFID:%u did:%u target pd count %u check NOK\n", + PS3_HOST(instance), cmd->index, disk_id, cmd->target_pd_count); goto l_out; } - if (disk_id > instance->ctrl_info.maxPdCount) { + if (disk_id > instance->ctrl_info.maxPdCount ) { LOG_DEBUG("disk_id is error.host_no:%u CFID:%u did:%u\n", - PS3_HOST(instance), cmd->index, disk_id); + PS3_HOST(instance), cmd->index, disk_id); goto l_out; } qos_pd_mgr = &instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; if (ps3_atomic_read(&qos_pd_mgr->valid) != 1) { LOG_DEBUG("qos pd is invalid. host_no:%u CFID:%u did:%u\n", - PS3_HOST(instance), cmd->index, disk_id); + PS3_HOST(instance), cmd->index, disk_id); goto l_out; } @@ -805,42 +750,36 @@ static void ps3_update_cmd_target_pd(struct ps3_cmd *cmd, return; } -static void ps3_r0_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) +static void ps3_r0_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) { - unsigned int stripe_offset = 0; - unsigned int strip_size_shift = 0; - unsigned char span_idx = 0; - unsigned int span_disk_idx = 0; - unsigned short disk_id = 0; + U32 stripe_offset = 0; + U32 strip_size_shift = 0; + U8 span_idx = 0; + U32 span_disk_idx = 0; + U16 disk_id= 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); LBA_TO_STRIPE_OFFSET(lba, vd_entry->stripeDataSize, stripe_offset); span_disk_idx = stripe_offset >> strip_size_shift; - if (vd_entry->span[span_idx].extent[span_disk_idx].state == - MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx] - .extent[span_disk_idx] - .phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_idx].state == MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx].extent[span_disk_idx].phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r0_target_pd_get(struct ps3_cmd *cmd) { - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned int left_len = cmd->io_attr.num_blocks; - unsigned int strip_len = 0; - unsigned char first_strip = PS3_TRUE; + U32 left_len = cmd->io_attr.num_blocks; + U32 strip_len = 0; + Bool first_strip = PS3_TRUE; while (left_len > 0) { ps3_r0_vlba_to_pd(cmd, vlba); if (first_strip) { - strip_len = - vd_entry->stripSize - - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); first_strip = PS3_FALSE; } else { @@ -853,12 +792,12 @@ static void ps3_r0_target_pd_get(struct ps3_cmd *cmd) static void ps3_r1_target_pd_get(struct ps3_cmd *cmd) { - unsigned char span_idx = 0; - unsigned short span_disk_idx = 0; - unsigned short disk_id = 0; + U8 span_idx = 0; + U16 span_disk_idx = 0; + U16 disk_id= 0; const struct PS3Extent *extent = NULL; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned char primary_valid = PS3_FALSE; + Bool primary_valid = PS3_FALSE; ps3_scsih_vlba_to_pd_calc(cmd); span_disk_idx = cmd->io_attr.span_pd_idx; @@ -879,46 +818,40 @@ static void ps3_r1_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r00_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) +static void ps3_r00_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) { - unsigned int stripe_offset = 0; - unsigned int strip_size_shift = 0; - unsigned char span_idx = 0; - unsigned int span_disk_idx = 0; - unsigned short disk_id = 0; + U32 stripe_offset = 0; + U32 strip_size_shift = 0; + U8 span_idx = 0; + U32 span_disk_idx = 0; + U16 disk_id= 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); LBA_TO_STRIPE_OFFSET(lba, vd_entry->stripeDataSize, stripe_offset); while (stripe_offset >= vd_entry->span[span_idx].spanStripeDataSize) { stripe_offset -= vd_entry->span[span_idx].spanStripeDataSize; span_idx++; } span_disk_idx = stripe_offset >> strip_size_shift; - if (vd_entry->span[span_idx].extent[span_disk_idx].state == - MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx] - .extent[span_disk_idx] - .phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_idx].state == MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx].extent[span_disk_idx].phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r00_target_pd_get(struct ps3_cmd *cmd) { - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned int left_len = cmd->io_attr.num_blocks; - unsigned int strip_len = 0; - unsigned char first_strip = PS3_TRUE; + U32 left_len = cmd->io_attr.num_blocks; + U32 strip_len = 0; + Bool first_strip = PS3_TRUE; while (left_len > 0) { ps3_r00_vlba_to_pd(cmd, vlba); if (first_strip) { - strip_len = - vd_entry->stripSize - - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); first_strip = PS3_FALSE; } else { @@ -929,15 +862,15 @@ static void ps3_r00_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r5_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) +static void ps3_r5_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_parity_disk_idx = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_parity_disk_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned short disk_id = 0; + U16 disk_id = 0; LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -945,41 +878,35 @@ static void ps3_r5_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) if (ps3_is_power_of_2(vd_entry->physDrvCnt)) { span_parity_disk_idx = stripe_idx & (vd_entry->physDrvCnt - 1); } else { - span_parity_disk_idx = - PS3_MOD64(stripe_idx, vd_entry->physDrvCnt); + span_parity_disk_idx = stripe_idx % vd_entry->physDrvCnt; } span_parity_disk_idx = vd_entry->physDrvCnt - span_parity_disk_idx - 1; strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_parity_disk_idx + span_data_disk_idx + 1; - if (span_data_disk_idx >= vd_entry->physDrvCnt) + if (span_data_disk_idx >= vd_entry->physDrvCnt) { span_data_disk_idx -= vd_entry->physDrvCnt; + } - if (vd_entry->span[0].extent[span_data_disk_idx].state == - MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[0] - .extent[span_data_disk_idx] - .phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[0].extent[span_data_disk_idx].state == MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[0].extent[span_data_disk_idx].phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r5_target_pd_get(struct ps3_cmd *cmd) { - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned int left_len = cmd->io_attr.num_blocks; - unsigned int strip_len = 0; - unsigned char first_strip = PS3_TRUE; + U32 left_len = cmd->io_attr.num_blocks; + U32 strip_len = 0; + Bool first_strip = PS3_TRUE; while (left_len > 0) { ps3_r5_vlba_to_pd(cmd, vlba); if (first_strip) { - strip_len = - vd_entry->stripSize - - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); first_strip = PS3_FALSE; } else { @@ -990,54 +917,51 @@ static void ps3_r5_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r6_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) +static void ps3_r6_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_q_disk_idx = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_q_disk_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned short disk_id = 0; + U16 disk_id = 0; LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); - if (ps3_is_power_of_2(vd_entry->physDrvCnt)) + if (ps3_is_power_of_2(vd_entry->physDrvCnt)){ span_q_disk_idx = stripe_idx & (vd_entry->physDrvCnt - 1); - else - span_q_disk_idx = PS3_MOD64(stripe_idx, vd_entry->physDrvCnt); + } else { + span_q_disk_idx = stripe_idx % vd_entry->physDrvCnt; + } span_q_disk_idx = (vd_entry->physDrvCnt) - span_q_disk_idx - 1; - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx + span_q_disk_idx + 1; - if (span_data_disk_idx >= vd_entry->physDrvCnt) + if ( span_data_disk_idx >= vd_entry->physDrvCnt) { span_data_disk_idx -= vd_entry->physDrvCnt; + } - if (vd_entry->span[0].extent[span_data_disk_idx].state == - MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[0] - .extent[span_data_disk_idx] - .phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[0].extent[span_data_disk_idx].state == MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[0].extent[span_data_disk_idx].phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r6_target_pd_get(struct ps3_cmd *cmd) { - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned int left_len = cmd->io_attr.num_blocks; - unsigned int strip_len = 0; + U32 left_len = cmd->io_attr.num_blocks; + U32 strip_len = 0; ps3_r6_vlba_to_pd(cmd, vlba); - strip_len = vd_entry->stripSize - - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); - left_len -= strip_len; + left_len -= strip_len; vlba += strip_len; while (left_len > 0) { strip_len = PS3_MIN(left_len, vd_entry->stripSize); @@ -1047,16 +971,16 @@ static void ps3_r6_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r50_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) +static void ps3_r50_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_parity_disk_idx = 0; - unsigned int span_idx = 0; - unsigned char span_pd_num = 0; - unsigned short disk_id = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_parity_disk_idx = 0; + U32 span_idx = 0; + U8 span_pd_num = 0; + U16 disk_id = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); @@ -1068,41 +992,38 @@ static void ps3_r50_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) } span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); - if (ps3_is_power_of_2(span_pd_num)) + if (ps3_is_power_of_2(span_pd_num)) { span_parity_disk_idx = stripe_idx & (span_pd_num - 1); - else - span_parity_disk_idx = PS3_MOD64(stripe_idx, span_pd_num); + } else { + span_parity_disk_idx = stripe_idx % span_pd_num; + } span_parity_disk_idx = span_pd_num - span_parity_disk_idx - 1; - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_parity_disk_idx + span_data_disk_idx + 1; - if (span_data_disk_idx >= span_pd_num) + if ( span_data_disk_idx >= span_pd_num) { span_data_disk_idx -= span_pd_num; + } - if (vd_entry->span[span_idx].extent[span_data_disk_idx].state == - MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx] - .extent[span_data_disk_idx] - .phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_data_disk_idx].state == MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx].extent[span_data_disk_idx].phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r50_target_pd_get(struct ps3_cmd *cmd) { - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned int left_len = cmd->io_attr.num_blocks; - unsigned int strip_len = 0; + U32 left_len = cmd->io_attr.num_blocks; + U32 strip_len = 0; ps3_r50_vlba_to_pd(cmd, vlba); - strip_len = vd_entry->stripSize - - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); - left_len -= strip_len; + left_len -= strip_len; vlba += strip_len; while (left_len > 0) { strip_len = PS3_MIN(left_len, vd_entry->stripSize); @@ -1112,17 +1033,17 @@ static void ps3_r50_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r60_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) +static void ps3_r60_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) { - unsigned int stripe_offset = 0; - unsigned long long stripe_idx = 0; - unsigned int strip_size_shift = 0; - unsigned int span_data_disk_idx = 0; - unsigned int span_q_disk_idx = 0; - unsigned int span_idx = 0; - unsigned char span_pd_num = 0; + U32 stripe_offset = 0; + U64 stripe_idx = 0; + U32 strip_size_shift = 0; + U32 span_data_disk_idx = 0; + U32 span_q_disk_idx = 0; + U32 span_idx = 0; + U8 span_pd_num = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned short disk_id = 0; + U16 disk_id = 0; LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -1135,35 +1056,31 @@ static void ps3_r60_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); RAID660_GET_PQ_SPINDLENO(stripe_idx, span_pd_num, span_q_disk_idx); - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx + span_q_disk_idx + 1; - if (span_data_disk_idx >= span_pd_num) + if ( span_data_disk_idx >= span_pd_num) { span_data_disk_idx -= span_pd_num; + } - if (vd_entry->span[span_idx].extent[span_data_disk_idx].state == - MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx] - .extent[span_data_disk_idx] - .phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_data_disk_idx].state == MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx].extent[span_data_disk_idx].phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r60_target_pd_get(struct ps3_cmd *cmd) { - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned int left_len = cmd->io_attr.num_blocks; - unsigned int strip_len = 0; + U32 left_len = cmd->io_attr.num_blocks; + U32 strip_len = 0; ps3_r60_vlba_to_pd(cmd, vlba); - strip_len = vd_entry->stripSize - - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); - left_len -= strip_len; + left_len -= strip_len; vlba += strip_len; while (left_len > 0) { strip_len = PS3_MIN(left_len, vd_entry->stripSize); @@ -1173,21 +1090,21 @@ static void ps3_r60_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r10_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) +static void ps3_r10_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) { - unsigned int stripe_offset = 0; - unsigned int strip_size_shift = 0; - unsigned char span_idx = 0; - unsigned int span_disk_idx = 0; - unsigned int span_disk_back_idx = 0; - unsigned short span_pd_num = 0; - unsigned short disk_id = 0; + U32 stripe_offset = 0; + U32 strip_size_shift = 0; + U8 span_idx = 0; + U32 span_disk_idx = 0; + U32 span_disk_back_idx = 0; + U16 span_pd_num = 0; + U16 disk_id= 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned char primary_valid = PS3_FALSE; + Bool primary_valid = PS3_FALSE; - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); LBA_TO_STRIPE_OFFSET(lba, vd_entry->stripeDataSize, stripe_offset); - while (stripe_offset >= vd_entry->span[span_idx].spanStripeDataSize) { + while(stripe_offset >= vd_entry->span[span_idx].spanStripeDataSize) { stripe_offset -= vd_entry->span[span_idx].spanStripeDataSize; span_idx++; } @@ -1195,13 +1112,15 @@ static void ps3_r10_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) span_disk_idx = span_disk_idx << 1; span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); if (span_pd_num & 1) { - if (span_disk_idx > span_pd_num) + if (span_disk_idx > span_pd_num ) { span_disk_idx -= span_pd_num; + } - if (span_disk_idx + 1 == span_pd_num) + if (span_disk_idx + 1 == span_pd_num) { span_disk_back_idx = 0; - else + } else { span_disk_back_idx = span_disk_idx + 1; + } } else { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { if (cmd->io_attr.span_pd_idx & 1) { @@ -1214,21 +1133,15 @@ static void ps3_r10_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) } } - if (vd_entry->span[span_idx].extent[span_disk_idx].state == - MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx] - .extent[span_disk_idx] - .phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_idx].state == MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx].extent[span_disk_idx].phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); primary_valid = PS3_TRUE; } if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag) || !primary_valid) { - if (vd_entry->span[span_idx].extent[span_disk_back_idx].state == - MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx] - .extent[span_disk_back_idx] - .phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_back_idx].state == MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx].extent[span_disk_back_idx].phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } @@ -1236,16 +1149,15 @@ static void ps3_r10_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) static void ps3_r10_target_pd_get(struct ps3_cmd *cmd) { - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; const struct PS3Extent *extent = NULL; - unsigned int left_len = cmd->io_attr.num_blocks; - unsigned int strip_len = 0; - unsigned short flat_pd_id = 0; - unsigned char primary_valid = PS3_FALSE; - unsigned char span_idx = 0; - unsigned char span_disk_idx = 0; + U32 left_len = cmd->io_attr.num_blocks; + U32 strip_len = 0; + U16 flat_pd_id = 0; + Bool primary_valid = PS3_FALSE; + U8 span_idx = 0; + U8 span_disk_idx = 0; ps3_scsih_vlba_to_pd_calc(cmd); span_idx = cmd->io_attr.span_idx; @@ -1260,15 +1172,14 @@ static void ps3_r10_target_pd_get(struct ps3_cmd *cmd) span_disk_idx = cmd->io_attr.span_pd_idx_p; extent = &vd_entry->span[span_idx].extent[span_disk_idx]; if (extent->state == MIC_PD_STATE_ONLINE) { - flat_pd_id = extent->phyDiskID.ps3Dev.phyDiskID; + flat_pd_id = extent->phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, flat_pd_id); } } - strip_len = vd_entry->stripSize - - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); - left_len -= strip_len; + left_len -= strip_len; vlba += strip_len; while (left_len > 0) { strip_len = PS3_MIN(left_len, vd_entry->stripSize); @@ -1278,28 +1189,30 @@ static void ps3_r10_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r1e_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) +static void ps3_r1e_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) { - unsigned int stripe_offset = 0; - unsigned int strip_size_shift = 0; - unsigned char span_idx = 0; - unsigned int span_disk_idx = 0; - unsigned int span_disk_back_idx = 0; - unsigned short disk_id = 0; + U32 stripe_offset = 0; + U32 strip_size_shift = 0; + U8 span_idx = 0; + U32 span_disk_idx = 0; + U32 span_disk_back_idx = 0; + U16 disk_id= 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - unsigned char primary_valid = PS3_FALSE; + Bool primary_valid = PS3_FALSE; - strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); LBA_TO_STRIPE_OFFSET(lba, vd_entry->stripeDataSize, stripe_offset); span_disk_idx = stripe_offset >> strip_size_shift; span_disk_idx = span_disk_idx << 1; if (vd_entry->physDrvCnt & 1) { - if (span_disk_idx > vd_entry->physDrvCnt) + if (span_disk_idx > vd_entry->physDrvCnt) { span_disk_idx -= vd_entry->physDrvCnt; - if (span_disk_idx + 1 == vd_entry->physDrvCnt) + } + if (span_disk_idx + 1 == vd_entry->physDrvCnt) { span_disk_back_idx = 0; - else + } else { span_disk_back_idx = span_disk_idx + 1; + } } else { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { if (cmd->io_attr.span_pd_idx & 1) { @@ -1312,20 +1225,14 @@ static void ps3_r1e_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) } } - if (vd_entry->span[span_idx].extent[span_disk_idx].state == - MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx] - .extent[span_disk_idx] - .phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_idx].state == MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx].extent[span_disk_idx].phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); primary_valid = PS3_TRUE; } if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag) || !primary_valid) { - if (vd_entry->span[span_idx].extent[span_disk_back_idx].state == - MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx] - .extent[span_disk_back_idx] - .phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_back_idx].state == MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx].extent[span_disk_back_idx].phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } @@ -1333,16 +1240,15 @@ static void ps3_r1e_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) static void ps3_r1e_target_pd_get(struct ps3_cmd *cmd) { - unsigned long long vlba = - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; const struct PS3Extent *extent = NULL; - unsigned int left_len = cmd->io_attr.num_blocks; - unsigned int strip_len = 0; - unsigned short flat_pd_id = 0; - unsigned char primary_valid = PS3_FALSE; - unsigned char span_idx = 0; - unsigned char span_disk_idx = 0; + U32 left_len = cmd->io_attr.num_blocks; + U32 strip_len = 0; + U16 flat_pd_id = 0; + Bool primary_valid = PS3_FALSE; + U8 span_idx = 0; + U8 span_disk_idx = 0; ps3_scsih_vlba_to_pd_calc(cmd); span_idx = cmd->io_attr.span_idx; @@ -1357,15 +1263,14 @@ static void ps3_r1e_target_pd_get(struct ps3_cmd *cmd) span_disk_idx = cmd->io_attr.span_pd_idx_p; extent = &vd_entry->span[span_idx].extent[span_disk_idx]; if (extent->state == MIC_PD_STATE_ONLINE) { - flat_pd_id = extent->phyDiskID.ps3Dev.phyDiskID; + flat_pd_id = extent->phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, flat_pd_id); } } - strip_len = vd_entry->stripSize - - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); - left_len -= strip_len; + left_len -= strip_len; vlba += strip_len; while (left_len > 0) { strip_len = PS3_MIN(left_len, vd_entry->stripSize); @@ -1375,11 +1280,9 @@ static void ps3_r1e_target_pd_get(struct ps3_cmd *cmd) } } -static inline void ps3_swap_in_array(struct ps3_qos_member_pd_info *arr, - unsigned short i, unsigned short j) +static inline void ps3_swap_in_array(struct ps3_qos_member_pd_info *arr, U16 i, U16 j) { struct ps3_qos_member_pd_info tmp; - tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; @@ -1387,13 +1290,13 @@ static inline void ps3_swap_in_array(struct ps3_qos_member_pd_info *arr, static void ps3_qos_target_pd_adjust(struct ps3_cmd *cmd) { - unsigned short i = 0; - unsigned short j = 0; + U16 i = 0; + U16 j = 0; for (i = 0; i < cmd->target_pd_count; i++) { for (j = i + 1; j < cmd->target_pd_count; j++) { if (cmd->target_pd[i].flat_disk_id > - cmd->target_pd[j].flat_disk_id) { + cmd->target_pd[j].flat_disk_id) { ps3_swap_in_array(cmd->target_pd, i, j); } } @@ -1403,67 +1306,60 @@ static void ps3_qos_target_pd_adjust(struct ps3_cmd *cmd) void ps3_qos_cmd_member_pd_calc(struct ps3_cmd *cmd) { const struct PS3VDEntry *vd_entry = NULL; - unsigned short disk_id = 0; + U16 disk_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_qos_pd_mgr *qos_peer_pd_mgr = NULL; static unsigned long j; - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { vd_entry = cmd->io_attr.vd_entry; if (cmd->cmd_word.direct == PS3_CMDWORD_DIRECT_ADVICE) { disk_id = PS3_PDID(&cmd->io_attr.pd_entry->disk_pos); if (ps3_is_r1x_write_cmd(cmd)) { - qos_pd_mgr = &cmd->instance->qos_context.pd_ctx - .qos_pd_mgrs[disk_id]; - disk_id = PS3_PDID( - &cmd->io_attr.peer_pd_entry->disk_pos); - qos_peer_pd_mgr = - &cmd->instance->qos_context.pd_ctx - .qos_pd_mgrs[disk_id]; - disk_id = (qos_pd_mgr->pd_quota <= - qos_peer_pd_mgr->pd_quota) ? - qos_pd_mgr->disk_id : - qos_peer_pd_mgr->disk_id; + qos_pd_mgr = &cmd->instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; + disk_id = PS3_PDID(&cmd->io_attr.peer_pd_entry->disk_pos); + qos_peer_pd_mgr = &cmd->instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; + disk_id = (qos_pd_mgr->pd_quota <= qos_peer_pd_mgr->pd_quota) ? + qos_pd_mgr->disk_id : qos_peer_pd_mgr->disk_id; } ps3_update_cmd_target_pd(cmd, disk_id); } else { - if (!vd_entry->isNvme && !vd_entry->isSsd) + if (!vd_entry->isNvme && !vd_entry->isSsd) { goto _out; - switch (vd_entry->raidLevel) { - case RAID0: - ps3_r0_target_pd_get(cmd); - break; - case RAID1: - ps3_r1_target_pd_get(cmd); - break; - case RAID10: - ps3_r10_target_pd_get(cmd); - break; - case RAID1E: - ps3_r1e_target_pd_get(cmd); - break; - case RAID00: - ps3_r00_target_pd_get(cmd); - break; - case RAID5: - ps3_r5_target_pd_get(cmd); - break; - case RAID6: - ps3_r6_target_pd_get(cmd); - break; - case RAID50: - ps3_r50_target_pd_get(cmd); - break; - case RAID60: - ps3_r60_target_pd_get(cmd); - break; - default: - LOG_ERROR_TIME_LIM( - &j, PS3_LOG_LIMIT_INTERVAL_MSEC, - "trace_id:0x%llx host_no:%u vd level:%d is illegal\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->io_attr.vd_entry->raidLevel); + } + switch(vd_entry->raidLevel) { + case RAID0: + ps3_r0_target_pd_get(cmd); + break; + case RAID1: + ps3_r1_target_pd_get(cmd); + break; + case RAID10: + ps3_r10_target_pd_get(cmd); + break; + case RAID1E: + ps3_r1e_target_pd_get(cmd); + break; + case RAID00: + ps3_r00_target_pd_get(cmd); + break; + case RAID5: + ps3_r5_target_pd_get(cmd); + break; + case RAID6: + ps3_r6_target_pd_get(cmd); + break; + case RAID50: + ps3_r50_target_pd_get(cmd); + break; + case RAID60: + ps3_r60_target_pd_get(cmd); + break; + default: + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "trace_id:0x%llx host_no:%u vd level:%d is illegal\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->io_attr.vd_entry->raidLevel); } ps3_qos_target_pd_adjust(cmd); @@ -1472,17 +1368,15 @@ void ps3_qos_cmd_member_pd_calc(struct ps3_cmd *cmd) ps3_update_cmd_target_pd(cmd, cmd->io_attr.disk_id); } _out: - LOG_DEBUG( - "qos target pd calc. host_no:%u cmd[%u,%u] pd_cnt:%u dev_t:%u diskid:%u\n", - PS3_HOST(cmd->instance), cmd->index, cmd->cmd_word.type, - cmd->target_pd_count, cmd->io_attr.dev_type, - cmd->io_attr.disk_id); + LOG_DEBUG("qos target pd calc. host_no:%u cmd[%u,%u] pd_cnt:%u dev_t:%u diskid:%u\n", + PS3_HOST(cmd->instance), cmd->index, cmd->cmd_word.type, cmd->target_pd_count, + cmd->io_attr.dev_type, cmd->io_attr.disk_id); } -unsigned short ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry) +U16 ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry) { - unsigned short ret = PS3_IS_SSD_EVEN_R1X_VD; - unsigned char span_idx = 0; + U16 ret = PS3_IS_SSD_EVEN_R1X_VD; + U8 span_idx = 0; if (!vd_entry->isSsd) { ret = PS3_IS_HDD_R1X_VD; @@ -1510,3 +1404,4 @@ unsigned short ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry) l_out: return ret; } + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.h b/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.h index bb4981a6ce89..41aa2b8a5abc 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_SCSIH_RAID_ENGINE_H_ #define _PS3_SCSIH_RAID_ENGINE_H_ @@ -14,18 +13,16 @@ enum ps3_odd_r1x_vd_judge_type { PS3_IS_VALID_R1X_VD }; -unsigned char ps3_scsih_is_same_strip(const struct PS3VDEntry *vd_entry, - unsigned int vlba_lo, - unsigned int lba_length); +Bool ps3_scsih_is_same_strip(const struct PS3VDEntry *vd_entry, U32 vlba_lo, U32 lba_length); -int ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd); +S32 ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd); -unsigned char ps3_scsih_vd_acc_att_build(struct ps3_cmd *cmd); +Bool ps3_scsih_vd_acc_att_build(struct ps3_cmd *cmd); -int ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd); +S32 ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd); void ps3_qos_cmd_member_pd_calc(struct ps3_cmd *cmd); -unsigned short ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry); +U16 ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry); -#endif +#endif \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.c b/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.c index 8a0d727bb74c..f4710fc29cca 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.c @@ -1,25 +1,23 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #ifndef _WINDOWS #include #include #include -#include "ps3_htp_trace_id.h" +#include "ps3_trace_id.h" #include "ps3_err_def.h" #include "ps3_trace_id_alloc.h" -static DEFINE_PER_CPU(union ps3_trace_id, ps3_trace_id); +static DEFINE_PER_CPU(ps3_trace_id_u, ps3_trace_id); -static unsigned char g_ps3_trace_id_switch = ps3_trace_id_switch_open; +static U8 g_ps3_trace_id_swith = ps3_trace_id_switch_open; -void ps3_trace_id_alloc(unsigned long long *trace_id) +void ps3_trace_id_alloc(U64 *trace_id) { - union ps3_trace_id *id = NULL; - unsigned long long trace_id_count = 0; + ps3_trace_id_u *id = NULL; + U64 trace_id_count = 0; - if (g_ps3_trace_id_switch != ps3_trace_id_switch_open) { + if (g_ps3_trace_id_swith != ps3_trace_id_switch_open) { *trace_id = 0; goto l_out; } @@ -29,20 +27,19 @@ void ps3_trace_id_alloc(unsigned long long *trace_id) trace_id_count = id->ps3_trace_id.count; ++trace_id_count; - id->ps3_trace_id.count = - (trace_id_count & TRACE_ID_CHIP_OUT_COUNT_MASK); + id->ps3_trace_id.count = (trace_id_count & TRACE_ID_CHIP_OUT_COUNT_MASK); *trace_id = id->trace_id; preempt_enable(); l_out: - return; + return ; } void ps3_trace_id_init(void) { - int cpu = 0; - union ps3_trace_id *id = NULL; + S32 cpu = 0; + ps3_trace_id_u *id = NULL; for_each_possible_cpu(cpu) { id = &per_cpu(ps3_trace_id, cpu); @@ -51,26 +48,27 @@ void ps3_trace_id_init(void) id->ps3_trace_id.count = 0; } + return; } -int ps3_trace_id_switch_store(unsigned char value) +S32 ps3_trace_id_switch_store(U8 value) { - int ret = PS3_SUCCESS; + S32 ret = PS3_SUCCESS; if (value != ps3_trace_id_switch_close && - value != ps3_trace_id_switch_open) { + value != ps3_trace_id_switch_open) { ret = PS3_FAILED; goto l_out; } - g_ps3_trace_id_switch = value; + g_ps3_trace_id_swith = value; l_out: return ret; } -unsigned char ps3_trace_id_switch_show(void) +U8 ps3_trace_id_switch_show(void) { - return g_ps3_trace_id_switch; + return g_ps3_trace_id_swith; } #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.h b/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.h index 118e7f587c2f..df6ddc6fe5d6 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_TRACE_ID_ALLOC_H_ #define _PS3_TRACE_ID_ALLOC_H_ @@ -14,21 +13,21 @@ enum { ps3_trace_id_switch_close, }; -union ps3_trace_id { - unsigned long long trace_id; +typedef union { + U64 trace_id; struct { - unsigned long long count : 52; - unsigned long long cpu_id : 11; - unsigned long long flag : 1; + U64 count : 52; + U64 cpu_id : 11; + U64 flag : 1; } ps3_trace_id; -}; +} ps3_trace_id_u; -void ps3_trace_id_alloc(unsigned long long *trace_id); +void ps3_trace_id_alloc(U64 *trace_id); void ps3_trace_id_init(void); -int ps3_trace_id_switch_store(unsigned char value); +S32 ps3_trace_id_switch_store(U8 value); -unsigned char ps3_trace_id_switch_show(void); +U8 ps3_trace_id_switch_show(void); -#endif +#endif \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/ps3_util.h b/drivers/scsi/linkdata/ps3stor/ps3_util.h index f83a6bc40dd7..52fd5aef709b 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_util.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_util.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_UTIL_H_ #define _PS3_UTIL_H_ @@ -14,16 +13,16 @@ #define PS3_DRV_MAX(x, y) ((x) > (y) ? (x) : (y)) -#define PCIE_DMA_HOST_ADDR_BIT53_MASK_CHECK(addr) \ +#define PCIE_DMA_HOST_ADDR_BIT53_MASK_CHECK(addr) \ (((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS_F1)) & (addr)) -#define PCIE_DMA_HOST_ADDR_BIT54_MASK_CHECK(addr) \ +#define PCIE_DMA_HOST_ADDR_BIT54_MASK_CHECK(addr) \ (((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS_F0)) & (addr)) enum { - PS3_BLOCK_SIZE_16 = 16, - PS3_BLOCK_SIZE_32 = 32, - PS3_BLOCK_SIZE_64 = 64, + PS3_BLOCK_SIZE_16 = 16, + PS3_BLOCK_SIZE_32 = 32, + PS3_BLOCK_SIZE_64 = 64, PS3_BLOCK_SIZE_128 = 128, PS3_BLOCK_SIZE_256 = 256, PS3_BLOCK_SIZE_512 = 512, @@ -33,38 +32,38 @@ enum { PS3_BLOCK_SIZE_8192 = 8192, }; -#define PS3_BLOCK_SIZE_16K (16uLL << 10) -#define PS3_BLOCK_SIZE_32K (32uLL << 10) -#define PS3_BLOCK_SIZE_64K (64uLL << 10) -#define PS3_BLOCK_SIZE_128K (128uLL << 10) -#define PS3_BLOCK_SIZE_256K (256uLL << 10) -#define PS3_BLOCK_SIZE_512K (512uLL << 10) -#define PS3_BLOCK_SIZE_1M (1uLL << 20) -#define PS3_BLOCK_SIZE_2M (2uLL << 20) -#define PS3_BLOCK_SIZE_4M (4uLL << 20) -#define PS3_BLOCK_SIZE_8M (8uLL << 20) -#define PS3_BLOCK_SIZE_16M (16uLL << 20) -#define PS3_BLOCK_SIZE_32M (32uLL << 20) -#define PS3_BLOCK_SIZE_64M (64uLL << 20) -#define PS3_BLOCK_SIZE_128M (128uLL << 20) -#define PS3_BLOCK_SIZE_256M (256uLL << 20) -#define PS3_BLOCK_SIZE_512M (512uLL << 20) -#define PS3_BLOCK_SIZE_1G (1uLL << 30) -#define PS3_BLOCK_SIZE_2G (2uLL << 30) -#define PS3_BLOCK_SIZE_4G (4uLL << 30) -#define PS3_BLOCK_SIZE_8G (8uLL << 30) -#define PS3_BLOCK_SIZE_16G (16uLL << 30) -#define PS3_BLOCK_SIZE_32G (32uLL << 30) -#define PS3_BLOCK_SIZE_64G (64uLL << 30) -#define PS3_BLOCK_SIZE_128G (128uLL << 30) -#define PS3_BLOCK_SIZE_256G (256uLL << 30) -#define PS3_BLOCK_SIZE_512G (512uLL << 30) -#define PS3_BLOCK_SIZE_1T (1uLL << 40) -#define PS3_BLOCK_SIZE_2T (2uLL << 40) -#define PS3_BLOCK_SIZE_4T (4uLL << 40) -#define PS3_BLOCK_SIZE_8T (8uLL << 40) -#define PS3_BLOCK_SIZE_16T (16uLL << 40) -#define PS3_BLOCK_SIZE_32T (32uLL << 40) +#define PS3_BLOCK_SIZE_16K (16uLL << 10) +#define PS3_BLOCK_SIZE_32K (32uLL << 10) +#define PS3_BLOCK_SIZE_64K (64uLL << 10) +#define PS3_BLOCK_SIZE_128K (128uLL << 10) +#define PS3_BLOCK_SIZE_256K (256uLL << 10) +#define PS3_BLOCK_SIZE_512K (512uLL << 10) +#define PS3_BLOCK_SIZE_1M (1uLL << 20) +#define PS3_BLOCK_SIZE_2M (2uLL << 20) +#define PS3_BLOCK_SIZE_4M (4uLL << 20) +#define PS3_BLOCK_SIZE_8M (8uLL << 20) +#define PS3_BLOCK_SIZE_16M (16uLL << 20) +#define PS3_BLOCK_SIZE_32M (32uLL << 20) +#define PS3_BLOCK_SIZE_64M (64uLL << 20) +#define PS3_BLOCK_SIZE_128M (128uLL << 20) +#define PS3_BLOCK_SIZE_256M (256uLL << 20) +#define PS3_BLOCK_SIZE_512M (512uLL << 20) +#define PS3_BLOCK_SIZE_1G (1uLL << 30) +#define PS3_BLOCK_SIZE_2G (2uLL << 30) +#define PS3_BLOCK_SIZE_4G (4uLL << 30) +#define PS3_BLOCK_SIZE_8G (8uLL << 30) +#define PS3_BLOCK_SIZE_16G (16uLL << 30) +#define PS3_BLOCK_SIZE_32G (32uLL << 30) +#define PS3_BLOCK_SIZE_64G (64uLL << 30) +#define PS3_BLOCK_SIZE_128G (128uLL << 30) +#define PS3_BLOCK_SIZE_256G (256uLL << 30) +#define PS3_BLOCK_SIZE_512G (512uLL << 30) +#define PS3_BLOCK_SIZE_1T (1uLL << 40) +#define PS3_BLOCK_SIZE_2T (2uLL << 40) +#define PS3_BLOCK_SIZE_4T (4uLL << 40) +#define PS3_BLOCK_SIZE_8T (8uLL << 40) +#define PS3_BLOCK_SIZE_16T (16uLL << 40) +#define PS3_BLOCK_SIZE_32T (32uLL << 40) enum { PS3_BLOCK_SIZE_SHIFT_4 = 4, @@ -111,9 +110,9 @@ enum { PS3_BLOCK_SIZE_SHIFT_32T = 45, }; -static inline unsigned int ps3_blocksize_to_shift(unsigned int block_size) +static inline U32 ps3_blocksize_to_shift(U32 block_size) { - unsigned int shift = 0; + U32 shift = 0; switch (block_size) { case PS3_BLOCK_SIZE_16: @@ -154,9 +153,9 @@ static inline unsigned int ps3_blocksize_to_shift(unsigned int block_size) return shift; } -static inline unsigned int ps3_ringsize_to_shift(unsigned long long ring_size) +static inline U32 ps3_ringsize_to_shift(U64 ring_size) { - unsigned int shift = 0; + U32 shift = 0; switch (ring_size) { case PS3_BLOCK_SIZE_512: @@ -277,9 +276,9 @@ static inline unsigned int ps3_ringsize_to_shift(unsigned long long ring_size) return shift; } -static unsigned char ps3_dma_addr_bit_pos_check(dma_addr_t handle) +static U8 ps3_dma_addr_bit_pos_check(dma_addr_t handle) { - unsigned char bit_pos = 0; + U8 bit_pos = 0; if (PCIE_DMA_HOST_ADDR_BIT54_MASK_CHECK(handle)) bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F0; @@ -287,127 +286,118 @@ static unsigned char ps3_dma_addr_bit_pos_check(dma_addr_t handle) bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F1; else bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS; + return bit_pos; } static inline struct dma_pool *ps3_dma_pool_create(const char *name, - struct device *dev, - size_t size, size_t align, - size_t boundary) + struct device *dev, size_t size, size_t align, size_t boundary) { struct dma_pool *pool = NULL; - pool = dma_pool_create(name, dev, size, align, boundary); - LOG_INFO( - "create dma pool:name '%s', size %lu, align %lu, boundary %lu, pool %p\n", - name, (unsigned long)size, (unsigned long)align, - (unsigned long)boundary, pool); + LOG_INFO("create dma pool:name '%s', size %lu, align %lu, boundary %lu, pool %p\n", + name, size, align, boundary, pool); return pool; } static inline void *ps3_dma_pool_alloc(struct ps3_instance *instance, - struct dma_pool *pool, gfp_t mem_flags, - dma_addr_t *handle) + struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle) { void *ret = dma_pool_alloc(pool, mem_flags, handle); - - if (ret != NULL) { - *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( - instance->dma_addr_bit_pos, *handle); + if(ret != NULL) { + *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, *handle); } return ret; } static inline void *ps3_dma_pool_zalloc(struct ps3_instance *instance, - struct dma_pool *pool, gfp_t mem_flags, - dma_addr_t *handle) + struct dma_pool *pool, gfp_t mem_flags, + dma_addr_t *handle) { void *ret = dma_pool_zalloc(pool, mem_flags, handle); - *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, - *handle); + *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, *handle); return ret; } static inline void ps3_dma_pool_destroy(struct dma_pool *pool) { dma_pool_destroy(pool); - LOG_INFO("pool destroy %p\n", pool); + LOG_INFO("pool destroy %p \n",pool); + return; } -static inline void ps3_dma_pool_free(struct dma_pool *pool, void *vaddr, - dma_addr_t dma) +static inline void ps3_dma_pool_free(struct dma_pool *pool, + void *vaddr, dma_addr_t dma) { - unsigned char bit_pos = 0; + U8 bit_pos = 0; bit_pos = ps3_dma_addr_bit_pos_check(dma); - dma_pool_free(pool, vaddr, - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dma)); + dma_pool_free(pool, vaddr, PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dma)); + return; } -static inline unsigned int ps3_scsi_channel_query(struct scsi_cmnd *scmd) +static inline U32 ps3_scsi_channel_query(struct scsi_cmnd *scmd) { - unsigned int ret = U32_MAX; + U32 ret = U32_MAX; - if (scmd == NULL) + if (scmd == NULL) { goto l_out; + } - if (scmd->device == NULL) + if (scmd->device == NULL) { goto l_out; + } ret = scmd->device->channel; l_out: return ret; } -static inline unsigned int ps3_scsi_target_query(struct scsi_cmnd *scmd) +static inline U32 ps3_scsi_target_query(struct scsi_cmnd *scmd) { - unsigned int ret = U32_MAX; + U32 ret = U32_MAX; - if (scmd == NULL) + if (scmd == NULL) { goto l_out; + } - if (scmd->device == NULL) + if (scmd->device == NULL) { goto l_out; + } ret = scmd->device->id; l_out: return ret; } -static inline void *ps3_dma_alloc_coherent(struct ps3_instance *instance, - size_t size, - unsigned long long *handle) +static inline void *ps3_dma_alloc_coherent(struct ps3_instance *instance, size_t size, + U64 *handle) { void *buffer = NULL; - - buffer = dma_alloc_coherent(&instance->pdev->dev, size, - (dma_addr_t *)handle, GFP_KERNEL); - *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, - *handle); + buffer = dma_alloc_coherent(&instance->pdev->dev, size, handle, GFP_KERNEL); + *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, *handle); return buffer; } -static inline void ps3_dma_free_coherent(struct ps3_instance *instance, - size_t size, void *vaddr, - unsigned long long dma_handle) +static inline void ps3_dma_free_coherent(struct ps3_instance *instance, size_t size, + void *vaddr, U64 dma_handle) { - unsigned char bit_pos = 0; + U8 bit_pos = 0; bit_pos = ps3_dma_addr_bit_pos_check(dma_handle); dma_free_coherent(&instance->pdev->dev, size, vaddr, - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, - dma_handle)); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dma_handle)); + return; } -static inline unsigned int ps3_utility_mod64(unsigned long long dividend, - unsigned int divisor) +static inline U32 ps3_utility_mod64(U64 dividend, U32 divisor) { - unsigned long long d = dividend; - unsigned int remainder = 0; + U64 d = dividend; + U32 remainder = 0; if (!divisor) { LOG_ERROR("DIVISOR is zero, in div fn\n"); - return (unsigned int)-1; + return (U32)-1; } #ifndef _WINDOWS @@ -417,27 +407,5 @@ static inline unsigned int ps3_utility_mod64(unsigned long long dividend, #endif return remainder; } - -static inline unsigned long long -ps3_utility_div64_32(unsigned long long dividend, unsigned int divisor) -{ - unsigned long long d = dividend; - - if (!divisor) - LOG_ERROR("DIVISOR is zero, in div64_32 fn\n"); - - do_div(d, divisor); - - return d; -} - -#if defined(CONFIG_64BIT) -#define PS3_DIV64_32(dividend, divisor) ((dividend) / (divisor)) -#define PS3_MOD64(dividend, divisor) ((dividend) % (divisor)) -#else -#define PS3_DIV64_32(dividend, divisor) \ - (ps3_utility_div64_32((dividend), (divisor))) -#define PS3_MOD64(dividend, divisor) (ps3_utility_mod64((dividend), (divisor))) #endif -#endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_watchdog.c b/drivers/scsi/linkdata/ps3stor/ps3_watchdog.c index 66521a695ca3..4a58bce80e25 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_watchdog.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_watchdog.c @@ -1,5 +1,3 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) LD. */ #ifndef _WINDOWS #include #include @@ -18,150 +16,129 @@ #include "ps3_dump.h" #include "ps3_module_para.h" #include "ps3_ioc_manager.h" +#include "ps3_err_inject.h" -#define PS3_WATCHDOG_NAME_MAX_LENGTH (48) -static int ps3_watchdog_fault_detect_and_recovery(struct ps3_instance *instance) +#define PS3_WATCHDOG_NAME_MAX_LENGTH (48) + +static S32 ps3_watchdog_fault_detect_and_recovery(struct ps3_instance *instance) { - unsigned int ioc_recovery_count = 0; - unsigned int ioc_state = PS3_FW_STATE_UNDEFINED; - int ret = PS3_SUCCESS; - unsigned int heartbeat_triggered = 0; + U32 ioc_recovery_count = 0; + U32 ioc_state = PS3_FW_STATE_UNDEFINED; + S32 ret = PS3_SUCCESS; + U32 heartbeat_triggered = 0; if (ps3_pci_err_recovery_get(instance)) { LOG_WARN_LIM("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } if (!ps3_ioc_recovery_count_get(instance, &ioc_recovery_count)) { ps3_atomic_inc(&instance->watchdog_reg_read_fail_count); LOG_ERROR_LIM("hno:%u get recovery count NOK, cnt: %d\n", - PS3_HOST(instance), - ps3_atomic_read( - &instance->watchdog_reg_read_fail_count)); + PS3_HOST(instance), ps3_atomic_read(&instance->watchdog_reg_read_fail_count)); goto l_out; } if (!ps3_ioc_state_get_with_check(instance, &ioc_state)) { ps3_atomic_inc(&instance->watchdog_reg_read_fail_count); LOG_ERROR_LIM("hno:%u get ioc state NOK, cnt: %u\n", - PS3_HOST(instance), - ps3_atomic_read( - &instance->watchdog_reg_read_fail_count)); + PS3_HOST(instance), ps3_atomic_read(&instance->watchdog_reg_read_fail_count)); goto l_out; } ps3_atomic_set(&instance->watchdog_reg_read_fail_count, 0); if (instance->ioc_adpter->ioc_heartbeat_detect) { - if ((instance->recovery_context->heartbeat_recovery == - PS3_HEARTBEAT_HARDRESET_DECIDE || - instance->recovery_context->heartbeat_recovery == - PS3_HEARTBEAT_HARDRESET_RECOVERY || - instance->recovery_context->heartbeat_recovery == - PS3_HEARTBEAT_HARDRESET_RETRY) && - (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE)) { + if ((instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE || + instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY || + instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RETRY) + &&(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { goto l_out; } - heartbeat_triggered = - instance->ioc_adpter->ioc_heartbeat_detect(instance); - if (heartbeat_triggered == PS3_TRUE && - !ps3_pci_err_recovery_get(instance)) { + heartbeat_triggered = instance->ioc_adpter->ioc_heartbeat_detect(instance); + if (heartbeat_triggered == PS3_TRUE + && !ps3_pci_err_recovery_get(instance)) { LOG_INFO("hno:%u heartbeat recovery triggered\n", - PS3_HOST(instance)); - ps3_mutex_lock(&instance->recovery_context - ->ps3_watchdog_recovery_mutex); - if (instance->recovery_context->heartbeat_recovery == - PS3_HEARTBEAT_NULL) { + PS3_HOST(instance)); + ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_NULL) { instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_DECIDE; } - ps3_mutex_unlock( - &instance->recovery_context - ->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); goto l_recovery; } } if (ioc_state == PS3_FW_STATE_FAULT || - ioc_state == PS3_FW_STATE_CRITICAL) { + ioc_state == PS3_FW_STATE_CRITICAL) { goto l_recovery; } if ((ioc_state == PS3_FW_STATE_RUNNING) && - (instance->recovery_context->ioc_recovery_count == - ioc_recovery_count)) { + (instance->recovery_context->ioc_recovery_count == + ioc_recovery_count)) { goto l_out; } - if (ioc_state == PS3_FW_STATE_RESET) + if (ioc_state == PS3_FW_STATE_RESET) { goto l_out; + } - if (ioc_recovery_count == PS3_IOC_RECOVERY_COUNT_MASK) + if (ioc_recovery_count == PS3_IOC_RECOVERY_COUNT_MASK) { goto l_out; + } - if (ioc_state == PS3_FW_STATE_UNDEFINED) + if (ioc_state == PS3_FW_STATE_UNDEFINED) { goto l_out; + } - if (ioc_state == PS3_FW_STATE_MASK) + if (ioc_state == PS3_FW_STATE_MASK) { goto l_out; + } l_recovery: - LOG_INFO( - "hno:%u watchdog recovery req, ioc_state[0x%x] ioc_reco_cnt[%u], local_reco_cnt[%u]\n", - PS3_HOST(instance), ioc_state, ioc_recovery_count, - instance->recovery_context->ioc_recovery_count); - - - if (ps3_atomic_read(&instance->state_machine.state) != - PS3_INSTANCE_STATE_DEAD) { - if (ps3_need_block_hard_reset_request(instance) || - PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { - LOG_WARN_LIM( - "hno:%u can not start reset request recovery_state:%d\n", - PS3_HOST(instance), - instance->recovery_context->recovery_state); + LOG_INFO("hno:%u watchdog recovery request, ioc_state[0x%x]," + " ioc_reco_cnt[%u], local_reco_cnt[%u]\n", + PS3_HOST(instance), ioc_state, ioc_recovery_count, + instance->recovery_context->ioc_recovery_count); + + PS3_IJ_SLEEP(200000, PS3_ERR_IJ_WATCHDOG_DELAY); + + if (ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD) { + if (ps3_need_block_hard_reset_request(instance) || PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) || \ + instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || \ + instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + LOG_WARN_LIM("hno:%u can not start reset request recovery_state:%d\n", + PS3_HOST(instance), instance->recovery_context->recovery_state); } else { - LOG_WARN( - "hno:%u ps3 watchdog recovery start, heartbeat_triggered:%u ioc_state:0x%x\n", - PS3_HOST(instance), heartbeat_triggered, - ioc_state); - if (ps3_recovery_request(instance) == PS3_SUCCESS) { + LOG_WARN("hno:%u ps3 watchdog recovery start, heartbeat_triggered:%u ioc_state:0x%x\n", + PS3_HOST(instance), heartbeat_triggered, ioc_state); + if(ps3_recovery_request(instance) == PS3_SUCCESS){ LOG_INFO("hno[%u], recovery success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; - } else { - LOG_ERROR( - "hno[%u], recovery request NOK, %s!\n", + }else{ + LOG_ERROR("hno[%u], recovery request NOK, %s!\n", PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read( - &instance->state_machine - .state))); + namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); return -PS3_FAILED; } } } l_out: - if (ps3_atomic_read(&instance->watchdog_reg_read_fail_count) >= - PS3_TRANS_DEAD_IOC_FAILED_MAX_COUNT) { + if (ps3_atomic_read(&instance->watchdog_reg_read_fail_count) >= PS3_TRANS_DEAD_IOC_FAILED_MAX_COUNT) { #ifdef PS3_HARDWARE_SIM - LOG_WARN( - "hno:%u reg read failed 5 times consecutively, simu platform ignore\n", + LOG_WARN("hno:%u reg read failed 5 times consecutively, simu platform ignore\n", PS3_HOST(instance)); #else ps3_instance_state_transfer_to_dead(instance); instance->watchdog_context.is_stop = PS3_TRUE; - LOG_ERROR( - "hno:%u reg read failed 5 times consecutively, transfer to dead\n", + LOG_ERROR("hno:%u reg read failed 5 times consecutively, transfer to dead\n", PS3_HOST(instance)); ret = -PS3_FAILED; #endif @@ -172,18 +149,19 @@ static int ps3_watchdog_fault_detect_and_recovery(struct ps3_instance *instance) #ifndef _WINDOWS -static void ps3_watchdog_service(struct work_struct *work) +static void ps3_watchdog_service(struct work_struct* work) { - struct ps3_watchdog_context *watchdog_ctx = ps3_container_of( - work, struct ps3_watchdog_context, watchdog_work.work); + struct ps3_watchdog_context* watchdog_ctx = + ps3_container_of(work, struct ps3_watchdog_context, + watchdog_work.work); struct ps3_instance *instance = watchdog_ctx->instance; - struct delayed_work *delayed_work = &watchdog_ctx->watchdog_work; - int ret = PS3_SUCCESS; + struct delayed_work* delayed_work = &watchdog_ctx->watchdog_work; + S32 ret = PS3_SUCCESS; if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { watchdog_ctx->is_halt = PS3_TRUE; goto l_next; } @@ -192,36 +170,36 @@ static void ps3_watchdog_service(struct work_struct *work) if (instance->is_probe_finish && instance->state_machine.is_load) { ret = ps3_watchdog_fault_detect_and_recovery(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u watchdog fault detect and recovery NOK watchdog service exit\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u watchdog fault detect and recovery \ + NOK watchdog service exit\n", + PS3_HOST(instance)); } } l_next: if (watchdog_ctx->is_stop) { - LOG_INFO("hno:%u watchdog has stop\n", PS3_HOST(instance)); + LOG_INFO("hno:%u watchdog has stop\n", + PS3_HOST(instance)); return; } - ps3_qos_waitq_poll(instance); + ps3_qos_waitq_poll(instance); if (watchdog_ctx->watchdog_queue != NULL) { queue_delayed_work(watchdog_ctx->watchdog_queue, delayed_work, - msecs_to_jiffies(PS3_WATCHDOG_INTERVAL)); + msecs_to_jiffies(PS3_WATCHDOG_INTERVAL)); } } -int ps3_watchdog_start(struct ps3_instance *instance) +S32 ps3_watchdog_start(struct ps3_instance *instance) { - struct ps3_watchdog_context *watchdog_ctx = &instance->watchdog_context; + struct ps3_watchdog_context* watchdog_ctx = &instance->watchdog_context; char watchdog_queue_name[PS3_WATCHDOG_NAME_MAX_LENGTH]; - struct delayed_work *delayed_work = &watchdog_ctx->watchdog_work; - + struct delayed_work* delayed_work = &watchdog_ctx->watchdog_work; ps3_atomic_inc(&instance->watchdog_ref); - mb(); /* in order to force CPU ordering */ + mb(); - if (watchdog_ctx->is_stop == PS3_FALSE) { + if (PS3_FALSE == watchdog_ctx->is_stop) { LOG_DEBUG("hno:%u watchdog running\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->watchdog_ref); return PS3_SUCCESS; @@ -229,7 +207,7 @@ int ps3_watchdog_start(struct ps3_instance *instance) if (watchdog_ctx->watchdog_queue != NULL) { LOG_DEBUG("hno:%u watchdog for is already started!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->watchdog_ref); goto l_out; } @@ -239,13 +217,13 @@ int ps3_watchdog_start(struct ps3_instance *instance) INIT_DELAYED_WORK(delayed_work, ps3_watchdog_service); snprintf(watchdog_queue_name, PS3_WATCHDOG_NAME_MAX_LENGTH, - "ps3_watchdog_service_host%d", instance->host->host_no); + "ps3_watchdog_service_host%d", instance->host->host_no); watchdog_ctx->watchdog_queue = create_singlethread_workqueue(watchdog_queue_name); if (watchdog_ctx->watchdog_queue == NULL) { LOG_ERROR("hno:%u watchdog work queue create failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->watchdog_ref); return -PS3_FAILED; } @@ -253,7 +231,7 @@ int ps3_watchdog_start(struct ps3_instance *instance) watchdog_ctx->instance = instance; watchdog_ctx->is_stop = PS3_FALSE; queue_delayed_work(watchdog_ctx->watchdog_queue, delayed_work, - msecs_to_jiffies(PS3_WATCHDOG_INTERVAL)); + msecs_to_jiffies(PS3_WATCHDOG_INTERVAL)); ps3_atomic_dec(&instance->watchdog_ref); l_out: @@ -262,44 +240,47 @@ int ps3_watchdog_start(struct ps3_instance *instance) void ps3_watchdog_stop(struct ps3_instance *instance) { - struct ps3_watchdog_context *watchdog_ctx = &instance->watchdog_context; - struct workqueue_struct *watchdog_queue; - struct delayed_work *delayed_work = &watchdog_ctx->watchdog_work; + struct ps3_watchdog_context* watchdog_ctx = &instance->watchdog_context; + struct workqueue_struct* watchdog_queue; + struct delayed_work* delayed_work = &watchdog_ctx->watchdog_work; - if (watchdog_ctx->is_stop == PS3_TRUE) + if (PS3_TRUE == watchdog_ctx->is_stop) { return; + } watchdog_ctx->is_stop = PS3_TRUE; - mb(); /* in order to force CPU ordering */ - while (ps3_atomic_read(&instance->watchdog_ref) != 0) + mb(); + while(ps3_atomic_read(&instance->watchdog_ref) != 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); + } if (watchdog_ctx->watchdog_queue != NULL) { watchdog_queue = watchdog_ctx->watchdog_queue; - if (!cancel_delayed_work_sync(delayed_work)) + if (!cancel_delayed_work_sync(delayed_work)) { flush_workqueue(watchdog_queue); + } destroy_workqueue(watchdog_queue); watchdog_ctx->watchdog_queue = NULL; LOG_INFO("hno:%u watchdog destroy work and stop\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } } #else static void ps3_watchdog_service(void *ins) { - struct ps3_instance *instance = (struct ps3_instance *)ins; - struct ps3_watchdog_context *watchdog_ctx = &instance->watchdog_context; - struct ps3_delay_worker *watchdog_work = &watchdog_ctx->watchdog_work; - int ret = PS3_SUCCESS; - - if (ps3_atomic_read(&instance->state_machine.state) != - PS3_INSTANCE_STATE_OPERATIONAL && - (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE)) { + struct ps3_instance *instance = (struct ps3_instance*)ins; + struct ps3_watchdog_context* watchdog_ctx = &instance->watchdog_context; + struct ps3_delay_worker* watchdog_work = &watchdog_ctx->watchdog_work; + S32 ret = PS3_SUCCESS; + + if(ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_OPERATIONAL && + (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE)) { watchdog_ctx->is_halt = PS3_TRUE; goto l_next; } @@ -309,15 +290,16 @@ static void ps3_watchdog_service(void *ins) if (instance->is_probe_finish) { ret = ps3_watchdog_fault_detect_and_recovery(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR( - "hno:%u watchdog fault detect and recovery failed watchdog service exit\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u watchdog fault detect and recovery \ + failed watchdog service exit\n", + PS3_HOST(instance)); } } l_next: if (watchdog_ctx->is_stop) { - LOG_DEBUG("hno:%u watchdog has stop\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u watchdog has stop\n", + PS3_HOST(instance)); return; } @@ -326,26 +308,25 @@ static void ps3_watchdog_service(void *ins) ps3_delay_worker_start(watchdog_work, PS3_WATCHDOG_INTERVAL); } -int ps3_watchdog_start(struct ps3_instance *instance) +S32 ps3_watchdog_start(struct ps3_instance *instance) { - int ret = PS3_SUCCESS; - struct ps3_watchdog_context *watchdog_ctx = &instance->watchdog_context; - struct ps3_delay_worker *watchdog_work = &watchdog_ctx->watchdog_work; + S32 ret = PS3_SUCCESS; + struct ps3_watchdog_context* watchdog_ctx = &instance->watchdog_context; + struct ps3_delay_worker* watchdog_work = &watchdog_ctx->watchdog_work; memset(watchdog_ctx, 0, sizeof(struct ps3_watchdog_context)); - if (ps3_delay_worker_init(instance, watchdog_work, - "ps3_watchdog_service", - ps3_watchdog_service) != PS3_SUCCESS) { - LOG_ERROR("hno:%u timer init failed\n", PS3_HOST(instance)); + if (ps3_delay_worker_init(instance, watchdog_work, "ps3_watchdog_service", ps3_watchdog_service) != PS3_SUCCESS) { + LOG_ERROR("hno:%u timer init failed\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } watchdog_ctx->is_stop = PS3_FALSE; - if (ps3_delay_worker_start(watchdog_work, PS3_WATCHDOG_INTERVAL) != - PS3_SUCCESS) { - LOG_ERROR("hno:%u timer request failed\n", PS3_HOST(instance)); + if (ps3_delay_worker_start(watchdog_work, PS3_WATCHDOG_INTERVAL) != PS3_SUCCESS) { + LOG_ERROR("hno:%u timer request failed\n", + PS3_HOST(instance)); ret = -PS3_FAILED; watchdog_ctx->is_stop = PS3_TRUE; goto l_out; @@ -357,14 +338,15 @@ int ps3_watchdog_start(struct ps3_instance *instance) void ps3_watchdog_stop(struct ps3_instance *instance) { - struct ps3_watchdog_context *watchdog_ctx = &instance->watchdog_context; - struct ps3_delay_worker *watchdog_work = &watchdog_ctx->watchdog_work; + struct ps3_watchdog_context* watchdog_ctx = &instance->watchdog_context; + struct ps3_delay_worker* watchdog_work = &watchdog_ctx->watchdog_work; watchdog_ctx->is_stop = PS3_TRUE; ps3_delay_worker_exit(watchdog_work); memset(watchdog_ctx, 0, sizeof(struct ps3_watchdog_context)); - LOG_WARN("hno:%u watchdog destroy work and stop\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u watchdog destory work and stop\n", + PS3_HOST(instance)); } #endif + diff --git a/drivers/scsi/linkdata/ps3stor/ps3_watchdog.h b/drivers/scsi/linkdata/ps3stor/ps3_watchdog.h index 1703ae1e426d..20308a88ccfb 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_watchdog.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_watchdog.h @@ -1,5 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) LD. */ + #ifndef _PS3_WATCHDOG_H_ #define _PS3_WATCHDOG_H_ @@ -13,7 +12,7 @@ #include "ps3_htp_def.h" #include "ps3_instance_manager.h" -#define PS3_WATCHDOG_INTERVAL (1000) +#define PS3_WATCHDOG_INTERVAL (1000) struct ps3_watchdog_context { #ifndef _WINDOWS @@ -23,11 +22,11 @@ struct ps3_watchdog_context { #else struct ps3_delay_worker watchdog_work; #endif - unsigned char is_stop; - unsigned char is_halt; + Bool is_stop; + Bool is_halt; }; -int ps3_watchdog_start(struct ps3_instance *instance); +S32 ps3_watchdog_start(struct ps3_instance *instance); void ps3_watchdog_stop(struct ps3_instance *instance); #endif -- Gitee