diff options
author | Tejun Heo <htejun@gmail.com> | 2007-08-06 05:36:22 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-12 14:55:30 -0400 |
commit | 9af5c9c97dc9d599281778864c72b385f0c63341 (patch) | |
tree | 8359986bd42c4a9a5b1993078aa9ee4c7971ac3d /drivers/ata/libata-core.c | |
parent | 640fdb504941fa2b9f6f274716fc9f97f2bf6bff (diff) |
libata-link: introduce ata_link
Introduce ata_link. It abstracts PHY and sits between ata_port and
ata_device. This new level of abstraction is necessary to support
SATA Port Multiplier, which basically adds a bunch of links (PHYs) to
a ATA host port. Fields related to command execution, spd_limit and
EH are per-link and thus moved to ata_link.
This patch only defines the host link. Multiple link handling will be
added later. Also, a lot of ap->link derefences are added but many of
them will be removed as each part is converted to deal directly with
ata_link instead of ata_port.
This patch introduces no behavior change.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: James Bottomley <James.Bottomley@SteelEye.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r-- | drivers/ata/libata-core.c | 157 |
1 files changed, 83 insertions, 74 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 772be09b4689..dd2de485124a 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -235,7 +235,7 @@ static int ata_rwcmd_protocol(struct ata_taskfile *tf, struct ata_device *dev) | |||
235 | if (dev->flags & ATA_DFLAG_PIO) { | 235 | if (dev->flags & ATA_DFLAG_PIO) { |
236 | tf->protocol = ATA_PROT_PIO; | 236 | tf->protocol = ATA_PROT_PIO; |
237 | index = dev->multi_count ? 0 : 8; | 237 | index = dev->multi_count ? 0 : 8; |
238 | } else if (lba48 && (dev->ap->flags & ATA_FLAG_PIO_LBA48)) { | 238 | } else if (lba48 && (dev->link->ap->flags & ATA_FLAG_PIO_LBA48)) { |
239 | /* Unable to use DMA due to host limitation */ | 239 | /* Unable to use DMA due to host limitation */ |
240 | tf->protocol = ATA_PROT_PIO; | 240 | tf->protocol = ATA_PROT_PIO; |
241 | index = dev->multi_count ? 0 : 8; | 241 | index = dev->multi_count ? 0 : 8; |
@@ -604,7 +604,7 @@ static const char *sata_spd_string(unsigned int spd) | |||
604 | void ata_dev_disable(struct ata_device *dev) | 604 | void ata_dev_disable(struct ata_device *dev) |
605 | { | 605 | { |
606 | if (ata_dev_enabled(dev)) { | 606 | if (ata_dev_enabled(dev)) { |
607 | if (ata_msg_drv(dev->ap)) | 607 | if (ata_msg_drv(dev->link->ap)) |
608 | ata_dev_printk(dev, KERN_WARNING, "disabled\n"); | 608 | ata_dev_printk(dev, KERN_WARNING, "disabled\n"); |
609 | ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | | 609 | ata_down_xfermask_limit(dev, ATA_DNXFER_FORCE_PIO0 | |
610 | ATA_DNXFER_QUIET); | 610 | ATA_DNXFER_QUIET); |
@@ -735,7 +735,7 @@ ata_dev_try_classify(struct ata_port *ap, unsigned int device, u8 *r_err) | |||
735 | /* see if device passed diags: if master then continue and warn later */ | 735 | /* see if device passed diags: if master then continue and warn later */ |
736 | if (err == 0 && device == 0) | 736 | if (err == 0 && device == 0) |
737 | /* diagnostic fail : do nothing _YET_ */ | 737 | /* diagnostic fail : do nothing _YET_ */ |
738 | ap->device[device].horkage |= ATA_HORKAGE_DIAGNOSTIC; | 738 | ap->link.device[device].horkage |= ATA_HORKAGE_DIAGNOSTIC; |
739 | else if (err == 1) | 739 | else if (err == 1) |
740 | /* do nothing */ ; | 740 | /* do nothing */ ; |
741 | else if ((device == 0) && (err == 0x81)) | 741 | else if ((device == 0) && (err == 0x81)) |
@@ -1150,7 +1150,7 @@ void ata_dev_select(struct ata_port *ap, unsigned int device, | |||
1150 | ap->ops->dev_select(ap, device); | 1150 | ap->ops->dev_select(ap, device); |
1151 | 1151 | ||
1152 | if (wait) { | 1152 | if (wait) { |
1153 | if (can_sleep && ap->device[device].class == ATA_DEV_ATAPI) | 1153 | if (can_sleep && ap->link.device[device].class == ATA_DEV_ATAPI) |
1154 | msleep(150); | 1154 | msleep(150); |
1155 | ata_wait_idle(ap); | 1155 | ata_wait_idle(ap); |
1156 | } | 1156 | } |
@@ -1346,7 +1346,8 @@ unsigned ata_exec_internal_sg(struct ata_device *dev, | |||
1346 | int dma_dir, struct scatterlist *sg, | 1346 | int dma_dir, struct scatterlist *sg, |
1347 | unsigned int n_elem) | 1347 | unsigned int n_elem) |
1348 | { | 1348 | { |
1349 | struct ata_port *ap = dev->ap; | 1349 | struct ata_link *link = dev->link; |
1350 | struct ata_port *ap = link->ap; | ||
1350 | u8 command = tf->command; | 1351 | u8 command = tf->command; |
1351 | struct ata_queued_cmd *qc; | 1352 | struct ata_queued_cmd *qc; |
1352 | unsigned int tag, preempted_tag; | 1353 | unsigned int tag, preempted_tag; |
@@ -1386,11 +1387,11 @@ unsigned ata_exec_internal_sg(struct ata_device *dev, | |||
1386 | qc->dev = dev; | 1387 | qc->dev = dev; |
1387 | ata_qc_reinit(qc); | 1388 | ata_qc_reinit(qc); |
1388 | 1389 | ||
1389 | preempted_tag = ap->active_tag; | 1390 | preempted_tag = link->active_tag; |
1390 | preempted_sactive = ap->sactive; | 1391 | preempted_sactive = link->sactive; |
1391 | preempted_qc_active = ap->qc_active; | 1392 | preempted_qc_active = ap->qc_active; |
1392 | ap->active_tag = ATA_TAG_POISON; | 1393 | link->active_tag = ATA_TAG_POISON; |
1393 | ap->sactive = 0; | 1394 | link->sactive = 0; |
1394 | ap->qc_active = 0; | 1395 | ap->qc_active = 0; |
1395 | 1396 | ||
1396 | /* prepare & issue qc */ | 1397 | /* prepare & issue qc */ |
@@ -1467,8 +1468,8 @@ unsigned ata_exec_internal_sg(struct ata_device *dev, | |||
1467 | err_mask = qc->err_mask; | 1468 | err_mask = qc->err_mask; |
1468 | 1469 | ||
1469 | ata_qc_free(qc); | 1470 | ata_qc_free(qc); |
1470 | ap->active_tag = preempted_tag; | 1471 | link->active_tag = preempted_tag; |
1471 | ap->sactive = preempted_sactive; | 1472 | link->sactive = preempted_sactive; |
1472 | ap->qc_active = preempted_qc_active; | 1473 | ap->qc_active = preempted_qc_active; |
1473 | 1474 | ||
1474 | /* XXX - Some LLDDs (sata_mv) disable port on command failure. | 1475 | /* XXX - Some LLDDs (sata_mv) disable port on command failure. |
@@ -1566,7 +1567,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev) | |||
1566 | { | 1567 | { |
1567 | /* Controller doesn't support IORDY. Probably a pointless check | 1568 | /* Controller doesn't support IORDY. Probably a pointless check |
1568 | as the caller should know this */ | 1569 | as the caller should know this */ |
1569 | if (adev->ap->flags & ATA_FLAG_NO_IORDY) | 1570 | if (adev->link->ap->flags & ATA_FLAG_NO_IORDY) |
1570 | return 0; | 1571 | return 0; |
1571 | /* PIO3 and higher it is mandatory */ | 1572 | /* PIO3 and higher it is mandatory */ |
1572 | if (adev->pio_mode > XFER_PIO_2) | 1573 | if (adev->pio_mode > XFER_PIO_2) |
@@ -1622,7 +1623,7 @@ static u32 ata_pio_mask_no_iordy(const struct ata_device *adev) | |||
1622 | int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | 1623 | int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, |
1623 | unsigned int flags, u16 *id) | 1624 | unsigned int flags, u16 *id) |
1624 | { | 1625 | { |
1625 | struct ata_port *ap = dev->ap; | 1626 | struct ata_port *ap = dev->link->ap; |
1626 | unsigned int class = *p_class; | 1627 | unsigned int class = *p_class; |
1627 | struct ata_taskfile tf; | 1628 | struct ata_taskfile tf; |
1628 | unsigned int err_mask = 0; | 1629 | unsigned int err_mask = 0; |
@@ -1774,13 +1775,14 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1774 | 1775 | ||
1775 | static inline u8 ata_dev_knobble(struct ata_device *dev) | 1776 | static inline u8 ata_dev_knobble(struct ata_device *dev) |
1776 | { | 1777 | { |
1777 | return ((dev->ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id))); | 1778 | struct ata_port *ap = dev->link->ap; |
1779 | return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id))); | ||
1778 | } | 1780 | } |
1779 | 1781 | ||
1780 | static void ata_dev_config_ncq(struct ata_device *dev, | 1782 | static void ata_dev_config_ncq(struct ata_device *dev, |
1781 | char *desc, size_t desc_sz) | 1783 | char *desc, size_t desc_sz) |
1782 | { | 1784 | { |
1783 | struct ata_port *ap = dev->ap; | 1785 | struct ata_port *ap = dev->link->ap; |
1784 | int hdepth = 0, ddepth = ata_id_queue_depth(dev->id); | 1786 | int hdepth = 0, ddepth = ata_id_queue_depth(dev->id); |
1785 | 1787 | ||
1786 | if (!ata_id_has_ncq(dev->id)) { | 1788 | if (!ata_id_has_ncq(dev->id)) { |
@@ -1817,8 +1819,8 @@ static void ata_dev_config_ncq(struct ata_device *dev, | |||
1817 | */ | 1819 | */ |
1818 | int ata_dev_configure(struct ata_device *dev) | 1820 | int ata_dev_configure(struct ata_device *dev) |
1819 | { | 1821 | { |
1820 | struct ata_port *ap = dev->ap; | 1822 | struct ata_port *ap = dev->link->ap; |
1821 | struct ata_eh_context *ehc = &ap->eh_context; | 1823 | struct ata_eh_context *ehc = &dev->link->eh_context; |
1822 | int print_info = ehc->i.flags & ATA_EHI_PRINTINFO; | 1824 | int print_info = ehc->i.flags & ATA_EHI_PRINTINFO; |
1823 | const u16 *id = dev->id; | 1825 | const u16 *id = dev->id; |
1824 | unsigned int xfer_mask; | 1826 | unsigned int xfer_mask; |
@@ -2116,7 +2118,7 @@ int ata_bus_probe(struct ata_port *ap) | |||
2116 | ap->ops->phy_reset(ap); | 2118 | ap->ops->phy_reset(ap); |
2117 | 2119 | ||
2118 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2120 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
2119 | dev = &ap->device[i]; | 2121 | dev = &ap->link.device[i]; |
2120 | 2122 | ||
2121 | if (!(ap->flags & ATA_FLAG_DISABLED) && | 2123 | if (!(ap->flags & ATA_FLAG_DISABLED) && |
2122 | dev->class != ATA_DEV_UNKNOWN) | 2124 | dev->class != ATA_DEV_UNKNOWN) |
@@ -2133,14 +2135,14 @@ int ata_bus_probe(struct ata_port *ap) | |||
2133 | state is undefined. Record the mode */ | 2135 | state is undefined. Record the mode */ |
2134 | 2136 | ||
2135 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 2137 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
2136 | ap->device[i].pio_mode = XFER_PIO_0; | 2138 | ap->link.device[i].pio_mode = XFER_PIO_0; |
2137 | 2139 | ||
2138 | /* read IDENTIFY page and configure devices. We have to do the identify | 2140 | /* read IDENTIFY page and configure devices. We have to do the identify |
2139 | specific sequence bass-ackwards so that PDIAG- is released by | 2141 | specific sequence bass-ackwards so that PDIAG- is released by |
2140 | the slave device */ | 2142 | the slave device */ |
2141 | 2143 | ||
2142 | for (i = ATA_MAX_DEVICES - 1; i >= 0; i--) { | 2144 | for (i = ATA_MAX_DEVICES - 1; i >= 0; i--) { |
2143 | dev = &ap->device[i]; | 2145 | dev = &ap->link.device[i]; |
2144 | 2146 | ||
2145 | if (tries[i]) | 2147 | if (tries[i]) |
2146 | dev->class = classes[i]; | 2148 | dev->class = classes[i]; |
@@ -2162,13 +2164,13 @@ int ata_bus_probe(struct ata_port *ap) | |||
2162 | this in the normal order so that the user doesn't get confused */ | 2164 | this in the normal order so that the user doesn't get confused */ |
2163 | 2165 | ||
2164 | for(i = 0; i < ATA_MAX_DEVICES; i++) { | 2166 | for(i = 0; i < ATA_MAX_DEVICES; i++) { |
2165 | dev = &ap->device[i]; | 2167 | dev = &ap->link.device[i]; |
2166 | if (!ata_dev_enabled(dev)) | 2168 | if (!ata_dev_enabled(dev)) |
2167 | continue; | 2169 | continue; |
2168 | 2170 | ||
2169 | ap->eh_context.i.flags |= ATA_EHI_PRINTINFO; | 2171 | ap->link.eh_context.i.flags |= ATA_EHI_PRINTINFO; |
2170 | rc = ata_dev_configure(dev); | 2172 | rc = ata_dev_configure(dev); |
2171 | ap->eh_context.i.flags &= ~ATA_EHI_PRINTINFO; | 2173 | ap->link.eh_context.i.flags &= ~ATA_EHI_PRINTINFO; |
2172 | if (rc) | 2174 | if (rc) |
2173 | goto fail; | 2175 | goto fail; |
2174 | } | 2176 | } |
@@ -2179,7 +2181,7 @@ int ata_bus_probe(struct ata_port *ap) | |||
2179 | goto fail; | 2181 | goto fail; |
2180 | 2182 | ||
2181 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 2183 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
2182 | if (ata_dev_enabled(&ap->device[i])) | 2184 | if (ata_dev_enabled(&ap->link.device[i])) |
2183 | return 0; | 2185 | return 0; |
2184 | 2186 | ||
2185 | /* no device present, disable port */ | 2187 | /* no device present, disable port */ |
@@ -2344,8 +2346,8 @@ void sata_phy_reset(struct ata_port *ap) | |||
2344 | 2346 | ||
2345 | struct ata_device *ata_dev_pair(struct ata_device *adev) | 2347 | struct ata_device *ata_dev_pair(struct ata_device *adev) |
2346 | { | 2348 | { |
2347 | struct ata_port *ap = adev->ap; | 2349 | struct ata_link *link = adev->link; |
2348 | struct ata_device *pair = &ap->device[1 - adev->devno]; | 2350 | struct ata_device *pair = &link->device[1 - adev->devno]; |
2349 | if (!ata_dev_enabled(pair)) | 2351 | if (!ata_dev_enabled(pair)) |
2350 | return NULL; | 2352 | return NULL; |
2351 | return pair; | 2353 | return pair; |
@@ -2366,8 +2368,8 @@ struct ata_device *ata_dev_pair(struct ata_device *adev) | |||
2366 | 2368 | ||
2367 | void ata_port_disable(struct ata_port *ap) | 2369 | void ata_port_disable(struct ata_port *ap) |
2368 | { | 2370 | { |
2369 | ap->device[0].class = ATA_DEV_NONE; | 2371 | ap->link.device[0].class = ATA_DEV_NONE; |
2370 | ap->device[1].class = ATA_DEV_NONE; | 2372 | ap->link.device[1].class = ATA_DEV_NONE; |
2371 | ap->flags |= ATA_FLAG_DISABLED; | 2373 | ap->flags |= ATA_FLAG_DISABLED; |
2372 | } | 2374 | } |
2373 | 2375 | ||
@@ -2400,9 +2402,9 @@ int sata_down_spd_limit(struct ata_port *ap) | |||
2400 | if (rc == 0) | 2402 | if (rc == 0) |
2401 | spd = (sstatus >> 4) & 0xf; | 2403 | spd = (sstatus >> 4) & 0xf; |
2402 | else | 2404 | else |
2403 | spd = ap->sata_spd; | 2405 | spd = ap->link.sata_spd; |
2404 | 2406 | ||
2405 | mask = ap->sata_spd_limit; | 2407 | mask = ap->link.sata_spd_limit; |
2406 | if (mask <= 1) | 2408 | if (mask <= 1) |
2407 | return -EINVAL; | 2409 | return -EINVAL; |
2408 | 2410 | ||
@@ -2422,7 +2424,7 @@ int sata_down_spd_limit(struct ata_port *ap) | |||
2422 | if (!mask) | 2424 | if (!mask) |
2423 | return -EINVAL; | 2425 | return -EINVAL; |
2424 | 2426 | ||
2425 | ap->sata_spd_limit = mask; | 2427 | ap->link.sata_spd_limit = mask; |
2426 | 2428 | ||
2427 | ata_port_printk(ap, KERN_WARNING, "limiting SATA link speed to %s\n", | 2429 | ata_port_printk(ap, KERN_WARNING, "limiting SATA link speed to %s\n", |
2428 | sata_spd_string(fls(mask))); | 2430 | sata_spd_string(fls(mask))); |
@@ -2434,10 +2436,10 @@ static int __sata_set_spd_needed(struct ata_port *ap, u32 *scontrol) | |||
2434 | { | 2436 | { |
2435 | u32 spd, limit; | 2437 | u32 spd, limit; |
2436 | 2438 | ||
2437 | if (ap->sata_spd_limit == UINT_MAX) | 2439 | if (ap->link.sata_spd_limit == UINT_MAX) |
2438 | limit = 0; | 2440 | limit = 0; |
2439 | else | 2441 | else |
2440 | limit = fls(ap->sata_spd_limit); | 2442 | limit = fls(ap->link.sata_spd_limit); |
2441 | 2443 | ||
2442 | spd = (*scontrol >> 4) & 0xf; | 2444 | spd = (*scontrol >> 4) & 0xf; |
2443 | *scontrol = (*scontrol & ~0xf0) | ((limit & 0xf) << 4); | 2445 | *scontrol = (*scontrol & ~0xf0) | ((limit & 0xf) << 4); |
@@ -2450,7 +2452,7 @@ static int __sata_set_spd_needed(struct ata_port *ap, u32 *scontrol) | |||
2450 | * @ap: Port in question | 2452 | * @ap: Port in question |
2451 | * | 2453 | * |
2452 | * Test whether the spd limit in SControl matches | 2454 | * Test whether the spd limit in SControl matches |
2453 | * @ap->sata_spd_limit. This function is used to determine | 2455 | * @ap->link.sata_spd_limit. This function is used to determine |
2454 | * whether hardreset is necessary to apply SATA spd | 2456 | * whether hardreset is necessary to apply SATA spd |
2455 | * configuration. | 2457 | * configuration. |
2456 | * | 2458 | * |
@@ -2749,7 +2751,7 @@ int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel) | |||
2749 | 2751 | ||
2750 | static int ata_dev_set_mode(struct ata_device *dev) | 2752 | static int ata_dev_set_mode(struct ata_device *dev) |
2751 | { | 2753 | { |
2752 | struct ata_eh_context *ehc = &dev->ap->eh_context; | 2754 | struct ata_eh_context *ehc = &dev->link->eh_context; |
2753 | unsigned int err_mask; | 2755 | unsigned int err_mask; |
2754 | int rc; | 2756 | int rc; |
2755 | 2757 | ||
@@ -2809,7 +2811,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2809 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2811 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
2810 | unsigned int pio_mask, dma_mask; | 2812 | unsigned int pio_mask, dma_mask; |
2811 | 2813 | ||
2812 | dev = &ap->device[i]; | 2814 | dev = &ap->link.device[i]; |
2813 | 2815 | ||
2814 | if (!ata_dev_enabled(dev)) | 2816 | if (!ata_dev_enabled(dev)) |
2815 | continue; | 2817 | continue; |
@@ -2830,7 +2832,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2830 | 2832 | ||
2831 | /* step 2: always set host PIO timings */ | 2833 | /* step 2: always set host PIO timings */ |
2832 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2834 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
2833 | dev = &ap->device[i]; | 2835 | dev = &ap->link.device[i]; |
2834 | if (!ata_dev_enabled(dev)) | 2836 | if (!ata_dev_enabled(dev)) |
2835 | continue; | 2837 | continue; |
2836 | 2838 | ||
@@ -2848,7 +2850,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2848 | 2850 | ||
2849 | /* step 3: set host DMA timings */ | 2851 | /* step 3: set host DMA timings */ |
2850 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2852 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
2851 | dev = &ap->device[i]; | 2853 | dev = &ap->link.device[i]; |
2852 | 2854 | ||
2853 | if (!ata_dev_enabled(dev) || !dev->dma_mode) | 2855 | if (!ata_dev_enabled(dev) || !dev->dma_mode) |
2854 | continue; | 2856 | continue; |
@@ -2861,7 +2863,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) | |||
2861 | 2863 | ||
2862 | /* step 4: update devices' xfer mode */ | 2864 | /* step 4: update devices' xfer mode */ |
2863 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 2865 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
2864 | dev = &ap->device[i]; | 2866 | dev = &ap->link.device[i]; |
2865 | 2867 | ||
2866 | /* don't update suspended devices' xfer mode */ | 2868 | /* don't update suspended devices' xfer mode */ |
2867 | if (!ata_dev_enabled(dev)) | 2869 | if (!ata_dev_enabled(dev)) |
@@ -3142,6 +3144,7 @@ static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, | |||
3142 | 3144 | ||
3143 | void ata_bus_reset(struct ata_port *ap) | 3145 | void ata_bus_reset(struct ata_port *ap) |
3144 | { | 3146 | { |
3147 | struct ata_device *device = ap->link.device; | ||
3145 | struct ata_ioports *ioaddr = &ap->ioaddr; | 3148 | struct ata_ioports *ioaddr = &ap->ioaddr; |
3146 | unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; | 3149 | unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; |
3147 | u8 err; | 3150 | u8 err; |
@@ -3177,19 +3180,19 @@ void ata_bus_reset(struct ata_port *ap) | |||
3177 | /* | 3180 | /* |
3178 | * determine by signature whether we have ATA or ATAPI devices | 3181 | * determine by signature whether we have ATA or ATAPI devices |
3179 | */ | 3182 | */ |
3180 | ap->device[0].class = ata_dev_try_classify(ap, 0, &err); | 3183 | device[0].class = ata_dev_try_classify(ap, 0, &err); |
3181 | if ((slave_possible) && (err != 0x81)) | 3184 | if ((slave_possible) && (err != 0x81)) |
3182 | ap->device[1].class = ata_dev_try_classify(ap, 1, &err); | 3185 | device[1].class = ata_dev_try_classify(ap, 1, &err); |
3183 | 3186 | ||
3184 | /* is double-select really necessary? */ | 3187 | /* is double-select really necessary? */ |
3185 | if (ap->device[1].class != ATA_DEV_NONE) | 3188 | if (device[1].class != ATA_DEV_NONE) |
3186 | ap->ops->dev_select(ap, 1); | 3189 | ap->ops->dev_select(ap, 1); |
3187 | if (ap->device[0].class != ATA_DEV_NONE) | 3190 | if (device[0].class != ATA_DEV_NONE) |
3188 | ap->ops->dev_select(ap, 0); | 3191 | ap->ops->dev_select(ap, 0); |
3189 | 3192 | ||
3190 | /* if no devices were detected, disable this port */ | 3193 | /* if no devices were detected, disable this port */ |
3191 | if ((ap->device[0].class == ATA_DEV_NONE) && | 3194 | if ((device[0].class == ATA_DEV_NONE) && |
3192 | (ap->device[1].class == ATA_DEV_NONE)) | 3195 | (device[1].class == ATA_DEV_NONE)) |
3193 | goto err_out; | 3196 | goto err_out; |
3194 | 3197 | ||
3195 | if (ap->flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST)) { | 3198 | if (ap->flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST)) { |
@@ -3331,7 +3334,7 @@ int sata_phy_resume(struct ata_port *ap, const unsigned long *params, | |||
3331 | */ | 3334 | */ |
3332 | int ata_std_prereset(struct ata_port *ap, unsigned long deadline) | 3335 | int ata_std_prereset(struct ata_port *ap, unsigned long deadline) |
3333 | { | 3336 | { |
3334 | struct ata_eh_context *ehc = &ap->eh_context; | 3337 | struct ata_eh_context *ehc = &ap->link.eh_context; |
3335 | const unsigned long *timing = sata_ehc_deb_timing(ehc); | 3338 | const unsigned long *timing = sata_ehc_deb_timing(ehc); |
3336 | int rc; | 3339 | int rc; |
3337 | 3340 | ||
@@ -3503,7 +3506,7 @@ int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing, | |||
3503 | int sata_std_hardreset(struct ata_port *ap, unsigned int *class, | 3506 | int sata_std_hardreset(struct ata_port *ap, unsigned int *class, |
3504 | unsigned long deadline) | 3507 | unsigned long deadline) |
3505 | { | 3508 | { |
3506 | const unsigned long *timing = sata_ehc_deb_timing(&ap->eh_context); | 3509 | const unsigned long *timing = sata_ehc_deb_timing(&ap->link.eh_context); |
3507 | int rc; | 3510 | int rc; |
3508 | 3511 | ||
3509 | DPRINTK("ENTER\n"); | 3512 | DPRINTK("ENTER\n"); |
@@ -3652,7 +3655,7 @@ static int ata_dev_same_device(struct ata_device *dev, unsigned int new_class, | |||
3652 | int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags) | 3655 | int ata_dev_reread_id(struct ata_device *dev, unsigned int readid_flags) |
3653 | { | 3656 | { |
3654 | unsigned int class = dev->class; | 3657 | unsigned int class = dev->class; |
3655 | u16 *id = (void *)dev->ap->sector_buf; | 3658 | u16 *id = (void *)dev->link->ap->sector_buf; |
3656 | int rc; | 3659 | int rc; |
3657 | 3660 | ||
3658 | /* read ID data */ | 3661 | /* read ID data */ |
@@ -3837,7 +3840,7 @@ static int ata_dma_blacklisted(const struct ata_device *dev) | |||
3837 | * DMA blacklist those ATAPI devices with CDB-intr (and use PIO) | 3840 | * DMA blacklist those ATAPI devices with CDB-intr (and use PIO) |
3838 | * if the LLDD handles only interrupts in the HSM_ST_LAST state. | 3841 | * if the LLDD handles only interrupts in the HSM_ST_LAST state. |
3839 | */ | 3842 | */ |
3840 | if ((dev->ap->flags & ATA_FLAG_PIO_POLLING) && | 3843 | if ((dev->link->ap->flags & ATA_FLAG_PIO_POLLING) && |
3841 | (dev->flags & ATA_DFLAG_CDB_INTR)) | 3844 | (dev->flags & ATA_DFLAG_CDB_INTR)) |
3842 | return 1; | 3845 | return 1; |
3843 | return (dev->horkage & ATA_HORKAGE_NODMA) ? 1 : 0; | 3846 | return (dev->horkage & ATA_HORKAGE_NODMA) ? 1 : 0; |
@@ -3857,7 +3860,8 @@ static int ata_dma_blacklisted(const struct ata_device *dev) | |||
3857 | */ | 3860 | */ |
3858 | static void ata_dev_xfermask(struct ata_device *dev) | 3861 | static void ata_dev_xfermask(struct ata_device *dev) |
3859 | { | 3862 | { |
3860 | struct ata_port *ap = dev->ap; | 3863 | struct ata_link *link = dev->link; |
3864 | struct ata_port *ap = link->ap; | ||
3861 | struct ata_host *host = ap->host; | 3865 | struct ata_host *host = ap->host; |
3862 | unsigned long xfer_mask; | 3866 | unsigned long xfer_mask; |
3863 | 3867 | ||
@@ -4482,7 +4486,7 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words) | |||
4482 | void ata_data_xfer(struct ata_device *adev, unsigned char *buf, | 4486 | void ata_data_xfer(struct ata_device *adev, unsigned char *buf, |
4483 | unsigned int buflen, int write_data) | 4487 | unsigned int buflen, int write_data) |
4484 | { | 4488 | { |
4485 | struct ata_port *ap = adev->ap; | 4489 | struct ata_port *ap = adev->link->ap; |
4486 | unsigned int words = buflen >> 1; | 4490 | unsigned int words = buflen >> 1; |
4487 | 4491 | ||
4488 | /* Transfer multiple of 2 bytes */ | 4492 | /* Transfer multiple of 2 bytes */ |
@@ -5188,7 +5192,7 @@ static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) | |||
5188 | 5192 | ||
5189 | struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev) | 5193 | struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev) |
5190 | { | 5194 | { |
5191 | struct ata_port *ap = dev->ap; | 5195 | struct ata_port *ap = dev->link->ap; |
5192 | struct ata_queued_cmd *qc; | 5196 | struct ata_queued_cmd *qc; |
5193 | 5197 | ||
5194 | qc = ata_qc_new(ap); | 5198 | qc = ata_qc_new(ap); |
@@ -5231,6 +5235,7 @@ void ata_qc_free(struct ata_queued_cmd *qc) | |||
5231 | void __ata_qc_complete(struct ata_queued_cmd *qc) | 5235 | void __ata_qc_complete(struct ata_queued_cmd *qc) |
5232 | { | 5236 | { |
5233 | struct ata_port *ap = qc->ap; | 5237 | struct ata_port *ap = qc->ap; |
5238 | struct ata_link *link = qc->dev->link; | ||
5234 | 5239 | ||
5235 | WARN_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */ | 5240 | WARN_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */ |
5236 | WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE)); | 5241 | WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE)); |
@@ -5240,9 +5245,9 @@ void __ata_qc_complete(struct ata_queued_cmd *qc) | |||
5240 | 5245 | ||
5241 | /* command should be marked inactive atomically with qc completion */ | 5246 | /* command should be marked inactive atomically with qc completion */ |
5242 | if (qc->tf.protocol == ATA_PROT_NCQ) | 5247 | if (qc->tf.protocol == ATA_PROT_NCQ) |
5243 | ap->sactive &= ~(1 << qc->tag); | 5248 | link->sactive &= ~(1 << qc->tag); |
5244 | else | 5249 | else |
5245 | ap->active_tag = ATA_TAG_POISON; | 5250 | link->active_tag = ATA_TAG_POISON; |
5246 | 5251 | ||
5247 | /* atapi: mark qc as inactive to prevent the interrupt handler | 5252 | /* atapi: mark qc as inactive to prevent the interrupt handler |
5248 | * from completing the command twice later, before the error handler | 5253 | * from completing the command twice later, before the error handler |
@@ -5411,19 +5416,20 @@ static inline int ata_should_dma_map(struct ata_queued_cmd *qc) | |||
5411 | void ata_qc_issue(struct ata_queued_cmd *qc) | 5416 | void ata_qc_issue(struct ata_queued_cmd *qc) |
5412 | { | 5417 | { |
5413 | struct ata_port *ap = qc->ap; | 5418 | struct ata_port *ap = qc->ap; |
5419 | struct ata_link *link = qc->dev->link; | ||
5414 | 5420 | ||
5415 | /* Make sure only one non-NCQ command is outstanding. The | 5421 | /* Make sure only one non-NCQ command is outstanding. The |
5416 | * check is skipped for old EH because it reuses active qc to | 5422 | * check is skipped for old EH because it reuses active qc to |
5417 | * request ATAPI sense. | 5423 | * request ATAPI sense. |
5418 | */ | 5424 | */ |
5419 | WARN_ON(ap->ops->error_handler && ata_tag_valid(ap->active_tag)); | 5425 | WARN_ON(ap->ops->error_handler && ata_tag_valid(link->active_tag)); |
5420 | 5426 | ||
5421 | if (qc->tf.protocol == ATA_PROT_NCQ) { | 5427 | if (qc->tf.protocol == ATA_PROT_NCQ) { |
5422 | WARN_ON(ap->sactive & (1 << qc->tag)); | 5428 | WARN_ON(link->sactive & (1 << qc->tag)); |
5423 | ap->sactive |= 1 << qc->tag; | 5429 | link->sactive |= 1 << qc->tag; |
5424 | } else { | 5430 | } else { |
5425 | WARN_ON(ap->sactive); | 5431 | WARN_ON(link->sactive); |
5426 | ap->active_tag = qc->tag; | 5432 | link->active_tag = qc->tag; |
5427 | } | 5433 | } |
5428 | 5434 | ||
5429 | qc->flags |= ATA_QCFLAG_ACTIVE; | 5435 | qc->flags |= ATA_QCFLAG_ACTIVE; |
@@ -5606,7 +5612,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
5606 | inline unsigned int ata_host_intr (struct ata_port *ap, | 5612 | inline unsigned int ata_host_intr (struct ata_port *ap, |
5607 | struct ata_queued_cmd *qc) | 5613 | struct ata_queued_cmd *qc) |
5608 | { | 5614 | { |
5609 | struct ata_eh_info *ehi = &ap->eh_info; | 5615 | struct ata_eh_info *ehi = &ap->link.eh_info; |
5610 | u8 status, host_stat = 0; | 5616 | u8 status, host_stat = 0; |
5611 | 5617 | ||
5612 | VPRINTK("ata%u: protocol %d task_state %d\n", | 5618 | VPRINTK("ata%u: protocol %d task_state %d\n", |
@@ -5721,7 +5727,7 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance) | |||
5721 | !(ap->flags & ATA_FLAG_DISABLED)) { | 5727 | !(ap->flags & ATA_FLAG_DISABLED)) { |
5722 | struct ata_queued_cmd *qc; | 5728 | struct ata_queued_cmd *qc; |
5723 | 5729 | ||
5724 | qc = ata_qc_from_tag(ap, ap->active_tag); | 5730 | qc = ata_qc_from_tag(ap, ap->link.active_tag); |
5725 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) && | 5731 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) && |
5726 | (qc->flags & ATA_QCFLAG_ACTIVE)) | 5732 | (qc->flags & ATA_QCFLAG_ACTIVE)) |
5727 | handled |= ata_host_intr(ap, qc); | 5733 | handled |= ata_host_intr(ap, qc); |
@@ -5921,8 +5927,8 @@ static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg, | |||
5921 | } | 5927 | } |
5922 | 5928 | ||
5923 | ap->pflags |= ATA_PFLAG_PM_PENDING; | 5929 | ap->pflags |= ATA_PFLAG_PM_PENDING; |
5924 | ap->eh_info.action |= action; | 5930 | ap->link.eh_info.action |= action; |
5925 | ap->eh_info.flags |= ehi_flags; | 5931 | ap->link.eh_info.flags |= ehi_flags; |
5926 | 5932 | ||
5927 | ata_port_schedule_eh(ap); | 5933 | ata_port_schedule_eh(ap); |
5928 | 5934 | ||
@@ -6026,12 +6032,13 @@ int ata_port_start(struct ata_port *ap) | |||
6026 | */ | 6032 | */ |
6027 | void ata_dev_init(struct ata_device *dev) | 6033 | void ata_dev_init(struct ata_device *dev) |
6028 | { | 6034 | { |
6029 | struct ata_port *ap = dev->ap; | 6035 | struct ata_link *link = dev->link; |
6036 | struct ata_port *ap = link->ap; | ||
6030 | unsigned long flags; | 6037 | unsigned long flags; |
6031 | 6038 | ||
6032 | /* SATA spd limit is bound to the first device */ | 6039 | /* SATA spd limit is bound to the first device */ |
6033 | ap->sata_spd_limit = ap->hw_sata_spd_limit; | 6040 | link->sata_spd_limit = link->hw_sata_spd_limit; |
6034 | ap->sata_spd = 0; | 6041 | link->sata_spd = 0; |
6035 | 6042 | ||
6036 | /* High bits of dev->flags are used to record warm plug | 6043 | /* High bits of dev->flags are used to record warm plug |
6037 | * requests which occur asynchronously. Synchronize using | 6044 | * requests which occur asynchronously. Synchronize using |
@@ -6080,8 +6087,8 @@ struct ata_port *ata_port_alloc(struct ata_host *host) | |||
6080 | ap->host = host; | 6087 | ap->host = host; |
6081 | ap->dev = host->dev; | 6088 | ap->dev = host->dev; |
6082 | 6089 | ||
6083 | ap->hw_sata_spd_limit = UINT_MAX; | 6090 | ap->link.hw_sata_spd_limit = UINT_MAX; |
6084 | ap->active_tag = ATA_TAG_POISON; | 6091 | ap->link.active_tag = ATA_TAG_POISON; |
6085 | ap->last_ctl = 0xFF; | 6092 | ap->last_ctl = 0xFF; |
6086 | 6093 | ||
6087 | #if defined(ATA_VERBOSE_DEBUG) | 6094 | #if defined(ATA_VERBOSE_DEBUG) |
@@ -6104,9 +6111,11 @@ struct ata_port *ata_port_alloc(struct ata_host *host) | |||
6104 | 6111 | ||
6105 | ap->cbl = ATA_CBL_NONE; | 6112 | ap->cbl = ATA_CBL_NONE; |
6106 | 6113 | ||
6114 | ap->link.ap = ap; | ||
6115 | |||
6107 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 6116 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
6108 | struct ata_device *dev = &ap->device[i]; | 6117 | struct ata_device *dev = &ap->link.device[i]; |
6109 | dev->ap = ap; | 6118 | dev->link = &ap->link; |
6110 | dev->devno = i; | 6119 | dev->devno = i; |
6111 | ata_dev_init(dev); | 6120 | ata_dev_init(dev); |
6112 | } | 6121 | } |
@@ -6402,9 +6411,9 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
6402 | if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) { | 6411 | if (sata_scr_read(ap, SCR_CONTROL, &scontrol) == 0) { |
6403 | int spd = (scontrol >> 4) & 0xf; | 6412 | int spd = (scontrol >> 4) & 0xf; |
6404 | if (spd) | 6413 | if (spd) |
6405 | ap->hw_sata_spd_limit &= (1 << spd) - 1; | 6414 | ap->link.hw_sata_spd_limit &= (1 << spd) - 1; |
6406 | } | 6415 | } |
6407 | ap->sata_spd_limit = ap->hw_sata_spd_limit; | 6416 | ap->link.sata_spd_limit = ap->link.hw_sata_spd_limit; |
6408 | 6417 | ||
6409 | /* report the secondary IRQ for second channel legacy */ | 6418 | /* report the secondary IRQ for second channel legacy */ |
6410 | irq_line = host->irq; | 6419 | irq_line = host->irq; |
@@ -6436,7 +6445,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
6436 | 6445 | ||
6437 | /* probe */ | 6446 | /* probe */ |
6438 | if (ap->ops->error_handler) { | 6447 | if (ap->ops->error_handler) { |
6439 | struct ata_eh_info *ehi = &ap->eh_info; | 6448 | struct ata_eh_info *ehi = &ap->link.eh_info; |
6440 | unsigned long flags; | 6449 | unsigned long flags; |
6441 | 6450 | ||
6442 | ata_port_probe(ap); | 6451 | ata_port_probe(ap); |
@@ -6560,7 +6569,7 @@ void ata_port_detach(struct ata_port *ap) | |||
6560 | spin_lock_irqsave(ap->lock, flags); | 6569 | spin_lock_irqsave(ap->lock, flags); |
6561 | 6570 | ||
6562 | for (i = 0; i < ATA_MAX_DEVICES; i++) | 6571 | for (i = 0; i < ATA_MAX_DEVICES; i++) |
6563 | ata_dev_disable(&ap->device[i]); | 6572 | ata_dev_disable(&ap->link.device[i]); |
6564 | 6573 | ||
6565 | spin_unlock_irqrestore(ap->lock, flags); | 6574 | spin_unlock_irqrestore(ap->lock, flags); |
6566 | 6575 | ||