| .. | .. |
|---|
| 75 | 75 | struct opal_dev *opal_dev; |
|---|
| 76 | 76 | #ifdef CONFIG_BLK_DEV_ZONED |
|---|
| 77 | 77 | u32 nr_zones; |
|---|
| 78 | + u32 rev_nr_zones; |
|---|
| 78 | 79 | u32 zone_blocks; |
|---|
| 79 | | - u32 zone_shift; |
|---|
| 80 | + u32 rev_zone_blocks; |
|---|
| 80 | 81 | u32 zones_optimal_open; |
|---|
| 81 | 82 | u32 zones_optimal_nonseq; |
|---|
| 82 | 83 | u32 zones_max_open; |
|---|
| 84 | + u32 *zones_wp_offset; |
|---|
| 85 | + spinlock_t zones_wp_offset_lock; |
|---|
| 86 | + u32 *rev_wp_offset; |
|---|
| 87 | + struct mutex rev_mutex; |
|---|
| 88 | + struct work_struct zone_wp_offset_work; |
|---|
| 89 | + char *zone_wp_update_buf; |
|---|
| 83 | 90 | #endif |
|---|
| 84 | 91 | atomic_t openers; |
|---|
| 85 | 92 | sector_t capacity; /* size in logical blocks */ |
|---|
| 93 | + int max_retries; |
|---|
| 86 | 94 | u32 max_xfer_blocks; |
|---|
| 87 | 95 | u32 opt_xfer_blocks; |
|---|
| 88 | 96 | u32 max_ws_blocks; |
|---|
| .. | .. |
|---|
| 136 | 144 | |
|---|
| 137 | 145 | #define sd_first_printk(prefix, sdsk, fmt, a...) \ |
|---|
| 138 | 146 | do { \ |
|---|
| 139 | | - if ((sdkp)->first_scan) \ |
|---|
| 147 | + if ((sdsk)->first_scan) \ |
|---|
| 140 | 148 | sd_printk(prefix, sdsk, fmt, ##a); \ |
|---|
| 141 | 149 | } while (0) |
|---|
| 142 | 150 | |
|---|
| .. | .. |
|---|
| 192 | 200 | return sector >> (ilog2(sdev->sector_size) - 9); |
|---|
| 193 | 201 | } |
|---|
| 194 | 202 | |
|---|
| 195 | | -/* |
|---|
| 196 | | - * Look up the DIX operation based on whether the command is read or |
|---|
| 197 | | - * write and whether dix and dif are enabled. |
|---|
| 198 | | - */ |
|---|
| 199 | | -static inline unsigned int sd_prot_op(bool write, bool dix, bool dif) |
|---|
| 200 | | -{ |
|---|
| 201 | | - /* Lookup table: bit 2 (write), bit 1 (dix), bit 0 (dif) */ |
|---|
| 202 | | - const unsigned int ops[] = { /* wrt dix dif */ |
|---|
| 203 | | - SCSI_PROT_NORMAL, /* 0 0 0 */ |
|---|
| 204 | | - SCSI_PROT_READ_STRIP, /* 0 0 1 */ |
|---|
| 205 | | - SCSI_PROT_READ_INSERT, /* 0 1 0 */ |
|---|
| 206 | | - SCSI_PROT_READ_PASS, /* 0 1 1 */ |
|---|
| 207 | | - SCSI_PROT_NORMAL, /* 1 0 0 */ |
|---|
| 208 | | - SCSI_PROT_WRITE_INSERT, /* 1 0 1 */ |
|---|
| 209 | | - SCSI_PROT_WRITE_STRIP, /* 1 1 0 */ |
|---|
| 210 | | - SCSI_PROT_WRITE_PASS, /* 1 1 1 */ |
|---|
| 211 | | - }; |
|---|
| 212 | | - |
|---|
| 213 | | - return ops[write << 2 | dix << 1 | dif]; |
|---|
| 214 | | -} |
|---|
| 215 | | - |
|---|
| 216 | | -/* |
|---|
| 217 | | - * Returns a mask of the protection flags that are valid for a given DIX |
|---|
| 218 | | - * operation. |
|---|
| 219 | | - */ |
|---|
| 220 | | -static inline unsigned int sd_prot_flag_mask(unsigned int prot_op) |
|---|
| 221 | | -{ |
|---|
| 222 | | - const unsigned int flag_mask[] = { |
|---|
| 223 | | - [SCSI_PROT_NORMAL] = 0, |
|---|
| 224 | | - |
|---|
| 225 | | - [SCSI_PROT_READ_STRIP] = SCSI_PROT_TRANSFER_PI | |
|---|
| 226 | | - SCSI_PROT_GUARD_CHECK | |
|---|
| 227 | | - SCSI_PROT_REF_CHECK | |
|---|
| 228 | | - SCSI_PROT_REF_INCREMENT, |
|---|
| 229 | | - |
|---|
| 230 | | - [SCSI_PROT_READ_INSERT] = SCSI_PROT_REF_INCREMENT | |
|---|
| 231 | | - SCSI_PROT_IP_CHECKSUM, |
|---|
| 232 | | - |
|---|
| 233 | | - [SCSI_PROT_READ_PASS] = SCSI_PROT_TRANSFER_PI | |
|---|
| 234 | | - SCSI_PROT_GUARD_CHECK | |
|---|
| 235 | | - SCSI_PROT_REF_CHECK | |
|---|
| 236 | | - SCSI_PROT_REF_INCREMENT | |
|---|
| 237 | | - SCSI_PROT_IP_CHECKSUM, |
|---|
| 238 | | - |
|---|
| 239 | | - [SCSI_PROT_WRITE_INSERT] = SCSI_PROT_TRANSFER_PI | |
|---|
| 240 | | - SCSI_PROT_REF_INCREMENT, |
|---|
| 241 | | - |
|---|
| 242 | | - [SCSI_PROT_WRITE_STRIP] = SCSI_PROT_GUARD_CHECK | |
|---|
| 243 | | - SCSI_PROT_REF_CHECK | |
|---|
| 244 | | - SCSI_PROT_REF_INCREMENT | |
|---|
| 245 | | - SCSI_PROT_IP_CHECKSUM, |
|---|
| 246 | | - |
|---|
| 247 | | - [SCSI_PROT_WRITE_PASS] = SCSI_PROT_TRANSFER_PI | |
|---|
| 248 | | - SCSI_PROT_GUARD_CHECK | |
|---|
| 249 | | - SCSI_PROT_REF_CHECK | |
|---|
| 250 | | - SCSI_PROT_REF_INCREMENT | |
|---|
| 251 | | - SCSI_PROT_IP_CHECKSUM, |
|---|
| 252 | | - }; |
|---|
| 253 | | - |
|---|
| 254 | | - return flag_mask[prot_op]; |
|---|
| 255 | | -} |
|---|
| 256 | | - |
|---|
| 257 | 203 | #ifdef CONFIG_BLK_DEV_INTEGRITY |
|---|
| 258 | 204 | |
|---|
| 259 | 205 | extern void sd_dif_config_host(struct scsi_disk *); |
|---|
| .. | .. |
|---|
| 273 | 219 | |
|---|
| 274 | 220 | #ifdef CONFIG_BLK_DEV_ZONED |
|---|
| 275 | 221 | |
|---|
| 276 | | -extern int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer); |
|---|
| 277 | | -extern void sd_zbc_remove(struct scsi_disk *sdkp); |
|---|
| 278 | | -extern void sd_zbc_print_zones(struct scsi_disk *sdkp); |
|---|
| 279 | | -extern int sd_zbc_setup_report_cmnd(struct scsi_cmnd *cmd); |
|---|
| 280 | | -extern int sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd); |
|---|
| 281 | | -extern void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, |
|---|
| 282 | | - struct scsi_sense_hdr *sshdr); |
|---|
| 222 | +void sd_zbc_release_disk(struct scsi_disk *sdkp); |
|---|
| 223 | +int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buffer); |
|---|
| 224 | +int sd_zbc_revalidate_zones(struct scsi_disk *sdkp); |
|---|
| 225 | +blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd, |
|---|
| 226 | + unsigned char op, bool all); |
|---|
| 227 | +unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes, |
|---|
| 228 | + struct scsi_sense_hdr *sshdr); |
|---|
| 229 | +int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, |
|---|
| 230 | + unsigned int nr_zones, report_zones_cb cb, void *data); |
|---|
| 231 | + |
|---|
| 232 | +blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba, |
|---|
| 233 | + unsigned int nr_blocks); |
|---|
| 283 | 234 | |
|---|
| 284 | 235 | #else /* CONFIG_BLK_DEV_ZONED */ |
|---|
| 236 | + |
|---|
| 237 | +static inline void sd_zbc_release_disk(struct scsi_disk *sdkp) {} |
|---|
| 285 | 238 | |
|---|
| 286 | 239 | static inline int sd_zbc_read_zones(struct scsi_disk *sdkp, |
|---|
| 287 | 240 | unsigned char *buf) |
|---|
| .. | .. |
|---|
| 289 | 242 | return 0; |
|---|
| 290 | 243 | } |
|---|
| 291 | 244 | |
|---|
| 292 | | -static inline void sd_zbc_remove(struct scsi_disk *sdkp) {} |
|---|
| 293 | | - |
|---|
| 294 | | -static inline void sd_zbc_print_zones(struct scsi_disk *sdkp) {} |
|---|
| 295 | | - |
|---|
| 296 | | -static inline int sd_zbc_setup_report_cmnd(struct scsi_cmnd *cmd) |
|---|
| 245 | +static inline int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) |
|---|
| 297 | 246 | { |
|---|
| 298 | | - return BLKPREP_INVALID; |
|---|
| 247 | + return 0; |
|---|
| 299 | 248 | } |
|---|
| 300 | 249 | |
|---|
| 301 | | -static inline int sd_zbc_setup_reset_cmnd(struct scsi_cmnd *cmd) |
|---|
| 250 | +static inline blk_status_t sd_zbc_setup_zone_mgmt_cmnd(struct scsi_cmnd *cmd, |
|---|
| 251 | + unsigned char op, |
|---|
| 252 | + bool all) |
|---|
| 302 | 253 | { |
|---|
| 303 | | - return BLKPREP_INVALID; |
|---|
| 254 | + return BLK_STS_TARGET; |
|---|
| 304 | 255 | } |
|---|
| 305 | 256 | |
|---|
| 306 | | -static inline void sd_zbc_complete(struct scsi_cmnd *cmd, |
|---|
| 307 | | - unsigned int good_bytes, |
|---|
| 308 | | - struct scsi_sense_hdr *sshdr) {} |
|---|
| 257 | +static inline unsigned int sd_zbc_complete(struct scsi_cmnd *cmd, |
|---|
| 258 | + unsigned int good_bytes, struct scsi_sense_hdr *sshdr) |
|---|
| 259 | +{ |
|---|
| 260 | + return good_bytes; |
|---|
| 261 | +} |
|---|
| 262 | + |
|---|
| 263 | +static inline blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, |
|---|
| 264 | + sector_t *lba, |
|---|
| 265 | + unsigned int nr_blocks) |
|---|
| 266 | +{ |
|---|
| 267 | + return BLK_STS_TARGET; |
|---|
| 268 | +} |
|---|
| 269 | + |
|---|
| 270 | +#define sd_zbc_report_zones NULL |
|---|
| 309 | 271 | |
|---|
| 310 | 272 | #endif /* CONFIG_BLK_DEV_ZONED */ |
|---|
| 311 | 273 | |
|---|
| 274 | +void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr); |
|---|
| 275 | +void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result); |
|---|
| 276 | + |
|---|
| 312 | 277 | #endif /* _SCSI_DISK_H */ |
|---|