diff options
author | Dan Williams <dan.j.williams@intel.com> | 2012-01-04 02:26:08 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-02-29 16:05:05 -0500 |
commit | c132f692085ac624d7c8123df781846c8dcb3166 (patch) | |
tree | c9009fcb9112812544f54efc6c134021dffb6545 /drivers/scsi/isci/port.c | |
parent | cb48d672bfeb4147f3e20d5b16fa2eb6377231e2 (diff) |
[SCSI] isci: kill iphy->isci_port lookups
This field is a holdover from the OS abstraction conversion. The stable
phy to port lookups are done via iphy->ownining_port under scic_lock.
After this conversion to use port->lldd_port the only volatile lookup is
the initial lookup in isci_port_formed(). After that point any lookup
via a successfully notified domain_device is guaranteed to be valid
until the domain_device is destroyed.
Delete ->start_complete as it is only set once and is set as a
consequence of the port going link up, by definition of getting a port
formed event the port is "ready".
While we are correcting port lookups also move the asd_sas_port table
out from under the isci_port. This is to preclude any temptation to use
container_of() to convert an asd_sas_port to an isci_port, the
association is dynamic and under libsas control.
Tested-by: Maciej Trela <maciej.trela@intel.com>
[dmilburn@redhat.com: fix i686 compile error]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/isci/port.c')
-rw-r--r-- | drivers/scsi/isci/port.c | 84 |
1 files changed, 61 insertions, 23 deletions
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c index 7c6ac58a5c4c..a28c9e6e2806 100644 --- a/drivers/scsi/isci/port.c +++ b/drivers/scsi/isci/port.c | |||
@@ -60,6 +60,21 @@ | |||
60 | #define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000) | 60 | #define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000) |
61 | #define SCU_DUMMY_INDEX (0xFFFF) | 61 | #define SCU_DUMMY_INDEX (0xFFFF) |
62 | 62 | ||
63 | static struct device *sciport_to_dev(struct isci_port *iport) | ||
64 | { | ||
65 | int i = iport->physical_port_index; | ||
66 | struct isci_port *table; | ||
67 | struct isci_host *ihost; | ||
68 | |||
69 | if (i == SCIC_SDS_DUMMY_PORT) | ||
70 | i = SCI_MAX_PORTS+1; | ||
71 | |||
72 | table = iport - i; | ||
73 | ihost = container_of(table, typeof(*ihost), ports[0]); | ||
74 | |||
75 | return &ihost->pdev->dev; | ||
76 | } | ||
77 | |||
63 | static void isci_port_change_state(struct isci_port *iport, enum isci_status status) | 78 | static void isci_port_change_state(struct isci_port *iport, enum isci_status status) |
64 | { | 79 | { |
65 | unsigned long flags; | 80 | unsigned long flags; |
@@ -165,17 +180,13 @@ static void isci_port_link_up(struct isci_host *isci_host, | |||
165 | struct sci_port_properties properties; | 180 | struct sci_port_properties properties; |
166 | unsigned long success = true; | 181 | unsigned long success = true; |
167 | 182 | ||
168 | BUG_ON(iphy->isci_port != NULL); | ||
169 | |||
170 | iphy->isci_port = iport; | ||
171 | |||
172 | dev_dbg(&isci_host->pdev->dev, | 183 | dev_dbg(&isci_host->pdev->dev, |
173 | "%s: isci_port = %p\n", | 184 | "%s: isci_port = %p\n", |
174 | __func__, iport); | 185 | __func__, iport); |
175 | 186 | ||
176 | spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags); | 187 | spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags); |
177 | 188 | ||
178 | isci_port_change_state(iphy->isci_port, isci_starting); | 189 | isci_port_change_state(iport, isci_starting); |
179 | 190 | ||
180 | sci_port_get_properties(iport, &properties); | 191 | sci_port_get_properties(iport, &properties); |
181 | 192 | ||
@@ -269,8 +280,6 @@ static void isci_port_link_down(struct isci_host *isci_host, | |||
269 | isci_host->sas_ha.notify_phy_event(&isci_phy->sas_phy, | 280 | isci_host->sas_ha.notify_phy_event(&isci_phy->sas_phy, |
270 | PHYE_LOSS_OF_SIGNAL); | 281 | PHYE_LOSS_OF_SIGNAL); |
271 | 282 | ||
272 | isci_phy->isci_port = NULL; | ||
273 | |||
274 | dev_dbg(&isci_host->pdev->dev, | 283 | dev_dbg(&isci_host->pdev->dev, |
275 | "%s: isci_port = %p - Done\n", __func__, isci_port); | 284 | "%s: isci_port = %p - Done\n", __func__, isci_port); |
276 | } | 285 | } |
@@ -288,7 +297,6 @@ static void isci_port_ready(struct isci_host *isci_host, struct isci_port *isci_ | |||
288 | dev_dbg(&isci_host->pdev->dev, | 297 | dev_dbg(&isci_host->pdev->dev, |
289 | "%s: isci_port = %p\n", __func__, isci_port); | 298 | "%s: isci_port = %p\n", __func__, isci_port); |
290 | 299 | ||
291 | complete_all(&isci_port->start_complete); | ||
292 | isci_port_change_state(isci_port, isci_ready); | 300 | isci_port_change_state(isci_port, isci_ready); |
293 | return; | 301 | return; |
294 | } | 302 | } |
@@ -1645,7 +1653,6 @@ void isci_port_init(struct isci_port *iport, struct isci_host *ihost, int index) | |||
1645 | INIT_LIST_HEAD(&iport->remote_dev_list); | 1653 | INIT_LIST_HEAD(&iport->remote_dev_list); |
1646 | INIT_LIST_HEAD(&iport->domain_dev_list); | 1654 | INIT_LIST_HEAD(&iport->domain_dev_list); |
1647 | spin_lock_init(&iport->state_lock); | 1655 | spin_lock_init(&iport->state_lock); |
1648 | init_completion(&iport->start_complete); | ||
1649 | iport->isci_host = ihost; | 1656 | iport->isci_host = ihost; |
1650 | isci_port_change_state(iport, isci_freed); | 1657 | isci_port_change_state(iport, isci_freed); |
1651 | } | 1658 | } |
@@ -1726,24 +1733,55 @@ int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *ipor | |||
1726 | return ret; | 1733 | return ret; |
1727 | } | 1734 | } |
1728 | 1735 | ||
1729 | /** | ||
1730 | * isci_port_deformed() - This function is called by libsas when a port becomes | ||
1731 | * inactive. | ||
1732 | * @phy: This parameter specifies the libsas phy with the inactive port. | ||
1733 | * | ||
1734 | */ | ||
1735 | void isci_port_deformed(struct asd_sas_phy *phy) | 1736 | void isci_port_deformed(struct asd_sas_phy *phy) |
1736 | { | 1737 | { |
1737 | pr_debug("%s: sas_phy = %p\n", __func__, phy); | 1738 | struct isci_host *ihost = phy->ha->lldd_ha; |
1739 | struct isci_port *iport = phy->port->lldd_port; | ||
1740 | unsigned long flags; | ||
1741 | int i; | ||
1742 | |||
1743 | /* we got a port notification on a port that was subsequently | ||
1744 | * torn down and libsas is just now catching up | ||
1745 | */ | ||
1746 | if (!iport) | ||
1747 | return; | ||
1748 | |||
1749 | spin_lock_irqsave(&ihost->scic_lock, flags); | ||
1750 | for (i = 0; i < SCI_MAX_PHYS; i++) { | ||
1751 | if (iport->active_phy_mask & 1 << i) | ||
1752 | break; | ||
1753 | } | ||
1754 | spin_unlock_irqrestore(&ihost->scic_lock, flags); | ||
1755 | |||
1756 | if (i >= SCI_MAX_PHYS) | ||
1757 | dev_dbg(&ihost->pdev->dev, "%s: port: %ld\n", | ||
1758 | __func__, (long) (iport - &ihost->ports[0])); | ||
1738 | } | 1759 | } |
1739 | 1760 | ||
1740 | /** | ||
1741 | * isci_port_formed() - This function is called by libsas when a port becomes | ||
1742 | * active. | ||
1743 | * @phy: This parameter specifies the libsas phy with the active port. | ||
1744 | * | ||
1745 | */ | ||
1746 | void isci_port_formed(struct asd_sas_phy *phy) | 1761 | void isci_port_formed(struct asd_sas_phy *phy) |
1747 | { | 1762 | { |
1748 | pr_debug("%s: sas_phy = %p, sas_port = %p\n", __func__, phy, phy->port); | 1763 | struct isci_host *ihost = phy->ha->lldd_ha; |
1764 | struct isci_phy *iphy = to_iphy(phy); | ||
1765 | struct asd_sas_port *port = phy->port; | ||
1766 | struct isci_port *iport; | ||
1767 | unsigned long flags; | ||
1768 | int i; | ||
1769 | |||
1770 | /* initial ports are formed as the driver is still initializing, | ||
1771 | * wait for that process to complete | ||
1772 | */ | ||
1773 | wait_for_start(ihost); | ||
1774 | |||
1775 | spin_lock_irqsave(&ihost->scic_lock, flags); | ||
1776 | for (i = 0; i < SCI_MAX_PORTS; i++) { | ||
1777 | iport = &ihost->ports[i]; | ||
1778 | if (iport->active_phy_mask & 1 << iphy->phy_index) | ||
1779 | break; | ||
1780 | } | ||
1781 | spin_unlock_irqrestore(&ihost->scic_lock, flags); | ||
1782 | |||
1783 | if (i >= SCI_MAX_PORTS) | ||
1784 | iport = NULL; | ||
1785 | |||
1786 | port->lldd_port = iport; | ||
1749 | } | 1787 | } |