diff options
| -rw-r--r-- | drivers/ata/libata-scsi.c | 38 | ||||
| -rw-r--r-- | drivers/scsi/ipr.c | 6 | ||||
| -rw-r--r-- | drivers/scsi/libfc/fc_lport.c | 12 | ||||
| -rw-r--r-- | drivers/scsi/libsas/sas_ata.c | 33 | ||||
| -rw-r--r-- | drivers/scsi/libsas/sas_discover.c | 61 | ||||
| -rw-r--r-- | drivers/scsi/libsas/sas_event.c | 24 | ||||
| -rw-r--r-- | drivers/scsi/libsas/sas_expander.c | 56 | ||||
| -rw-r--r-- | drivers/scsi/libsas/sas_init.c | 11 | ||||
| -rw-r--r-- | drivers/scsi/libsas/sas_internal.h | 6 | ||||
| -rw-r--r-- | drivers/scsi/libsas/sas_phy.c | 21 | ||||
| -rw-r--r-- | drivers/scsi/libsas/sas_port.c | 17 | ||||
| -rw-r--r-- | drivers/scsi/scsi_lib.c | 2 | ||||
| -rw-r--r-- | include/linux/libata.h | 3 | ||||
| -rw-r--r-- | include/scsi/libsas.h | 40 | ||||
| -rw-r--r-- | include/scsi/sas_ata.h | 4 |
15 files changed, 198 insertions, 136 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 93dabdcd2cbe..22226350cd0c 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
| @@ -3399,7 +3399,8 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht) | |||
| 3399 | */ | 3399 | */ |
| 3400 | shost->max_host_blocked = 1; | 3400 | shost->max_host_blocked = 1; |
| 3401 | 3401 | ||
| 3402 | rc = scsi_add_host(ap->scsi_host, &ap->tdev); | 3402 | rc = scsi_add_host_with_dma(ap->scsi_host, |
| 3403 | &ap->tdev, ap->host->dev); | ||
| 3403 | if (rc) | 3404 | if (rc) |
| 3404 | goto err_add; | 3405 | goto err_add; |
| 3405 | } | 3406 | } |
| @@ -3838,18 +3839,25 @@ void ata_sas_port_stop(struct ata_port *ap) | |||
| 3838 | } | 3839 | } |
| 3839 | EXPORT_SYMBOL_GPL(ata_sas_port_stop); | 3840 | EXPORT_SYMBOL_GPL(ata_sas_port_stop); |
| 3840 | 3841 | ||
| 3841 | int ata_sas_async_port_init(struct ata_port *ap) | 3842 | /** |
| 3843 | * ata_sas_async_probe - simply schedule probing and return | ||
| 3844 | * @ap: Port to probe | ||
| 3845 | * | ||
| 3846 | * For batch scheduling of probe for sas attached ata devices, assumes | ||
| 3847 | * the port has already been through ata_sas_port_init() | ||
| 3848 | */ | ||
| 3849 | void ata_sas_async_probe(struct ata_port *ap) | ||
| 3842 | { | 3850 | { |
| 3843 | int rc = ap->ops->port_start(ap); | 3851 | __ata_port_probe(ap); |
| 3844 | 3852 | } | |
| 3845 | if (!rc) { | 3853 | EXPORT_SYMBOL_GPL(ata_sas_async_probe); |
| 3846 | ap->print_id = atomic_inc_return(&ata_print_id); | ||
| 3847 | __ata_port_probe(ap); | ||
| 3848 | } | ||
| 3849 | 3854 | ||
| 3850 | return rc; | 3855 | int ata_sas_sync_probe(struct ata_port *ap) |
| 3856 | { | ||
| 3857 | return ata_port_probe(ap); | ||
| 3851 | } | 3858 | } |
| 3852 | EXPORT_SYMBOL_GPL(ata_sas_async_port_init); | 3859 | EXPORT_SYMBOL_GPL(ata_sas_sync_probe); |
| 3860 | |||
| 3853 | 3861 | ||
| 3854 | /** | 3862 | /** |
| 3855 | * ata_sas_port_init - Initialize a SATA device | 3863 | * ata_sas_port_init - Initialize a SATA device |
| @@ -3866,12 +3874,10 @@ int ata_sas_port_init(struct ata_port *ap) | |||
| 3866 | { | 3874 | { |
| 3867 | int rc = ap->ops->port_start(ap); | 3875 | int rc = ap->ops->port_start(ap); |
| 3868 | 3876 | ||
| 3869 | if (!rc) { | 3877 | if (rc) |
| 3870 | ap->print_id = atomic_inc_return(&ata_print_id); | 3878 | return rc; |
| 3871 | rc = ata_port_probe(ap); | 3879 | ap->print_id = atomic_inc_return(&ata_print_id); |
| 3872 | } | 3880 | return 0; |
| 3873 | |||
| 3874 | return rc; | ||
| 3875 | } | 3881 | } |
| 3876 | EXPORT_SYMBOL_GPL(ata_sas_port_init); | 3882 | EXPORT_SYMBOL_GPL(ata_sas_port_init); |
| 3877 | 3883 | ||
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index e002cd466e9a..467dc38246f9 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
| @@ -4549,8 +4549,12 @@ static int ipr_ata_slave_alloc(struct scsi_device *sdev) | |||
| 4549 | ENTER; | 4549 | ENTER; |
| 4550 | if (sdev->sdev_target) | 4550 | if (sdev->sdev_target) |
| 4551 | sata_port = sdev->sdev_target->hostdata; | 4551 | sata_port = sdev->sdev_target->hostdata; |
| 4552 | if (sata_port) | 4552 | if (sata_port) { |
| 4553 | rc = ata_sas_port_init(sata_port->ap); | 4553 | rc = ata_sas_port_init(sata_port->ap); |
| 4554 | if (rc == 0) | ||
| 4555 | rc = ata_sas_sync_probe(sata_port->ap); | ||
| 4556 | } | ||
| 4557 | |||
| 4554 | if (rc) | 4558 | if (rc) |
| 4555 | ipr_slave_destroy(sdev); | 4559 | ipr_slave_destroy(sdev); |
| 4556 | 4560 | ||
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index ef9560dff295..cc83b66d45b7 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c | |||
| @@ -1742,17 +1742,19 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
| 1742 | 1742 | ||
| 1743 | mfs = ntohs(flp->fl_csp.sp_bb_data) & | 1743 | mfs = ntohs(flp->fl_csp.sp_bb_data) & |
| 1744 | FC_SP_BB_DATA_MASK; | 1744 | FC_SP_BB_DATA_MASK; |
| 1745 | if (mfs >= FC_SP_MIN_MAX_PAYLOAD && | 1745 | |
| 1746 | mfs <= lport->mfs) { | 1746 | if (mfs < FC_SP_MIN_MAX_PAYLOAD || mfs > FC_SP_MAX_MAX_PAYLOAD) { |
| 1747 | lport->mfs = mfs; | ||
| 1748 | fc_host_maxframe_size(lport->host) = mfs; | ||
| 1749 | } else { | ||
| 1750 | FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, " | 1747 | FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, " |
| 1751 | "lport->mfs:%hu\n", mfs, lport->mfs); | 1748 | "lport->mfs:%hu\n", mfs, lport->mfs); |
| 1752 | fc_lport_error(lport, fp); | 1749 | fc_lport_error(lport, fp); |
| 1753 | goto err; | 1750 | goto err; |
| 1754 | } | 1751 | } |
| 1755 | 1752 | ||
| 1753 | if (mfs <= lport->mfs) { | ||
| 1754 | lport->mfs = mfs; | ||
| 1755 | fc_host_maxframe_size(lport->host) = mfs; | ||
| 1756 | } | ||
| 1757 | |||
| 1756 | csp_flags = ntohs(flp->fl_csp.sp_features); | 1758 | csp_flags = ntohs(flp->fl_csp.sp_features); |
| 1757 | r_a_tov = ntohl(flp->fl_csp.sp_r_a_tov); | 1759 | r_a_tov = ntohl(flp->fl_csp.sp_r_a_tov); |
| 1758 | e_d_tov = ntohl(flp->fl_csp.sp_e_d_tov); | 1760 | e_d_tov = ntohl(flp->fl_csp.sp_e_d_tov); |
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index bc0cecc6ad62..441d88ad99a7 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c | |||
| @@ -546,11 +546,12 @@ static struct ata_port_info sata_port_info = { | |||
| 546 | .port_ops = &sas_sata_ops | 546 | .port_ops = &sas_sata_ops |
| 547 | }; | 547 | }; |
| 548 | 548 | ||
| 549 | int sas_ata_init_host_and_port(struct domain_device *found_dev) | 549 | int sas_ata_init(struct domain_device *found_dev) |
| 550 | { | 550 | { |
| 551 | struct sas_ha_struct *ha = found_dev->port->ha; | 551 | struct sas_ha_struct *ha = found_dev->port->ha; |
| 552 | struct Scsi_Host *shost = ha->core.shost; | 552 | struct Scsi_Host *shost = ha->core.shost; |
| 553 | struct ata_port *ap; | 553 | struct ata_port *ap; |
| 554 | int rc; | ||
| 554 | 555 | ||
| 555 | ata_host_init(&found_dev->sata_dev.ata_host, | 556 | ata_host_init(&found_dev->sata_dev.ata_host, |
| 556 | ha->dev, | 557 | ha->dev, |
| @@ -567,8 +568,11 @@ int sas_ata_init_host_and_port(struct domain_device *found_dev) | |||
| 567 | ap->private_data = found_dev; | 568 | ap->private_data = found_dev; |
| 568 | ap->cbl = ATA_CBL_SATA; | 569 | ap->cbl = ATA_CBL_SATA; |
| 569 | ap->scsi_host = shost; | 570 | ap->scsi_host = shost; |
| 570 | /* publish initialized ata port */ | 571 | rc = ata_sas_port_init(ap); |
| 571 | smp_wmb(); | 572 | if (rc) { |
| 573 | ata_sas_port_destroy(ap); | ||
| 574 | return rc; | ||
| 575 | } | ||
| 572 | found_dev->sata_dev.ap = ap; | 576 | found_dev->sata_dev.ap = ap; |
| 573 | 577 | ||
| 574 | return 0; | 578 | return 0; |
| @@ -648,18 +652,13 @@ static void sas_get_ata_command_set(struct domain_device *dev) | |||
| 648 | void sas_probe_sata(struct asd_sas_port *port) | 652 | void sas_probe_sata(struct asd_sas_port *port) |
| 649 | { | 653 | { |
| 650 | struct domain_device *dev, *n; | 654 | struct domain_device *dev, *n; |
| 651 | int err; | ||
| 652 | 655 | ||
| 653 | mutex_lock(&port->ha->disco_mutex); | 656 | mutex_lock(&port->ha->disco_mutex); |
| 654 | list_for_each_entry_safe(dev, n, &port->disco_list, disco_list_node) { | 657 | list_for_each_entry(dev, &port->disco_list, disco_list_node) { |
| 655 | if (!dev_is_sata(dev)) | 658 | if (!dev_is_sata(dev)) |
| 656 | continue; | 659 | continue; |
| 657 | 660 | ||
| 658 | err = sas_ata_init_host_and_port(dev); | 661 | ata_sas_async_probe(dev->sata_dev.ap); |
| 659 | if (err) | ||
| 660 | sas_fail_probe(dev, __func__, err); | ||
| 661 | else | ||
| 662 | ata_sas_async_port_init(dev->sata_dev.ap); | ||
| 663 | } | 662 | } |
| 664 | mutex_unlock(&port->ha->disco_mutex); | 663 | mutex_unlock(&port->ha->disco_mutex); |
| 665 | 664 | ||
| @@ -718,18 +717,6 @@ static void async_sas_ata_eh(void *data, async_cookie_t cookie) | |||
| 718 | sas_put_device(dev); | 717 | sas_put_device(dev); |
| 719 | } | 718 | } |
| 720 | 719 | ||
| 721 | static bool sas_ata_dev_eh_valid(struct domain_device *dev) | ||
| 722 | { | ||
| 723 | struct ata_port *ap; | ||
| 724 | |||
| 725 | if (!dev_is_sata(dev)) | ||
| 726 | return false; | ||
| 727 | ap = dev->sata_dev.ap; | ||
| 728 | /* consume fully initialized ata ports */ | ||
| 729 | smp_rmb(); | ||
| 730 | return !!ap; | ||
| 731 | } | ||
| 732 | |||
| 733 | void sas_ata_strategy_handler(struct Scsi_Host *shost) | 720 | void sas_ata_strategy_handler(struct Scsi_Host *shost) |
| 734 | { | 721 | { |
| 735 | struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost); | 722 | struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost); |
| @@ -753,7 +740,7 @@ void sas_ata_strategy_handler(struct Scsi_Host *shost) | |||
| 753 | 740 | ||
| 754 | spin_lock(&port->dev_list_lock); | 741 | spin_lock(&port->dev_list_lock); |
| 755 | list_for_each_entry(dev, &port->dev_list, dev_list_node) { | 742 | list_for_each_entry(dev, &port->dev_list, dev_list_node) { |
| 756 | if (!sas_ata_dev_eh_valid(dev)) | 743 | if (!dev_is_sata(dev)) |
| 757 | continue; | 744 | continue; |
| 758 | async_schedule_domain(async_sas_ata_eh, dev, &async); | 745 | async_schedule_domain(async_sas_ata_eh, dev, &async); |
| 759 | } | 746 | } |
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c index 364679675602..629a0865b130 100644 --- a/drivers/scsi/libsas/sas_discover.c +++ b/drivers/scsi/libsas/sas_discover.c | |||
| @@ -72,6 +72,7 @@ static int sas_get_port_device(struct asd_sas_port *port) | |||
| 72 | struct asd_sas_phy *phy; | 72 | struct asd_sas_phy *phy; |
| 73 | struct sas_rphy *rphy; | 73 | struct sas_rphy *rphy; |
| 74 | struct domain_device *dev; | 74 | struct domain_device *dev; |
| 75 | int rc = -ENODEV; | ||
| 75 | 76 | ||
| 76 | dev = sas_alloc_device(); | 77 | dev = sas_alloc_device(); |
| 77 | if (!dev) | 78 | if (!dev) |
| @@ -110,9 +111,16 @@ static int sas_get_port_device(struct asd_sas_port *port) | |||
| 110 | 111 | ||
| 111 | sas_init_dev(dev); | 112 | sas_init_dev(dev); |
| 112 | 113 | ||
| 114 | dev->port = port; | ||
| 113 | switch (dev->dev_type) { | 115 | switch (dev->dev_type) { |
| 114 | case SAS_END_DEV: | ||
| 115 | case SATA_DEV: | 116 | case SATA_DEV: |
| 117 | rc = sas_ata_init(dev); | ||
| 118 | if (rc) { | ||
| 119 | rphy = NULL; | ||
| 120 | break; | ||
| 121 | } | ||
| 122 | /* fall through */ | ||
| 123 | case SAS_END_DEV: | ||
| 116 | rphy = sas_end_device_alloc(port->port); | 124 | rphy = sas_end_device_alloc(port->port); |
| 117 | break; | 125 | break; |
| 118 | case EDGE_DEV: | 126 | case EDGE_DEV: |
| @@ -131,19 +139,14 @@ static int sas_get_port_device(struct asd_sas_port *port) | |||
| 131 | 139 | ||
| 132 | if (!rphy) { | 140 | if (!rphy) { |
| 133 | sas_put_device(dev); | 141 | sas_put_device(dev); |
| 134 | return -ENODEV; | 142 | return rc; |
| 135 | } | 143 | } |
| 136 | 144 | ||
| 137 | spin_lock_irq(&port->phy_list_lock); | ||
| 138 | list_for_each_entry(phy, &port->phy_list, port_phy_el) | ||
| 139 | sas_phy_set_target(phy, dev); | ||
| 140 | spin_unlock_irq(&port->phy_list_lock); | ||
| 141 | rphy->identify.phy_identifier = phy->phy->identify.phy_identifier; | 145 | rphy->identify.phy_identifier = phy->phy->identify.phy_identifier; |
| 142 | memcpy(dev->sas_addr, port->attached_sas_addr, SAS_ADDR_SIZE); | 146 | memcpy(dev->sas_addr, port->attached_sas_addr, SAS_ADDR_SIZE); |
| 143 | sas_fill_in_rphy(dev, rphy); | 147 | sas_fill_in_rphy(dev, rphy); |
| 144 | sas_hash_addr(dev->hashed_sas_addr, dev->sas_addr); | 148 | sas_hash_addr(dev->hashed_sas_addr, dev->sas_addr); |
| 145 | port->port_dev = dev; | 149 | port->port_dev = dev; |
| 146 | dev->port = port; | ||
| 147 | dev->linkrate = port->linkrate; | 150 | dev->linkrate = port->linkrate; |
| 148 | dev->min_linkrate = port->linkrate; | 151 | dev->min_linkrate = port->linkrate; |
| 149 | dev->max_linkrate = port->linkrate; | 152 | dev->max_linkrate = port->linkrate; |
| @@ -155,6 +158,7 @@ static int sas_get_port_device(struct asd_sas_port *port) | |||
| 155 | sas_device_set_phy(dev, port->port); | 158 | sas_device_set_phy(dev, port->port); |
| 156 | 159 | ||
| 157 | dev->rphy = rphy; | 160 | dev->rphy = rphy; |
| 161 | get_device(&dev->rphy->dev); | ||
| 158 | 162 | ||
| 159 | if (dev_is_sata(dev) || dev->dev_type == SAS_END_DEV) | 163 | if (dev_is_sata(dev) || dev->dev_type == SAS_END_DEV) |
| 160 | list_add_tail(&dev->disco_list_node, &port->disco_list); | 164 | list_add_tail(&dev->disco_list_node, &port->disco_list); |
| @@ -164,6 +168,11 @@ static int sas_get_port_device(struct asd_sas_port *port) | |||
| 164 | spin_unlock_irq(&port->dev_list_lock); | 168 | spin_unlock_irq(&port->dev_list_lock); |
| 165 | } | 169 | } |
| 166 | 170 | ||
| 171 | spin_lock_irq(&port->phy_list_lock); | ||
| 172 | list_for_each_entry(phy, &port->phy_list, port_phy_el) | ||
| 173 | sas_phy_set_target(phy, dev); | ||
| 174 | spin_unlock_irq(&port->phy_list_lock); | ||
| 175 | |||
| 167 | return 0; | 176 | return 0; |
| 168 | } | 177 | } |
| 169 | 178 | ||
| @@ -205,8 +214,7 @@ void sas_notify_lldd_dev_gone(struct domain_device *dev) | |||
| 205 | static void sas_probe_devices(struct work_struct *work) | 214 | static void sas_probe_devices(struct work_struct *work) |
| 206 | { | 215 | { |
| 207 | struct domain_device *dev, *n; | 216 | struct domain_device *dev, *n; |
| 208 | struct sas_discovery_event *ev = | 217 | struct sas_discovery_event *ev = to_sas_discovery_event(work); |
| 209 | container_of(work, struct sas_discovery_event, work); | ||
| 210 | struct asd_sas_port *port = ev->port; | 218 | struct asd_sas_port *port = ev->port; |
| 211 | 219 | ||
| 212 | clear_bit(DISCE_PROBE, &port->disc.pending); | 220 | clear_bit(DISCE_PROBE, &port->disc.pending); |
| @@ -255,6 +263,9 @@ void sas_free_device(struct kref *kref) | |||
| 255 | { | 263 | { |
| 256 | struct domain_device *dev = container_of(kref, typeof(*dev), kref); | 264 | struct domain_device *dev = container_of(kref, typeof(*dev), kref); |
| 257 | 265 | ||
| 266 | put_device(&dev->rphy->dev); | ||
| 267 | dev->rphy = NULL; | ||
| 268 | |||
| 258 | if (dev->parent) | 269 | if (dev->parent) |
| 259 | sas_put_device(dev->parent); | 270 | sas_put_device(dev->parent); |
| 260 | 271 | ||
| @@ -291,8 +302,7 @@ static void sas_unregister_common_dev(struct asd_sas_port *port, struct domain_d | |||
| 291 | static void sas_destruct_devices(struct work_struct *work) | 302 | static void sas_destruct_devices(struct work_struct *work) |
| 292 | { | 303 | { |
| 293 | struct domain_device *dev, *n; | 304 | struct domain_device *dev, *n; |
| 294 | struct sas_discovery_event *ev = | 305 | struct sas_discovery_event *ev = to_sas_discovery_event(work); |
| 295 | container_of(work, struct sas_discovery_event, work); | ||
| 296 | struct asd_sas_port *port = ev->port; | 306 | struct asd_sas_port *port = ev->port; |
| 297 | 307 | ||
| 298 | clear_bit(DISCE_DESTRUCT, &port->disc.pending); | 308 | clear_bit(DISCE_DESTRUCT, &port->disc.pending); |
| @@ -302,7 +312,6 @@ static void sas_destruct_devices(struct work_struct *work) | |||
| 302 | 312 | ||
| 303 | sas_remove_children(&dev->rphy->dev); | 313 | sas_remove_children(&dev->rphy->dev); |
| 304 | sas_rphy_delete(dev->rphy); | 314 | sas_rphy_delete(dev->rphy); |
| 305 | dev->rphy = NULL; | ||
| 306 | sas_unregister_common_dev(port, dev); | 315 | sas_unregister_common_dev(port, dev); |
| 307 | } | 316 | } |
| 308 | } | 317 | } |
| @@ -314,11 +323,11 @@ void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *dev) | |||
| 314 | /* this rphy never saw sas_rphy_add */ | 323 | /* this rphy never saw sas_rphy_add */ |
| 315 | list_del_init(&dev->disco_list_node); | 324 | list_del_init(&dev->disco_list_node); |
| 316 | sas_rphy_free(dev->rphy); | 325 | sas_rphy_free(dev->rphy); |
| 317 | dev->rphy = NULL; | ||
| 318 | sas_unregister_common_dev(port, dev); | 326 | sas_unregister_common_dev(port, dev); |
| 327 | return; | ||
| 319 | } | 328 | } |
| 320 | 329 | ||
| 321 | if (dev->rphy && !test_and_set_bit(SAS_DEV_DESTROY, &dev->state)) { | 330 | if (!test_and_set_bit(SAS_DEV_DESTROY, &dev->state)) { |
| 322 | sas_rphy_unlink(dev->rphy); | 331 | sas_rphy_unlink(dev->rphy); |
| 323 | list_move_tail(&dev->disco_list_node, &port->destroy_list); | 332 | list_move_tail(&dev->disco_list_node, &port->destroy_list); |
| 324 | sas_discover_event(dev->port, DISCE_DESTRUCT); | 333 | sas_discover_event(dev->port, DISCE_DESTRUCT); |
| @@ -377,8 +386,7 @@ static void sas_discover_domain(struct work_struct *work) | |||
| 377 | { | 386 | { |
| 378 | struct domain_device *dev; | 387 | struct domain_device *dev; |
| 379 | int error = 0; | 388 | int error = 0; |
| 380 | struct sas_discovery_event *ev = | 389 | struct sas_discovery_event *ev = to_sas_discovery_event(work); |
| 381 | container_of(work, struct sas_discovery_event, work); | ||
| 382 | struct asd_sas_port *port = ev->port; | 390 | struct asd_sas_port *port = ev->port; |
| 383 | 391 | ||
| 384 | clear_bit(DISCE_DISCOVER_DOMAIN, &port->disc.pending); | 392 | clear_bit(DISCE_DISCOVER_DOMAIN, &port->disc.pending); |
| @@ -419,8 +427,6 @@ static void sas_discover_domain(struct work_struct *work) | |||
| 419 | 427 | ||
| 420 | if (error) { | 428 | if (error) { |
| 421 | sas_rphy_free(dev->rphy); | 429 | sas_rphy_free(dev->rphy); |
| 422 | dev->rphy = NULL; | ||
| 423 | |||
| 424 | list_del_init(&dev->disco_list_node); | 430 | list_del_init(&dev->disco_list_node); |
| 425 | spin_lock_irq(&port->dev_list_lock); | 431 | spin_lock_irq(&port->dev_list_lock); |
| 426 | list_del_init(&dev->dev_list_node); | 432 | list_del_init(&dev->dev_list_node); |
| @@ -437,8 +443,7 @@ static void sas_discover_domain(struct work_struct *work) | |||
| 437 | static void sas_revalidate_domain(struct work_struct *work) | 443 | static void sas_revalidate_domain(struct work_struct *work) |
| 438 | { | 444 | { |
| 439 | int res = 0; | 445 | int res = 0; |
| 440 | struct sas_discovery_event *ev = | 446 | struct sas_discovery_event *ev = to_sas_discovery_event(work); |
| 441 | container_of(work, struct sas_discovery_event, work); | ||
| 442 | struct asd_sas_port *port = ev->port; | 447 | struct asd_sas_port *port = ev->port; |
| 443 | struct sas_ha_struct *ha = port->ha; | 448 | struct sas_ha_struct *ha = port->ha; |
| 444 | 449 | ||
| @@ -466,21 +471,25 @@ static void sas_revalidate_domain(struct work_struct *work) | |||
| 466 | 471 | ||
| 467 | /* ---------- Events ---------- */ | 472 | /* ---------- Events ---------- */ |
| 468 | 473 | ||
| 469 | static void sas_chain_work(struct sas_ha_struct *ha, struct work_struct *work) | 474 | static void sas_chain_work(struct sas_ha_struct *ha, struct sas_work *sw) |
| 470 | { | 475 | { |
| 471 | /* chained work is not subject to SA_HA_DRAINING or SAS_HA_REGISTERED */ | 476 | /* chained work is not subject to SA_HA_DRAINING or |
| 472 | scsi_queue_work(ha->core.shost, work); | 477 | * SAS_HA_REGISTERED, because it is either submitted in the |
| 478 | * workqueue, or known to be submitted from a context that is | ||
| 479 | * not racing against draining | ||
| 480 | */ | ||
| 481 | scsi_queue_work(ha->core.shost, &sw->work); | ||
| 473 | } | 482 | } |
| 474 | 483 | ||
| 475 | static void sas_chain_event(int event, unsigned long *pending, | 484 | static void sas_chain_event(int event, unsigned long *pending, |
| 476 | struct work_struct *work, | 485 | struct sas_work *sw, |
| 477 | struct sas_ha_struct *ha) | 486 | struct sas_ha_struct *ha) |
| 478 | { | 487 | { |
| 479 | if (!test_and_set_bit(event, pending)) { | 488 | if (!test_and_set_bit(event, pending)) { |
| 480 | unsigned long flags; | 489 | unsigned long flags; |
| 481 | 490 | ||
| 482 | spin_lock_irqsave(&ha->state_lock, flags); | 491 | spin_lock_irqsave(&ha->state_lock, flags); |
| 483 | sas_chain_work(ha, work); | 492 | sas_chain_work(ha, sw); |
| 484 | spin_unlock_irqrestore(&ha->state_lock, flags); | 493 | spin_unlock_irqrestore(&ha->state_lock, flags); |
| 485 | } | 494 | } |
| 486 | } | 495 | } |
| @@ -519,7 +528,7 @@ void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *port) | |||
| 519 | 528 | ||
| 520 | disc->pending = 0; | 529 | disc->pending = 0; |
| 521 | for (i = 0; i < DISC_NUM_EVENTS; i++) { | 530 | for (i = 0; i < DISC_NUM_EVENTS; i++) { |
| 522 | INIT_WORK(&disc->disc_work[i].work, sas_event_fns[i]); | 531 | INIT_SAS_WORK(&disc->disc_work[i].work, sas_event_fns[i]); |
| 523 | disc->disc_work[i].port = port; | 532 | disc->disc_work[i].port = port; |
| 524 | } | 533 | } |
| 525 | } | 534 | } |
diff --git a/drivers/scsi/libsas/sas_event.c b/drivers/scsi/libsas/sas_event.c index 16639bbae629..4e4292d210c1 100644 --- a/drivers/scsi/libsas/sas_event.c +++ b/drivers/scsi/libsas/sas_event.c | |||
| @@ -27,19 +27,21 @@ | |||
| 27 | #include "sas_internal.h" | 27 | #include "sas_internal.h" |
| 28 | #include "sas_dump.h" | 28 | #include "sas_dump.h" |
| 29 | 29 | ||
| 30 | void sas_queue_work(struct sas_ha_struct *ha, struct work_struct *work) | 30 | void sas_queue_work(struct sas_ha_struct *ha, struct sas_work *sw) |
| 31 | { | 31 | { |
| 32 | if (!test_bit(SAS_HA_REGISTERED, &ha->state)) | 32 | if (!test_bit(SAS_HA_REGISTERED, &ha->state)) |
| 33 | return; | 33 | return; |
| 34 | 34 | ||
| 35 | if (test_bit(SAS_HA_DRAINING, &ha->state)) | 35 | if (test_bit(SAS_HA_DRAINING, &ha->state)) { |
| 36 | list_add(&work->entry, &ha->defer_q); | 36 | /* add it to the defer list, if not already pending */ |
| 37 | else | 37 | if (list_empty(&sw->drain_node)) |
| 38 | scsi_queue_work(ha->core.shost, work); | 38 | list_add(&sw->drain_node, &ha->defer_q); |
| 39 | } else | ||
| 40 | scsi_queue_work(ha->core.shost, &sw->work); | ||
| 39 | } | 41 | } |
| 40 | 42 | ||
| 41 | static void sas_queue_event(int event, unsigned long *pending, | 43 | static void sas_queue_event(int event, unsigned long *pending, |
| 42 | struct work_struct *work, | 44 | struct sas_work *work, |
| 43 | struct sas_ha_struct *ha) | 45 | struct sas_ha_struct *ha) |
| 44 | { | 46 | { |
| 45 | if (!test_and_set_bit(event, pending)) { | 47 | if (!test_and_set_bit(event, pending)) { |
| @@ -55,7 +57,7 @@ static void sas_queue_event(int event, unsigned long *pending, | |||
| 55 | void __sas_drain_work(struct sas_ha_struct *ha) | 57 | void __sas_drain_work(struct sas_ha_struct *ha) |
| 56 | { | 58 | { |
| 57 | struct workqueue_struct *wq = ha->core.shost->work_q; | 59 | struct workqueue_struct *wq = ha->core.shost->work_q; |
| 58 | struct work_struct *w, *_w; | 60 | struct sas_work *sw, *_sw; |
| 59 | 61 | ||
| 60 | set_bit(SAS_HA_DRAINING, &ha->state); | 62 | set_bit(SAS_HA_DRAINING, &ha->state); |
| 61 | /* flush submitters */ | 63 | /* flush submitters */ |
| @@ -66,9 +68,9 @@ void __sas_drain_work(struct sas_ha_struct *ha) | |||
| 66 | 68 | ||
| 67 | spin_lock_irq(&ha->state_lock); | 69 | spin_lock_irq(&ha->state_lock); |
| 68 | clear_bit(SAS_HA_DRAINING, &ha->state); | 70 | clear_bit(SAS_HA_DRAINING, &ha->state); |
| 69 | list_for_each_entry_safe(w, _w, &ha->defer_q, entry) { | 71 | list_for_each_entry_safe(sw, _sw, &ha->defer_q, drain_node) { |
| 70 | list_del_init(&w->entry); | 72 | list_del_init(&sw->drain_node); |
| 71 | sas_queue_work(ha, w); | 73 | sas_queue_work(ha, sw); |
| 72 | } | 74 | } |
| 73 | spin_unlock_irq(&ha->state_lock); | 75 | spin_unlock_irq(&ha->state_lock); |
| 74 | } | 76 | } |
| @@ -151,7 +153,7 @@ int sas_init_events(struct sas_ha_struct *sas_ha) | |||
| 151 | int i; | 153 | int i; |
| 152 | 154 | ||
| 153 | for (i = 0; i < HA_NUM_EVENTS; i++) { | 155 | for (i = 0; i < HA_NUM_EVENTS; i++) { |
| 154 | INIT_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]); | 156 | INIT_SAS_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]); |
| 155 | sas_ha->ha_events[i].ha = sas_ha; | 157 | sas_ha->ha_events[i].ha = sas_ha; |
| 156 | } | 158 | } |
| 157 | 159 | ||
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 05acd9e35fc4..caa0525d2523 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c | |||
| @@ -202,6 +202,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp) | |||
| 202 | u8 sas_addr[SAS_ADDR_SIZE]; | 202 | u8 sas_addr[SAS_ADDR_SIZE]; |
| 203 | struct smp_resp *resp = rsp; | 203 | struct smp_resp *resp = rsp; |
| 204 | struct discover_resp *dr = &resp->disc; | 204 | struct discover_resp *dr = &resp->disc; |
| 205 | struct sas_ha_struct *ha = dev->port->ha; | ||
| 205 | struct expander_device *ex = &dev->ex_dev; | 206 | struct expander_device *ex = &dev->ex_dev; |
| 206 | struct ex_phy *phy = &ex->ex_phy[phy_id]; | 207 | struct ex_phy *phy = &ex->ex_phy[phy_id]; |
| 207 | struct sas_rphy *rphy = dev->rphy; | 208 | struct sas_rphy *rphy = dev->rphy; |
| @@ -209,6 +210,8 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp) | |||
| 209 | char *type; | 210 | char *type; |
| 210 | 211 | ||
| 211 | if (new_phy) { | 212 | if (new_phy) { |
| 213 | if (WARN_ON_ONCE(test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state))) | ||
| 214 | return; | ||
| 212 | phy->phy = sas_phy_alloc(&rphy->dev, phy_id); | 215 | phy->phy = sas_phy_alloc(&rphy->dev, phy_id); |
| 213 | 216 | ||
| 214 | /* FIXME: error_handling */ | 217 | /* FIXME: error_handling */ |
| @@ -233,6 +236,8 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp) | |||
| 233 | memcpy(sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); | 236 | memcpy(sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); |
| 234 | 237 | ||
| 235 | phy->attached_dev_type = to_dev_type(dr); | 238 | phy->attached_dev_type = to_dev_type(dr); |
| 239 | if (test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state)) | ||
| 240 | goto out; | ||
| 236 | phy->phy_id = phy_id; | 241 | phy->phy_id = phy_id; |
| 237 | phy->linkrate = dr->linkrate; | 242 | phy->linkrate = dr->linkrate; |
| 238 | phy->attached_sata_host = dr->attached_sata_host; | 243 | phy->attached_sata_host = dr->attached_sata_host; |
| @@ -240,7 +245,14 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp) | |||
| 240 | phy->attached_sata_ps = dr->attached_sata_ps; | 245 | phy->attached_sata_ps = dr->attached_sata_ps; |
| 241 | phy->attached_iproto = dr->iproto << 1; | 246 | phy->attached_iproto = dr->iproto << 1; |
| 242 | phy->attached_tproto = dr->tproto << 1; | 247 | phy->attached_tproto = dr->tproto << 1; |
| 243 | memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE); | 248 | /* help some expanders that fail to zero sas_address in the 'no |
| 249 | * device' case | ||
| 250 | */ | ||
| 251 | if (phy->attached_dev_type == NO_DEVICE || | ||
| 252 | phy->linkrate < SAS_LINK_RATE_1_5_GBPS) | ||
| 253 | memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); | ||
| 254 | else | ||
| 255 | memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE); | ||
| 244 | phy->attached_phy_id = dr->attached_phy_id; | 256 | phy->attached_phy_id = dr->attached_phy_id; |
| 245 | phy->phy_change_count = dr->change_count; | 257 | phy->phy_change_count = dr->change_count; |
| 246 | phy->routing_attr = dr->routing_attr; | 258 | phy->routing_attr = dr->routing_attr; |
| @@ -266,6 +278,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp) | |||
| 266 | return; | 278 | return; |
| 267 | } | 279 | } |
| 268 | 280 | ||
| 281 | out: | ||
| 269 | switch (phy->attached_dev_type) { | 282 | switch (phy->attached_dev_type) { |
| 270 | case SATA_PENDING: | 283 | case SATA_PENDING: |
| 271 | type = "stp pending"; | 284 | type = "stp pending"; |
| @@ -304,7 +317,15 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp) | |||
| 304 | else | 317 | else |
| 305 | return; | 318 | return; |
| 306 | 319 | ||
| 307 | SAS_DPRINTK("ex %016llx phy%02d:%c:%X attached: %016llx (%s)\n", | 320 | /* if the attached device type changed and ata_eh is active, |
| 321 | * make sure we run revalidation when eh completes (see: | ||
| 322 | * sas_enable_revalidation) | ||
| 323 | */ | ||
| 324 | if (test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state)) | ||
| 325 | set_bit(DISCE_REVALIDATE_DOMAIN, &dev->port->disc.pending); | ||
| 326 | |||
| 327 | SAS_DPRINTK("%sex %016llx phy%02d:%c:%X attached: %016llx (%s)\n", | ||
| 328 | test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state) ? "ata: " : "", | ||
| 308 | SAS_ADDR(dev->sas_addr), phy->phy_id, | 329 | SAS_ADDR(dev->sas_addr), phy->phy_id, |
| 309 | sas_route_char(dev, phy), phy->linkrate, | 330 | sas_route_char(dev, phy), phy->linkrate, |
| 310 | SAS_ADDR(phy->attached_sas_addr), type); | 331 | SAS_ADDR(phy->attached_sas_addr), type); |
| @@ -776,13 +797,16 @@ static struct domain_device *sas_ex_discover_end_dev( | |||
| 776 | if (res) | 797 | if (res) |
| 777 | goto out_free; | 798 | goto out_free; |
| 778 | 799 | ||
| 800 | sas_init_dev(child); | ||
| 801 | res = sas_ata_init(child); | ||
| 802 | if (res) | ||
| 803 | goto out_free; | ||
| 779 | rphy = sas_end_device_alloc(phy->port); | 804 | rphy = sas_end_device_alloc(phy->port); |
| 780 | if (unlikely(!rphy)) | 805 | if (!rphy) |
| 781 | goto out_free; | 806 | goto out_free; |
| 782 | 807 | ||
| 783 | sas_init_dev(child); | ||
| 784 | |||
| 785 | child->rphy = rphy; | 808 | child->rphy = rphy; |
| 809 | get_device(&rphy->dev); | ||
| 786 | 810 | ||
| 787 | list_add_tail(&child->disco_list_node, &parent->port->disco_list); | 811 | list_add_tail(&child->disco_list_node, &parent->port->disco_list); |
| 788 | 812 | ||
| @@ -806,6 +830,7 @@ static struct domain_device *sas_ex_discover_end_dev( | |||
| 806 | sas_init_dev(child); | 830 | sas_init_dev(child); |
| 807 | 831 | ||
| 808 | child->rphy = rphy; | 832 | child->rphy = rphy; |
| 833 | get_device(&rphy->dev); | ||
| 809 | sas_fill_in_rphy(child, rphy); | 834 | sas_fill_in_rphy(child, rphy); |
| 810 | 835 | ||
| 811 | list_add_tail(&child->disco_list_node, &parent->port->disco_list); | 836 | list_add_tail(&child->disco_list_node, &parent->port->disco_list); |
| @@ -830,8 +855,6 @@ static struct domain_device *sas_ex_discover_end_dev( | |||
| 830 | 855 | ||
| 831 | out_list_del: | 856 | out_list_del: |
| 832 | sas_rphy_free(child->rphy); | 857 | sas_rphy_free(child->rphy); |
| 833 | child->rphy = NULL; | ||
| 834 | |||
| 835 | list_del(&child->disco_list_node); | 858 | list_del(&child->disco_list_node); |
| 836 | spin_lock_irq(&parent->port->dev_list_lock); | 859 | spin_lock_irq(&parent->port->dev_list_lock); |
| 837 | list_del(&child->dev_list_node); | 860 | list_del(&child->dev_list_node); |
| @@ -911,6 +934,7 @@ static struct domain_device *sas_ex_discover_expander( | |||
| 911 | } | 934 | } |
| 912 | port = parent->port; | 935 | port = parent->port; |
| 913 | child->rphy = rphy; | 936 | child->rphy = rphy; |
| 937 | get_device(&rphy->dev); | ||
| 914 | edev = rphy_to_expander_device(rphy); | 938 | edev = rphy_to_expander_device(rphy); |
| 915 | child->dev_type = phy->attached_dev_type; | 939 | child->dev_type = phy->attached_dev_type; |
| 916 | kref_get(&parent->kref); | 940 | kref_get(&parent->kref); |
| @@ -934,6 +958,7 @@ static struct domain_device *sas_ex_discover_expander( | |||
| 934 | 958 | ||
| 935 | res = sas_discover_expander(child); | 959 | res = sas_discover_expander(child); |
| 936 | if (res) { | 960 | if (res) { |
| 961 | sas_rphy_delete(rphy); | ||
| 937 | spin_lock_irq(&parent->port->dev_list_lock); | 962 | spin_lock_irq(&parent->port->dev_list_lock); |
| 938 | list_del(&child->dev_list_node); | 963 | list_del(&child->dev_list_node); |
| 939 | spin_unlock_irq(&parent->port->dev_list_lock); | 964 | spin_unlock_irq(&parent->port->dev_list_lock); |
| @@ -1718,9 +1743,17 @@ static int sas_find_bcast_phy(struct domain_device *dev, int *phy_id, | |||
| 1718 | int phy_change_count = 0; | 1743 | int phy_change_count = 0; |
| 1719 | 1744 | ||
| 1720 | res = sas_get_phy_change_count(dev, i, &phy_change_count); | 1745 | res = sas_get_phy_change_count(dev, i, &phy_change_count); |
| 1721 | if (res) | 1746 | switch (res) { |
| 1722 | goto out; | 1747 | case SMP_RESP_PHY_VACANT: |
| 1723 | else if (phy_change_count != ex->ex_phy[i].phy_change_count) { | 1748 | case SMP_RESP_NO_PHY: |
| 1749 | continue; | ||
| 1750 | case SMP_RESP_FUNC_ACC: | ||
| 1751 | break; | ||
| 1752 | default: | ||
| 1753 | return res; | ||
| 1754 | } | ||
| 1755 | |||
| 1756 | if (phy_change_count != ex->ex_phy[i].phy_change_count) { | ||
| 1724 | if (update) | 1757 | if (update) |
| 1725 | ex->ex_phy[i].phy_change_count = | 1758 | ex->ex_phy[i].phy_change_count = |
| 1726 | phy_change_count; | 1759 | phy_change_count; |
| @@ -1728,8 +1761,7 @@ static int sas_find_bcast_phy(struct domain_device *dev, int *phy_id, | |||
| 1728 | return 0; | 1761 | return 0; |
| 1729 | } | 1762 | } |
| 1730 | } | 1763 | } |
| 1731 | out: | 1764 | return 0; |
| 1732 | return res; | ||
| 1733 | } | 1765 | } |
| 1734 | 1766 | ||
| 1735 | static int sas_get_ex_change_count(struct domain_device *dev, int *ecc) | 1767 | static int sas_get_ex_change_count(struct domain_device *dev, int *ecc) |
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c index 120bff64be30..10cb5ae30977 100644 --- a/drivers/scsi/libsas/sas_init.c +++ b/drivers/scsi/libsas/sas_init.c | |||
| @@ -94,8 +94,7 @@ void sas_hash_addr(u8 *hashed, const u8 *sas_addr) | |||
| 94 | 94 | ||
| 95 | void sas_hae_reset(struct work_struct *work) | 95 | void sas_hae_reset(struct work_struct *work) |
| 96 | { | 96 | { |
| 97 | struct sas_ha_event *ev = | 97 | struct sas_ha_event *ev = to_sas_ha_event(work); |
| 98 | container_of(work, struct sas_ha_event, work); | ||
| 99 | struct sas_ha_struct *ha = ev->ha; | 98 | struct sas_ha_struct *ha = ev->ha; |
| 100 | 99 | ||
| 101 | clear_bit(HAE_RESET, &ha->pending); | 100 | clear_bit(HAE_RESET, &ha->pending); |
| @@ -369,14 +368,14 @@ static void sas_phy_release(struct sas_phy *phy) | |||
| 369 | 368 | ||
| 370 | static void phy_reset_work(struct work_struct *work) | 369 | static void phy_reset_work(struct work_struct *work) |
| 371 | { | 370 | { |
| 372 | struct sas_phy_data *d = container_of(work, typeof(*d), reset_work); | 371 | struct sas_phy_data *d = container_of(work, typeof(*d), reset_work.work); |
| 373 | 372 | ||
| 374 | d->reset_result = transport_sas_phy_reset(d->phy, d->hard_reset); | 373 | d->reset_result = transport_sas_phy_reset(d->phy, d->hard_reset); |
| 375 | } | 374 | } |
| 376 | 375 | ||
| 377 | static void phy_enable_work(struct work_struct *work) | 376 | static void phy_enable_work(struct work_struct *work) |
| 378 | { | 377 | { |
| 379 | struct sas_phy_data *d = container_of(work, typeof(*d), enable_work); | 378 | struct sas_phy_data *d = container_of(work, typeof(*d), enable_work.work); |
| 380 | 379 | ||
| 381 | d->enable_result = sas_phy_enable(d->phy, d->enable); | 380 | d->enable_result = sas_phy_enable(d->phy, d->enable); |
| 382 | } | 381 | } |
| @@ -389,8 +388,8 @@ static int sas_phy_setup(struct sas_phy *phy) | |||
| 389 | return -ENOMEM; | 388 | return -ENOMEM; |
| 390 | 389 | ||
| 391 | mutex_init(&d->event_lock); | 390 | mutex_init(&d->event_lock); |
| 392 | INIT_WORK(&d->reset_work, phy_reset_work); | 391 | INIT_SAS_WORK(&d->reset_work, phy_reset_work); |
| 393 | INIT_WORK(&d->enable_work, phy_enable_work); | 392 | INIT_SAS_WORK(&d->enable_work, phy_enable_work); |
| 394 | d->phy = phy; | 393 | d->phy = phy; |
| 395 | phy->hostdata = d; | 394 | phy->hostdata = d; |
| 396 | 395 | ||
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h index f05c63879949..507e4cf12e56 100644 --- a/drivers/scsi/libsas/sas_internal.h +++ b/drivers/scsi/libsas/sas_internal.h | |||
| @@ -45,10 +45,10 @@ struct sas_phy_data { | |||
| 45 | struct mutex event_lock; | 45 | struct mutex event_lock; |
| 46 | int hard_reset; | 46 | int hard_reset; |
| 47 | int reset_result; | 47 | int reset_result; |
| 48 | struct work_struct reset_work; | 48 | struct sas_work reset_work; |
| 49 | int enable; | 49 | int enable; |
| 50 | int enable_result; | 50 | int enable_result; |
| 51 | struct work_struct enable_work; | 51 | struct sas_work enable_work; |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| 54 | void sas_scsi_recover_host(struct Scsi_Host *shost); | 54 | void sas_scsi_recover_host(struct Scsi_Host *shost); |
| @@ -80,7 +80,7 @@ void sas_porte_broadcast_rcvd(struct work_struct *work); | |||
| 80 | void sas_porte_link_reset_err(struct work_struct *work); | 80 | void sas_porte_link_reset_err(struct work_struct *work); |
| 81 | void sas_porte_timer_event(struct work_struct *work); | 81 | void sas_porte_timer_event(struct work_struct *work); |
| 82 | void sas_porte_hard_reset(struct work_struct *work); | 82 | void sas_porte_hard_reset(struct work_struct *work); |
| 83 | void sas_queue_work(struct sas_ha_struct *ha, struct work_struct *work); | 83 | void sas_queue_work(struct sas_ha_struct *ha, struct sas_work *sw); |
| 84 | 84 | ||
| 85 | int sas_notify_lldd_dev_found(struct domain_device *); | 85 | int sas_notify_lldd_dev_found(struct domain_device *); |
| 86 | void sas_notify_lldd_dev_gone(struct domain_device *); | 86 | void sas_notify_lldd_dev_gone(struct domain_device *); |
diff --git a/drivers/scsi/libsas/sas_phy.c b/drivers/scsi/libsas/sas_phy.c index dcfd4a9105c5..521422e857ab 100644 --- a/drivers/scsi/libsas/sas_phy.c +++ b/drivers/scsi/libsas/sas_phy.c | |||
| @@ -32,8 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | static void sas_phye_loss_of_signal(struct work_struct *work) | 33 | static void sas_phye_loss_of_signal(struct work_struct *work) |
| 34 | { | 34 | { |
| 35 | struct asd_sas_event *ev = | 35 | struct asd_sas_event *ev = to_asd_sas_event(work); |
| 36 | container_of(work, struct asd_sas_event, work); | ||
| 37 | struct asd_sas_phy *phy = ev->phy; | 36 | struct asd_sas_phy *phy = ev->phy; |
| 38 | 37 | ||
| 39 | clear_bit(PHYE_LOSS_OF_SIGNAL, &phy->phy_events_pending); | 38 | clear_bit(PHYE_LOSS_OF_SIGNAL, &phy->phy_events_pending); |
| @@ -43,8 +42,7 @@ static void sas_phye_loss_of_signal(struct work_struct *work) | |||
| 43 | 42 | ||
| 44 | static void sas_phye_oob_done(struct work_struct *work) | 43 | static void sas_phye_oob_done(struct work_struct *work) |
| 45 | { | 44 | { |
| 46 | struct asd_sas_event *ev = | 45 | struct asd_sas_event *ev = to_asd_sas_event(work); |
| 47 | container_of(work, struct asd_sas_event, work); | ||
| 48 | struct asd_sas_phy *phy = ev->phy; | 46 | struct asd_sas_phy *phy = ev->phy; |
| 49 | 47 | ||
| 50 | clear_bit(PHYE_OOB_DONE, &phy->phy_events_pending); | 48 | clear_bit(PHYE_OOB_DONE, &phy->phy_events_pending); |
| @@ -53,8 +51,7 @@ static void sas_phye_oob_done(struct work_struct *work) | |||
| 53 | 51 | ||
| 54 | static void sas_phye_oob_error(struct work_struct *work) | 52 | static void sas_phye_oob_error(struct work_struct *work) |
| 55 | { | 53 | { |
| 56 | struct asd_sas_event *ev = | 54 | struct asd_sas_event *ev = to_asd_sas_event(work); |
| 57 | container_of(work, struct asd_sas_event, work); | ||
| 58 | struct asd_sas_phy *phy = ev->phy; | 55 | struct asd_sas_phy *phy = ev->phy; |
| 59 | struct sas_ha_struct *sas_ha = phy->ha; | 56 | struct sas_ha_struct *sas_ha = phy->ha; |
| 60 | struct asd_sas_port *port = phy->port; | 57 | struct asd_sas_port *port = phy->port; |
| @@ -85,8 +82,7 @@ static void sas_phye_oob_error(struct work_struct *work) | |||
| 85 | 82 | ||
| 86 | static void sas_phye_spinup_hold(struct work_struct *work) | 83 | static void sas_phye_spinup_hold(struct work_struct *work) |
| 87 | { | 84 | { |
| 88 | struct asd_sas_event *ev = | 85 | struct asd_sas_event *ev = to_asd_sas_event(work); |
| 89 | container_of(work, struct asd_sas_event, work); | ||
| 90 | struct asd_sas_phy *phy = ev->phy; | 86 | struct asd_sas_phy *phy = ev->phy; |
| 91 | struct sas_ha_struct *sas_ha = phy->ha; | 87 | struct sas_ha_struct *sas_ha = phy->ha; |
| 92 | struct sas_internal *i = | 88 | struct sas_internal *i = |
| @@ -127,14 +123,12 @@ int sas_register_phys(struct sas_ha_struct *sas_ha) | |||
| 127 | phy->error = 0; | 123 | phy->error = 0; |
| 128 | INIT_LIST_HEAD(&phy->port_phy_el); | 124 | INIT_LIST_HEAD(&phy->port_phy_el); |
| 129 | for (k = 0; k < PORT_NUM_EVENTS; k++) { | 125 | for (k = 0; k < PORT_NUM_EVENTS; k++) { |
| 130 | INIT_WORK(&phy->port_events[k].work, | 126 | INIT_SAS_WORK(&phy->port_events[k].work, sas_port_event_fns[k]); |
| 131 | sas_port_event_fns[k]); | ||
| 132 | phy->port_events[k].phy = phy; | 127 | phy->port_events[k].phy = phy; |
| 133 | } | 128 | } |
| 134 | 129 | ||
| 135 | for (k = 0; k < PHY_NUM_EVENTS; k++) { | 130 | for (k = 0; k < PHY_NUM_EVENTS; k++) { |
| 136 | INIT_WORK(&phy->phy_events[k].work, | 131 | INIT_SAS_WORK(&phy->phy_events[k].work, sas_phy_event_fns[k]); |
| 137 | sas_phy_event_fns[k]); | ||
| 138 | phy->phy_events[k].phy = phy; | 132 | phy->phy_events[k].phy = phy; |
| 139 | } | 133 | } |
| 140 | 134 | ||
| @@ -144,8 +138,7 @@ int sas_register_phys(struct sas_ha_struct *sas_ha) | |||
| 144 | spin_lock_init(&phy->sas_prim_lock); | 138 | spin_lock_init(&phy->sas_prim_lock); |
| 145 | phy->frame_rcvd_size = 0; | 139 | phy->frame_rcvd_size = 0; |
| 146 | 140 | ||
| 147 | phy->phy = sas_phy_alloc(&sas_ha->core.shost->shost_gendev, | 141 | phy->phy = sas_phy_alloc(&sas_ha->core.shost->shost_gendev, i); |
| 148 | i); | ||
| 149 | if (!phy->phy) | 142 | if (!phy->phy) |
| 150 | return -ENOMEM; | 143 | return -ENOMEM; |
| 151 | 144 | ||
diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c index eb19c016d500..e884a8c58a0c 100644 --- a/drivers/scsi/libsas/sas_port.c +++ b/drivers/scsi/libsas/sas_port.c | |||
| @@ -123,7 +123,7 @@ static void sas_form_port(struct asd_sas_phy *phy) | |||
| 123 | spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags); | 123 | spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags); |
| 124 | 124 | ||
| 125 | if (!port->port) { | 125 | if (!port->port) { |
| 126 | port->port = sas_port_alloc(phy->phy->dev.parent, phy->id); | 126 | port->port = sas_port_alloc(phy->phy->dev.parent, port->id); |
| 127 | BUG_ON(!port->port); | 127 | BUG_ON(!port->port); |
| 128 | sas_port_add(port->port); | 128 | sas_port_add(port->port); |
| 129 | } | 129 | } |
| @@ -208,8 +208,7 @@ void sas_deform_port(struct asd_sas_phy *phy, int gone) | |||
| 208 | 208 | ||
| 209 | void sas_porte_bytes_dmaed(struct work_struct *work) | 209 | void sas_porte_bytes_dmaed(struct work_struct *work) |
| 210 | { | 210 | { |
| 211 | struct asd_sas_event *ev = | 211 | struct asd_sas_event *ev = to_asd_sas_event(work); |
| 212 | container_of(work, struct asd_sas_event, work); | ||
| 213 | struct asd_sas_phy *phy = ev->phy; | 212 | struct asd_sas_phy *phy = ev->phy; |
| 214 | 213 | ||
| 215 | clear_bit(PORTE_BYTES_DMAED, &phy->port_events_pending); | 214 | clear_bit(PORTE_BYTES_DMAED, &phy->port_events_pending); |
| @@ -219,8 +218,7 @@ void sas_porte_bytes_dmaed(struct work_struct *work) | |||
| 219 | 218 | ||
| 220 | void sas_porte_broadcast_rcvd(struct work_struct *work) | 219 | void sas_porte_broadcast_rcvd(struct work_struct *work) |
| 221 | { | 220 | { |
| 222 | struct asd_sas_event *ev = | 221 | struct asd_sas_event *ev = to_asd_sas_event(work); |
| 223 | container_of(work, struct asd_sas_event, work); | ||
| 224 | struct asd_sas_phy *phy = ev->phy; | 222 | struct asd_sas_phy *phy = ev->phy; |
| 225 | unsigned long flags; | 223 | unsigned long flags; |
| 226 | u32 prim; | 224 | u32 prim; |
| @@ -237,8 +235,7 @@ void sas_porte_broadcast_rcvd(struct work_struct *work) | |||
| 237 | 235 | ||
| 238 | void sas_porte_link_reset_err(struct work_struct *work) | 236 | void sas_porte_link_reset_err(struct work_struct *work) |
| 239 | { | 237 | { |
| 240 | struct asd_sas_event *ev = | 238 | struct asd_sas_event *ev = to_asd_sas_event(work); |
| 241 | container_of(work, struct asd_sas_event, work); | ||
| 242 | struct asd_sas_phy *phy = ev->phy; | 239 | struct asd_sas_phy *phy = ev->phy; |
| 243 | 240 | ||
| 244 | clear_bit(PORTE_LINK_RESET_ERR, &phy->port_events_pending); | 241 | clear_bit(PORTE_LINK_RESET_ERR, &phy->port_events_pending); |
| @@ -248,8 +245,7 @@ void sas_porte_link_reset_err(struct work_struct *work) | |||
| 248 | 245 | ||
| 249 | void sas_porte_timer_event(struct work_struct *work) | 246 | void sas_porte_timer_event(struct work_struct *work) |
| 250 | { | 247 | { |
| 251 | struct asd_sas_event *ev = | 248 | struct asd_sas_event *ev = to_asd_sas_event(work); |
| 252 | container_of(work, struct asd_sas_event, work); | ||
| 253 | struct asd_sas_phy *phy = ev->phy; | 249 | struct asd_sas_phy *phy = ev->phy; |
| 254 | 250 | ||
| 255 | clear_bit(PORTE_TIMER_EVENT, &phy->port_events_pending); | 251 | clear_bit(PORTE_TIMER_EVENT, &phy->port_events_pending); |
| @@ -259,8 +255,7 @@ void sas_porte_timer_event(struct work_struct *work) | |||
| 259 | 255 | ||
| 260 | void sas_porte_hard_reset(struct work_struct *work) | 256 | void sas_porte_hard_reset(struct work_struct *work) |
| 261 | { | 257 | { |
| 262 | struct asd_sas_event *ev = | 258 | struct asd_sas_event *ev = to_asd_sas_event(work); |
| 263 | container_of(work, struct asd_sas_event, work); | ||
| 264 | struct asd_sas_phy *phy = ev->phy; | 259 | struct asd_sas_phy *phy = ev->phy; |
| 265 | 260 | ||
| 266 | clear_bit(PORTE_HARD_RESET, &phy->port_events_pending); | 261 | clear_bit(PORTE_HARD_RESET, &phy->port_events_pending); |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ead6405f3e51..5dfd7495d1a1 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
| @@ -1638,7 +1638,7 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost, | |||
| 1638 | request_fn_proc *request_fn) | 1638 | request_fn_proc *request_fn) |
| 1639 | { | 1639 | { |
| 1640 | struct request_queue *q; | 1640 | struct request_queue *q; |
| 1641 | struct device *dev = shost->shost_gendev.parent; | 1641 | struct device *dev = shost->dma_dev; |
| 1642 | 1642 | ||
| 1643 | q = blk_init_queue(request_fn, NULL); | 1643 | q = blk_init_queue(request_fn, NULL); |
| 1644 | if (!q) | 1644 | if (!q) |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 42378d637ffb..e926df7b54c9 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
| @@ -996,7 +996,8 @@ extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev, | |||
| 996 | extern void ata_sas_port_destroy(struct ata_port *); | 996 | extern void ata_sas_port_destroy(struct ata_port *); |
| 997 | extern struct ata_port *ata_sas_port_alloc(struct ata_host *, | 997 | extern struct ata_port *ata_sas_port_alloc(struct ata_host *, |
| 998 | struct ata_port_info *, struct Scsi_Host *); | 998 | struct ata_port_info *, struct Scsi_Host *); |
| 999 | extern int ata_sas_async_port_init(struct ata_port *); | 999 | extern void ata_sas_async_probe(struct ata_port *ap); |
| 1000 | extern int ata_sas_sync_probe(struct ata_port *ap); | ||
| 1000 | extern int ata_sas_port_init(struct ata_port *); | 1001 | extern int ata_sas_port_init(struct ata_port *); |
| 1001 | extern int ata_sas_port_start(struct ata_port *ap); | 1002 | extern int ata_sas_port_start(struct ata_port *ap); |
| 1002 | extern void ata_sas_port_stop(struct ata_port *ap); | 1003 | extern void ata_sas_port_stop(struct ata_port *ap); |
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 5f5ed1b8b41b..f4f1c96dca72 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h | |||
| @@ -217,11 +217,29 @@ struct domain_device { | |||
| 217 | struct kref kref; | 217 | struct kref kref; |
| 218 | }; | 218 | }; |
| 219 | 219 | ||
| 220 | struct sas_discovery_event { | 220 | struct sas_work { |
| 221 | struct list_head drain_node; | ||
| 221 | struct work_struct work; | 222 | struct work_struct work; |
| 223 | }; | ||
| 224 | |||
| 225 | static inline void INIT_SAS_WORK(struct sas_work *sw, void (*fn)(struct work_struct *)) | ||
| 226 | { | ||
| 227 | INIT_WORK(&sw->work, fn); | ||
| 228 | INIT_LIST_HEAD(&sw->drain_node); | ||
| 229 | } | ||
| 230 | |||
| 231 | struct sas_discovery_event { | ||
| 232 | struct sas_work work; | ||
| 222 | struct asd_sas_port *port; | 233 | struct asd_sas_port *port; |
| 223 | }; | 234 | }; |
| 224 | 235 | ||
| 236 | static inline struct sas_discovery_event *to_sas_discovery_event(struct work_struct *work) | ||
| 237 | { | ||
| 238 | struct sas_discovery_event *ev = container_of(work, typeof(*ev), work.work); | ||
| 239 | |||
| 240 | return ev; | ||
| 241 | } | ||
| 242 | |||
| 225 | struct sas_discovery { | 243 | struct sas_discovery { |
| 226 | struct sas_discovery_event disc_work[DISC_NUM_EVENTS]; | 244 | struct sas_discovery_event disc_work[DISC_NUM_EVENTS]; |
| 227 | unsigned long pending; | 245 | unsigned long pending; |
| @@ -244,7 +262,7 @@ struct asd_sas_port { | |||
| 244 | struct list_head destroy_list; | 262 | struct list_head destroy_list; |
| 245 | enum sas_linkrate linkrate; | 263 | enum sas_linkrate linkrate; |
| 246 | 264 | ||
| 247 | struct work_struct work; | 265 | struct sas_work work; |
| 248 | 266 | ||
| 249 | /* public: */ | 267 | /* public: */ |
| 250 | int id; | 268 | int id; |
| @@ -270,10 +288,17 @@ struct asd_sas_port { | |||
| 270 | }; | 288 | }; |
| 271 | 289 | ||
| 272 | struct asd_sas_event { | 290 | struct asd_sas_event { |
| 273 | struct work_struct work; | 291 | struct sas_work work; |
| 274 | struct asd_sas_phy *phy; | 292 | struct asd_sas_phy *phy; |
| 275 | }; | 293 | }; |
| 276 | 294 | ||
| 295 | static inline struct asd_sas_event *to_asd_sas_event(struct work_struct *work) | ||
| 296 | { | ||
| 297 | struct asd_sas_event *ev = container_of(work, typeof(*ev), work.work); | ||
| 298 | |||
| 299 | return ev; | ||
| 300 | } | ||
| 301 | |||
| 277 | /* The phy pretty much is controlled by the LLDD. | 302 | /* The phy pretty much is controlled by the LLDD. |
| 278 | * The class only reads those fields. | 303 | * The class only reads those fields. |
| 279 | */ | 304 | */ |
| @@ -333,10 +358,17 @@ struct scsi_core { | |||
| 333 | }; | 358 | }; |
| 334 | 359 | ||
| 335 | struct sas_ha_event { | 360 | struct sas_ha_event { |
| 336 | struct work_struct work; | 361 | struct sas_work work; |
| 337 | struct sas_ha_struct *ha; | 362 | struct sas_ha_struct *ha; |
| 338 | }; | 363 | }; |
| 339 | 364 | ||
| 365 | static inline struct sas_ha_event *to_sas_ha_event(struct work_struct *work) | ||
| 366 | { | ||
| 367 | struct sas_ha_event *ev = container_of(work, typeof(*ev), work.work); | ||
| 368 | |||
| 369 | return ev; | ||
| 370 | } | ||
| 371 | |||
| 340 | enum sas_ha_state { | 372 | enum sas_ha_state { |
| 341 | SAS_HA_REGISTERED, | 373 | SAS_HA_REGISTERED, |
| 342 | SAS_HA_DRAINING, | 374 | SAS_HA_DRAINING, |
diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h index cdccd2eb7b6c..77670e823ed8 100644 --- a/include/scsi/sas_ata.h +++ b/include/scsi/sas_ata.h | |||
| @@ -37,7 +37,7 @@ static inline int dev_is_sata(struct domain_device *dev) | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy); | 39 | int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy); |
| 40 | int sas_ata_init_host_and_port(struct domain_device *found_dev); | 40 | int sas_ata_init(struct domain_device *dev); |
| 41 | void sas_ata_task_abort(struct sas_task *task); | 41 | void sas_ata_task_abort(struct sas_task *task); |
| 42 | void sas_ata_strategy_handler(struct Scsi_Host *shost); | 42 | void sas_ata_strategy_handler(struct Scsi_Host *shost); |
| 43 | void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q, | 43 | void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q, |
| @@ -52,7 +52,7 @@ static inline int dev_is_sata(struct domain_device *dev) | |||
| 52 | { | 52 | { |
| 53 | return 0; | 53 | return 0; |
| 54 | } | 54 | } |
| 55 | static inline int sas_ata_init_host_and_port(struct domain_device *found_dev) | 55 | static inline int sas_ata_init(struct domain_device *dev) |
| 56 | { | 56 | { |
| 57 | return 0; | 57 | return 0; |
| 58 | } | 58 | } |
