Skip to contentSkip to conversation

aic94xx: add transport class phy reset capability

PATCH In review James Bottomley 2 participants 3 messages Aug 25, 2006 – Aug 26, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aic94xx: add transport class phy reset capability

This wires in the transport class hard and link reset phy ability. It does local phy resets via the HBA callback functions, but it also does expander phy resets vi the SMP PHY_CONTROL messages.

James

drivers/scsi/libsas/sas_init.c +27 -0
Index: BUILD-2.6/drivers/scsi/libsas/sas_init.c
===================================================================
@@ -132,7 +132,34 @@
 	return 0;
 }
 
+static int sas_phy_reset(struct sas_phy *phy, int hard_reset)
+{
+	int ret;
+	enum phy_func reset_type;
+
+	if (hard_reset)
+		reset_type = PHY_FUNC_HARD_RESET;
+	else
+		reset_type = PHY_FUNC_LINK_RESET;
+
+	if (scsi_is_host_device(phy->dev.parent)) {
+		struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
+		struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost);
+		struct asd_sas_phy *asd_phy = sas_ha->sas_phy[phy->number];
+		struct sas_internal *i =
+			to_sas_internal(sas_ha->core.shost->transportt);
+
+		ret = i->dft->lldd_control_phy(asd_phy, reset_type);
+	} else {
+		struct sas_rphy *rphy = dev_to_rphy(phy->dev.parent);
+		struct domain_device *ddev = sas_find_dev_by_rphy(rphy);
+		ret = sas_smp_phy_control(ddev, phy->number, reset_type);
+	}
+	return ret;
+}
+
 static struct sas_function_template sft = {
+	.phy_reset = sas_phy_reset,
 };
 
 extern struct scsi_transport_template *
drivers/scsi/libsas/sas_expander.c +5 -7
Index: BUILD-2.6/drivers/scsi/libsas/sas_expander.c
===================================================================
@@ -36,8 +36,6 @@
 static int sas_configure_phy(struct domain_device *dev, int phy_id,
 			     u8 *sas_addr, int include);
 static int sas_disable_routing(struct domain_device *dev,  u8 *sas_addr);
-static int smp_phy_control(struct domain_device *dev, int phy_id,
-			   enum phy_func phy_func);
 
 #if 0
 /* FIXME: smp needs to migrate into the sas class */
@@ -242,7 +240,7 @@
 			break;
 		/* In order to generate the dev to host FIS, we
 		 * send a link reset to the expander port */
-		smp_phy_control(dev, single, PHY_FUNC_LINK_RESET);
+		sas_smp_phy_control(dev, single, PHY_FUNC_LINK_RESET);
 		/* Wait for the reset to trigger the negotiation */
 		msleep(500);
 	}
@@ -436,8 +434,8 @@
 #define PC_REQ_SIZE  44
 #define PC_RESP_SIZE 8
 
-static int smp_phy_control(struct domain_device *dev, int phy_id,
-			   enum phy_func phy_func)
+int sas_smp_phy_control(struct domain_device *dev, int phy_id,
+			enum phy_func phy_func)
 {
 	u8 *pc_req;
 	u8 *pc_resp;
@@ -469,7 +467,7 @@
 	struct expander_device *ex = &dev->ex_dev;
 	struct ex_phy *phy = &ex->ex_phy[phy_id];
 
-	smp_phy_control(dev, phy_id, PHY_FUNC_DISABLE);
+	sas_smp_phy_control(dev, phy_id, PHY_FUNC_DISABLE);
 	phy->linkrate = PHY_DISABLED;
 }
 
@@ -768,7 +766,7 @@
 
 	/* Phy state */
 	if (ex_phy->linkrate == PHY_SPINUP_HOLD) {
-		if (!smp_phy_control(dev, phy_id, PHY_FUNC_LINK_RESET))
+		if (!sas_smp_phy_control(dev, phy_id, PHY_FUNC_LINK_RESET))
 			res = sas_ex_phy_discover(dev, phy_id);
 		if (res)
 			return res;
drivers/scsi/libsas/sas_internal.h +4 -0
Index: BUILD-2.6/drivers/scsi/libsas/sas_internal.h
===================================================================
@@ -68,6 +68,10 @@
 int sas_notify_lldd_dev_found(struct domain_device *);
 void sas_notify_lldd_dev_gone(struct domain_device *);
 
+int sas_smp_phy_control(struct domain_device *dev, int phy_id,
+			enum phy_func phy_func);
+
+struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy);
 
 void sas_hae_reset(void *);
 
drivers/scsi/libsas/sas_scsi_host.c +11 -5
Index: BUILD-2.6/drivers/scsi/libsas/sas_scsi_host.c
===================================================================
@@ -813,10 +813,9 @@
 	.port_ops = &sas_sata_ops
 };
 
-static inline struct domain_device *sas_find_dev(struct scsi_target *starget)
+struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy)
 {
-	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
-	struct sas_rphy *rphy = dev_to_rphy(starget->dev.parent);
+	struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent);
 	struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
 	struct domain_device *found_dev = NULL;
 	int i;
@@ -842,11 +841,18 @@
 	return found_dev;
 }
 
+static inline struct domain_device *sas_find_target(struct scsi_target *starget)
+{
+	struct sas_rphy *rphy = dev_to_rphy(starget->dev.parent);
+
+	return sas_find_dev_by_rphy(rphy);
+}
+
 int sas_target_alloc(struct scsi_target *starget)
 {
 	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
 	struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
-	struct domain_device *found_dev = sas_find_dev(starget);
+	struct domain_device *found_dev = sas_find_target(starget);
 
 	if (!found_dev)
 		return -ENODEV;
@@ -1098,7 +1104,7 @@
 
 void sas_target_destroy(struct scsi_target *starget)
 {
-	struct domain_device *found_dev = sas_find_dev(starget);
+	struct domain_device *found_dev = sas_find_target(starget);
 
 	if (!found_dev)
 		return;
#1 lore raw
Quoted 3 lines · James Bottomley

This wires in the transport class hard and link reset phy ability. It does local phy resets via the HBA callback functions, but it also does expander phy resets vi the SMP PHY_CONTROL messages.

James,
The ability to disable a phy (on a HBA or on an expander) is also a very useful capability. Does the sas_transport give us that capability?

There is a way to effectively disable a phy on a SAS disk as well: use SEND DIAGNOSTIC to send the SAS protocol specific diagnostic page to put the disk phy in CJTPAT (jitter pattern) generation mode. However unless another phy is accessible on that disk to clear that state, a power cycle is needed to re-enable a phy in jitter pattern generation mode.

Doug Gilbert

#2 lore raw
Quoted 3 lines · Douglas Gilbert

The ability to disable a phy (on a HBA or on an expander) is also a very useful capability. Does the sas_transport give us that capability?

It could ... It's just another parameter to SMP_PHY_CONTROL. However, I'm just wiring up the existing functions ... feel free to send patches if you want new function.

Quoted 7 lines

There is a way to effectively disable a phy on a SAS disk as well: use SEND DIAGNOSTIC to send the SAS protocol specific diagnostic page to put the disk phy in CJTPAT (jitter pattern) generation mode. However unless another phy is accessible on that disk to clear that state, a power cycle is needed to re-enable a phy in jitter pattern generation mode.

That doesn't sound terribly safe ... most SAS cages only connect up one of the internal ports, so effectively there's no way to terminate this for most SAS setups.

James