aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd_dif.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/sd_dif.c')
-rw-r--r--drivers/scsi/sd_dif.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index 4d17f3d35aac..3ebb1f289490 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -311,25 +311,26 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
311 struct scsi_device *sdp = sdkp->device; 311 struct scsi_device *sdp = sdkp->device;
312 struct gendisk *disk = sdkp->disk; 312 struct gendisk *disk = sdkp->disk;
313 u8 type = sdkp->protection_type; 313 u8 type = sdkp->protection_type;
314 int dif, dix;
314 315
315 /* If this HBA doesn't support DIX, resort to normal I/O or DIF */ 316 dif = scsi_host_dif_capable(sdp->host, type);
316 if (scsi_host_dix_capable(sdp->host, type) == 0) { 317 dix = scsi_host_dix_capable(sdp->host, type);
317 318
318 if (type == SD_DIF_TYPE0_PROTECTION) 319 if (!dix && scsi_host_dix_capable(sdp->host, 0)) {
319 return; 320 dif = 0; dix = 1;
320 321 }
321 if (scsi_host_dif_capable(sdp->host, type) == 0) {
322 sd_printk(KERN_INFO, sdkp, "Type %d protection " \
323 "unsupported by HBA. Disabling DIF.\n", type);
324 sdkp->protection_type = 0;
325 return;
326 }
327 322
328 sd_printk(KERN_INFO, sdkp, "Enabling DIF Type %d protection\n", 323 if (type) {
329 type); 324 if (dif)
325 sd_printk(KERN_NOTICE, sdkp,
326 "Enabling DIF Type %d protection\n", type);
327 else
328 sd_printk(KERN_NOTICE, sdkp,
329 "Disabling DIF Type %d protection\n", type);
330 }
330 331
332 if (!dix)
331 return; 333 return;
332 }
333 334
334 /* Enable DMA of protection information */ 335 /* Enable DMA of protection information */
335 if (scsi_host_get_guard(sdkp->device->host) & SHOST_DIX_GUARD_IP) 336 if (scsi_host_get_guard(sdkp->device->host) & SHOST_DIX_GUARD_IP)
@@ -343,17 +344,17 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
343 else 344 else
344 blk_integrity_register(disk, &dif_type1_integrity_crc); 345 blk_integrity_register(disk, &dif_type1_integrity_crc);
345 346
346 sd_printk(KERN_INFO, sdkp, 347 sd_printk(KERN_NOTICE, sdkp,
347 "Enabling %s integrity protection\n", disk->integrity->name); 348 "Enabling DIX %s protection\n", disk->integrity->name);
348 349
349 /* Signal to block layer that we support sector tagging */ 350 /* Signal to block layer that we support sector tagging */
350 if (type && sdkp->ATO) { 351 if (dif && type && sdkp->ATO) {
351 if (type == SD_DIF_TYPE3_PROTECTION) 352 if (type == SD_DIF_TYPE3_PROTECTION)
352 disk->integrity->tag_size = sizeof(u16) + sizeof(u32); 353 disk->integrity->tag_size = sizeof(u16) + sizeof(u32);
353 else 354 else
354 disk->integrity->tag_size = sizeof(u16); 355 disk->integrity->tag_size = sizeof(u16);
355 356
356 sd_printk(KERN_INFO, sdkp, "DIF application tag size %u\n", 357 sd_printk(KERN_NOTICE, sdkp, "DIF application tag size %u\n",
357 disk->integrity->tag_size); 358 disk->integrity->tag_size);
358 } 359 }
359} 360}
@@ -361,7 +362,7 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
361/* 362/*
362 * DIF DMA operation magic decoder ring. 363 * DIF DMA operation magic decoder ring.
363 */ 364 */
364void sd_dif_op(struct scsi_cmnd *scmd, unsigned int dif, unsigned int dix) 365void sd_dif_op(struct scsi_cmnd *scmd, unsigned int dif, unsigned int dix, unsigned int type)
365{ 366{
366 int csum_convert, prot_op; 367 int csum_convert, prot_op;
367 368
@@ -406,7 +407,8 @@ void sd_dif_op(struct scsi_cmnd *scmd, unsigned int dif, unsigned int dix)
406 } 407 }
407 408
408 scsi_set_prot_op(scmd, prot_op); 409 scsi_set_prot_op(scmd, prot_op);
409 scsi_set_prot_type(scmd, dif); 410 if (dif)
411 scsi_set_prot_type(scmd, type);
410} 412}
411 413
412/* 414/*