[SCSI] scsi_transport_sas: remove local_attached flag
authorJames Bottomley <James.Bottomley@steeleye.com>
Fri, 25 Aug 2006 18:48:18 +0000 (13:48 -0500)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Mon, 28 Aug 2006 03:30:11 +0000 (22:30 -0500)
This flag denotes local attachment of the phy.  There are two problems
with it:

1) It's actually redundant ... you can get the same information simply
by seeing whether a host is the phys parent
2) we condition a lot of phy parameters on it on the false assumption
that we can only control local phys.  I'm wiring up phy resets in the
aic94xx now, and it will be able to reset non-local phys as well.

I fixed 2) by moving the local check into the reset and stats function
of the mptsas, since that seems to be the only HBA that can't
(currently) control non-local phys.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/message/fusion/mptsas.c
drivers/scsi/scsi_transport_sas.c
include/scsi/scsi_transport_sas.h

index dfdd1e4..b752a47 100644 (file)
@@ -852,6 +852,10 @@ static int mptsas_get_linkerrors(struct sas_phy *phy)
        dma_addr_t dma_handle;
        int error;
 
        dma_addr_t dma_handle;
        int error;
 
+       /* FIXME: only have link errors on local phys */
+       if (!scsi_is_sas_phy_local(phy))
+               return -EINVAL;
+
        hdr.PageVersion = MPI_SASPHY1_PAGEVERSION;
        hdr.ExtPageLength = 0;
        hdr.PageNumber = 1 /* page number 1*/;
        hdr.PageVersion = MPI_SASPHY1_PAGEVERSION;
        hdr.ExtPageLength = 0;
        hdr.PageNumber = 1 /* page number 1*/;
@@ -924,6 +928,10 @@ static int mptsas_phy_reset(struct sas_phy *phy, int hard_reset)
        unsigned long timeleft;
        int error = -ERESTARTSYS;
 
        unsigned long timeleft;
        int error = -ERESTARTSYS;
 
+       /* FIXME: fusion doesn't allow non-local phy reset */
+       if (!scsi_is_sas_phy_local(phy))
+               return -EINVAL;
+
        /* not implemented for expanders */
        if (phy->identify.target_port_protocols & SAS_PROTOCOL_SMP)
                return -ENXIO;
        /* not implemented for expanders */
        if (phy->identify.target_port_protocols & SAS_PROTOCOL_SMP)
                return -ENXIO;
@@ -1570,9 +1578,6 @@ static int mptsas_probe_one_phy(struct device *dev,
 
        if (!phy_info->phy) {
 
 
        if (!phy_info->phy) {
 
-               if (local)
-                       phy->local_attached = 1;
-
                error = sas_phy_add(phy);
                if (error) {
                        sas_phy_free(phy);
                error = sas_phy_add(phy);
                if (error) {
                        sas_phy_free(phy);
index 5a625c3..d518c12 100644 (file)
@@ -266,9 +266,6 @@ show_sas_phy_##field(struct class_device *cdev, char *buf)          \
        struct sas_internal *i = to_sas_internal(shost->transportt);    \
        int error;                                                      \
                                                                        \
        struct sas_internal *i = to_sas_internal(shost->transportt);    \
        int error;                                                      \
                                                                        \
-       if (!phy->local_attached)                                       \
-               return -EINVAL;                                         \
-                                                                       \
        error = i->f->get_linkerrors ? i->f->get_linkerrors(phy) : 0;   \
        if (error)                                                      \
                return error;                                           \
        error = i->f->get_linkerrors ? i->f->get_linkerrors(phy) : 0;   \
        if (error)                                                      \
                return error;                                           \
@@ -299,9 +296,6 @@ static ssize_t do_sas_phy_reset(struct class_device *cdev,
        struct sas_internal *i = to_sas_internal(shost->transportt);
        int error;
 
        struct sas_internal *i = to_sas_internal(shost->transportt);
        int error;
 
-       if (!phy->local_attached)
-               return -EINVAL;
-
        error = i->f->phy_reset(phy, hard_reset);
        if (error)
                return error;
        error = i->f->phy_reset(phy, hard_reset);
        if (error)
                return error;
@@ -849,7 +843,7 @@ show_sas_rphy_enclosure_identifier(struct class_device *cdev, char *buf)
         * Only devices behind an expander are supported, because the
         * enclosure identifier is a SMP feature.
         */
         * Only devices behind an expander are supported, because the
         * enclosure identifier is a SMP feature.
         */
-       if (phy->local_attached)
+       if (scsi_is_sas_phy_local(phy))
                return -EINVAL;
 
        error = i->f->get_enclosure_identifier(rphy, &identifier);
                return -EINVAL;
 
        error = i->f->get_enclosure_identifier(rphy, &identifier);
@@ -870,7 +864,7 @@ show_sas_rphy_bay_identifier(struct class_device *cdev, char *buf)
        struct sas_internal *i = to_sas_internal(shost->transportt);
        int val;
 
        struct sas_internal *i = to_sas_internal(shost->transportt);
        int val;
 
-       if (phy->local_attached)
+       if (scsi_is_sas_phy_local(phy))
                return -EINVAL;
 
        val = i->f->get_bay_identifier(rphy);
                return -EINVAL;
 
        val = i->f->get_bay_identifier(rphy);
index 6cc2314..eeb2200 100644 (file)
@@ -57,9 +57,6 @@ struct sas_phy {
        enum sas_linkrate       maximum_linkrate_hw;
        enum sas_linkrate       maximum_linkrate;
 
        enum sas_linkrate       maximum_linkrate_hw;
        enum sas_linkrate       maximum_linkrate;
 
-       /* internal state */
-       unsigned int            local_attached : 1;
-
        /* link error statistics */
        u32                     invalid_dword_count;
        u32                     running_disparity_error_count;
        /* link error statistics */
        u32                     invalid_dword_count;
        u32                     running_disparity_error_count;
@@ -196,4 +193,6 @@ scsi_is_sas_expander_device(struct device *dev)
                rphy->identify.device_type == SAS_EDGE_EXPANDER_DEVICE;
 }
 
                rphy->identify.device_type == SAS_EDGE_EXPANDER_DEVICE;
 }
 
+#define scsi_is_sas_phy_local(phy)     scsi_is_host_device((phy)->dev.parent)
+
 #endif /* SCSI_TRANSPORT_SAS_H */
 #endif /* SCSI_TRANSPORT_SAS_H */