[SCSI] isci: remove IDEV_EH hack to disable "discovery-time" ata resets
[pandora-kernel.git] / drivers / scsi / isci / remote_device.c
index b207cd3..934d21e 100644 (file)
@@ -53,6 +53,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include <scsi/sas.h>
+#include <linux/bitops.h>
 #include "isci.h"
 #include "port.h"
 #include "remote_device.h"
@@ -1101,6 +1102,7 @@ static enum sci_status sci_remote_device_da_construct(struct isci_port *iport,
                                                       struct isci_remote_device *idev)
 {
        enum sci_status status;
+       struct sci_port_properties properties;
        struct domain_device *dev = idev->domain_dev;
 
        sci_remote_device_construct(iport, idev);
@@ -1110,6 +1112,11 @@ static enum sci_status sci_remote_device_da_construct(struct isci_port *iport,
         * entries will be needed to store the remote node.
         */
        idev->is_direct_attached = true;
+
+       sci_port_get_properties(iport, &properties);
+       /* Get accurate port width from port's phy mask for a DA device. */
+       idev->device_port_width = hweight32(properties.phy_mask);
+
        status = sci_controller_allocate_remote_node_context(iport->owning_controller,
                                                                  idev,
                                                                  &idev->rnc.remote_node_index);
@@ -1125,9 +1132,6 @@ static enum sci_status sci_remote_device_da_construct(struct isci_port *iport,
 
        idev->connection_rate = sci_port_get_max_allowed_speed(iport);
 
-       /* / @todo Should I assign the port width by reading all of the phys on the port? */
-       idev->device_port_width = 1;
-
        return SCI_SUCCESS;
 }
 
@@ -1304,7 +1308,6 @@ void isci_remote_device_release(struct kref *kref)
        clear_bit(IDEV_STOP_PENDING, &idev->flags);
        clear_bit(IDEV_IO_READY, &idev->flags);
        clear_bit(IDEV_GONE, &idev->flags);
-       clear_bit(IDEV_EH, &idev->flags);
        smp_mb__before_clear_bit();
        clear_bit(IDEV_ALLOCATED, &idev->flags);
        wake_up(&ihost->eventq);
@@ -1377,34 +1380,17 @@ void isci_remote_device_gone(struct domain_device *dev)
  *
  * status, zero indicates success.
  */
-int isci_remote_device_found(struct domain_device *domain_dev)
+int isci_remote_device_found(struct domain_device *dev)
 {
-       struct isci_host *isci_host = dev_to_ihost(domain_dev);
-       struct isci_port *isci_port;
-       struct isci_phy *isci_phy;
-       struct asd_sas_port *sas_port;
-       struct asd_sas_phy *sas_phy;
+       struct isci_host *isci_host = dev_to_ihost(dev);
+       struct isci_port *isci_port = dev->port->lldd_port;
        struct isci_remote_device *isci_device;
        enum sci_status status;
 
        dev_dbg(&isci_host->pdev->dev,
-               "%s: domain_device = %p\n", __func__, domain_dev);
-
-       wait_for_start(isci_host);
-
-       sas_port = domain_dev->port;
-       sas_phy = list_first_entry(&sas_port->phy_list, struct asd_sas_phy,
-                                  port_phy_el);
-       isci_phy = to_iphy(sas_phy);
-       isci_port = isci_phy->isci_port;
-
-       /* we are being called for a device on this port,
-        * so it has to come up eventually
-        */
-       wait_for_completion(&isci_port->start_complete);
+               "%s: domain_device = %p\n", __func__, dev);
 
-       if ((isci_stopping == isci_port_get_state(isci_port)) ||
-           (isci_stopped == isci_port_get_state(isci_port)))
+       if (!isci_port)
                return -ENODEV;
 
        isci_device = isci_remote_device_alloc(isci_host, isci_port);
@@ -1415,7 +1401,7 @@ int isci_remote_device_found(struct domain_device *domain_dev)
        INIT_LIST_HEAD(&isci_device->node);
 
        spin_lock_irq(&isci_host->scic_lock);
-       isci_device->domain_dev = domain_dev;
+       isci_device->domain_dev = dev;
        isci_device->isci_port = isci_port;
        list_add_tail(&isci_device->node, &isci_port->remote_dev_list);
 
@@ -1428,7 +1414,7 @@ int isci_remote_device_found(struct domain_device *domain_dev)
 
        if (status == SCI_SUCCESS) {
                /* device came up, advertise it to the world */
-               domain_dev->lldd_dev = isci_device;
+               dev->lldd_dev = isci_device;
        } else
                isci_put_device(isci_device);
        spin_unlock_irq(&isci_host->scic_lock);