diff options
Diffstat (limited to 'drivers/ata/libata-core.c')
| -rw-r--r-- | drivers/ata/libata-core.c | 252 |
1 files changed, 217 insertions, 35 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 79e3a8e7a84a..1ee9499bd343 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
| @@ -163,6 +163,67 @@ MODULE_LICENSE("GPL"); | |||
| 163 | MODULE_VERSION(DRV_VERSION); | 163 | MODULE_VERSION(DRV_VERSION); |
| 164 | 164 | ||
| 165 | 165 | ||
| 166 | /* | ||
| 167 | * Iterator helpers. Don't use directly. | ||
| 168 | * | ||
| 169 | * LOCKING: | ||
| 170 | * Host lock or EH context. | ||
| 171 | */ | ||
| 172 | struct ata_link *__ata_port_next_link(struct ata_port *ap, | ||
| 173 | struct ata_link *link, bool dev_only) | ||
| 174 | { | ||
| 175 | /* NULL link indicates start of iteration */ | ||
| 176 | if (!link) { | ||
| 177 | if (dev_only && sata_pmp_attached(ap)) | ||
| 178 | return ap->pmp_link; | ||
| 179 | return &ap->link; | ||
| 180 | } | ||
| 181 | |||
| 182 | /* we just iterated over the host master link, what's next? */ | ||
| 183 | if (link == &ap->link) { | ||
| 184 | if (!sata_pmp_attached(ap)) { | ||
| 185 | if (unlikely(ap->slave_link) && !dev_only) | ||
| 186 | return ap->slave_link; | ||
| 187 | return NULL; | ||
| 188 | } | ||
| 189 | return ap->pmp_link; | ||
| 190 | } | ||
| 191 | |||
| 192 | /* slave_link excludes PMP */ | ||
| 193 | if (unlikely(link == ap->slave_link)) | ||
| 194 | return NULL; | ||
| 195 | |||
| 196 | /* iterate to the next PMP link */ | ||
| 197 | if (++link < ap->pmp_link + ap->nr_pmp_links) | ||
| 198 | return link; | ||
| 199 | return NULL; | ||
| 200 | } | ||
| 201 | |||
| 202 | /** | ||
| 203 | * ata_dev_phys_link - find physical link for a device | ||
| 204 | * @dev: ATA device to look up physical link for | ||
| 205 | * | ||
| 206 | * Look up physical link which @dev is attached to. Note that | ||
| 207 | * this is different from @dev->link only when @dev is on slave | ||
| 208 | * link. For all other cases, it's the same as @dev->link. | ||
| 209 | * | ||
| 210 | * LOCKING: | ||
| 211 | * Don't care. | ||
| 212 | * | ||
| 213 | * RETURNS: | ||
| 214 | * Pointer to the found physical link. | ||
| 215 | */ | ||
| 216 | struct ata_link *ata_dev_phys_link(struct ata_device *dev) | ||
| 217 | { | ||
| 218 | struct ata_port *ap = dev->link->ap; | ||
| 219 | |||
| 220 | if (!ap->slave_link) | ||
| 221 | return dev->link; | ||
| 222 | if (!dev->devno) | ||
| 223 | return &ap->link; | ||
| 224 | return ap->slave_link; | ||
| 225 | } | ||
| 226 | |||
| 166 | /** | 227 | /** |
| 167 | * ata_force_cbl - force cable type according to libata.force | 228 | * ata_force_cbl - force cable type according to libata.force |
| 168 | * @ap: ATA port of interest | 229 | * @ap: ATA port of interest |
| @@ -206,7 +267,8 @@ void ata_force_cbl(struct ata_port *ap) | |||
| 206 | * the host link and all fan-out ports connected via PMP. If the | 267 | * the host link and all fan-out ports connected via PMP. If the |
| 207 | * device part is specified as 0 (e.g. 1.00:), it specifies the | 268 | * device part is specified as 0 (e.g. 1.00:), it specifies the |
| 208 | * first fan-out link not the host link. Device number 15 always | 269 | * first fan-out link not the host link. Device number 15 always |
| 209 | * points to the host link whether PMP is attached or not. | 270 | * points to the host link whether PMP is attached or not. If the |
| 271 | * controller has slave link, device number 16 points to it. | ||
| 210 | * | 272 | * |
| 211 | * LOCKING: | 273 | * LOCKING: |
| 212 | * EH context. | 274 | * EH context. |
| @@ -214,12 +276,11 @@ void ata_force_cbl(struct ata_port *ap) | |||
| 214 | static void ata_force_link_limits(struct ata_link *link) | 276 | static void ata_force_link_limits(struct ata_link *link) |
| 215 | { | 277 | { |
| 216 | bool did_spd = false; | 278 | bool did_spd = false; |
| 217 | int linkno, i; | 279 | int linkno = link->pmp; |
| 280 | int i; | ||
| 218 | 281 | ||
| 219 | if (ata_is_host_link(link)) | 282 | if (ata_is_host_link(link)) |
| 220 | linkno = 15; | 283 | linkno += 15; |
| 221 | else | ||
| 222 | linkno = link->pmp; | ||
| 223 | 284 | ||
| 224 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { | 285 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { |
| 225 | const struct ata_force_ent *fe = &ata_force_tbl[i]; | 286 | const struct ata_force_ent *fe = &ata_force_tbl[i]; |
| @@ -266,9 +327,9 @@ static void ata_force_xfermask(struct ata_device *dev) | |||
| 266 | int alt_devno = devno; | 327 | int alt_devno = devno; |
| 267 | int i; | 328 | int i; |
| 268 | 329 | ||
| 269 | /* allow n.15 for the first device attached to host port */ | 330 | /* allow n.15/16 for devices attached to host port */ |
| 270 | if (ata_is_host_link(dev->link) && devno == 0) | 331 | if (ata_is_host_link(dev->link)) |
| 271 | alt_devno = 15; | 332 | alt_devno += 15; |
| 272 | 333 | ||
| 273 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { | 334 | for (i = ata_force_tbl_size - 1; i >= 0; i--) { |
| 274 | const struct ata_force_ent *fe = &ata_force_tbl[i]; | 335 | const struct ata_force_ent *fe = &ata_force_tbl[i]; |
| @@ -320,9 +381,9 @@ static void ata_force_horkage(struct ata_device *dev) | |||
| 320 | int alt_devno = devno; | 381 | int alt_devno = devno; |
| 321 | int i; | 382 | int i; |
| 322 | 383 | ||
| 323 | /* allow n.15 for the first device attached to host port */ | 384 | /* allow n.15/16 for devices attached to host port */ |
| 324 | if (ata_is_host_link(dev->link) && devno == 0) | 385 | if (ata_is_host_link(dev->link)) |
| 325 | alt_devno = 15; | 386 | alt_devno += 15; |
| 326 | 387 | ||
| 327 | for (i = 0; i < ata_force_tbl_size; i++) { | 388 | for (i = 0; i < ata_force_tbl_size; i++) { |
| 328 | const struct ata_force_ent *fe = &ata_force_tbl[i]; | 389 | const struct ata_force_ent *fe = &ata_force_tbl[i]; |
| @@ -2681,7 +2742,7 @@ static void sata_print_link_status(struct ata_link *link) | |||
| 2681 | return; | 2742 | return; |
| 2682 | sata_scr_read(link, SCR_CONTROL, &scontrol); | 2743 | sata_scr_read(link, SCR_CONTROL, &scontrol); |
| 2683 | 2744 | ||
| 2684 | if (ata_link_online(link)) { | 2745 | if (ata_phys_link_online(link)) { |
| 2685 | tmp = (sstatus >> 4) & 0xf; | 2746 | tmp = (sstatus >> 4) & 0xf; |
| 2686 | ata_link_printk(link, KERN_INFO, | 2747 | ata_link_printk(link, KERN_INFO, |
| 2687 | "SATA link up %s (SStatus %X SControl %X)\n", | 2748 | "SATA link up %s (SStatus %X SControl %X)\n", |
| @@ -3372,6 +3433,12 @@ int ata_wait_ready(struct ata_link *link, unsigned long deadline, | |||
| 3372 | unsigned long nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT); | 3433 | unsigned long nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT); |
| 3373 | int warned = 0; | 3434 | int warned = 0; |
| 3374 | 3435 | ||
| 3436 | /* Slave readiness can't be tested separately from master. On | ||
| 3437 | * M/S emulation configuration, this function should be called | ||
| 3438 | * only on the master and it will handle both master and slave. | ||
| 3439 | */ | ||
| 3440 | WARN_ON(link == link->ap->slave_link); | ||
| 3441 | |||
| 3375 | if (time_after(nodev_deadline, deadline)) | 3442 | if (time_after(nodev_deadline, deadline)) |
| 3376 | nodev_deadline = deadline; | 3443 | nodev_deadline = deadline; |
| 3377 | 3444 | ||
| @@ -3593,7 +3660,7 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline) | |||
| 3593 | } | 3660 | } |
| 3594 | 3661 | ||
| 3595 | /* no point in trying softreset on offline link */ | 3662 | /* no point in trying softreset on offline link */ |
| 3596 | if (ata_link_offline(link)) | 3663 | if (ata_phys_link_offline(link)) |
| 3597 | ehc->i.action &= ~ATA_EH_SOFTRESET; | 3664 | ehc->i.action &= ~ATA_EH_SOFTRESET; |
| 3598 | 3665 | ||
| 3599 | return 0; | 3666 | return 0; |
| @@ -3671,7 +3738,7 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing, | |||
| 3671 | if (rc) | 3738 | if (rc) |
| 3672 | goto out; | 3739 | goto out; |
| 3673 | /* if link is offline nothing more to do */ | 3740 | /* if link is offline nothing more to do */ |
| 3674 | if (ata_link_offline(link)) | 3741 | if (ata_phys_link_offline(link)) |
| 3675 | goto out; | 3742 | goto out; |
| 3676 | 3743 | ||
| 3677 | /* Link is online. From this point, -ENODEV too is an error. */ | 3744 | /* Link is online. From this point, -ENODEV too is an error. */ |
| @@ -4868,10 +4935,8 @@ int sata_scr_valid(struct ata_link *link) | |||
| 4868 | int sata_scr_read(struct ata_link *link, int reg, u32 *val) | 4935 | int sata_scr_read(struct ata_link *link, int reg, u32 *val) |
| 4869 | { | 4936 | { |
| 4870 | if (ata_is_host_link(link)) { | 4937 | if (ata_is_host_link(link)) { |
| 4871 | struct ata_port *ap = link->ap; | ||
| 4872 | |||
| 4873 | if (sata_scr_valid(link)) | 4938 | if (sata_scr_valid(link)) |
| 4874 | return ap->ops->scr_read(ap, reg, val); | 4939 | return link->ap->ops->scr_read(link, reg, val); |
| 4875 | return -EOPNOTSUPP; | 4940 | return -EOPNOTSUPP; |
| 4876 | } | 4941 | } |
| 4877 | 4942 | ||
| @@ -4897,10 +4962,8 @@ int sata_scr_read(struct ata_link *link, int reg, u32 *val) | |||
| 4897 | int sata_scr_write(struct ata_link *link, int reg, u32 val) | 4962 | int sata_scr_write(struct ata_link *link, int reg, u32 val) |
| 4898 | { | 4963 | { |
| 4899 | if (ata_is_host_link(link)) { | 4964 | if (ata_is_host_link(link)) { |
| 4900 | struct ata_port *ap = link->ap; | ||
| 4901 | |||
| 4902 | if (sata_scr_valid(link)) | 4965 | if (sata_scr_valid(link)) |
| 4903 | return ap->ops->scr_write(ap, reg, val); | 4966 | return link->ap->ops->scr_write(link, reg, val); |
| 4904 | return -EOPNOTSUPP; | 4967 | return -EOPNOTSUPP; |
| 4905 | } | 4968 | } |
| 4906 | 4969 | ||
| @@ -4925,13 +4988,12 @@ int sata_scr_write(struct ata_link *link, int reg, u32 val) | |||
| 4925 | int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) | 4988 | int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) |
| 4926 | { | 4989 | { |
| 4927 | if (ata_is_host_link(link)) { | 4990 | if (ata_is_host_link(link)) { |
| 4928 | struct ata_port *ap = link->ap; | ||
| 4929 | int rc; | 4991 | int rc; |
| 4930 | 4992 | ||
| 4931 | if (sata_scr_valid(link)) { | 4993 | if (sata_scr_valid(link)) { |
| 4932 | rc = ap->ops->scr_write(ap, reg, val); | 4994 | rc = link->ap->ops->scr_write(link, reg, val); |
| 4933 | if (rc == 0) | 4995 | if (rc == 0) |
| 4934 | rc = ap->ops->scr_read(ap, reg, &val); | 4996 | rc = link->ap->ops->scr_read(link, reg, &val); |
| 4935 | return rc; | 4997 | return rc; |
| 4936 | } | 4998 | } |
| 4937 | return -EOPNOTSUPP; | 4999 | return -EOPNOTSUPP; |
| @@ -4941,7 +5003,7 @@ int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) | |||
| 4941 | } | 5003 | } |
| 4942 | 5004 | ||
| 4943 | /** | 5005 | /** |
| 4944 | * ata_link_online - test whether the given link is online | 5006 | * ata_phys_link_online - test whether the given link is online |
| 4945 | * @link: ATA link to test | 5007 | * @link: ATA link to test |
| 4946 | * | 5008 | * |
| 4947 | * Test whether @link is online. Note that this function returns | 5009 | * Test whether @link is online. Note that this function returns |
| @@ -4952,20 +5014,20 @@ int sata_scr_write_flush(struct ata_link *link, int reg, u32 val) | |||
| 4952 | * None. | 5014 | * None. |
| 4953 | * | 5015 | * |
| 4954 | * RETURNS: | 5016 | * RETURNS: |
| 4955 | * 1 if the port online status is available and online. | 5017 | * True if the port online status is available and online. |
| 4956 | */ | 5018 | */ |
| 4957 | int ata_link_online(struct ata_link *link) | 5019 | bool ata_phys_link_online(struct ata_link *link) |
| 4958 | { | 5020 | { |
| 4959 | u32 sstatus; | 5021 | u32 sstatus; |
| 4960 | 5022 | ||
| 4961 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && | 5023 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && |
| 4962 | (sstatus & 0xf) == 0x3) | 5024 | (sstatus & 0xf) == 0x3) |
| 4963 | return 1; | 5025 | return true; |
| 4964 | return 0; | 5026 | return false; |
| 4965 | } | 5027 | } |
| 4966 | 5028 | ||
| 4967 | /** | 5029 | /** |
| 4968 | * ata_link_offline - test whether the given link is offline | 5030 | * ata_phys_link_offline - test whether the given link is offline |
| 4969 | * @link: ATA link to test | 5031 | * @link: ATA link to test |
| 4970 | * | 5032 | * |
| 4971 | * Test whether @link is offline. Note that this function | 5033 | * Test whether @link is offline. Note that this function |
| @@ -4976,16 +5038,68 @@ int ata_link_online(struct ata_link *link) | |||
| 4976 | * None. | 5038 | * None. |
| 4977 | * | 5039 | * |
| 4978 | * RETURNS: | 5040 | * RETURNS: |
| 4979 | * 1 if the port offline status is available and offline. | 5041 | * True if the port offline status is available and offline. |
| 4980 | */ | 5042 | */ |
| 4981 | int ata_link_offline(struct ata_link *link) | 5043 | bool ata_phys_link_offline(struct ata_link *link) |
| 4982 | { | 5044 | { |
| 4983 | u32 sstatus; | 5045 | u32 sstatus; |
| 4984 | 5046 | ||
| 4985 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && | 5047 | if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0 && |
| 4986 | (sstatus & 0xf) != 0x3) | 5048 | (sstatus & 0xf) != 0x3) |
| 4987 | return 1; | 5049 | return true; |
| 4988 | return 0; | 5050 | return false; |
| 5051 | } | ||
| 5052 | |||
| 5053 | /** | ||
| 5054 | * ata_link_online - test whether the given link is online | ||
| 5055 | * @link: ATA link to test | ||
| 5056 | * | ||
| 5057 | * Test whether @link is online. This is identical to | ||
| 5058 | * ata_phys_link_online() when there's no slave link. When | ||
| 5059 | * there's a slave link, this function should only be called on | ||
| 5060 | * the master link and will return true if any of M/S links is | ||
| 5061 | * online. | ||
| 5062 | * | ||
| 5063 | * LOCKING: | ||
| 5064 | * None. | ||
| 5065 | * | ||
| 5066 | * RETURNS: | ||
| 5067 | * True if the port online status is available and online. | ||
| 5068 | */ | ||
| 5069 | bool ata_link_online(struct ata_link *link) | ||
| 5070 | { | ||
| 5071 | struct ata_link *slave = link->ap->slave_link; | ||
| 5072 | |||
| 5073 | WARN_ON(link == slave); /* shouldn't be called on slave link */ | ||
| 5074 | |||
| 5075 | return ata_phys_link_online(link) || | ||
| 5076 | (slave && ata_phys_link_online(slave)); | ||
| 5077 | } | ||
| 5078 | |||
| 5079 | /** | ||
| 5080 | * ata_link_offline - test whether the given link is offline | ||
| 5081 | * @link: ATA link to test | ||
| 5082 | * | ||
| 5083 | * Test whether @link is offline. This is identical to | ||
| 5084 | * ata_phys_link_offline() when there's no slave link. When | ||
| 5085 | * there's a slave link, this function should only be called on | ||
| 5086 | * the master link and will return true if both M/S links are | ||
| 5087 | * offline. | ||
| 5088 | * | ||
| 5089 | * LOCKING: | ||
| 5090 | * None. | ||
| 5091 | * | ||
| 5092 | * RETURNS: | ||
| 5093 | * True if the port offline status is available and offline. | ||
| 5094 | */ | ||
| 5095 | bool ata_link_offline(struct ata_link *link) | ||
| 5096 | { | ||
| 5097 | struct ata_link *slave = link->ap->slave_link; | ||
| 5098 | |||
| 5099 | WARN_ON(link == slave); /* shouldn't be called on slave link */ | ||
| 5100 | |||
| 5101 | return ata_phys_link_offline(link) && | ||
| 5102 | (!slave || ata_phys_link_offline(slave)); | ||
| 4989 | } | 5103 | } |
| 4990 | 5104 | ||
| 4991 | #ifdef CONFIG_PM | 5105 | #ifdef CONFIG_PM |
| @@ -5127,11 +5241,11 @@ int ata_port_start(struct ata_port *ap) | |||
| 5127 | */ | 5241 | */ |
| 5128 | void ata_dev_init(struct ata_device *dev) | 5242 | void ata_dev_init(struct ata_device *dev) |
| 5129 | { | 5243 | { |
| 5130 | struct ata_link *link = dev->link; | 5244 | struct ata_link *link = ata_dev_phys_link(dev); |
| 5131 | struct ata_port *ap = link->ap; | 5245 | struct ata_port *ap = link->ap; |
| 5132 | unsigned long flags; | 5246 | unsigned long flags; |
| 5133 | 5247 | ||
| 5134 | /* SATA spd limit is bound to the first device */ | 5248 | /* SATA spd limit is bound to the attached device, reset together */ |
| 5135 | link->sata_spd_limit = link->hw_sata_spd_limit; | 5249 | link->sata_spd_limit = link->hw_sata_spd_limit; |
| 5136 | link->sata_spd = 0; | 5250 | link->sata_spd = 0; |
| 5137 | 5251 | ||
| @@ -5264,6 +5378,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host) | |||
| 5264 | INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan); | 5378 | INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan); |
| 5265 | INIT_LIST_HEAD(&ap->eh_done_q); | 5379 | INIT_LIST_HEAD(&ap->eh_done_q); |
| 5266 | init_waitqueue_head(&ap->eh_wait_q); | 5380 | init_waitqueue_head(&ap->eh_wait_q); |
| 5381 | init_completion(&ap->park_req_pending); | ||
| 5267 | init_timer_deferrable(&ap->fastdrain_timer); | 5382 | init_timer_deferrable(&ap->fastdrain_timer); |
| 5268 | ap->fastdrain_timer.function = ata_eh_fastdrain_timerfn; | 5383 | ap->fastdrain_timer.function = ata_eh_fastdrain_timerfn; |
| 5269 | ap->fastdrain_timer.data = (unsigned long)ap; | 5384 | ap->fastdrain_timer.data = (unsigned long)ap; |
| @@ -5294,6 +5409,7 @@ static void ata_host_release(struct device *gendev, void *res) | |||
| 5294 | scsi_host_put(ap->scsi_host); | 5409 | scsi_host_put(ap->scsi_host); |
| 5295 | 5410 | ||
| 5296 | kfree(ap->pmp_link); | 5411 | kfree(ap->pmp_link); |
| 5412 | kfree(ap->slave_link); | ||
| 5297 | kfree(ap); | 5413 | kfree(ap); |
| 5298 | host->ports[i] = NULL; | 5414 | host->ports[i] = NULL; |
| 5299 | } | 5415 | } |
| @@ -5414,6 +5530,68 @@ struct ata_host *ata_host_alloc_pinfo(struct device *dev, | |||
| 5414 | return host; | 5530 | return host; |
| 5415 | } | 5531 | } |
| 5416 | 5532 | ||
| 5533 | /** | ||
| 5534 | * ata_slave_link_init - initialize slave link | ||
| 5535 | * @ap: port to initialize slave link for | ||
| 5536 | * | ||
| 5537 | * Create and initialize slave link for @ap. This enables slave | ||
| 5538 | * link handling on the port. | ||
| 5539 | * | ||
| 5540 | * In libata, a port contains links and a link contains devices. | ||
| 5541 | * There is single host link but if a PMP is attached to it, | ||
| 5542 | * there can be multiple fan-out links. On SATA, there's usually | ||
| 5543 | * a single device connected to a link but PATA and SATA | ||
| 5544 | * controllers emulating TF based interface can have two - master | ||
| 5545 | * and slave. | ||
| 5546 | * | ||
| 5547 | * However, there are a few controllers which don't fit into this | ||
| 5548 | * abstraction too well - SATA controllers which emulate TF | ||
| 5549 | * interface with both master and slave devices but also have | ||
| 5550 | * separate SCR register sets for each device. These controllers | ||
| 5551 | * need separate links for physical link handling | ||
| 5552 | * (e.g. onlineness, link speed) but should be treated like a | ||
| 5553 | * traditional M/S controller for everything else (e.g. command | ||
| 5554 | * issue, softreset). | ||
| 5555 | * | ||
| 5556 | * slave_link is libata's way of handling this class of | ||
| 5557 | * controllers without impacting core layer too much. For | ||
| 5558 | * anything other than physical link handling, the default host | ||
| 5559 | * link is used for both master and slave. For physical link | ||
| 5560 | * handling, separate @ap->slave_link is used. All dirty details | ||
| 5561 | * are implemented inside libata core layer. From LLD's POV, the | ||
| 5562 | * only difference is that prereset, hardreset and postreset are | ||
| 5563 | * called once more for the slave link, so the reset sequence | ||
| 5564 | * looks like the following. | ||
| 5565 | * | ||
| 5566 | * prereset(M) -> prereset(S) -> hardreset(M) -> hardreset(S) -> | ||
| 5567 | * softreset(M) -> postreset(M) -> postreset(S) | ||
| 5568 | * | ||
| 5569 | * Note that softreset is called only for the master. Softreset | ||
| 5570 | * resets both M/S by definition, so SRST on master should handle | ||
| 5571 | * both (the standard method will work just fine). | ||
| 5572 | * | ||
| 5573 | * LOCKING: | ||
| 5574 | * Should be called before host is registered. | ||
| 5575 | * | ||
| 5576 | * RETURNS: | ||
| 5577 | * 0 on success, -errno on failure. | ||
| 5578 | */ | ||
| 5579 | int ata_slave_link_init(struct ata_port *ap) | ||
| 5580 | { | ||
| 5581 | struct ata_link *link; | ||
| 5582 | |||
| 5583 | WARN_ON(ap->slave_link); | ||
| 5584 | WARN_ON(ap->flags & ATA_FLAG_PMP); | ||
| 5585 | |||
| 5586 | link = kzalloc(sizeof(*link), GFP_KERNEL); | ||
| 5587 | if (!link) | ||
| 5588 | return -ENOMEM; | ||
| 5589 | |||
| 5590 | ata_link_init(ap, link, 1); | ||
| 5591 | ap->slave_link = link; | ||
| 5592 | return 0; | ||
| 5593 | } | ||
| 5594 | |||
| 5417 | static void ata_host_stop(struct device *gendev, void *res) | 5595 | static void ata_host_stop(struct device *gendev, void *res) |
| 5418 | { | 5596 | { |
| 5419 | struct ata_host *host = dev_get_drvdata(gendev); | 5597 | struct ata_host *host = dev_get_drvdata(gendev); |
| @@ -5640,6 +5818,8 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
| 5640 | 5818 | ||
| 5641 | /* init sata_spd_limit to the current value */ | 5819 | /* init sata_spd_limit to the current value */ |
| 5642 | sata_link_init_spd(&ap->link); | 5820 | sata_link_init_spd(&ap->link); |
| 5821 | if (ap->slave_link) | ||
| 5822 | sata_link_init_spd(ap->slave_link); | ||
| 5643 | 5823 | ||
| 5644 | /* print per-port info to dmesg */ | 5824 | /* print per-port info to dmesg */ |
| 5645 | xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask, | 5825 | xfer_mask = ata_pack_xfermask(ap->pio_mask, ap->mwdma_mask, |
| @@ -6260,10 +6440,12 @@ EXPORT_SYMBOL_GPL(ata_base_port_ops); | |||
| 6260 | EXPORT_SYMBOL_GPL(sata_port_ops); | 6440 | EXPORT_SYMBOL_GPL(sata_port_ops); |
| 6261 | EXPORT_SYMBOL_GPL(ata_dummy_port_ops); | 6441 | EXPORT_SYMBOL_GPL(ata_dummy_port_ops); |
| 6262 | EXPORT_SYMBOL_GPL(ata_dummy_port_info); | 6442 | EXPORT_SYMBOL_GPL(ata_dummy_port_info); |
| 6443 | EXPORT_SYMBOL_GPL(__ata_port_next_link); | ||
| 6263 | EXPORT_SYMBOL_GPL(ata_std_bios_param); | 6444 | EXPORT_SYMBOL_GPL(ata_std_bios_param); |
| 6264 | EXPORT_SYMBOL_GPL(ata_host_init); | 6445 | EXPORT_SYMBOL_GPL(ata_host_init); |
| 6265 | EXPORT_SYMBOL_GPL(ata_host_alloc); | 6446 | EXPORT_SYMBOL_GPL(ata_host_alloc); |
| 6266 | EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo); | 6447 | EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo); |
| 6448 | EXPORT_SYMBOL_GPL(ata_slave_link_init); | ||
| 6267 | EXPORT_SYMBOL_GPL(ata_host_start); | 6449 | EXPORT_SYMBOL_GPL(ata_host_start); |
| 6268 | EXPORT_SYMBOL_GPL(ata_host_register); | 6450 | EXPORT_SYMBOL_GPL(ata_host_register); |
| 6269 | EXPORT_SYMBOL_GPL(ata_host_activate); | 6451 | EXPORT_SYMBOL_GPL(ata_host_activate); |
