1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * mtip32xx.h - Header file for the P320 SSD Block Driver 4*4882a593Smuzhiyun * Copyright (C) 2011 Micron Technology, Inc. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * Portions of this code were derived from works subjected to the 7*4882a593Smuzhiyun * following copyright: 8*4882a593Smuzhiyun * Copyright (C) 2009 Integrated Device Technology, Inc. 9*4882a593Smuzhiyun */ 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #ifndef __MTIP32XX_H__ 12*4882a593Smuzhiyun #define __MTIP32XX_H__ 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun #include <linux/spinlock.h> 15*4882a593Smuzhiyun #include <linux/rwsem.h> 16*4882a593Smuzhiyun #include <linux/ata.h> 17*4882a593Smuzhiyun #include <linux/interrupt.h> 18*4882a593Smuzhiyun #include <linux/genhd.h> 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun /* Offset of Subsystem Device ID in pci confoguration space */ 21*4882a593Smuzhiyun #define PCI_SUBSYSTEM_DEVICEID 0x2E 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun /* offset of Device Control register in PCIe extended capabilites space */ 24*4882a593Smuzhiyun #define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun /* check for erase mode support during secure erase */ 27*4882a593Smuzhiyun #define MTIP_SEC_ERASE_MODE 0x2 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun /* # of times to retry timed out/failed IOs */ 30*4882a593Smuzhiyun #define MTIP_MAX_RETRIES 2 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun /* Various timeout values in ms */ 33*4882a593Smuzhiyun #define MTIP_NCQ_CMD_TIMEOUT_MS 15000 34*4882a593Smuzhiyun #define MTIP_IOCTL_CMD_TIMEOUT_MS 5000 35*4882a593Smuzhiyun #define MTIP_INT_CMD_TIMEOUT_MS 5000 36*4882a593Smuzhiyun #define MTIP_QUIESCE_IO_TIMEOUT_MS (MTIP_NCQ_CMD_TIMEOUT_MS * \ 37*4882a593Smuzhiyun (MTIP_MAX_RETRIES + 1)) 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun /* check for timeouts every 500ms */ 40*4882a593Smuzhiyun #define MTIP_TIMEOUT_CHECK_PERIOD 500 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun /* ftl rebuild */ 43*4882a593Smuzhiyun #define MTIP_FTL_REBUILD_OFFSET 142 44*4882a593Smuzhiyun #define MTIP_FTL_REBUILD_MAGIC 0xED51 45*4882a593Smuzhiyun #define MTIP_FTL_REBUILD_TIMEOUT_MS 2400000 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun /* unaligned IO handling */ 48*4882a593Smuzhiyun #define MTIP_MAX_UNALIGNED_SLOTS 2 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun /* Macro to extract the tag bit number from a tag value. */ 51*4882a593Smuzhiyun #define MTIP_TAG_BIT(tag) (tag & 0x1F) 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun /* 54*4882a593Smuzhiyun * Macro to extract the tag index from a tag value. The index 55*4882a593Smuzhiyun * is used to access the correct s_active/Command Issue register based 56*4882a593Smuzhiyun * on the tag value. 57*4882a593Smuzhiyun */ 58*4882a593Smuzhiyun #define MTIP_TAG_INDEX(tag) (tag >> 5) 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun /* 61*4882a593Smuzhiyun * Maximum number of scatter gather entries 62*4882a593Smuzhiyun * a single command may have. 63*4882a593Smuzhiyun */ 64*4882a593Smuzhiyun #define MTIP_MAX_SG 504 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun /* 67*4882a593Smuzhiyun * Maximum number of slot groups (Command Issue & s_active registers) 68*4882a593Smuzhiyun * NOTE: This is the driver maximum; check dd->slot_groups for actual value. 69*4882a593Smuzhiyun */ 70*4882a593Smuzhiyun #define MTIP_MAX_SLOT_GROUPS 8 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun /* Internal command tag. */ 73*4882a593Smuzhiyun #define MTIP_TAG_INTERNAL 0 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun /* Micron Vendor ID & P320x SSD Device ID */ 76*4882a593Smuzhiyun #define PCI_VENDOR_ID_MICRON 0x1344 77*4882a593Smuzhiyun #define P320H_DEVICE_ID 0x5150 78*4882a593Smuzhiyun #define P320M_DEVICE_ID 0x5151 79*4882a593Smuzhiyun #define P320S_DEVICE_ID 0x5152 80*4882a593Smuzhiyun #define P325M_DEVICE_ID 0x5153 81*4882a593Smuzhiyun #define P420H_DEVICE_ID 0x5160 82*4882a593Smuzhiyun #define P420M_DEVICE_ID 0x5161 83*4882a593Smuzhiyun #define P425M_DEVICE_ID 0x5163 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun /* Driver name and version strings */ 86*4882a593Smuzhiyun #define MTIP_DRV_NAME "mtip32xx" 87*4882a593Smuzhiyun #define MTIP_DRV_VERSION "1.3.1" 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun /* Maximum number of minor device numbers per device. */ 90*4882a593Smuzhiyun #define MTIP_MAX_MINORS 16 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun /* Maximum number of supported command slots. */ 93*4882a593Smuzhiyun #define MTIP_MAX_COMMAND_SLOTS (MTIP_MAX_SLOT_GROUPS * 32) 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun /* 96*4882a593Smuzhiyun * Per-tag bitfield size in longs. 97*4882a593Smuzhiyun * Linux bit manipulation functions 98*4882a593Smuzhiyun * (i.e. test_and_set_bit, find_next_zero_bit) 99*4882a593Smuzhiyun * manipulate memory in longs, so we try to make the math work. 100*4882a593Smuzhiyun * take the slot groups and find the number of longs, rounding up. 101*4882a593Smuzhiyun * Careful! i386 and x86_64 use different size longs! 102*4882a593Smuzhiyun */ 103*4882a593Smuzhiyun #define U32_PER_LONG (sizeof(long) / sizeof(u32)) 104*4882a593Smuzhiyun #define SLOTBITS_IN_LONGS ((MTIP_MAX_SLOT_GROUPS + \ 105*4882a593Smuzhiyun (U32_PER_LONG-1))/U32_PER_LONG) 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun /* BAR number used to access the HBA registers. */ 108*4882a593Smuzhiyun #define MTIP_ABAR 5 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun #ifdef DEBUG 111*4882a593Smuzhiyun #define dbg_printk(format, arg...) \ 112*4882a593Smuzhiyun printk(pr_fmt(format), ##arg); 113*4882a593Smuzhiyun #else 114*4882a593Smuzhiyun #define dbg_printk(format, arg...) 115*4882a593Smuzhiyun #endif 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun #define MTIP_DFS_MAX_BUF_SIZE 1024 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun enum { 120*4882a593Smuzhiyun /* below are bit numbers in 'flags' defined in mtip_port */ 121*4882a593Smuzhiyun MTIP_PF_IC_ACTIVE_BIT = 0, /* pio/ioctl */ 122*4882a593Smuzhiyun MTIP_PF_EH_ACTIVE_BIT = 1, /* error handling */ 123*4882a593Smuzhiyun MTIP_PF_SE_ACTIVE_BIT = 2, /* secure erase */ 124*4882a593Smuzhiyun MTIP_PF_DM_ACTIVE_BIT = 3, /* download microcde */ 125*4882a593Smuzhiyun MTIP_PF_TO_ACTIVE_BIT = 9, /* timeout handling */ 126*4882a593Smuzhiyun MTIP_PF_PAUSE_IO = ((1 << MTIP_PF_IC_ACTIVE_BIT) | 127*4882a593Smuzhiyun (1 << MTIP_PF_EH_ACTIVE_BIT) | 128*4882a593Smuzhiyun (1 << MTIP_PF_SE_ACTIVE_BIT) | 129*4882a593Smuzhiyun (1 << MTIP_PF_DM_ACTIVE_BIT) | 130*4882a593Smuzhiyun (1 << MTIP_PF_TO_ACTIVE_BIT)), 131*4882a593Smuzhiyun MTIP_PF_HOST_CAP_64 = 10, /* cache HOST_CAP_64 */ 132*4882a593Smuzhiyun 133*4882a593Smuzhiyun MTIP_PF_SVC_THD_ACTIVE_BIT = 4, 134*4882a593Smuzhiyun MTIP_PF_ISSUE_CMDS_BIT = 5, 135*4882a593Smuzhiyun MTIP_PF_REBUILD_BIT = 6, 136*4882a593Smuzhiyun MTIP_PF_SVC_THD_STOP_BIT = 8, 137*4882a593Smuzhiyun 138*4882a593Smuzhiyun MTIP_PF_SVC_THD_WORK = ((1 << MTIP_PF_EH_ACTIVE_BIT) | 139*4882a593Smuzhiyun (1 << MTIP_PF_ISSUE_CMDS_BIT) | 140*4882a593Smuzhiyun (1 << MTIP_PF_REBUILD_BIT) | 141*4882a593Smuzhiyun (1 << MTIP_PF_SVC_THD_STOP_BIT) | 142*4882a593Smuzhiyun (1 << MTIP_PF_TO_ACTIVE_BIT)), 143*4882a593Smuzhiyun 144*4882a593Smuzhiyun /* below are bit numbers in 'dd_flag' defined in driver_data */ 145*4882a593Smuzhiyun MTIP_DDF_SEC_LOCK_BIT = 0, 146*4882a593Smuzhiyun MTIP_DDF_REMOVE_PENDING_BIT = 1, 147*4882a593Smuzhiyun MTIP_DDF_OVER_TEMP_BIT = 2, 148*4882a593Smuzhiyun MTIP_DDF_WRITE_PROTECT_BIT = 3, 149*4882a593Smuzhiyun MTIP_DDF_CLEANUP_BIT = 5, 150*4882a593Smuzhiyun MTIP_DDF_RESUME_BIT = 6, 151*4882a593Smuzhiyun MTIP_DDF_INIT_DONE_BIT = 7, 152*4882a593Smuzhiyun MTIP_DDF_REBUILD_FAILED_BIT = 8, 153*4882a593Smuzhiyun MTIP_DDF_REMOVAL_BIT = 9, 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun MTIP_DDF_STOP_IO = ((1 << MTIP_DDF_REMOVE_PENDING_BIT) | 156*4882a593Smuzhiyun (1 << MTIP_DDF_SEC_LOCK_BIT) | 157*4882a593Smuzhiyun (1 << MTIP_DDF_OVER_TEMP_BIT) | 158*4882a593Smuzhiyun (1 << MTIP_DDF_WRITE_PROTECT_BIT) | 159*4882a593Smuzhiyun (1 << MTIP_DDF_REBUILD_FAILED_BIT)), 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun }; 162*4882a593Smuzhiyun 163*4882a593Smuzhiyun struct smart_attr { 164*4882a593Smuzhiyun u8 attr_id; 165*4882a593Smuzhiyun __le16 flags; 166*4882a593Smuzhiyun u8 cur; 167*4882a593Smuzhiyun u8 worst; 168*4882a593Smuzhiyun __le32 data; 169*4882a593Smuzhiyun u8 res[3]; 170*4882a593Smuzhiyun } __packed; 171*4882a593Smuzhiyun 172*4882a593Smuzhiyun struct mtip_work { 173*4882a593Smuzhiyun struct work_struct work; 174*4882a593Smuzhiyun void *port; 175*4882a593Smuzhiyun int cpu_binding; 176*4882a593Smuzhiyun u32 completed; 177*4882a593Smuzhiyun } ____cacheline_aligned_in_smp; 178*4882a593Smuzhiyun 179*4882a593Smuzhiyun #define DEFINE_HANDLER(group) \ 180*4882a593Smuzhiyun void mtip_workq_sdbf##group(struct work_struct *work) \ 181*4882a593Smuzhiyun { \ 182*4882a593Smuzhiyun struct mtip_work *w = (struct mtip_work *) work; \ 183*4882a593Smuzhiyun mtip_workq_sdbfx(w->port, group, w->completed); \ 184*4882a593Smuzhiyun } 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun /* Register Frame Information Structure (FIS), host to device. */ 187*4882a593Smuzhiyun struct host_to_dev_fis { 188*4882a593Smuzhiyun /* 189*4882a593Smuzhiyun * FIS type. 190*4882a593Smuzhiyun * - 27h Register FIS, host to device. 191*4882a593Smuzhiyun * - 34h Register FIS, device to host. 192*4882a593Smuzhiyun * - 39h DMA Activate FIS, device to host. 193*4882a593Smuzhiyun * - 41h DMA Setup FIS, bi-directional. 194*4882a593Smuzhiyun * - 46h Data FIS, bi-directional. 195*4882a593Smuzhiyun * - 58h BIST Activate FIS, bi-directional. 196*4882a593Smuzhiyun * - 5Fh PIO Setup FIS, device to host. 197*4882a593Smuzhiyun * - A1h Set Device Bits FIS, device to host. 198*4882a593Smuzhiyun */ 199*4882a593Smuzhiyun unsigned char type; 200*4882a593Smuzhiyun unsigned char opts; 201*4882a593Smuzhiyun unsigned char command; 202*4882a593Smuzhiyun unsigned char features; 203*4882a593Smuzhiyun 204*4882a593Smuzhiyun union { 205*4882a593Smuzhiyun unsigned char lba_low; 206*4882a593Smuzhiyun unsigned char sector; 207*4882a593Smuzhiyun }; 208*4882a593Smuzhiyun union { 209*4882a593Smuzhiyun unsigned char lba_mid; 210*4882a593Smuzhiyun unsigned char cyl_low; 211*4882a593Smuzhiyun }; 212*4882a593Smuzhiyun union { 213*4882a593Smuzhiyun unsigned char lba_hi; 214*4882a593Smuzhiyun unsigned char cyl_hi; 215*4882a593Smuzhiyun }; 216*4882a593Smuzhiyun union { 217*4882a593Smuzhiyun unsigned char device; 218*4882a593Smuzhiyun unsigned char head; 219*4882a593Smuzhiyun }; 220*4882a593Smuzhiyun 221*4882a593Smuzhiyun union { 222*4882a593Smuzhiyun unsigned char lba_low_ex; 223*4882a593Smuzhiyun unsigned char sector_ex; 224*4882a593Smuzhiyun }; 225*4882a593Smuzhiyun union { 226*4882a593Smuzhiyun unsigned char lba_mid_ex; 227*4882a593Smuzhiyun unsigned char cyl_low_ex; 228*4882a593Smuzhiyun }; 229*4882a593Smuzhiyun union { 230*4882a593Smuzhiyun unsigned char lba_hi_ex; 231*4882a593Smuzhiyun unsigned char cyl_hi_ex; 232*4882a593Smuzhiyun }; 233*4882a593Smuzhiyun unsigned char features_ex; 234*4882a593Smuzhiyun 235*4882a593Smuzhiyun unsigned char sect_count; 236*4882a593Smuzhiyun unsigned char sect_cnt_ex; 237*4882a593Smuzhiyun unsigned char res2; 238*4882a593Smuzhiyun unsigned char control; 239*4882a593Smuzhiyun 240*4882a593Smuzhiyun unsigned int res3; 241*4882a593Smuzhiyun }; 242*4882a593Smuzhiyun 243*4882a593Smuzhiyun /* Command header structure. */ 244*4882a593Smuzhiyun struct mtip_cmd_hdr { 245*4882a593Smuzhiyun /* 246*4882a593Smuzhiyun * Command options. 247*4882a593Smuzhiyun * - Bits 31:16 Number of PRD entries. 248*4882a593Smuzhiyun * - Bits 15:8 Unused in this implementation. 249*4882a593Smuzhiyun * - Bit 7 Prefetch bit, informs the drive to prefetch PRD entries. 250*4882a593Smuzhiyun * - Bit 6 Write bit, should be set when writing data to the device. 251*4882a593Smuzhiyun * - Bit 5 Unused in this implementation. 252*4882a593Smuzhiyun * - Bits 4:0 Length of the command FIS in DWords (DWord = 4 bytes). 253*4882a593Smuzhiyun */ 254*4882a593Smuzhiyun __le32 opts; 255*4882a593Smuzhiyun /* This field is unsed when using NCQ. */ 256*4882a593Smuzhiyun union { 257*4882a593Smuzhiyun __le32 byte_count; 258*4882a593Smuzhiyun __le32 status; 259*4882a593Smuzhiyun }; 260*4882a593Smuzhiyun /* 261*4882a593Smuzhiyun * Lower 32 bits of the command table address associated with this 262*4882a593Smuzhiyun * header. The command table addresses must be 128 byte aligned. 263*4882a593Smuzhiyun */ 264*4882a593Smuzhiyun __le32 ctba; 265*4882a593Smuzhiyun /* 266*4882a593Smuzhiyun * If 64 bit addressing is used this field is the upper 32 bits 267*4882a593Smuzhiyun * of the command table address associated with this command. 268*4882a593Smuzhiyun */ 269*4882a593Smuzhiyun __le32 ctbau; 270*4882a593Smuzhiyun /* Reserved and unused. */ 271*4882a593Smuzhiyun u32 res[4]; 272*4882a593Smuzhiyun }; 273*4882a593Smuzhiyun 274*4882a593Smuzhiyun /* Command scatter gather structure (PRD). */ 275*4882a593Smuzhiyun struct mtip_cmd_sg { 276*4882a593Smuzhiyun /* 277*4882a593Smuzhiyun * Low 32 bits of the data buffer address. For P320 this 278*4882a593Smuzhiyun * address must be 8 byte aligned signified by bits 2:0 being 279*4882a593Smuzhiyun * set to 0. 280*4882a593Smuzhiyun */ 281*4882a593Smuzhiyun __le32 dba; 282*4882a593Smuzhiyun /* 283*4882a593Smuzhiyun * When 64 bit addressing is used this field is the upper 284*4882a593Smuzhiyun * 32 bits of the data buffer address. 285*4882a593Smuzhiyun */ 286*4882a593Smuzhiyun __le32 dba_upper; 287*4882a593Smuzhiyun /* Unused. */ 288*4882a593Smuzhiyun __le32 reserved; 289*4882a593Smuzhiyun /* 290*4882a593Smuzhiyun * Bit 31: interrupt when this data block has been transferred. 291*4882a593Smuzhiyun * Bits 30..22: reserved 292*4882a593Smuzhiyun * Bits 21..0: byte count (minus 1). For P320 the byte count must be 293*4882a593Smuzhiyun * 8 byte aligned signified by bits 2:0 being set to 1. 294*4882a593Smuzhiyun */ 295*4882a593Smuzhiyun __le32 info; 296*4882a593Smuzhiyun }; 297*4882a593Smuzhiyun struct mtip_port; 298*4882a593Smuzhiyun 299*4882a593Smuzhiyun struct mtip_int_cmd; 300*4882a593Smuzhiyun 301*4882a593Smuzhiyun /* Structure used to describe a command. */ 302*4882a593Smuzhiyun struct mtip_cmd { 303*4882a593Smuzhiyun void *command; /* ptr to command table entry */ 304*4882a593Smuzhiyun 305*4882a593Smuzhiyun dma_addr_t command_dma; /* corresponding physical address */ 306*4882a593Smuzhiyun 307*4882a593Smuzhiyun int scatter_ents; /* Number of scatter list entries used */ 308*4882a593Smuzhiyun 309*4882a593Smuzhiyun int unaligned; /* command is unaligned on 4k boundary */ 310*4882a593Smuzhiyun 311*4882a593Smuzhiyun union { 312*4882a593Smuzhiyun struct scatterlist sg[MTIP_MAX_SG]; /* Scatter list entries */ 313*4882a593Smuzhiyun struct mtip_int_cmd *icmd; 314*4882a593Smuzhiyun }; 315*4882a593Smuzhiyun 316*4882a593Smuzhiyun int retries; /* The number of retries left for this command. */ 317*4882a593Smuzhiyun 318*4882a593Smuzhiyun int direction; /* Data transfer direction */ 319*4882a593Smuzhiyun blk_status_t status; 320*4882a593Smuzhiyun }; 321*4882a593Smuzhiyun 322*4882a593Smuzhiyun /* Structure used to describe a port. */ 323*4882a593Smuzhiyun struct mtip_port { 324*4882a593Smuzhiyun /* Pointer back to the driver data for this port. */ 325*4882a593Smuzhiyun struct driver_data *dd; 326*4882a593Smuzhiyun /* 327*4882a593Smuzhiyun * Used to determine if the data pointed to by the 328*4882a593Smuzhiyun * identify field is valid. 329*4882a593Smuzhiyun */ 330*4882a593Smuzhiyun unsigned long identify_valid; 331*4882a593Smuzhiyun /* Base address of the memory mapped IO for the port. */ 332*4882a593Smuzhiyun void __iomem *mmio; 333*4882a593Smuzhiyun /* Array of pointers to the memory mapped s_active registers. */ 334*4882a593Smuzhiyun void __iomem *s_active[MTIP_MAX_SLOT_GROUPS]; 335*4882a593Smuzhiyun /* Array of pointers to the memory mapped completed registers. */ 336*4882a593Smuzhiyun void __iomem *completed[MTIP_MAX_SLOT_GROUPS]; 337*4882a593Smuzhiyun /* Array of pointers to the memory mapped Command Issue registers. */ 338*4882a593Smuzhiyun void __iomem *cmd_issue[MTIP_MAX_SLOT_GROUPS]; 339*4882a593Smuzhiyun /* 340*4882a593Smuzhiyun * Pointer to the beginning of the command header memory as used 341*4882a593Smuzhiyun * by the driver. 342*4882a593Smuzhiyun */ 343*4882a593Smuzhiyun void *command_list; 344*4882a593Smuzhiyun /* 345*4882a593Smuzhiyun * Pointer to the beginning of the command header memory as used 346*4882a593Smuzhiyun * by the DMA. 347*4882a593Smuzhiyun */ 348*4882a593Smuzhiyun dma_addr_t command_list_dma; 349*4882a593Smuzhiyun /* 350*4882a593Smuzhiyun * Pointer to the beginning of the RX FIS memory as used 351*4882a593Smuzhiyun * by the driver. 352*4882a593Smuzhiyun */ 353*4882a593Smuzhiyun void *rxfis; 354*4882a593Smuzhiyun /* 355*4882a593Smuzhiyun * Pointer to the beginning of the RX FIS memory as used 356*4882a593Smuzhiyun * by the DMA. 357*4882a593Smuzhiyun */ 358*4882a593Smuzhiyun dma_addr_t rxfis_dma; 359*4882a593Smuzhiyun /* 360*4882a593Smuzhiyun * Pointer to the DMA region for RX Fis, Identify, RLE10, and SMART 361*4882a593Smuzhiyun */ 362*4882a593Smuzhiyun void *block1; 363*4882a593Smuzhiyun /* 364*4882a593Smuzhiyun * DMA address of region for RX Fis, Identify, RLE10, and SMART 365*4882a593Smuzhiyun */ 366*4882a593Smuzhiyun dma_addr_t block1_dma; 367*4882a593Smuzhiyun /* 368*4882a593Smuzhiyun * Pointer to the beginning of the identify data memory as used 369*4882a593Smuzhiyun * by the driver. 370*4882a593Smuzhiyun */ 371*4882a593Smuzhiyun u16 *identify; 372*4882a593Smuzhiyun /* 373*4882a593Smuzhiyun * Pointer to the beginning of the identify data memory as used 374*4882a593Smuzhiyun * by the DMA. 375*4882a593Smuzhiyun */ 376*4882a593Smuzhiyun dma_addr_t identify_dma; 377*4882a593Smuzhiyun /* 378*4882a593Smuzhiyun * Pointer to the beginning of a sector buffer that is used 379*4882a593Smuzhiyun * by the driver when issuing internal commands. 380*4882a593Smuzhiyun */ 381*4882a593Smuzhiyun u16 *sector_buffer; 382*4882a593Smuzhiyun /* 383*4882a593Smuzhiyun * Pointer to the beginning of a sector buffer that is used 384*4882a593Smuzhiyun * by the DMA when the driver issues internal commands. 385*4882a593Smuzhiyun */ 386*4882a593Smuzhiyun dma_addr_t sector_buffer_dma; 387*4882a593Smuzhiyun 388*4882a593Smuzhiyun u16 *log_buf; 389*4882a593Smuzhiyun dma_addr_t log_buf_dma; 390*4882a593Smuzhiyun 391*4882a593Smuzhiyun u8 *smart_buf; 392*4882a593Smuzhiyun dma_addr_t smart_buf_dma; 393*4882a593Smuzhiyun 394*4882a593Smuzhiyun /* 395*4882a593Smuzhiyun * used to queue commands when an internal command is in progress 396*4882a593Smuzhiyun * or error handling is active 397*4882a593Smuzhiyun */ 398*4882a593Smuzhiyun unsigned long cmds_to_issue[SLOTBITS_IN_LONGS]; 399*4882a593Smuzhiyun /* Used by mtip_service_thread to wait for an event */ 400*4882a593Smuzhiyun wait_queue_head_t svc_wait; 401*4882a593Smuzhiyun /* 402*4882a593Smuzhiyun * indicates the state of the port. Also, helps the service thread 403*4882a593Smuzhiyun * to determine its action on wake up. 404*4882a593Smuzhiyun */ 405*4882a593Smuzhiyun unsigned long flags; 406*4882a593Smuzhiyun /* 407*4882a593Smuzhiyun * Timer used to complete commands that have been active for too long. 408*4882a593Smuzhiyun */ 409*4882a593Smuzhiyun unsigned long ic_pause_timer; 410*4882a593Smuzhiyun 411*4882a593Smuzhiyun /* Counter to control queue depth of unaligned IOs */ 412*4882a593Smuzhiyun atomic_t cmd_slot_unal; 413*4882a593Smuzhiyun 414*4882a593Smuzhiyun /* Spinlock for working around command-issue bug. */ 415*4882a593Smuzhiyun spinlock_t cmd_issue_lock[MTIP_MAX_SLOT_GROUPS]; 416*4882a593Smuzhiyun }; 417*4882a593Smuzhiyun 418*4882a593Smuzhiyun /* 419*4882a593Smuzhiyun * Driver private data structure. 420*4882a593Smuzhiyun * 421*4882a593Smuzhiyun * One structure is allocated per probed device. 422*4882a593Smuzhiyun */ 423*4882a593Smuzhiyun struct driver_data { 424*4882a593Smuzhiyun void __iomem *mmio; /* Base address of the HBA registers. */ 425*4882a593Smuzhiyun 426*4882a593Smuzhiyun int major; /* Major device number. */ 427*4882a593Smuzhiyun 428*4882a593Smuzhiyun int instance; /* Instance number. First device probed is 0, ... */ 429*4882a593Smuzhiyun 430*4882a593Smuzhiyun struct gendisk *disk; /* Pointer to our gendisk structure. */ 431*4882a593Smuzhiyun 432*4882a593Smuzhiyun struct pci_dev *pdev; /* Pointer to the PCI device structure. */ 433*4882a593Smuzhiyun 434*4882a593Smuzhiyun struct request_queue *queue; /* Our request queue. */ 435*4882a593Smuzhiyun 436*4882a593Smuzhiyun struct blk_mq_tag_set tags; /* blk_mq tags */ 437*4882a593Smuzhiyun 438*4882a593Smuzhiyun struct mtip_port *port; /* Pointer to the port data structure. */ 439*4882a593Smuzhiyun 440*4882a593Smuzhiyun unsigned product_type; /* magic value declaring the product type */ 441*4882a593Smuzhiyun 442*4882a593Smuzhiyun unsigned slot_groups; /* number of slot groups the product supports */ 443*4882a593Smuzhiyun 444*4882a593Smuzhiyun unsigned long index; /* Index to determine the disk name */ 445*4882a593Smuzhiyun 446*4882a593Smuzhiyun unsigned long dd_flag; /* NOTE: use atomic bit operations on this */ 447*4882a593Smuzhiyun 448*4882a593Smuzhiyun struct task_struct *mtip_svc_handler; /* task_struct of svc thd */ 449*4882a593Smuzhiyun 450*4882a593Smuzhiyun struct dentry *dfs_node; 451*4882a593Smuzhiyun 452*4882a593Smuzhiyun bool sr; 453*4882a593Smuzhiyun 454*4882a593Smuzhiyun int numa_node; /* NUMA support */ 455*4882a593Smuzhiyun 456*4882a593Smuzhiyun char workq_name[32]; 457*4882a593Smuzhiyun 458*4882a593Smuzhiyun struct workqueue_struct *isr_workq; 459*4882a593Smuzhiyun 460*4882a593Smuzhiyun atomic_t irq_workers_active; 461*4882a593Smuzhiyun 462*4882a593Smuzhiyun struct mtip_work work[MTIP_MAX_SLOT_GROUPS]; 463*4882a593Smuzhiyun 464*4882a593Smuzhiyun int isr_binding; 465*4882a593Smuzhiyun 466*4882a593Smuzhiyun struct block_device *bdev; 467*4882a593Smuzhiyun 468*4882a593Smuzhiyun struct list_head online_list; /* linkage for online list */ 469*4882a593Smuzhiyun 470*4882a593Smuzhiyun struct list_head remove_list; /* linkage for removing list */ 471*4882a593Smuzhiyun 472*4882a593Smuzhiyun int unal_qdepth; /* qdepth of unaligned IO queue */ 473*4882a593Smuzhiyun }; 474*4882a593Smuzhiyun 475*4882a593Smuzhiyun #endif 476