diff options
| author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-26 22:18:22 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-26 22:18:22 -0500 |
| commit | 6d272940537e834848d88c11b428e9973b8fa2bc (patch) | |
| tree | f01b6d173c62e5f9daeb50937ff6d1d17e4320f6 /drivers/ata/libata-scsi.c | |
| parent | f4d53cedce872fe1439818d15e067b497b5d466f (diff) | |
| parent | e190222d04cb1119c62876ac87cf9b9403ba3bd5 (diff) | |
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev: (21 commits)
libata: bump transfer chunk size if it's odd
libata: Return proper ATA INT status in pata_bf54x driver
pata_ali: trim trailing whitespace (fix checkpatch complaints)
pata_isapnp: Polled devices
pata_hpt37x: Fix cable detect bug spotted by Sergei
pata_ali: Lots of problems still showing up with small ATAPI DMA
pata_ali: Add Mitac 8317 and derivatives
libata-core: List more documentation sources for reference
ata_piix: Invalid use of writel/readl with iomap
sata_sil24: fix sg table sizing
pata_jmicron: fix disabled port handling in jmicron_pre_reset()
pata_sil680: kill bogus reset code (take 2)
ata_piix: port enable for the first SATA controller of ICH8 is 0xf not 0x3
ata_piix: only enable the first port on apple macbook pro
ata_piix: reorganize controller IDs
pata_sis.c: Add Packard Bell EasyNote K5305 to laptops
libata-scsi: be tolerant of 12-byte ATAPI commands in 16-byte CDBs
libata: use ATA_HORKAGE_STUCK_ERR for ATAPI tape drives
libata: workaround DRQ=1 ERR=1 for ATAPI tape drives
libata: remove unused functions
...
Diffstat (limited to 'drivers/ata/libata-scsi.c')
| -rw-r--r-- | drivers/ata/libata-scsi.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 94144ed50a6b..a883bb03d4c7 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
| @@ -2485,11 +2485,40 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc) | |||
| 2485 | if (!using_pio && ata_check_atapi_dma(qc)) | 2485 | if (!using_pio && ata_check_atapi_dma(qc)) |
| 2486 | using_pio = 1; | 2486 | using_pio = 1; |
| 2487 | 2487 | ||
| 2488 | /* Some controller variants snoop this value for Packet transfers | 2488 | /* Some controller variants snoop this value for Packet |
| 2489 | to do state machine and FIFO management. Thus we want to set it | 2489 | * transfers to do state machine and FIFO management. Thus we |
| 2490 | properly, and for DMA where it is effectively meaningless */ | 2490 | * want to set it properly, and for DMA where it is |
| 2491 | * effectively meaningless. | ||
| 2492 | */ | ||
| 2491 | nbytes = min(qc->nbytes, (unsigned int)63 * 1024); | 2493 | nbytes = min(qc->nbytes, (unsigned int)63 * 1024); |
| 2492 | 2494 | ||
| 2495 | /* Most ATAPI devices which honor transfer chunk size don't | ||
| 2496 | * behave according to the spec when odd chunk size which | ||
| 2497 | * matches the transfer length is specified. If the number of | ||
| 2498 | * bytes to transfer is 2n+1. According to the spec, what | ||
| 2499 | * should happen is to indicate that 2n+1 is going to be | ||
| 2500 | * transferred and transfer 2n+2 bytes where the last byte is | ||
| 2501 | * padding. | ||
| 2502 | * | ||
| 2503 | * In practice, this doesn't happen. ATAPI devices first | ||
| 2504 | * indicate and transfer 2n bytes and then indicate and | ||
| 2505 | * transfer 2 bytes where the last byte is padding. | ||
| 2506 | * | ||
| 2507 | * This inconsistency confuses several controllers which | ||
| 2508 | * perform PIO using DMA such as Intel AHCIs and sil3124/32. | ||
| 2509 | * These controllers use actual number of transferred bytes to | ||
| 2510 | * update DMA poitner and transfer of 4n+2 bytes make those | ||
| 2511 | * controller push DMA pointer by 4n+4 bytes because SATA data | ||
| 2512 | * FISes are aligned to 4 bytes. This causes data corruption | ||
| 2513 | * and buffer overrun. | ||
| 2514 | * | ||
| 2515 | * Always setting nbytes to even number solves this problem | ||
| 2516 | * because then ATAPI devices don't have to split data at 2n | ||
| 2517 | * boundaries. | ||
| 2518 | */ | ||
| 2519 | if (nbytes & 0x1) | ||
| 2520 | nbytes++; | ||
| 2521 | |||
| 2493 | qc->tf.lbam = (nbytes & 0xFF); | 2522 | qc->tf.lbam = (nbytes & 0xFF); |
| 2494 | qc->tf.lbah = (nbytes >> 8); | 2523 | qc->tf.lbah = (nbytes >> 8); |
| 2495 | 2524 | ||
| @@ -2869,7 +2898,8 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, | |||
| 2869 | xlat_func = NULL; | 2898 | xlat_func = NULL; |
| 2870 | if (likely((scsi_op != ATA_16) || !atapi_passthru16)) { | 2899 | if (likely((scsi_op != ATA_16) || !atapi_passthru16)) { |
| 2871 | /* relay SCSI command to ATAPI device */ | 2900 | /* relay SCSI command to ATAPI device */ |
| 2872 | if (unlikely(scmd->cmd_len > dev->cdb_len)) | 2901 | int len = COMMAND_SIZE(scsi_op); |
| 2902 | if (unlikely(len > scmd->cmd_len || len > dev->cdb_len)) | ||
| 2873 | goto bad_cdb_len; | 2903 | goto bad_cdb_len; |
| 2874 | 2904 | ||
| 2875 | xlat_func = atapi_xlat; | 2905 | xlat_func = atapi_xlat; |
