Commit 4a9c7b3359889399aacb94019bbdfc9f38d4cff7
Committed by
Jeff Garzik
1 parent
c77a036bec
Exists in
master
and in
7 other branches
libata: fix device iteration bugs
There were several places where only enabled devices should be iterated over but device enabledness wasn't checked. * IDENTIFY data 40 wire check in cable_is_40wire() * xfer_mode/ncq_enabled saving in ata_scsi_error() * DUBIOUS_XFER handling in ata_set_mode() While at it, reformat comments in cable_is_40wire(). Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Showing 2 changed files with 28 additions and 15 deletions Side-by-side Diff
drivers/ata/libata-core.c
... | ... | @@ -4156,29 +4156,33 @@ |
4156 | 4156 | struct ata_link *link; |
4157 | 4157 | struct ata_device *dev; |
4158 | 4158 | |
4159 | - /* If the controller thinks we are 40 wire, we are */ | |
4159 | + /* If the controller thinks we are 40 wire, we are. */ | |
4160 | 4160 | if (ap->cbl == ATA_CBL_PATA40) |
4161 | 4161 | return 1; |
4162 | - /* If the controller thinks we are 80 wire, we are */ | |
4162 | + | |
4163 | + /* If the controller thinks we are 80 wire, we are. */ | |
4163 | 4164 | if (ap->cbl == ATA_CBL_PATA80 || ap->cbl == ATA_CBL_SATA) |
4164 | 4165 | return 0; |
4165 | - /* If the system is known to be 40 wire short cable (eg laptop), | |
4166 | - then we allow 80 wire modes even if the drive isn't sure */ | |
4166 | + | |
4167 | + /* If the system is known to be 40 wire short cable (eg | |
4168 | + * laptop), then we allow 80 wire modes even if the drive | |
4169 | + * isn't sure. | |
4170 | + */ | |
4167 | 4171 | if (ap->cbl == ATA_CBL_PATA40_SHORT) |
4168 | 4172 | return 0; |
4169 | - /* If the controller doesn't know we scan | |
4170 | 4173 | |
4171 | - - Note: We look for all 40 wire detects at this point. | |
4172 | - Any 80 wire detect is taken to be 80 wire cable | |
4173 | - because | |
4174 | - - In many setups only the one drive (slave if present) | |
4175 | - will give a valid detect | |
4176 | - - If you have a non detect capable drive you don't | |
4177 | - want it to colour the choice | |
4178 | - */ | |
4174 | + /* If the controller doesn't know, we scan. | |
4175 | + * | |
4176 | + * Note: We look for all 40 wire detects at this point. Any | |
4177 | + * 80 wire detect is taken to be 80 wire cable because | |
4178 | + * - in many setups only the one drive (slave if present) will | |
4179 | + * give a valid detect | |
4180 | + * - if you have a non detect capable drive you don't want it | |
4181 | + * to colour the choice | |
4182 | + */ | |
4179 | 4183 | ata_port_for_each_link(link, ap) { |
4180 | 4184 | ata_link_for_each_dev(dev, link) { |
4181 | - if (!ata_is_40wire(dev)) | |
4185 | + if (ata_dev_enabled(dev) && !ata_is_40wire(dev)) | |
4182 | 4186 | return 0; |
4183 | 4187 | } |
4184 | 4188 | } |
drivers/ata/libata-eh.c
... | ... | @@ -603,6 +603,9 @@ |
603 | 603 | ata_link_for_each_dev(dev, link) { |
604 | 604 | int devno = dev->devno; |
605 | 605 | |
606 | + if (!ata_dev_enabled(dev)) | |
607 | + continue; | |
608 | + | |
606 | 609 | ehc->saved_xfer_mode[devno] = dev->xfer_mode; |
607 | 610 | if (ata_ncq_enabled(dev)) |
608 | 611 | ehc->saved_ncq_enabled |= 1 << devno; |
... | ... | @@ -2787,6 +2790,9 @@ |
2787 | 2790 | |
2788 | 2791 | /* if data transfer is verified, clear DUBIOUS_XFER on ering top */ |
2789 | 2792 | ata_link_for_each_dev(dev, link) { |
2793 | + if (!ata_dev_enabled(dev)) | |
2794 | + continue; | |
2795 | + | |
2790 | 2796 | if (!(dev->flags & ATA_DFLAG_DUBIOUS_XFER)) { |
2791 | 2797 | struct ata_ering_entry *ent; |
2792 | 2798 | |
... | ... | @@ -2807,6 +2813,9 @@ |
2807 | 2813 | struct ata_eh_context *ehc = &link->eh_context; |
2808 | 2814 | u8 saved_xfer_mode = ehc->saved_xfer_mode[dev->devno]; |
2809 | 2815 | u8 saved_ncq = !!(ehc->saved_ncq_enabled & (1 << dev->devno)); |
2816 | + | |
2817 | + if (!ata_dev_enabled(dev)) | |
2818 | + continue; | |
2810 | 2819 | |
2811 | 2820 | if (dev->xfer_mode != saved_xfer_mode || |
2812 | 2821 | ata_ncq_enabled(dev) != saved_ncq) |