| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * mtip32xx.h - Header file for the P320 SSD Block Driver |
|---|
| 3 | 4 | * Copyright (C) 2011 Micron Technology, Inc. |
|---|
| .. | .. |
|---|
| 5 | 6 | * Portions of this code were derived from works subjected to the |
|---|
| 6 | 7 | * following copyright: |
|---|
| 7 | 8 | * Copyright (C) 2009 Integrated Device Technology, Inc. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 11 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | | - * (at your option) any later version. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | | - * GNU General Public License for more details. |
|---|
| 18 | | - * |
|---|
| 19 | 9 | */ |
|---|
| 20 | 10 | |
|---|
| 21 | 11 | #ifndef __MTIP32XX_H__ |
|---|
| .. | .. |
|---|
| 126 | 116 | |
|---|
| 127 | 117 | #define MTIP_DFS_MAX_BUF_SIZE 1024 |
|---|
| 128 | 118 | |
|---|
| 129 | | -#define __force_bit2int (unsigned int __force) |
|---|
| 130 | | - |
|---|
| 131 | 119 | enum { |
|---|
| 132 | 120 | /* below are bit numbers in 'flags' defined in mtip_port */ |
|---|
| 133 | 121 | MTIP_PF_IC_ACTIVE_BIT = 0, /* pio/ioctl */ |
|---|
| .. | .. |
|---|
| 174 | 162 | |
|---|
| 175 | 163 | struct smart_attr { |
|---|
| 176 | 164 | u8 attr_id; |
|---|
| 177 | | - u16 flags; |
|---|
| 165 | + __le16 flags; |
|---|
| 178 | 166 | u8 cur; |
|---|
| 179 | 167 | u8 worst; |
|---|
| 180 | | - u32 data; |
|---|
| 168 | + __le32 data; |
|---|
| 181 | 169 | u8 res[3]; |
|---|
| 182 | 170 | } __packed; |
|---|
| 183 | 171 | |
|---|
| .. | .. |
|---|
| 194 | 182 | struct mtip_work *w = (struct mtip_work *) work; \ |
|---|
| 195 | 183 | mtip_workq_sdbfx(w->port, group, w->completed); \ |
|---|
| 196 | 184 | } |
|---|
| 197 | | - |
|---|
| 198 | | -#define MTIP_TRIM_TIMEOUT_MS 240000 |
|---|
| 199 | | -#define MTIP_MAX_TRIM_ENTRIES 8 |
|---|
| 200 | | -#define MTIP_MAX_TRIM_ENTRY_LEN 0xfff8 |
|---|
| 201 | | - |
|---|
| 202 | | -struct mtip_trim_entry { |
|---|
| 203 | | - u32 lba; /* starting lba of region */ |
|---|
| 204 | | - u16 rsvd; /* unused */ |
|---|
| 205 | | - u16 range; /* # of 512b blocks to trim */ |
|---|
| 206 | | -} __packed; |
|---|
| 207 | | - |
|---|
| 208 | | -struct mtip_trim { |
|---|
| 209 | | - /* Array of regions to trim */ |
|---|
| 210 | | - struct mtip_trim_entry entry[MTIP_MAX_TRIM_ENTRIES]; |
|---|
| 211 | | -} __packed; |
|---|
| 212 | 185 | |
|---|
| 213 | 186 | /* Register Frame Information Structure (FIS), host to device. */ |
|---|
| 214 | 187 | struct host_to_dev_fis { |
|---|
| .. | .. |
|---|
| 278 | 251 | * - Bit 5 Unused in this implementation. |
|---|
| 279 | 252 | * - Bits 4:0 Length of the command FIS in DWords (DWord = 4 bytes). |
|---|
| 280 | 253 | */ |
|---|
| 281 | | - unsigned int opts; |
|---|
| 254 | + __le32 opts; |
|---|
| 282 | 255 | /* This field is unsed when using NCQ. */ |
|---|
| 283 | 256 | union { |
|---|
| 284 | | - unsigned int byte_count; |
|---|
| 285 | | - unsigned int status; |
|---|
| 257 | + __le32 byte_count; |
|---|
| 258 | + __le32 status; |
|---|
| 286 | 259 | }; |
|---|
| 287 | 260 | /* |
|---|
| 288 | 261 | * Lower 32 bits of the command table address associated with this |
|---|
| 289 | 262 | * header. The command table addresses must be 128 byte aligned. |
|---|
| 290 | 263 | */ |
|---|
| 291 | | - unsigned int ctba; |
|---|
| 264 | + __le32 ctba; |
|---|
| 292 | 265 | /* |
|---|
| 293 | 266 | * If 64 bit addressing is used this field is the upper 32 bits |
|---|
| 294 | 267 | * of the command table address associated with this command. |
|---|
| 295 | 268 | */ |
|---|
| 296 | | - unsigned int ctbau; |
|---|
| 269 | + __le32 ctbau; |
|---|
| 297 | 270 | /* Reserved and unused. */ |
|---|
| 298 | | - unsigned int res[4]; |
|---|
| 271 | + u32 res[4]; |
|---|
| 299 | 272 | }; |
|---|
| 300 | 273 | |
|---|
| 301 | 274 | /* Command scatter gather structure (PRD). */ |
|---|
| .. | .. |
|---|
| 305 | 278 | * address must be 8 byte aligned signified by bits 2:0 being |
|---|
| 306 | 279 | * set to 0. |
|---|
| 307 | 280 | */ |
|---|
| 308 | | - unsigned int dba; |
|---|
| 281 | + __le32 dba; |
|---|
| 309 | 282 | /* |
|---|
| 310 | 283 | * When 64 bit addressing is used this field is the upper |
|---|
| 311 | 284 | * 32 bits of the data buffer address. |
|---|
| 312 | 285 | */ |
|---|
| 313 | | - unsigned int dba_upper; |
|---|
| 286 | + __le32 dba_upper; |
|---|
| 314 | 287 | /* Unused. */ |
|---|
| 315 | | - unsigned int reserved; |
|---|
| 288 | + __le32 reserved; |
|---|
| 316 | 289 | /* |
|---|
| 317 | 290 | * Bit 31: interrupt when this data block has been transferred. |
|---|
| 318 | 291 | * Bits 30..22: reserved |
|---|
| 319 | 292 | * Bits 21..0: byte count (minus 1). For P320 the byte count must be |
|---|
| 320 | 293 | * 8 byte aligned signified by bits 2:0 being set to 1. |
|---|
| 321 | 294 | */ |
|---|
| 322 | | - unsigned int info; |
|---|
| 295 | + __le32 info; |
|---|
| 323 | 296 | }; |
|---|
| 324 | 297 | struct mtip_port; |
|---|
| 325 | 298 | |
|---|
| 299 | +struct mtip_int_cmd; |
|---|
| 300 | + |
|---|
| 326 | 301 | /* Structure used to describe a command. */ |
|---|
| 327 | 302 | struct mtip_cmd { |
|---|
| 328 | | - |
|---|
| 329 | | - struct mtip_cmd_hdr *command_header; /* ptr to command header entry */ |
|---|
| 330 | | - |
|---|
| 331 | | - dma_addr_t command_header_dma; /* corresponding physical address */ |
|---|
| 332 | | - |
|---|
| 333 | 303 | void *command; /* ptr to command table entry */ |
|---|
| 334 | 304 | |
|---|
| 335 | 305 | dma_addr_t command_dma; /* corresponding physical address */ |
|---|
| .. | .. |
|---|
| 338 | 308 | |
|---|
| 339 | 309 | int unaligned; /* command is unaligned on 4k boundary */ |
|---|
| 340 | 310 | |
|---|
| 341 | | - struct scatterlist sg[MTIP_MAX_SG]; /* Scatter list entries */ |
|---|
| 311 | + union { |
|---|
| 312 | + struct scatterlist sg[MTIP_MAX_SG]; /* Scatter list entries */ |
|---|
| 313 | + struct mtip_int_cmd *icmd; |
|---|
| 314 | + }; |
|---|
| 342 | 315 | |
|---|
| 343 | 316 | int retries; /* The number of retries left for this command. */ |
|---|
| 344 | 317 | |
|---|
| .. | .. |
|---|
| 435 | 408 | */ |
|---|
| 436 | 409 | unsigned long ic_pause_timer; |
|---|
| 437 | 410 | |
|---|
| 438 | | - /* Semaphore to control queue depth of unaligned IOs */ |
|---|
| 439 | | - struct semaphore cmd_slot_unal; |
|---|
| 411 | + /* Counter to control queue depth of unaligned IOs */ |
|---|
| 412 | + atomic_t cmd_slot_unal; |
|---|
| 440 | 413 | |
|---|
| 441 | 414 | /* Spinlock for working around command-issue bug. */ |
|---|
| 442 | 415 | spinlock_t cmd_issue_lock[MTIP_MAX_SLOT_GROUPS]; |
|---|
| .. | .. |
|---|
| 475 | 448 | struct task_struct *mtip_svc_handler; /* task_struct of svc thd */ |
|---|
| 476 | 449 | |
|---|
| 477 | 450 | struct dentry *dfs_node; |
|---|
| 478 | | - |
|---|
| 479 | | - bool trim_supp; /* flag indicating trim support */ |
|---|
| 480 | 451 | |
|---|
| 481 | 452 | bool sr; |
|---|
| 482 | 453 | |
|---|