Skip to contentSkip to conversation

isci updates for -next

PATCH In review Dan Williams 3 participants 8 messages Feb 10, 2012 – Feb 19, 2012

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

cover isci updates for -next

This is a resend of the T10 DIF and clock gating patches (checkpatch fixups), some debug updates, and a fix for driver load/unload testing.

This is based on branch of the pending libsas changes as it grew an entanglement with the phy reference counting and lldd_port reworks.

---

Andrzej Jakowski (1):
isci: improvements in driver unloading routine

Dan Williams (2):
isci: debug, provide state-enum-to-string conversions
isci: improve phy event warnings

Dave Jiang (1):
isci: T10 DIF support

Marcin Tomczak (1):
isci: enable clock gating

 drivers/scsi/isci/host.c                |    9 +
 drivers/scsi/isci/init.c                |   10 +
 drivers/scsi/isci/phy.c                 |  157 +++++++++++++---------
 drivers/scsi/isci/phy.h                 |  154 ++++++++--------------
 drivers/scsi/isci/port.c                |   46 ++++---
 drivers/scsi/isci/port.h                |  103 ++++++---------
 drivers/scsi/isci/registers.h           |   27 ++++
 drivers/scsi/isci/remote_device.c       |   50 ++++---
 drivers/scsi/isci/remote_device.h       |  205 +++++++++++++----------------
 drivers/scsi/isci/remote_node_context.c |   19 +--
 drivers/scsi/isci/remote_node_context.h |   97 ++++++--------
 drivers/scsi/isci/request.c             |  172 +++++++++++++++++++++++-
 drivers/scsi/isci/request.h             |  219 +++++++++++++------------------
 drivers/scsi/isci/scu_task_context.h    |   55 ++++++--
 14 files changed, 732 insertions(+), 591 deletions(-)
#1 lore raw

PATCH 1/5 isci: T10 DIF support

From: Dave Jiang <[email protected]>

This allows the controller to do WRITE_INSERT and READ_STRIP for SAS disks that support protection information. SAS disks must be formatted with protection information to use this feature via sg_format.

  sg3_utils-1.32 -- sg_format version 1.19 20110730
  sg_format usage:
  sg_format --format --verbose --pinfo /dev/sda
---
 drivers/scsi/isci/init.c             |    7 ++
 drivers/scsi/isci/request.c          |  147 ++++++++++++++++++++++++++++++++++
 drivers/scsi/isci/scu_task_context.h |   55 +++++++++----
 3 files changed, 193 insertions(+), 16 deletions(-)
drivers/scsi/isci/init.c +7 -0
index f682ca1..c3fe39b 100644
@@ -523,6 +523,13 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic
 			goto err_host_alloc;
 		}
 		pci_info->hosts[i] = h;
+
+		/* turn on DIF support */
+		scsi_host_set_prot(h->shost,
+				   SHOST_DIF_TYPE1_PROTECTION |
+				   SHOST_DIF_TYPE2_PROTECTION |
+				   SHOST_DIF_TYPE3_PROTECTION);
+		scsi_host_set_guard(h->shost, SHOST_DIX_GUARD_CRC);
 	}
 
 	err = isci_setup_interrupts(pdev);
drivers/scsi/isci/request.c +147 -0

171 lines not on this page · raw message

drivers/scsi/isci/scu_task_context.h +39 -16

87 lines not on this page · raw message

Acked-by on v1 1/5
#2 lore raw

Re: [PATCH v1 1/5] isci: T10 DIF support

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Dan" == Dan Williams <[email protected]> writes:

Dan> This allows the controller to do WRITE_INSERT and READ_STRIP for Dan> SAS disks that support protection information. SAS disks must be Dan> formatted with protection information to use this feature via Dan> sg_format.

I have not been able to locate a suitable machine for testing. But the way this patch hooks into SCSI looks correct.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#3 lore raw

PATCH 2/5 isci: enable clock gating

In reply to Dan Williams

From: Marcin Tomczak <[email protected]>

Enabling clock gating for power savings on entry to controller ready state. Disable SCU clock gating for power savings on exit from the controller ready state.

The gating is fully automated by silicon after setting the mode.

---
 drivers/scsi/isci/host.c      |    9 +++++++++
 drivers/scsi/isci/registers.h |   27 +++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 2 deletions(-)
drivers/scsi/isci/host.c +9 -0
index 36c443f..2b62af2 100644
@@ -1489,6 +1489,15 @@ sci_controller_set_interrupt_coalescence(struct isci_host *ihost,
 static void sci_controller_ready_state_enter(struct sci_base_state_machine *sm)
 {
 	struct isci_host *ihost = container_of(sm, typeof(*ihost), sm);
+	u32 val;
+
+	/* enable clock gating for power control of the scu unit */
+	val = readl(&ihost->smu_registers->clock_gating_control);
+	val &= ~(SMU_CGUCR_GEN_BIT(REGCLK_ENABLE) |
+		 SMU_CGUCR_GEN_BIT(TXCLK_ENABLE) |
+		 SMU_CGUCR_GEN_BIT(XCLK_ENABLE));
+	val |= SMU_CGUCR_GEN_BIT(IDLE_ENABLE);
+	writel(val, &ihost->smu_registers->clock_gating_control);
 
 	/* set the default interrupt coalescence number and timeout value. */
 	sci_controller_set_interrupt_coalescence(ihost, 0, 0);
drivers/scsi/isci/registers.h +25 -2
index eaa541a..f232f7e 100644
@@ -370,6 +370,27 @@ struct scu_iit_entry {
 		>> SMU_DEVICE_CONTEXT_CAPACITY_MAX_RNC_SHIFT \
 	)
 
+/* ************************************************************************** */
+#define SMU_CLOCK_GATING_CONTROL_IDLE_ENABLE_SHIFT    (0)
+#define SMU_CLOCK_GATING_CONTROL_IDLE_ENABLE_MASK     (0x00000001)
+#define SMU_CLOCK_GATING_CONTROL_XCLK_ENABLE_SHIFT    (1)
+#define SMU_CLOCK_GATING_CONTROL_XCLK_ENABLE_MASK     (0x00000002)
+#define SMU_CLOCK_GATING_CONTROL_TXCLK_ENABLE_SHIFT   (2)
+#define SMU_CLOCK_GATING_CONTROL_TXCLK_ENABLE_MASK    (0x00000004)
+#define SMU_CLOCK_GATING_CONTROL_REGCLK_ENABLE_SHIFT  (3)
+#define SMU_CLOCK_GATING_CONTROL_REGCLK_ENABLE_MASK   (0x00000008)
+#define SMU_CLOCK_GATING_CONTROL_IDLE_TIMEOUT_SHIFT   (16)
+#define SMU_CLOCK_GATING_CONTROL_IDLE_TIMEOUT_MASK    (0x000F0000)
+#define SMU_CLOCK_GATING_CONTROL_FORCE_IDLE_SHIFT     (31)
+#define SMU_CLOCK_GATING_CONTROL_FORCE_IDLE_MASK      (0x80000000)
+#define SMU_CLOCK_GATING_CONTROL_RESERVED_MASK        (0x7FF0FFF0)
+
+#define SMU_CGUCR_GEN_VAL(name, value) \
+	SCU_GEN_VALUE(SMU_CLOCK_GATING_CONTROL_##name, value)
+
+#define SMU_CGUCR_GEN_BIT(name) \
+	SCU_GEN_BIT(SMU_CLOCK_GATING_CONTROL_##name)
+
 /* -------------------------------------------------------------------------- */
 
 #define SMU_CONTROL_STATUS_TASK_CONTEXT_RANGE_ENABLE_SHIFT      (0)
@@ -992,8 +1013,10 @@ struct smu_registers {
 	u32 mmr_address_window;
 /* 0x00A4 SMDW */
 	u32 mmr_data_window;
-	u32 reserved_A8;
-	u32 reserved_AC;
+/* 0x00A8 CGUCR */
+	u32 clock_gating_control;
+/* 0x00AC CGUPC */
+	u32 clock_gating_performance;
 /* A whole bunch of reserved space */
 	u32 reserved_Bx[4];
 	u32 reserved_Cx[4];
#4 lore raw

PATCH 3/5 isci: debug, provide state-enum-to-string conversions

In reply to Dan Williams

Debugging the driver requires tracing the state transtions and tracing state names is less work than decoding numbers.

---
 drivers/scsi/isci/phy.c                 |   34 +++--
 drivers/scsi/isci/phy.h                 |  154 ++++++++--------------
 drivers/scsi/isci/port.c                |   46 ++++---
 drivers/scsi/isci/port.h                |  103 ++++++---------
 drivers/scsi/isci/remote_device.c       |   50 ++++---
 drivers/scsi/isci/remote_device.h       |  205 +++++++++++++----------------
 drivers/scsi/isci/remote_node_context.c |   19 +--
 drivers/scsi/isci/remote_node_context.h |   97 ++++++--------
 drivers/scsi/isci/request.c             |   25 ++--
 drivers/scsi/isci/request.h             |  219 +++++++++++++------------------
 10 files changed, 432 insertions(+), 520 deletions(-)
drivers/scsi/isci/phy.c +22 -12
index 8d412ca..87064f1 100644
@@ -59,6 +59,16 @@
 #include "scu_event_codes.h"
 #include "probe_roms.h"
 
+#undef C
+#define C(a) (#a)
+static const char *phy_state_name(enum sci_phy_states state)
+{
+	static const char * const strings[] = PHY_STATES;
+
+	return strings[state];
+}
+#undef C
+
 /* Maximum arbitration wait time in micro-seconds */
 #define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME  (700)
 
@@ -454,8 +464,8 @@ enum sci_status sci_phy_start(struct isci_phy *iphy)
 	enum sci_phy_states state = iphy->sm.current_state_id;
 
 	if (state != SCI_PHY_STOPPED) {
-		dev_dbg(sciphy_to_dev(iphy),
-			 "%s: in wrong state: %d\n", __func__, state);
+		dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
+			__func__, phy_state_name(state));
 		return SCI_FAILURE_INVALID_STATE;
 	}
 
@@ -480,8 +490,8 @@ enum sci_status sci_phy_stop(struct isci_phy *iphy)
 	case SCI_PHY_READY:
 		break;
 	default:
-		dev_dbg(sciphy_to_dev(iphy),
-			"%s: in wrong state: %d\n", __func__, state);
+		dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
+			__func__, phy_state_name(state));
 		return SCI_FAILURE_INVALID_STATE;
 	}
 
@@ -494,8 +504,8 @@ enum sci_status sci_phy_reset(struct isci_phy *iphy)
 	enum sci_phy_states state = iphy->sm.current_state_id;
 
 	if (state != SCI_PHY_READY) {
-		dev_dbg(sciphy_to_dev(iphy),
-			"%s: in wrong state: %d\n", __func__, state);
+		dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
+			__func__, phy_state_name(state));
 		return SCI_FAILURE_INVALID_STATE;
 	}
 
@@ -544,8 +554,8 @@ enum sci_status sci_phy_consume_power_handler(struct isci_phy *iphy)
 		return SCI_SUCCESS;
 	}
 	default:
-		dev_dbg(sciphy_to_dev(iphy),
-			"%s: in wrong state: %d\n", __func__, state);
+		dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
+			__func__, phy_state_name(state));
 		return SCI_FAILURE_INVALID_STATE;
 	}
 }
@@ -870,8 +880,8 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 		}
 		return SCI_SUCCESS;
 	default:
-		dev_dbg(sciphy_to_dev(iphy),
-			"%s: in wrong state: %d\n", __func__, state);
+		dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
+			__func__, phy_state_name(state));
 		return SCI_FAILURE_INVALID_STATE;
 	}
 }
@@ -964,8 +974,8 @@ enum sci_status sci_phy_frame_handler(struct isci_phy *iphy, u32 frame_index)
 		return result;
 	}
 	default:
-		dev_dbg(sciphy_to_dev(iphy),
-			"%s: in wrong state: %d\n", __func__, state);
+		dev_dbg(sciphy_to_dev(iphy), "%s: in wrong state: %s\n",
+			__func__, phy_state_name(state));
 		return SCI_FAILURE_INVALID_STATE;
 	}
 
drivers/scsi/isci/phy.h +59 -95

160 lines not on this page · raw message

drivers/scsi/isci/port.c +28 -18

106 lines not on this page · raw message

drivers/scsi/isci/port.h +40 -63

110 lines not on this page · raw message

drivers/scsi/isci/remote_device.c +30 -20

116 lines not on this page · raw message

drivers/scsi/isci/remote_device.h +92 -113

214 lines not on this page · raw message

drivers/scsi/isci/remote_node_context.c +8 -11
index 748e833..3a94634 100644
@@ -60,18 +60,15 @@
 #include "scu_event_codes.h"
 #include "scu_task_context.h"
 
+#undef C
+#define C(a) (#a)
+const char *rnc_state_name(enum scis_sds_remote_node_context_states state)
+{
+	static const char * const strings[] = RNC_STATES;
 
-/**
- *
- * @sci_rnc: The RNC for which the is posted request is being made.
- *
- * This method will return true if the RNC is not in the initial state.  In all
- * other states the RNC is considered active and this will return true. The
- * destroy request of the state machine drives the RNC back to the initial
- * state.  If the state machine changes then this routine will also have to be
- * changed. bool true if the state machine is not in the initial state false if
- * the state machine is in the initial state
- */
+	return strings[state];
+}
+#undef C
 
 /**
  *
drivers/scsi/isci/remote_node_context.h +43 -54

104 lines not on this page · raw message

drivers/scsi/isci/request.c +16 -9
index 1a39ce5..ab18ee0fe 100644
@@ -61,6 +61,16 @@
 #include "scu_event_codes.h"
 #include "sas.h"
 
+#undef C
+#define C(a) (#a)
+const char *req_state_name(enum sci_base_request_states state)
+{
+	static const char * const strings[] = REQUEST_STATES;
+
+	return strings[state];
+}
+#undef C
+
 static struct scu_sgl_element_pair *to_sgl_element_pair(struct isci_request *ireq,
 							int idx)
 {
@@ -910,7 +920,8 @@ enum sci_status sci_request_complete(struct isci_request *ireq)
 
 	state = ireq->sm.current_state_id;
 	if (WARN_ONCE(state != SCI_REQ_COMPLETED,
-		      "isci: request completion from wrong state (%d)\n", state))
+		      "isci: request completion from wrong state (%s)\n",
+		      req_state_name(state)))
 		return SCI_FAILURE_INVALID_STATE;
 
 	if (ireq->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX)
@@ -931,8 +942,8 @@ enum sci_status sci_io_request_event_handler(struct isci_request *ireq,
 	state = ireq->sm.current_state_id;
 
 	if (state != SCI_REQ_STP_PIO_DATA_IN) {
-		dev_warn(&ihost->pdev->dev, "%s: (%x) in wrong state %d\n",
-			 __func__, event_code, state);
+		dev_warn(&ihost->pdev->dev, "%s: (%x) in wrong state %s\n",
+			 __func__, event_code, req_state_name(state));
 
 		return SCI_FAILURE_INVALID_STATE;
 	}
@@ -2306,12 +2317,8 @@ sci_io_request_tc_completion(struct isci_request *ireq,
 		return atapi_data_tc_completion_handler(ireq, completion_code);
 
 	default:
-		dev_warn(&ihost->pdev->dev,
-			 "%s: SCIC IO Request given task completion "
-			 "notification %x while in wrong state %d\n",
-			 __func__,
-			 completion_code,
-			 state);
+		dev_warn(&ihost->pdev->dev, "%s: %x in wrong state %s\n",
+			 __func__, completion_code, req_state_name(state));
 		return SCI_FAILURE_INVALID_STATE;
 	}
 }
drivers/scsi/isci/request.h +94 -125

228 lines not on this page · raw message

maintainer
#5 lore raw

Re: [PATCH v1 3/5] isci: debug, provide state-enum-to-string conversions

Quoted 4 lines · Dan Williams

Debugging the driver requires tracing the state transtions and tracing state names is less work than decoding numbers.

I've got 1 now and 2 was sent as a previous patch, so I have it. This one doesn't apply:

patching file drivers/scsi/isci/phy.c
Hunk #2 succeeded at 456 (offset -8 lines). Hunk #3 succeeded at 482 (offset -8 lines). Hunk #4 succeeded at 496 (offset -8 lines). Hunk #5 succeeded at 546 (offset -8 lines). Hunk #6 succeeded at 872 (offset -8 lines). Hunk #7 succeeded at 966 (offset -8 lines). patching file drivers/scsi/isci/phy.h
Hunk #1 succeeded at 344 (offset 1 line). patching file drivers/scsi/isci/port.c
Hunk #1 FAILED at 60.
Hunk #2 succeeded at 1097 (offset 43 lines). Hunk #3 succeeded at 1172 (offset 43 lines). Hunk #4 succeeded at 1187 (offset 43 lines). Hunk #5 succeeded at 1282 (offset 43 lines). Hunk #6 succeeded at 1332 (offset 43 lines). Hunk #7 succeeded at 1375 (offset 43 lines). Hunk #8 succeeded at 1405 (offset 43 lines). Hunk #9 succeeded at 1425 (offset 43 lines). Hunk #10 succeeded at 1440 (offset 43 lines). 1 out of 10 hunks FAILED -- saving rejects to file drivers/scsi/isci/port.c.rej
patching file drivers/scsi/isci/port.h
Hunk #1 succeeded at 147 (offset 3 lines). patching file drivers/scsi/isci/remote_device.c patching file drivers/scsi/isci/remote_device.h Hunk #1 succeeded at 180 (offset 1 line). patching file drivers/scsi/isci/remote_node_context.c patching file drivers/scsi/isci/remote_node_context.h patching file drivers/scsi/isci/request.c Hunk #2 succeeded at 957 (offset 37 lines). Hunk #3 succeeded at 979 (offset 37 lines). Hunk #4 succeeded at 2466 (offset 149 lines). patching file drivers/scsi/isci/request.h Hunk #1 FAILED at 182.
1 out of 1 hunk FAILED -- saving rejects to file drivers/scsi/isci/request.h.rej

James

#6 lore raw

PATCH 4/5 isci: improve phy event warnings

In reply to Dan Williams

isci occasionally spews messages like:

isci 0000:03:00.0: sci_phy_event_handler: PHY starting substate machine received unexpected event_code b3940000

...which is not very helpful, since we don't know which controller, which phy, the exact state, or a decode of the event.

---
 drivers/scsi/isci/phy.c |  123 +++++++++++++++++++++++++++--------------------
 1 files changed, 71 insertions(+), 52 deletions(-)
drivers/scsi/isci/phy.c +71 -52
index 87064f1..fab3586 100644
@@ -77,12 +77,17 @@ enum sas_linkrate sci_phy_linkrate(struct isci_phy *iphy)
 	return iphy->max_negotiated_speed;
 }
 
-static struct device *sciphy_to_dev(struct isci_phy *iphy)
+static struct isci_host *phy_to_host(struct isci_phy *iphy)
 {
 	struct isci_phy *table = iphy - iphy->phy_index;
 	struct isci_host *ihost = container_of(table, typeof(*ihost), phys[0]);
 
-	return &ihost->pdev->dev;
+	return ihost;
+}
+
+static struct device *sciphy_to_dev(struct isci_phy *iphy)
+{
+	return &phy_to_host(iphy)->pdev->dev;
 }
 
 static enum sci_status
@@ -609,6 +614,60 @@ static void sci_phy_complete_link_training(struct isci_phy *iphy,
 	sci_change_state(&iphy->sm, next_state);
 }
 
+static const char *phy_event_name(u32 event_code)
+{
+	switch (scu_get_event_code(event_code)) {
+	case SCU_EVENT_PORT_SELECTOR_DETECTED:
+		return "port selector";
+	case SCU_EVENT_SENT_PORT_SELECTION:
+		return "port selection";
+	case SCU_EVENT_HARD_RESET_TRANSMITTED:
+		return "tx hard reset";
+	case SCU_EVENT_HARD_RESET_RECEIVED:
+		return "rx hard reset";
+	case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT:
+		return "identify timeout";
+	case SCU_EVENT_LINK_FAILURE:
+		return "link fail";
+	case SCU_EVENT_SATA_SPINUP_HOLD:
+		return "sata spinup hold";
+	case SCU_EVENT_SAS_15_SSC:
+	case SCU_EVENT_SAS_15:
+		return "sas 1.5";
+	case SCU_EVENT_SAS_30_SSC:
+	case SCU_EVENT_SAS_30:
+		return "sas 3.0";
+	case SCU_EVENT_SAS_60_SSC:
+	case SCU_EVENT_SAS_60:
+		return "sas 6.0";
+	case SCU_EVENT_SATA_15_SSC:
+	case SCU_EVENT_SATA_15:
+		return "sata 1.5";
+	case SCU_EVENT_SATA_30_SSC:
+	case SCU_EVENT_SATA_30:
+		return "sata 3.0";
+	case SCU_EVENT_SATA_60_SSC:
+	case SCU_EVENT_SATA_60:
+		return "sata 6.0";
+	case SCU_EVENT_SAS_PHY_DETECTED:
+		return "sas detect";
+	case SCU_EVENT_SATA_PHY_DETECTED:
+		return "sata detect";
+	default:
+		return "unknown";
+	}
+}
+
+#define phy_event_dbg(iphy, state, code) \
+	dev_dbg(sciphy_to_dev(iphy), "phy-%d:%d: %s event: %s (%x)\n", \
+		phy_to_host(iphy)->id, iphy->phy_index, \
+		phy_state_name(state), phy_event_name(code), code)
+
+#define phy_event_warn(iphy, state, code) \
+	dev_warn(sciphy_to_dev(iphy), "phy-%d:%d: %s event: %s (%x)\n", \
+		phy_to_host(iphy)->id, iphy->phy_index, \
+		phy_state_name(state), phy_event_name(code), code)
+
 enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 {
 	enum sci_phy_states state = iphy->sm.current_state_id;
@@ -625,11 +684,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 			iphy->is_in_link_training = true;
 			break;
 		default:
-			dev_dbg(sciphy_to_dev(iphy),
-				"%s: PHY starting substate machine received "
-				"unexpected event_code %x\n",
-				__func__,
-				event_code);
+			phy_event_dbg(iphy, state, event_code);
 			return SCI_FAILURE;
 		}
 		return SCI_SUCCESS;
@@ -666,11 +721,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 			sci_change_state(&iphy->sm, SCI_PHY_STARTING);
 			break;
 		default:
-			dev_warn(sciphy_to_dev(iphy),
-				 "%s: PHY starting substate machine received "
-				 "unexpected event_code %x\n",
-				 __func__, event_code);
-
+			phy_event_warn(iphy, state, event_code);
 			return SCI_FAILURE;
 			break;
 		}
@@ -695,10 +746,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 			sci_change_state(&iphy->sm, SCI_PHY_STARTING);
 			break;
 		default:
-			dev_warn(sciphy_to_dev(iphy),
-				 "%s: PHY starting substate machine received "
-				 "unexpected event_code %x\n",
-				 __func__, event_code);
+			phy_event_warn(iphy, state, event_code);
 			return SCI_FAILURE;
 		}
 		return SCI_SUCCESS;
@@ -709,11 +757,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 			sci_change_state(&iphy->sm, SCI_PHY_STARTING);
 			break;
 		default:
-			dev_warn(sciphy_to_dev(iphy),
-				"%s: PHY starting substate machine received unexpected "
-				"event_code %x\n",
-				__func__,
-				event_code);
+			phy_event_warn(iphy, state, event_code);
 			return SCI_FAILURE;
 		}
 		return SCI_SUCCESS;
@@ -737,11 +781,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 			break;
 
 		default:
-			dev_warn(sciphy_to_dev(iphy),
-				 "%s: PHY starting substate machine received "
-				 "unexpected event_code %x\n",
-				 __func__, event_code);
-
+			phy_event_warn(iphy, state, event_code);
 			return SCI_FAILURE;
 		}
 		return SCI_SUCCESS;
@@ -769,12 +809,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 			sci_phy_start_sas_link_training(iphy);
 			break;
 		default:
-			dev_warn(sciphy_to_dev(iphy),
-				 "%s: PHY starting substate machine received "
-				 "unexpected event_code %x\n",
-				 __func__,
-				 event_code);
-
+			phy_event_warn(iphy, state, event_code);
 			return SCI_FAILURE;
 		}
 		return SCI_SUCCESS;
@@ -811,11 +846,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 			sci_phy_start_sas_link_training(iphy);
 			break;
 		default:
-			dev_warn(sciphy_to_dev(iphy),
-				 "%s: PHY starting substate machine received "
-				 "unexpected event_code %x\n",
-				 __func__, event_code);
-
+			phy_event_warn(iphy, state, event_code);
 			return SCI_FAILURE;
 		}
 
@@ -833,12 +864,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 			break;
 
 		default:
-			dev_warn(sciphy_to_dev(iphy),
-				 "%s: PHY starting substate machine received "
-				 "unexpected event_code %x\n",
-				 __func__,
-				 event_code);
-
+			phy_event_warn(iphy, state, event_code);
 			return SCI_FAILURE;
 		}
 		return SCI_SUCCESS;
@@ -856,10 +882,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 				iphy->bcn_received_while_port_unassigned = true;
 			break;
 		default:
-			dev_warn(sciphy_to_dev(iphy),
-				 "%sP SCIC PHY 0x%p ready state machine received "
-				 "unexpected event_code %x\n",
-				 __func__, iphy, event_code);
+			phy_event_warn(iphy, state, event_code);
 			return SCI_FAILURE_INVALID_STATE;
 		}
 		return SCI_SUCCESS;
@@ -870,11 +893,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
 			sci_change_state(&iphy->sm, SCI_PHY_STARTING);
 			break;
 		default:
-			dev_warn(sciphy_to_dev(iphy),
-				 "%s: SCIC PHY 0x%p resetting state machine received "
-				 "unexpected event_code %x\n",
-				 __func__, iphy, event_code);
-
+			phy_event_warn(iphy, state, event_code);
 			return SCI_FAILURE_INVALID_STATE;
 			break;
 		}
#7 lore raw

PATCH 5/5 isci: improvements in driver unloading routine

In reply to Dan Williams

From: Andrzej Jakowski <[email protected]>

This patch fixes scenario where driver removal should be possible only when driver is in READY state. Also it removes redundant invocation of routine disabling SCU interrupts - this method is called somewhere else in driver deinitialization path.

---
 drivers/scsi/isci/init.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/scsi/isci/init.c +2 -1
index c3fe39b..7c7de43 100644
@@ -60,6 +60,7 @@
 #include <linux/efi.h>
 #include <asm/string.h>
 #include <scsi/scsi_host.h>
+#include "host.h"
 #include "isci.h"
 #include "task.h"
 #include "probe_roms.h"
@@ -553,9 +554,9 @@ static void __devexit isci_pci_remove(struct pci_dev *pdev)
 	int i;
 
 	for_each_isci_host(i, ihost, pdev) {
+		wait_for_start(ihost);
 		isci_unregister(ihost);
 		isci_host_deinit(ihost);
-		sci_controller_disable_interrupts(ihost);
 	}
 }