diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2006-02-20 16:56:08 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2006-02-20 16:56:08 -0500 |
commit | 11fff8287fdaeb700df79aa8253650b60c7b21e2 (patch) | |
tree | a0b695f44810b4cf8c4b3f81dd25811a10871003 | |
parent | a5fd79ccd60b7c9cc0221dfaaa950933eff6af99 (diff) | |
parent | f131883e73a8662dc92c3ea371ae9ded0c8f2c37 (diff) |
Merge branch 'upstream'
-rw-r--r-- | drivers/scsi/ata_piix.c | 78 | ||||
-rw-r--r-- | drivers/scsi/libata-core.c | 18 | ||||
-rw-r--r-- | drivers/scsi/sata_qstor.c | 2 | ||||
-rw-r--r-- | include/linux/libata.h | 16 |
4 files changed, 67 insertions, 47 deletions
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 4cc1108f721a..c662bf531514 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c | |||
@@ -131,8 +131,8 @@ enum { | |||
131 | static int piix_init_one (struct pci_dev *pdev, | 131 | static int piix_init_one (struct pci_dev *pdev, |
132 | const struct pci_device_id *ent); | 132 | const struct pci_device_id *ent); |
133 | 133 | ||
134 | static void piix_pata_phy_reset(struct ata_port *ap); | 134 | static int piix_pata_probe_reset(struct ata_port *ap, unsigned int *classes); |
135 | static void piix_sata_phy_reset(struct ata_port *ap); | 135 | static int piix_sata_probe_reset(struct ata_port *ap, unsigned int *classes); |
136 | static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev); | 136 | static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev); |
137 | static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev); | 137 | static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev); |
138 | 138 | ||
@@ -207,7 +207,7 @@ static const struct ata_port_operations piix_pata_ops = { | |||
207 | .exec_command = ata_exec_command, | 207 | .exec_command = ata_exec_command, |
208 | .dev_select = ata_std_dev_select, | 208 | .dev_select = ata_std_dev_select, |
209 | 209 | ||
210 | .phy_reset = piix_pata_phy_reset, | 210 | .probe_reset = piix_pata_probe_reset, |
211 | 211 | ||
212 | .bmdma_setup = ata_bmdma_setup, | 212 | .bmdma_setup = ata_bmdma_setup, |
213 | .bmdma_start = ata_bmdma_start, | 213 | .bmdma_start = ata_bmdma_start, |
@@ -235,7 +235,7 @@ static const struct ata_port_operations piix_sata_ops = { | |||
235 | .exec_command = ata_exec_command, | 235 | .exec_command = ata_exec_command, |
236 | .dev_select = ata_std_dev_select, | 236 | .dev_select = ata_std_dev_select, |
237 | 237 | ||
238 | .phy_reset = piix_sata_phy_reset, | 238 | .probe_reset = piix_sata_probe_reset, |
239 | 239 | ||
240 | .bmdma_setup = ata_bmdma_setup, | 240 | .bmdma_setup = ata_bmdma_setup, |
241 | .bmdma_start = ata_bmdma_start, | 241 | .bmdma_start = ata_bmdma_start, |
@@ -258,8 +258,7 @@ static struct ata_port_info piix_port_info[] = { | |||
258 | /* ich5_pata */ | 258 | /* ich5_pata */ |
259 | { | 259 | { |
260 | .sht = &piix_sht, | 260 | .sht = &piix_sht, |
261 | .host_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | | 261 | .host_flags = ATA_FLAG_SLAVE_POSS | PIIX_FLAG_CHECKINTR, |
262 | PIIX_FLAG_CHECKINTR, | ||
263 | .pio_mask = 0x1f, /* pio0-4 */ | 262 | .pio_mask = 0x1f, /* pio0-4 */ |
264 | #if 0 | 263 | #if 0 |
265 | .mwdma_mask = 0x06, /* mwdma1-2 */ | 264 | .mwdma_mask = 0x06, /* mwdma1-2 */ |
@@ -273,8 +272,8 @@ static struct ata_port_info piix_port_info[] = { | |||
273 | /* ich5_sata */ | 272 | /* ich5_sata */ |
274 | { | 273 | { |
275 | .sht = &piix_sht, | 274 | .sht = &piix_sht, |
276 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | | 275 | .host_flags = ATA_FLAG_SATA | PIIX_FLAG_COMBINED | |
277 | PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR, | 276 | PIIX_FLAG_CHECKINTR, |
278 | .pio_mask = 0x1f, /* pio0-4 */ | 277 | .pio_mask = 0x1f, /* pio0-4 */ |
279 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 278 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
280 | .udma_mask = 0x7f, /* udma0-6 */ | 279 | .udma_mask = 0x7f, /* udma0-6 */ |
@@ -284,7 +283,7 @@ static struct ata_port_info piix_port_info[] = { | |||
284 | /* piix4_pata */ | 283 | /* piix4_pata */ |
285 | { | 284 | { |
286 | .sht = &piix_sht, | 285 | .sht = &piix_sht, |
287 | .host_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, | 286 | .host_flags = ATA_FLAG_SLAVE_POSS, |
288 | .pio_mask = 0x1f, /* pio0-4 */ | 287 | .pio_mask = 0x1f, /* pio0-4 */ |
289 | #if 0 | 288 | #if 0 |
290 | .mwdma_mask = 0x06, /* mwdma1-2 */ | 289 | .mwdma_mask = 0x06, /* mwdma1-2 */ |
@@ -298,8 +297,7 @@ static struct ata_port_info piix_port_info[] = { | |||
298 | /* ich6_sata */ | 297 | /* ich6_sata */ |
299 | { | 298 | { |
300 | .sht = &piix_sht, | 299 | .sht = &piix_sht, |
301 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | | 300 | .host_flags = ATA_FLAG_SATA | PIIX_FLAG_COMBINED_ICH6 | |
302 | PIIX_FLAG_COMBINED_ICH6 | | ||
303 | PIIX_FLAG_CHECKINTR | ATA_FLAG_SLAVE_POSS, | 301 | PIIX_FLAG_CHECKINTR | ATA_FLAG_SLAVE_POSS, |
304 | .pio_mask = 0x1f, /* pio0-4 */ | 302 | .pio_mask = 0x1f, /* pio0-4 */ |
305 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 303 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
@@ -310,8 +308,7 @@ static struct ata_port_info piix_port_info[] = { | |||
310 | /* ich6_sata_ahci */ | 308 | /* ich6_sata_ahci */ |
311 | { | 309 | { |
312 | .sht = &piix_sht, | 310 | .sht = &piix_sht, |
313 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | | 311 | .host_flags = ATA_FLAG_SATA | PIIX_FLAG_COMBINED_ICH6 | |
314 | PIIX_FLAG_COMBINED_ICH6 | | ||
315 | PIIX_FLAG_CHECKINTR | ATA_FLAG_SLAVE_POSS | | 312 | PIIX_FLAG_CHECKINTR | ATA_FLAG_SLAVE_POSS | |
316 | PIIX_FLAG_AHCI, | 313 | PIIX_FLAG_AHCI, |
317 | .pio_mask = 0x1f, /* pio0-4 */ | 314 | .pio_mask = 0x1f, /* pio0-4 */ |
@@ -366,30 +363,42 @@ cbl40: | |||
366 | } | 363 | } |
367 | 364 | ||
368 | /** | 365 | /** |
369 | * piix_pata_phy_reset - Probe specified port on PATA host controller | 366 | * piix_pata_probeinit - probeinit for PATA host controller |
370 | * @ap: Port to probe | 367 | * @ap: Target port |
371 | * | 368 | * |
372 | * Probe PATA phy. | 369 | * Probeinit including cable detection. |
373 | * | 370 | * |
374 | * LOCKING: | 371 | * LOCKING: |
375 | * None (inherited from caller). | 372 | * None (inherited from caller). |
376 | */ | 373 | */ |
374 | static void piix_pata_probeinit(struct ata_port *ap) | ||
375 | { | ||
376 | piix_pata_cbl_detect(ap); | ||
377 | ata_std_probeinit(ap); | ||
378 | } | ||
377 | 379 | ||
378 | static void piix_pata_phy_reset(struct ata_port *ap) | 380 | /** |
381 | * piix_pata_probe_reset - Perform reset on PATA port and classify | ||
382 | * @ap: Port to reset | ||
383 | * @classes: Resulting classes of attached devices | ||
384 | * | ||
385 | * Reset PATA phy and classify attached devices. | ||
386 | * | ||
387 | * LOCKING: | ||
388 | * None (inherited from caller). | ||
389 | */ | ||
390 | static int piix_pata_probe_reset(struct ata_port *ap, unsigned int *classes) | ||
379 | { | 391 | { |
380 | struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); | 392 | struct pci_dev *pdev = to_pci_dev(ap->host_set->dev); |
381 | 393 | ||
382 | if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->hard_port_no])) { | 394 | if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->hard_port_no])) { |
383 | ata_port_disable(ap); | ||
384 | printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id); | 395 | printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id); |
385 | return; | 396 | return 0; |
386 | } | 397 | } |
387 | 398 | ||
388 | piix_pata_cbl_detect(ap); | 399 | return ata_drive_probe_reset(ap, piix_pata_probeinit, |
389 | 400 | ata_std_softreset, NULL, | |
390 | ata_port_probe(ap); | 401 | ata_std_postreset, classes); |
391 | |||
392 | ata_bus_reset(ap); | ||
393 | } | 402 | } |
394 | 403 | ||
395 | /** | 404 | /** |
@@ -437,28 +446,25 @@ static int piix_sata_probe (struct ata_port *ap) | |||
437 | } | 446 | } |
438 | 447 | ||
439 | /** | 448 | /** |
440 | * piix_sata_phy_reset - Probe specified port on SATA host controller | 449 | * piix_sata_probe_reset - Perform reset on SATA port and classify |
441 | * @ap: Port to probe | 450 | * @ap: Port to reset |
451 | * @classes: Resulting classes of attached devices | ||
442 | * | 452 | * |
443 | * Probe SATA phy. | 453 | * Reset SATA phy and classify attached devices. |
444 | * | 454 | * |
445 | * LOCKING: | 455 | * LOCKING: |
446 | * None (inherited from caller). | 456 | * None (inherited from caller). |
447 | */ | 457 | */ |
448 | 458 | static int piix_sata_probe_reset(struct ata_port *ap, unsigned int *classes) | |
449 | static void piix_sata_phy_reset(struct ata_port *ap) | ||
450 | { | 459 | { |
451 | if (!piix_sata_probe(ap)) { | 460 | if (!piix_sata_probe(ap)) { |
452 | ata_port_disable(ap); | ||
453 | printk(KERN_INFO "ata%u: SATA port has no device.\n", ap->id); | 461 | printk(KERN_INFO "ata%u: SATA port has no device.\n", ap->id); |
454 | return; | 462 | return 0; |
455 | } | 463 | } |
456 | 464 | ||
457 | ap->cbl = ATA_CBL_SATA; | 465 | return ata_drive_probe_reset(ap, ata_std_probeinit, |
458 | 466 | ata_std_softreset, NULL, | |
459 | ata_port_probe(ap); | 467 | ata_std_postreset, classes); |
460 | |||
461 | ata_bus_reset(ap); | ||
462 | } | 468 | } |
463 | 469 | ||
464 | /** | 470 | /** |
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index ed852348ba24..8b83c4e45208 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -2113,7 +2113,6 @@ int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class) | |||
2113 | * This function is invoked after a successful reset. Note that | 2113 | * This function is invoked after a successful reset. Note that |
2114 | * the device might have been reset more than once using | 2114 | * the device might have been reset more than once using |
2115 | * different reset methods before postreset is invoked. | 2115 | * different reset methods before postreset is invoked. |
2116 | * postreset is also reponsible for setting cable type. | ||
2117 | * | 2116 | * |
2118 | * This function is to be used as standard callback for | 2117 | * This function is to be used as standard callback for |
2119 | * ata_drive_*_reset(). | 2118 | * ata_drive_*_reset(). |
@@ -2125,7 +2124,7 @@ void ata_std_postreset(struct ata_port *ap, unsigned int *classes) | |||
2125 | { | 2124 | { |
2126 | DPRINTK("ENTER\n"); | 2125 | DPRINTK("ENTER\n"); |
2127 | 2126 | ||
2128 | /* set cable type */ | 2127 | /* set cable type if it isn't already set */ |
2129 | if (ap->cbl == ATA_CBL_NONE && ap->flags & ATA_FLAG_SATA) | 2128 | if (ap->cbl == ATA_CBL_NONE && ap->flags & ATA_FLAG_SATA) |
2130 | ap->cbl = ATA_CBL_SATA; | 2129 | ap->cbl = ATA_CBL_SATA; |
2131 | 2130 | ||
@@ -2592,7 +2591,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
2592 | WARN_ON(sg == NULL); | 2591 | WARN_ON(sg == NULL); |
2593 | 2592 | ||
2594 | if (qc->flags & ATA_QCFLAG_SINGLE) | 2593 | if (qc->flags & ATA_QCFLAG_SINGLE) |
2595 | WARN_ON(qc->n_elem != 1); | 2594 | WARN_ON(qc->n_elem > 1); |
2596 | 2595 | ||
2597 | VPRINTK("unmapping %u sg elements\n", qc->n_elem); | 2596 | VPRINTK("unmapping %u sg elements\n", qc->n_elem); |
2598 | 2597 | ||
@@ -2615,7 +2614,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc) | |||
2615 | kunmap_atomic(addr, KM_IRQ0); | 2614 | kunmap_atomic(addr, KM_IRQ0); |
2616 | } | 2615 | } |
2617 | } else { | 2616 | } else { |
2618 | if (sg_dma_len(&sg[0]) > 0) | 2617 | if (qc->n_elem) |
2619 | dma_unmap_single(ap->host_set->dev, | 2618 | dma_unmap_single(ap->host_set->dev, |
2620 | sg_dma_address(&sg[0]), sg_dma_len(&sg[0]), | 2619 | sg_dma_address(&sg[0]), sg_dma_len(&sg[0]), |
2621 | dir); | 2620 | dir); |
@@ -2648,7 +2647,7 @@ static void ata_fill_sg(struct ata_queued_cmd *qc) | |||
2648 | unsigned int idx; | 2647 | unsigned int idx; |
2649 | 2648 | ||
2650 | WARN_ON(qc->__sg == NULL); | 2649 | WARN_ON(qc->__sg == NULL); |
2651 | WARN_ON(qc->n_elem == 0); | 2650 | WARN_ON(qc->n_elem == 0 && qc->pad_len == 0); |
2652 | 2651 | ||
2653 | idx = 0; | 2652 | idx = 0; |
2654 | ata_for_each_sg(sg, qc) { | 2653 | ata_for_each_sg(sg, qc) { |
@@ -2793,6 +2792,7 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) | |||
2793 | int dir = qc->dma_dir; | 2792 | int dir = qc->dma_dir; |
2794 | struct scatterlist *sg = qc->__sg; | 2793 | struct scatterlist *sg = qc->__sg; |
2795 | dma_addr_t dma_address; | 2794 | dma_addr_t dma_address; |
2795 | int trim_sg = 0; | ||
2796 | 2796 | ||
2797 | /* we must lengthen transfers to end on a 32-bit boundary */ | 2797 | /* we must lengthen transfers to end on a 32-bit boundary */ |
2798 | qc->pad_len = sg->length & 3; | 2798 | qc->pad_len = sg->length & 3; |
@@ -2812,13 +2812,15 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) | |||
2812 | sg_dma_len(psg) = ATA_DMA_PAD_SZ; | 2812 | sg_dma_len(psg) = ATA_DMA_PAD_SZ; |
2813 | /* trim sg */ | 2813 | /* trim sg */ |
2814 | sg->length -= qc->pad_len; | 2814 | sg->length -= qc->pad_len; |
2815 | if (sg->length == 0) | ||
2816 | trim_sg = 1; | ||
2815 | 2817 | ||
2816 | DPRINTK("padding done, sg->length=%u pad_len=%u\n", | 2818 | DPRINTK("padding done, sg->length=%u pad_len=%u\n", |
2817 | sg->length, qc->pad_len); | 2819 | sg->length, qc->pad_len); |
2818 | } | 2820 | } |
2819 | 2821 | ||
2820 | if (!sg->length) { | 2822 | if (trim_sg) { |
2821 | sg_dma_address(sg) = 0; | 2823 | qc->n_elem--; |
2822 | goto skip_map; | 2824 | goto skip_map; |
2823 | } | 2825 | } |
2824 | 2826 | ||
@@ -2831,9 +2833,9 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc) | |||
2831 | } | 2833 | } |
2832 | 2834 | ||
2833 | sg_dma_address(sg) = dma_address; | 2835 | sg_dma_address(sg) = dma_address; |
2834 | skip_map: | ||
2835 | sg_dma_len(sg) = sg->length; | 2836 | sg_dma_len(sg) = sg->length; |
2836 | 2837 | ||
2838 | skip_map: | ||
2837 | DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg), | 2839 | DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg), |
2838 | qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); | 2840 | qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); |
2839 | 2841 | ||
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c index bfc1dc8e7779..bf7bb9ec18d0 100644 --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c | |||
@@ -277,7 +277,7 @@ static unsigned int qs_fill_sg(struct ata_queued_cmd *qc) | |||
277 | u8 *prd = pp->pkt + QS_CPB_BYTES; | 277 | u8 *prd = pp->pkt + QS_CPB_BYTES; |
278 | 278 | ||
279 | WARN_ON(qc->__sg == NULL); | 279 | WARN_ON(qc->__sg == NULL); |
280 | WARN_ON(qc->n_elem == 0); | 280 | WARN_ON(qc->n_elem == 0 && qc->pad_len == 0); |
281 | 281 | ||
282 | nelem = 0; | 282 | nelem = 0; |
283 | ata_for_each_sg(sg, qc) { | 283 | ata_for_each_sg(sg, qc) { |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 63500881acc6..2558abac9fb2 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -619,17 +619,29 @@ ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) | |||
619 | } | 619 | } |
620 | 620 | ||
621 | static inline struct scatterlist * | 621 | static inline struct scatterlist * |
622 | ata_qc_first_sg(struct ata_queued_cmd *qc) | ||
623 | { | ||
624 | if (qc->n_elem) | ||
625 | return qc->__sg; | ||
626 | if (qc->pad_len) | ||
627 | return &qc->pad_sgent; | ||
628 | return NULL; | ||
629 | } | ||
630 | |||
631 | static inline struct scatterlist * | ||
622 | ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc) | 632 | ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc) |
623 | { | 633 | { |
624 | if (sg == &qc->pad_sgent) | 634 | if (sg == &qc->pad_sgent) |
625 | return NULL; | 635 | return NULL; |
626 | if (++sg - qc->__sg < qc->n_elem) | 636 | if (++sg - qc->__sg < qc->n_elem) |
627 | return sg; | 637 | return sg; |
628 | return qc->pad_len ? &qc->pad_sgent : NULL; | 638 | if (qc->pad_len) |
639 | return &qc->pad_sgent; | ||
640 | return NULL; | ||
629 | } | 641 | } |
630 | 642 | ||
631 | #define ata_for_each_sg(sg, qc) \ | 643 | #define ata_for_each_sg(sg, qc) \ |
632 | for (sg = qc->__sg; sg; sg = ata_qc_next_sg(sg, qc)) | 644 | for (sg = ata_qc_first_sg(qc); sg; sg = ata_qc_next_sg(sg, qc)) |
633 | 645 | ||
634 | static inline unsigned int ata_tag_valid(unsigned int tag) | 646 | static inline unsigned int ata_tag_valid(unsigned int tag) |
635 | { | 647 | { |