View | Details | Raw Unified | Return to bug 229260
Collapse All | Expand All

(-)a/drivers/ata/libata-core.c (-29 / +11 lines)
Lines 2046-2055 int ata_dev_configure(struct ata_device *dev) Link Here
2046
		dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128,
2046
		dev->max_sectors = min_t(unsigned int, ATA_MAX_SECTORS_128,
2047
					 dev->max_sectors);
2047
					 dev->max_sectors);
2048
2048
2049
	/* limit ATAPI DMA to R/W commands only */
2050
	if (ata_device_blacklisted(dev) & ATA_HORKAGE_DMA_RW_ONLY)
2051
		dev->horkage |= ATA_HORKAGE_DMA_RW_ONLY;
2052
2053
	if (ap->ops->dev_config)
2049
	if (ap->ops->dev_config)
2054
		ap->ops->dev_config(dev);
2050
		ap->ops->dev_config(dev);
2055
2051
Lines 3780-3787 static const struct ata_blacklist_entry ata_device_blacklist [] = { Link Here
3780
	{ "IOMEGA  ZIP 250       ATAPI", NULL,	ATA_HORKAGE_NODMA }, /* temporary fix */
3776
	{ "IOMEGA  ZIP 250       ATAPI", NULL,	ATA_HORKAGE_NODMA }, /* temporary fix */
3781
3777
3782
	/* Weird ATAPI devices */
3778
	/* Weird ATAPI devices */
3783
	{ "TORiSAN DVD-ROM DRD-N216", NULL,	ATA_HORKAGE_MAX_SEC_128 |
3779
	{ "TORiSAN DVD-ROM DRD-N216", NULL,	ATA_HORKAGE_MAX_SEC_128 },
3784
						ATA_HORKAGE_DMA_RW_ONLY },
3785
3780
3786
	/* Devices we expect to fail diagnostics */
3781
	/* Devices we expect to fail diagnostics */
3787
3782
Lines 4107-4112 static void ata_fill_sg(struct ata_queued_cmd *qc) Link Here
4107
	if (idx)
4102
	if (idx)
4108
		ap->prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT);
4103
		ap->prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT);
4109
}
4104
}
4105
4110
/**
4106
/**
4111
 *	ata_check_atapi_dma - Check whether ATAPI DMA can be supported
4107
 *	ata_check_atapi_dma - Check whether ATAPI DMA can be supported
4112
 *	@qc: Metadata associated with taskfile to check
4108
 *	@qc: Metadata associated with taskfile to check
Lines 4124-4156 static void ata_fill_sg(struct ata_queued_cmd *qc) Link Here
4124
int ata_check_atapi_dma(struct ata_queued_cmd *qc)
4120
int ata_check_atapi_dma(struct ata_queued_cmd *qc)
4125
{
4121
{
4126
	struct ata_port *ap = qc->ap;
4122
	struct ata_port *ap = qc->ap;
4127
	int rc = 0; /* Assume ATAPI DMA is OK by default */
4123
4128
4124
	/* Don't allow DMA if it isn't multiple of 16 bytes.  Quite a
4129
	/* some drives can only do ATAPI DMA on read/write */
4125
	 * few ATAPI devices choke on such DMA requests.
4130
	if (unlikely(qc->dev->horkage & ATA_HORKAGE_DMA_RW_ONLY)) {
4126
	 */
4131
		struct scsi_cmnd *cmd = qc->scsicmd;
4127
	if (unlikely(qc->nbytes & 15))
4132
		u8 *scsicmd = cmd->cmnd;
4128
		return 1;
4133
4134
		switch (scsicmd[0]) {
4135
		case READ_10:
4136
		case WRITE_10:
4137
		case READ_12:
4138
		case WRITE_12:
4139
		case READ_6:
4140
		case WRITE_6:
4141
			/* atapi dma maybe ok */
4142
			break;
4143
		default:
4144
			/* turn off atapi dma */
4145
			return 1;
4146
		}
4147
	}
4148
4129
4149
	if (ap->ops->check_atapi_dma)
4130
	if (ap->ops->check_atapi_dma)
4150
		rc = ap->ops->check_atapi_dma(qc);
4131
		return ap->ops->check_atapi_dma(qc);
4151
4132
4152
	return rc;
4133
	return 0;
4153
}
4134
}
4135
4154
/**
4136
/**
4155
 *	ata_qc_prep - Prepare taskfile for submission
4137
 *	ata_qc_prep - Prepare taskfile for submission
4156
 *	@qc: Metadata associated with taskfile to be prepared
4138
 *	@qc: Metadata associated with taskfile to be prepared
(-)a/drivers/ata/libata-scsi.c (-12 / +8 lines)
Lines 2384-2394 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) Link Here
2384
	int using_pio = (dev->flags & ATA_DFLAG_PIO);
2384
	int using_pio = (dev->flags & ATA_DFLAG_PIO);
2385
	int nodata = (scmd->sc_data_direction == DMA_NONE);
2385
	int nodata = (scmd->sc_data_direction == DMA_NONE);
2386
2386
2387
	if (!using_pio)
2388
		/* Check whether ATAPI DMA is safe */
2389
		if (ata_check_atapi_dma(qc))
2390
			using_pio = 1;
2391
2392
	memset(qc->cdb, 0, dev->cdb_len);
2387
	memset(qc->cdb, 0, dev->cdb_len);
2393
	memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len);
2388
	memcpy(qc->cdb, scmd->cmnd, scmd->cmd_len);
2394
2389
Lines 2401-2419 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) Link Here
2401
	}
2396
	}
2402
2397
2403
	qc->tf.command = ATA_CMD_PACKET;
2398
	qc->tf.command = ATA_CMD_PACKET;
2399
	qc->nbytes = scmd->request_bufflen;
2400
2401
	/* check whether ATAPI DMA is safe */
2402
	if (!using_pio && ata_check_atapi_dma(qc))
2403
		using_pio = 1;
2404
2404
2405
	/* no data, or PIO data xfer */
2406
	if (using_pio || nodata) {
2405
	if (using_pio || nodata) {
2406
		/* no data, or PIO data xfer */
2407
		if (nodata)
2407
		if (nodata)
2408
			qc->tf.protocol = ATA_PROT_ATAPI_NODATA;
2408
			qc->tf.protocol = ATA_PROT_ATAPI_NODATA;
2409
		else
2409
		else
2410
			qc->tf.protocol = ATA_PROT_ATAPI;
2410
			qc->tf.protocol = ATA_PROT_ATAPI;
2411
		qc->tf.lbam = (8 * 1024) & 0xff;
2411
		qc->tf.lbam = (8 * 1024) & 0xff;
2412
		qc->tf.lbah = (8 * 1024) >> 8;
2412
		qc->tf.lbah = (8 * 1024) >> 8;
2413
	}
2413
	} else {
2414
2414
		/* DMA data xfer */
2415
	/* DMA data xfer */
2416
	else {
2417
		qc->tf.protocol = ATA_PROT_ATAPI_DMA;
2415
		qc->tf.protocol = ATA_PROT_ATAPI_DMA;
2418
		qc->tf.feature |= ATAPI_PKT_DMA;
2416
		qc->tf.feature |= ATAPI_PKT_DMA;
2419
2417
Lines 2422-2429 static unsigned int atapi_xlat(struct ata_queued_cmd *qc) Link Here
2422
			qc->tf.feature |= ATAPI_DMADIR;
2420
			qc->tf.feature |= ATAPI_DMADIR;
2423
	}
2421
	}
2424
2422
2425
	qc->nbytes = scmd->request_bufflen;
2426
2427
	return 0;
2423
	return 0;
2428
}
2424
}
2429
2425
(-)a/include/linux/libata.h (-1 lines)
Lines 298-304 enum { Link Here
298
	ATA_HORKAGE_NODMA	= (1 << 1),	/* DMA problems */
298
	ATA_HORKAGE_NODMA	= (1 << 1),	/* DMA problems */
299
	ATA_HORKAGE_NONCQ	= (1 << 2),	/* Don't use NCQ */
299
	ATA_HORKAGE_NONCQ	= (1 << 2),	/* Don't use NCQ */
300
	ATA_HORKAGE_MAX_SEC_128	= (1 << 3),	/* Limit max sects to 128 */
300
	ATA_HORKAGE_MAX_SEC_128	= (1 << 3),	/* Limit max sects to 128 */
301
	ATA_HORKAGE_DMA_RW_ONLY	= (1 << 4),	/* ATAPI DMA for RW only */
302
};
301
};
303
302
304
enum hsm_task_states {
303
enum hsm_task_states {

Return to bug 229260