diff options
Diffstat (limited to 'drivers/scsi/libata-scsi.c')
-rw-r--r-- | drivers/scsi/libata-scsi.c | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index cebf9b31b516..fc547ca295fa 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c | |||
@@ -662,6 +662,41 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) | |||
662 | } | 662 | } |
663 | } | 663 | } |
664 | 664 | ||
665 | static void ata_scsi_sdev_config(struct scsi_device *sdev) | ||
666 | { | ||
667 | sdev->use_10_for_rw = 1; | ||
668 | sdev->use_10_for_ms = 1; | ||
669 | } | ||
670 | |||
671 | static void ata_scsi_dev_config(struct scsi_device *sdev, | ||
672 | struct ata_device *dev) | ||
673 | { | ||
674 | unsigned int max_sectors; | ||
675 | |||
676 | /* TODO: 2048 is an arbitrary number, not the | ||
677 | * hardware maximum. This should be increased to | ||
678 | * 65534 when Jens Axboe's patch for dynamically | ||
679 | * determining max_sectors is merged. | ||
680 | */ | ||
681 | max_sectors = ATA_MAX_SECTORS; | ||
682 | if (dev->flags & ATA_DFLAG_LBA48) | ||
683 | max_sectors = 2048; | ||
684 | if (dev->max_sectors) | ||
685 | max_sectors = dev->max_sectors; | ||
686 | |||
687 | blk_queue_max_sectors(sdev->request_queue, max_sectors); | ||
688 | |||
689 | /* | ||
690 | * SATA DMA transfers must be multiples of 4 byte, so | ||
691 | * we need to pad ATAPI transfers using an extra sg. | ||
692 | * Decrement max hw segments accordingly. | ||
693 | */ | ||
694 | if (dev->class == ATA_DEV_ATAPI) { | ||
695 | request_queue_t *q = sdev->request_queue; | ||
696 | blk_queue_max_hw_segments(q, q->max_hw_segments - 1); | ||
697 | } | ||
698 | } | ||
699 | |||
665 | /** | 700 | /** |
666 | * ata_scsi_slave_config - Set SCSI device attributes | 701 | * ata_scsi_slave_config - Set SCSI device attributes |
667 | * @sdev: SCSI device to examine | 702 | * @sdev: SCSI device to examine |
@@ -676,41 +711,18 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc) | |||
676 | 711 | ||
677 | int ata_scsi_slave_config(struct scsi_device *sdev) | 712 | int ata_scsi_slave_config(struct scsi_device *sdev) |
678 | { | 713 | { |
679 | sdev->use_10_for_rw = 1; | 714 | ata_scsi_sdev_config(sdev); |
680 | sdev->use_10_for_ms = 1; | ||
681 | 715 | ||
682 | blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); | 716 | blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); |
683 | 717 | ||
684 | if (sdev->id < ATA_MAX_DEVICES) { | 718 | if (sdev->id < ATA_MAX_DEVICES) { |
685 | struct ata_port *ap; | 719 | struct ata_port *ap; |
686 | struct ata_device *dev; | 720 | struct ata_device *dev; |
687 | unsigned int max_sectors; | ||
688 | 721 | ||
689 | ap = (struct ata_port *) &sdev->host->hostdata[0]; | 722 | ap = (struct ata_port *) &sdev->host->hostdata[0]; |
690 | dev = &ap->device[sdev->id]; | 723 | dev = &ap->device[sdev->id]; |
691 | 724 | ||
692 | /* TODO: 2048 is an arbitrary number, not the | 725 | ata_scsi_dev_config(sdev, dev); |
693 | * hardware maximum. This should be increased to | ||
694 | * 65534 when Jens Axboe's patch for dynamically | ||
695 | * determining max_sectors is merged. | ||
696 | */ | ||
697 | max_sectors = ATA_MAX_SECTORS; | ||
698 | if (dev->flags & ATA_DFLAG_LBA48) | ||
699 | max_sectors = 2048; | ||
700 | if (dev->max_sectors) | ||
701 | max_sectors = dev->max_sectors; | ||
702 | |||
703 | blk_queue_max_sectors(sdev->request_queue, max_sectors); | ||
704 | |||
705 | /* | ||
706 | * SATA DMA transfers must be multiples of 4 byte, so | ||
707 | * we need to pad ATAPI transfers using an extra sg. | ||
708 | * Decrement max hw segments accordingly. | ||
709 | */ | ||
710 | if (dev->class == ATA_DEV_ATAPI) { | ||
711 | request_queue_t *q = sdev->request_queue; | ||
712 | blk_queue_max_hw_segments(q, q->max_hw_segments - 1); | ||
713 | } | ||
714 | } | 726 | } |
715 | 727 | ||
716 | return 0; /* scsi layer doesn't check return value, sigh */ | 728 | return 0; /* scsi layer doesn't check return value, sigh */ |