Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 478698
Collapse All | Expand All

(-)a/drivers/scsi/scsi.c (-4 / +4 lines)
Lines 1070-1077 EXPORT_SYMBOL_GPL(scsi_get_vpd_page); Link Here
1070
 * @opcode:	opcode for command to look up
1070
 * @opcode:	opcode for command to look up
1071
 *
1071
 *
1072
 * Uses the REPORT SUPPORTED OPERATION CODES to look up the given
1072
 * Uses the REPORT SUPPORTED OPERATION CODES to look up the given
1073
 * opcode. Returns -EINVAL if RSOC fails, 0 if the command opcode is
1073
 * opcode. Returns 0 if RSOC fails or if the command opcode is
1074
 * unsupported and 1 if the device claims to support the command.
1074
 * unsupported. Returns 1 if the device claims to support the command.
1075
 */
1075
 */
1076
int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
1076
int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
1077
		       unsigned int len, unsigned char opcode)
1077
		       unsigned int len, unsigned char opcode)
Lines 1081-1087 int scsi_report_opcode(struct scsi_devic Link Here
1081
	int result;
1081
	int result;
1082
1082
1083
	if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
1083
	if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
1084
		return -EINVAL;
1084
		return 0;
1085
1085
1086
	memset(cmd, 0, 16);
1086
	memset(cmd, 0, 16);
1087
	cmd[0] = MAINTENANCE_IN;
1087
	cmd[0] = MAINTENANCE_IN;
Lines 1097-1103 int scsi_report_opcode(struct scsi_devic Link Here
1097
	if (result && scsi_sense_valid(&sshdr) &&
1097
	if (result && scsi_sense_valid(&sshdr) &&
1098
	    sshdr.sense_key == ILLEGAL_REQUEST &&
1098
	    sshdr.sense_key == ILLEGAL_REQUEST &&
1099
	    (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00)
1099
	    (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00)
1100
		return -EINVAL;
1100
		return 0;
1101
1101
1102
	if ((buffer[1] & 3) == 3) /* Command supported */
1102
	if ((buffer[1] & 3) == 3) /* Command supported */
1103
		return 1;
1103
		return 1;
(-)a/drivers/scsi/sd.c (-32 / +14 lines)
Lines 442-451 sd_store_write_same_blocks(struct device Link Here
442
442
443
	if (max == 0)
443
	if (max == 0)
444
		sdp->no_write_same = 1;
444
		sdp->no_write_same = 1;
445
	else if (max <= SD_MAX_WS16_BLOCKS) {
445
	else if (max <= SD_MAX_WS16_BLOCKS)
446
		sdp->no_write_same = 0;
447
		sdkp->max_ws_blocks = max;
446
		sdkp->max_ws_blocks = max;
448
	}
449
447
450
	sd_config_write_same(sdkp);
448
	sd_config_write_same(sdkp);
451
449
Lines 742-747 static void sd_config_write_same(struct Link Here
742
{
740
{
743
	struct request_queue *q = sdkp->disk->queue;
741
	struct request_queue *q = sdkp->disk->queue;
744
	unsigned int logical_block_size = sdkp->device->sector_size;
742
	unsigned int logical_block_size = sdkp->device->sector_size;
743
	unsigned int blocks = 0;
745
744
746
	if (sdkp->device->no_write_same) {
745
	if (sdkp->device->no_write_same) {
747
		sdkp->max_ws_blocks = 0;
746
		sdkp->max_ws_blocks = 0;
Lines 753-772 static void sd_config_write_same(struct Link Here
753
	 * blocks per I/O unless the device explicitly advertises a
752
	 * blocks per I/O unless the device explicitly advertises a
754
	 * bigger limit.
753
	 * bigger limit.
755
	 */
754
	 */
756
	if (sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS)
755
	if (sdkp->max_ws_blocks == 0)
757
		sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks,
756
		sdkp->max_ws_blocks = SD_MAX_WS10_BLOCKS;
758
						   (u32)SD_MAX_WS16_BLOCKS);
757
759
	else if (sdkp->ws16 || sdkp->ws10 || sdkp->device->no_report_opcodes)
758
	if (sdkp->ws16 || sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS)
760
		sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks,
759
		blocks = min_not_zero(sdkp->max_ws_blocks,
761
						   (u32)SD_MAX_WS10_BLOCKS);
760
				      (u32)SD_MAX_WS16_BLOCKS);
762
	else {
761
	else
763
		sdkp->device->no_write_same = 1;
762
		blocks = min_not_zero(sdkp->max_ws_blocks,
764
		sdkp->max_ws_blocks = 0;
763
				      (u32)SD_MAX_WS10_BLOCKS);
765
	}
766
764
767
out:
765
out:
768
	blk_queue_max_write_same_sectors(q, sdkp->max_ws_blocks *
766
	blk_queue_max_write_same_sectors(q, blocks * (logical_block_size >> 9));
769
					 (logical_block_size >> 9));
770
}
767
}
771
768
772
/**
769
/**
Lines 2638-2661 static void sd_read_block_provisioning(s Link Here
2638
2635
2639
static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)
2636
static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)
2640
{
2637
{
2641
	struct scsi_device *sdev = sdkp->device;
2638
	if (scsi_report_opcode(sdkp->device, buffer, SD_BUF_SIZE,
2642
2639
			       WRITE_SAME_16))
2643
	if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, INQUIRY) < 0) {
2644
		sdev->no_report_opcodes = 1;
2645
2646
		/* Disable WRITE SAME if REPORT SUPPORTED OPERATION
2647
		 * CODES is unsupported and the device has an ATA
2648
		 * Information VPD page (SAT).
2649
		 */
2650
		if (!scsi_get_vpd_page(sdev, 0x89, buffer, SD_BUF_SIZE))
2651
			sdev->no_write_same = 1;
2652
	}
2653
2654
	if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME_16) == 1)
2655
		sdkp->ws16 = 1;
2640
		sdkp->ws16 = 1;
2656
2657
	if (scsi_report_opcode(sdev, buffer, SD_BUF_SIZE, WRITE_SAME) == 1)
2658
		sdkp->ws10 = 1;
2659
}
2641
}
2660
2642
2661
static int sd_try_extended_inquiry(struct scsi_device *sdp)
2643
static int sd_try_extended_inquiry(struct scsi_device *sdp)
(-)a/drivers/scsi/sd.h (-1 lines)
Lines 84-90 struct scsi_disk { Link Here
84
	unsigned	lbpws : 1;
84
	unsigned	lbpws : 1;
85
	unsigned	lbpws10 : 1;
85
	unsigned	lbpws10 : 1;
86
	unsigned	lbpvpd : 1;
86
	unsigned	lbpvpd : 1;
87
	unsigned	ws10 : 1;
88
	unsigned	ws16 : 1;
87
	unsigned	ws16 : 1;
89
};
88
};
90
#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)
89
#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)

Return to bug 478698