瀏覽代碼

[SCSI] sas: add flag for locally attached PHYs

Add a flag to mark a PHY as attached to the HBA as opposed to beeing on
an expander.  This is needed because various features are only supported
on those.  This is a crude hack, the proper fix would be to use
different classes for host-attached vs expander phys.  I'm looking into
that.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Christoph Hellwig 19 年之前
父節點
當前提交
ac01bbbd3b
共有 3 個文件被更改,包括 13 次插入3 次删除
  1. 7 3
      drivers/message/fusion/mptsas.c
  2. 3 0
      drivers/scsi/scsi_transport_sas.c
  3. 3 0
      include/scsi/scsi_transport_sas.h

+ 7 - 3
drivers/message/fusion/mptsas.c

@@ -760,7 +760,7 @@ mptsas_parse_device_info(struct sas_identify *identify,
 }
 }
 
 
 static int mptsas_probe_one_phy(struct device *dev,
 static int mptsas_probe_one_phy(struct device *dev,
-		struct mptsas_phyinfo *phy_info, int index)
+		struct mptsas_phyinfo *phy_info, int index, int local)
 {
 {
 	struct sas_phy *port;
 	struct sas_phy *port;
 	int error;
 	int error;
@@ -853,6 +853,9 @@ static int mptsas_probe_one_phy(struct device *dev,
 		break;
 		break;
 	}
 	}
 
 
+	if (local)
+		port->local_attached = 1;
+
 	error = sas_phy_add(port);
 	error = sas_phy_add(port);
 	if (error) {
 	if (error) {
 		sas_phy_free(port);
 		sas_phy_free(port);
@@ -918,7 +921,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc, int *index)
 		}
 		}
 
 
 		mptsas_probe_one_phy(&ioc->sh->shost_gendev,
 		mptsas_probe_one_phy(&ioc->sh->shost_gendev,
-				     &port_info->phy_info[i], *index);
+				     &port_info->phy_info[i], *index, 1);
 		(*index)++;
 		(*index)++;
 	}
 	}
 
 
@@ -989,7 +992,8 @@ mptsas_probe_expander_phys(MPT_ADAPTER *ioc, u32 *handle, int *index)
 			}
 			}
 		}
 		}
 
 
-		mptsas_probe_one_phy(parent, &port_info->phy_info[i], *index);
+		mptsas_probe_one_phy(parent, &port_info->phy_info[i],
+				     *index, 0);
 		(*index)++;
 		(*index)++;
 	}
 	}
 
 

+ 3 - 0
drivers/scsi/scsi_transport_sas.c

@@ -266,6 +266,9 @@ show_sas_phy_##field(struct class_device *cdev, char *buf)		\
 	struct sas_internal *i = to_sas_internal(shost->transportt);	\
 	struct sas_internal *i = to_sas_internal(shost->transportt);	\
 	int error;							\
 	int error;							\
 									\
 									\
+	if (!phy->local_attached)					\
+		return -EINVAL;						\
+									\
 	error = i->f->get_linkerrors(phy);				\
 	error = i->f->get_linkerrors(phy);				\
 	if (error)							\
 	if (error)							\
 		return error;						\
 		return error;						\

+ 3 - 0
include/scsi/scsi_transport_sas.h

@@ -56,6 +56,9 @@ struct sas_phy {
 	enum sas_linkrate	maximum_linkrate;
 	enum sas_linkrate	maximum_linkrate;
 	u8			port_identifier;
 	u8			port_identifier;
 
 
+	/* internal state */
+	unsigned int		local_attached : 1;
+
 	/* link error statistics */
 	/* link error statistics */
 	u32			invalid_dword_count;
 	u32			invalid_dword_count;
 	u32			running_disparity_error_count;
 	u32			running_disparity_error_count;