All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] pci: New PCI-E reset API
@ 2007-02-19 14:47 Brian King
  2007-02-19 14:47   ` Brian King
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Brian King @ 2007-02-19 14:47 UTC (permalink / raw)
  To: greg; +Cc: James.Bottomley, linux-scsi, linuxppc-dev, paulus, brking, linux-pci


Adds a new API which can be used to issue various types
of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
This is needed for an ipr PCI-E adapter which does not properly
implement BIST. Running BIST on this adapter results in PCI-E
errors. The only reliable reset mechanism that exists on this
hardware is PCI Fundamental reset (warm reset). Since driving
this type of reset is architecture unique, this provides the
necessary hooks for architectures to add this support.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 linux-2.6-bjking1/drivers/pci/pci.c   |   29 +++++++++++++++++++++++++++++
 linux-2.6-bjking1/include/linux/pci.h |   14 ++++++++++++++
 2 files changed, 43 insertions(+)

diff -puN drivers/pci/pci.c~pci_pci_reset_api drivers/pci/pci.c
--- linux-2.6/drivers/pci/pci.c~pci_pci_reset_api	2007-02-16 10:10:30.000000000 -0600
+++ linux-2.6-bjking1/drivers/pci/pci.c	2007-02-16 10:10:30.000000000 -0600
@@ -893,6 +893,34 @@ pci_disable_device(struct pci_dev *dev)
 }
 
 /**
+ * pcibios_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI-E reset state for the device. This is the default
+ * implementation. Architecture implementations can override this.
+ */
+int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
+							enum pcie_reset_state state)
+{
+	return -EINVAL;
+}
+
+/**
+ * pci_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI reset state for the device.
+ */
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
+{
+	return pcibios_set_pcie_reset_state(dev, state);
+}
+
+/**
  * pci_enable_wake - enable device to generate PME# when suspended
  * @dev: - PCI device to operate on
  * @state: - Current state of device.
@@ -1374,4 +1402,5 @@ EXPORT_SYMBOL(pci_set_power_state);
 EXPORT_SYMBOL(pci_save_state);
 EXPORT_SYMBOL(pci_restore_state);
 EXPORT_SYMBOL(pci_enable_wake);
+EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
 
diff -puN include/linux/pci.h~pci_pci_reset_api include/linux/pci.h
--- linux-2.6/include/linux/pci.h~pci_pci_reset_api	2007-02-16 10:10:30.000000000 -0600
+++ linux-2.6-bjking1/include/linux/pci.h	2007-02-16 10:10:30.000000000 -0600
@@ -96,6 +96,19 @@ enum pci_channel_state {
 	pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
 };
 
+typedef unsigned int __bitwise pcie_reset_state_t;
+
+enum pcie_reset_state {
+	/* Reset is NOT asserted (Use to deassert reset) */
+	pci_reset_normal = (__force pcie_reset_state_t) 1,
+
+	/* Use #PERST to reset PCI-E device */
+	pci_reset_pcie_warm_reset = (__force pcie_reset_state_t) 2,
+
+	/* Use PCI-E Hot Reset to reset device */
+	pci_reset_pcie_hot_reset = (__force pcie_reset_state_t) 3
+};
+
 typedef unsigned short __bitwise pci_bus_flags_t;
 enum pci_bus_flags {
 	PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
@@ -539,6 +552,7 @@ static inline int pci_is_managed(struct 
 
 void pci_disable_device(struct pci_dev *dev);
 void pci_set_master(struct pci_dev *dev);
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
 #define HAVE_PCI_SET_MWI
 int __must_check pci_set_mwi(struct pci_dev *dev);
 void pci_clear_mwi(struct pci_dev *dev);
_

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 2/3] powerpc: Add powerpc PCI-E reset API implementation
  2007-02-19 14:47 [PATCH 1/3] pci: New PCI-E reset API Brian King
@ 2007-02-19 14:47   ` Brian King
  2007-02-19 14:47   ` Brian King
  2007-03-08 20:44   ` Brian King
  2 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-19 14:47 UTC (permalink / raw)
  To: greg; +Cc: linux-pci, paulus, linuxppc-dev, James.Bottomley, linux-scsi, brking


Adds the pSeries platform implementation for a new PCI API
which can be used to issue various types of PCI-E reset,
including PCI-E warm reset and PCI-E hot reset. This is needed
for an ipr PCI-E adapter which does not properly implement BIST.
Running BIST on this adapter results in PCI-E errors. The only
reliable reset mechanism that exists on this hardware is PCI
Fundamental reset (warm reset). 

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 linux-2.6-bjking1/arch/powerpc/platforms/pseries/eeh.c |   30 +++++++++++++++++
 1 files changed, 30 insertions(+)

diff -puN arch/powerpc/platforms/pseries/eeh.c~powerpc_slot_reset_api3 arch/powerpc/platforms/pseries/eeh.c
--- linux-2.6/arch/powerpc/platforms/pseries/eeh.c~powerpc_slot_reset_api3	2007-02-01 10:29:21.000000000 -0600
+++ linux-2.6-bjking1/arch/powerpc/platforms/pseries/eeh.c	2007-02-01 10:30:59.000000000 -0600
@@ -561,6 +561,36 @@ rtas_pci_slot_reset(struct pci_dn *pdn, 
 }
 
 /**
+ * pcibios_set_pcie_slot_reset - Set PCI-E reset state
+ * @dev:	pci device struct
+ * @state:	reset state to enter
+ *
+ * Return value:
+ * 	0 if success
+ **/
+int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
+{
+	struct device_node *dn = pci_device_to_OF_node(dev);
+	struct pci_dn *pdn = PCI_DN(dn);
+
+	switch (state) {
+	case pci_reset_normal:
+		rtas_pci_slot_reset(pdn, 0);
+		break;
+	case pci_reset_pcie_hot_reset:
+		rtas_pci_slot_reset(pdn, 1);
+		break;
+	case pci_reset_pcie_warm_reset:
+		rtas_pci_slot_reset(pdn, 3);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	return 0;
+}
+
+/**
  * rtas_set_slot_reset -- assert the pci #RST line for 1/4 second
  * @pdn: pci device node to be reset.
  *
_

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 2/3] powerpc: Add powerpc PCI-E reset API implementation
@ 2007-02-19 14:47   ` Brian King
  0 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-19 14:47 UTC (permalink / raw)
  To: greg; +Cc: James.Bottomley, linux-scsi, linuxppc-dev, paulus, brking, linux-pci


Adds the pSeries platform implementation for a new PCI API
which can be used to issue various types of PCI-E reset,
including PCI-E warm reset and PCI-E hot reset. This is needed
for an ipr PCI-E adapter which does not properly implement BIST.
Running BIST on this adapter results in PCI-E errors. The only
reliable reset mechanism that exists on this hardware is PCI
Fundamental reset (warm reset). 

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 linux-2.6-bjking1/arch/powerpc/platforms/pseries/eeh.c |   30 +++++++++++++++++
 1 files changed, 30 insertions(+)

diff -puN arch/powerpc/platforms/pseries/eeh.c~powerpc_slot_reset_api3 arch/powerpc/platforms/pseries/eeh.c
--- linux-2.6/arch/powerpc/platforms/pseries/eeh.c~powerpc_slot_reset_api3	2007-02-01 10:29:21.000000000 -0600
+++ linux-2.6-bjking1/arch/powerpc/platforms/pseries/eeh.c	2007-02-01 10:30:59.000000000 -0600
@@ -561,6 +561,36 @@ rtas_pci_slot_reset(struct pci_dn *pdn, 
 }
 
 /**
+ * pcibios_set_pcie_slot_reset - Set PCI-E reset state
+ * @dev:	pci device struct
+ * @state:	reset state to enter
+ *
+ * Return value:
+ * 	0 if success
+ **/
+int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
+{
+	struct device_node *dn = pci_device_to_OF_node(dev);
+	struct pci_dn *pdn = PCI_DN(dn);
+
+	switch (state) {
+	case pci_reset_normal:
+		rtas_pci_slot_reset(pdn, 0);
+		break;
+	case pci_reset_pcie_hot_reset:
+		rtas_pci_slot_reset(pdn, 1);
+		break;
+	case pci_reset_pcie_warm_reset:
+		rtas_pci_slot_reset(pdn, 3);
+		break;
+	default:
+		return -EINVAL;
+	};
+
+	return 0;
+}
+
+/**
  * rtas_set_slot_reset -- assert the pci #RST line for 1/4 second
  * @pdn: pci device node to be reset.
  *
_

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 3/3] ipr: Use PCI-E reset API for new ipr adapter
  2007-02-19 14:47 [PATCH 1/3] pci: New PCI-E reset API Brian King
@ 2007-02-19 14:47   ` Brian King
  2007-02-19 14:47   ` Brian King
  2007-03-08 20:44   ` Brian King
  2 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-19 14:47 UTC (permalink / raw)
  To: greg; +Cc: linux-pci, paulus, linuxppc-dev, James.Bottomley, linux-scsi, brking


Use a newly added PCI API to issue a PCI Fundamental reset
(warm reset) to a new ipr PCI-E adapter. Typically, the
ipr adapter uses the start BIST bit in config space to reset
an adapter. Issuing start BIST on this particular adapter
results in the PCI-E logic on the card losing sync, which
causes PCI-E errors, making the card unusable. The only reset
mechanism that exists on this hardware that does not have this
problem is PCI Fundamental reset (warm reset).

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 linux-2.6-bjking1/drivers/scsi/ipr.c |   61 ++++++++++++++++++++++++++++++++---
 linux-2.6-bjking1/drivers/scsi/ipr.h |   10 ++++-
 2 files changed, 64 insertions(+), 7 deletions(-)

diff -puN drivers/scsi/ipr.h~ipr_pci_reset6 drivers/scsi/ipr.h
--- linux-2.6/drivers/scsi/ipr.h~ipr_pci_reset6	2007-02-16 10:16:07.000000000 -0600
+++ linux-2.6-bjking1/drivers/scsi/ipr.h	2007-02-16 10:18:40.000000000 -0600
@@ -37,8 +37,8 @@
 /*
  * Literals
  */
-#define IPR_DRIVER_VERSION "2.3.1"
-#define IPR_DRIVER_DATE "(January 23, 2007)"
+#define IPR_DRIVER_VERSION "2.3.2"
+#define IPR_DRIVER_DATE "(January 26, 2007)"
 
 /*
  * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
@@ -104,6 +104,9 @@
 #define IPR_IOASC_IOA_WAS_RESET			0x10000001
 #define IPR_IOASC_PCI_ACCESS_ERROR			0x10000002
 
+/* Driver data flags */
+#define IPR_USE_PCI_WARM_RESET			0x00000001
+
 #define IPR_DEFAULT_MAX_ERROR_DUMP			984
 #define IPR_NUM_LOG_HCAMS				2
 #define IPR_NUM_CFG_CHG_HCAMS				2
@@ -182,6 +185,7 @@
 #define IPR_WAIT_FOR_RESET_TIMEOUT		(2 * HZ)
 #define IPR_CHECK_FOR_RESET_TIMEOUT		(HZ / 10)
 #define IPR_WAIT_FOR_BIST_TIMEOUT		(2 * HZ)
+#define IPR_PCI_RESET_TIMEOUT			(HZ / 2)
 #define IPR_DUMP_TIMEOUT			(15 * HZ)
 
 /*
@@ -1058,6 +1062,7 @@ struct ipr_ioa_cfg {
 	u8 allow_cmds:1;
 	u8 allow_ml_add_del:1;
 	u8 needs_hard_reset:1;
+	u8 needs_warm_reset:1;
 
 	enum ipr_cache_state cache_state;
 	u16 type; /* CCIN of the card */
@@ -1150,6 +1155,7 @@ struct ipr_ioa_cfg {
 	struct pci_pool *ipr_cmd_pool;
 
 	struct ipr_cmnd *reset_cmd;
+	int (*reset) (struct ipr_cmnd *);
 
 	struct ata_host ata_host;
 	char ipr_cmd_label[8];
diff -puN drivers/scsi/ipr.c~ipr_pci_reset6 drivers/scsi/ipr.c
--- linux-2.6/drivers/scsi/ipr.c~ipr_pci_reset6	2007-02-16 10:16:07.000000000 -0600
+++ linux-2.6-bjking1/drivers/scsi/ipr.c	2007-02-16 10:18:29.000000000 -0600
@@ -6397,6 +6397,48 @@ static int ipr_reset_start_bist(struct i
 }
 
 /**
+ * ipr_reset_slot_reset_done - Clear PCI reset to the adapter
+ * @ipr_cmd:	ipr command struct
+ *
+ * Description: This clears PCI reset to the adapter and delays two seconds.
+ *
+ * Return value:
+ * 	IPR_RC_JOB_RETURN
+ **/
+static int ipr_reset_slot_reset_done(struct ipr_cmnd *ipr_cmd)
+{
+	ENTER;
+	pci_set_pcie_reset_state(ipr_cmd->ioa_cfg->pdev, pci_reset_normal);
+	ipr_cmd->job_step = ipr_reset_bist_done;
+	ipr_reset_start_timer(ipr_cmd, IPR_WAIT_FOR_BIST_TIMEOUT);
+	LEAVE;
+	return IPR_RC_JOB_RETURN;
+}
+
+/**
+ * ipr_reset_slot_reset - Reset the PCI slot of the adapter.
+ * @ipr_cmd:	ipr command struct
+ *
+ * Description: This asserts PCI reset to the adapter.
+ *
+ * Return value:
+ * 	IPR_RC_JOB_RETURN
+ **/
+static int ipr_reset_slot_reset(struct ipr_cmnd *ipr_cmd)
+{
+	struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
+	struct pci_dev *pdev = ioa_cfg->pdev;
+
+	ENTER;
+	pci_block_user_cfg_access(pdev);
+	pci_set_pcie_reset_state(pdev, pci_reset_pcie_warm_reset);
+	ipr_cmd->job_step = ipr_reset_slot_reset_done;
+	ipr_reset_start_timer(ipr_cmd, IPR_PCI_RESET_TIMEOUT);
+	LEAVE;
+	return IPR_RC_JOB_RETURN;
+}
+
+/**
  * ipr_reset_allowed - Query whether or not IOA can be reset
  * @ioa_cfg:	ioa config struct
  *
@@ -6435,7 +6477,7 @@ static int ipr_reset_wait_to_start_bist(
 		ipr_cmd->u.time_left -= IPR_CHECK_FOR_RESET_TIMEOUT;
 		ipr_reset_start_timer(ipr_cmd, IPR_CHECK_FOR_RESET_TIMEOUT);
 	} else {
-		ipr_cmd->job_step = ipr_reset_start_bist;
+		ipr_cmd->job_step = ioa_cfg->reset;
 		rc = IPR_RC_JOB_CONTINUE;
 	}
 
@@ -6468,7 +6510,7 @@ static int ipr_reset_alert(struct ipr_cm
 		writel(IPR_UPROCI_RESET_ALERT, ioa_cfg->regs.set_uproc_interrupt_reg);
 		ipr_cmd->job_step = ipr_reset_wait_to_start_bist;
 	} else {
-		ipr_cmd->job_step = ipr_reset_start_bist;
+		ipr_cmd->job_step = ioa_cfg->reset;
 	}
 
 	ipr_cmd->u.time_left = IPR_WAIT_FOR_RESET_TIMEOUT;
@@ -6748,8 +6790,11 @@ static pci_ers_result_t ipr_pci_slot_res
 	struct ipr_ioa_cfg *ioa_cfg = pci_get_drvdata(pdev);
 
 	spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
-	_ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_restore_cfg_space,
-	                                 IPR_SHUTDOWN_NONE);
+	if (ioa_cfg->needs_warm_reset)
+		ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
+	else
+		_ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_restore_cfg_space,
+					IPR_SHUTDOWN_NONE);
 	spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags);
 	return PCI_ERS_RESULT_RECOVERED;
 }
@@ -7313,6 +7358,12 @@ static int __devinit ipr_probe_ioa(struc
 		goto cleanup_nolog;
 	}
 
+	if (dev_id->driver_data & IPR_USE_PCI_WARM_RESET) {
+		ioa_cfg->needs_warm_reset = 1;
+		ioa_cfg->reset = ipr_reset_slot_reset;
+	} else
+		ioa_cfg->reset = ipr_reset_start_bist;
+
 	spin_lock(&ipr_driver_lock);
 	list_add_tail(&ioa_cfg->queue, &ipr_ioa_head);
 	spin_unlock(&ipr_driver_lock);
@@ -7553,7 +7604,7 @@ static struct pci_device_id ipr_pci_tabl
 	{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
 	      PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 0, 0, 0 },
 	{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E,
-	      PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7, 0, 0, 0 },
+	      PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7, 0, 0, IPR_USE_PCI_WARM_RESET},
 	{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE,
 		PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780, 0, 0, 0 },
 	{ PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
_

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 3/3] ipr: Use PCI-E reset API for new ipr adapter
@ 2007-02-19 14:47   ` Brian King
  0 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-19 14:47 UTC (permalink / raw)
  To: greg; +Cc: James.Bottomley, linux-scsi, linuxppc-dev, paulus, brking, linux-pci


Use a newly added PCI API to issue a PCI Fundamental reset
(warm reset) to a new ipr PCI-E adapter. Typically, the
ipr adapter uses the start BIST bit in config space to reset
an adapter. Issuing start BIST on this particular adapter
results in the PCI-E logic on the card losing sync, which
causes PCI-E errors, making the card unusable. The only reset
mechanism that exists on this hardware that does not have this
problem is PCI Fundamental reset (warm reset).

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 linux-2.6-bjking1/drivers/scsi/ipr.c |   61 ++++++++++++++++++++++++++++++++---
 linux-2.6-bjking1/drivers/scsi/ipr.h |   10 ++++-
 2 files changed, 64 insertions(+), 7 deletions(-)

diff -puN drivers/scsi/ipr.h~ipr_pci_reset6 drivers/scsi/ipr.h
--- linux-2.6/drivers/scsi/ipr.h~ipr_pci_reset6	2007-02-16 10:16:07.000000000 -0600
+++ linux-2.6-bjking1/drivers/scsi/ipr.h	2007-02-16 10:18:40.000000000 -0600
@@ -37,8 +37,8 @@
 /*
  * Literals
  */
-#define IPR_DRIVER_VERSION "2.3.1"
-#define IPR_DRIVER_DATE "(January 23, 2007)"
+#define IPR_DRIVER_VERSION "2.3.2"
+#define IPR_DRIVER_DATE "(January 26, 2007)"
 
 /*
  * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
@@ -104,6 +104,9 @@
 #define IPR_IOASC_IOA_WAS_RESET			0x10000001
 #define IPR_IOASC_PCI_ACCESS_ERROR			0x10000002
 
+/* Driver data flags */
+#define IPR_USE_PCI_WARM_RESET			0x00000001
+
 #define IPR_DEFAULT_MAX_ERROR_DUMP			984
 #define IPR_NUM_LOG_HCAMS				2
 #define IPR_NUM_CFG_CHG_HCAMS				2
@@ -182,6 +185,7 @@
 #define IPR_WAIT_FOR_RESET_TIMEOUT		(2 * HZ)
 #define IPR_CHECK_FOR_RESET_TIMEOUT		(HZ / 10)
 #define IPR_WAIT_FOR_BIST_TIMEOUT		(2 * HZ)
+#define IPR_PCI_RESET_TIMEOUT			(HZ / 2)
 #define IPR_DUMP_TIMEOUT			(15 * HZ)
 
 /*
@@ -1058,6 +1062,7 @@ struct ipr_ioa_cfg {
 	u8 allow_cmds:1;
 	u8 allow_ml_add_del:1;
 	u8 needs_hard_reset:1;
+	u8 needs_warm_reset:1;
 
 	enum ipr_cache_state cache_state;
 	u16 type; /* CCIN of the card */
@@ -1150,6 +1155,7 @@ struct ipr_ioa_cfg {
 	struct pci_pool *ipr_cmd_pool;
 
 	struct ipr_cmnd *reset_cmd;
+	int (*reset) (struct ipr_cmnd *);
 
 	struct ata_host ata_host;
 	char ipr_cmd_label[8];
diff -puN drivers/scsi/ipr.c~ipr_pci_reset6 drivers/scsi/ipr.c
--- linux-2.6/drivers/scsi/ipr.c~ipr_pci_reset6	2007-02-16 10:16:07.000000000 -0600
+++ linux-2.6-bjking1/drivers/scsi/ipr.c	2007-02-16 10:18:29.000000000 -0600
@@ -6397,6 +6397,48 @@ static int ipr_reset_start_bist(struct i
 }
 
 /**
+ * ipr_reset_slot_reset_done - Clear PCI reset to the adapter
+ * @ipr_cmd:	ipr command struct
+ *
+ * Description: This clears PCI reset to the adapter and delays two seconds.
+ *
+ * Return value:
+ * 	IPR_RC_JOB_RETURN
+ **/
+static int ipr_reset_slot_reset_done(struct ipr_cmnd *ipr_cmd)
+{
+	ENTER;
+	pci_set_pcie_reset_state(ipr_cmd->ioa_cfg->pdev, pci_reset_normal);
+	ipr_cmd->job_step = ipr_reset_bist_done;
+	ipr_reset_start_timer(ipr_cmd, IPR_WAIT_FOR_BIST_TIMEOUT);
+	LEAVE;
+	return IPR_RC_JOB_RETURN;
+}
+
+/**
+ * ipr_reset_slot_reset - Reset the PCI slot of the adapter.
+ * @ipr_cmd:	ipr command struct
+ *
+ * Description: This asserts PCI reset to the adapter.
+ *
+ * Return value:
+ * 	IPR_RC_JOB_RETURN
+ **/
+static int ipr_reset_slot_reset(struct ipr_cmnd *ipr_cmd)
+{
+	struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
+	struct pci_dev *pdev = ioa_cfg->pdev;
+
+	ENTER;
+	pci_block_user_cfg_access(pdev);
+	pci_set_pcie_reset_state(pdev, pci_reset_pcie_warm_reset);
+	ipr_cmd->job_step = ipr_reset_slot_reset_done;
+	ipr_reset_start_timer(ipr_cmd, IPR_PCI_RESET_TIMEOUT);
+	LEAVE;
+	return IPR_RC_JOB_RETURN;
+}
+
+/**
  * ipr_reset_allowed - Query whether or not IOA can be reset
  * @ioa_cfg:	ioa config struct
  *
@@ -6435,7 +6477,7 @@ static int ipr_reset_wait_to_start_bist(
 		ipr_cmd->u.time_left -= IPR_CHECK_FOR_RESET_TIMEOUT;
 		ipr_reset_start_timer(ipr_cmd, IPR_CHECK_FOR_RESET_TIMEOUT);
 	} else {
-		ipr_cmd->job_step = ipr_reset_start_bist;
+		ipr_cmd->job_step = ioa_cfg->reset;
 		rc = IPR_RC_JOB_CONTINUE;
 	}
 
@@ -6468,7 +6510,7 @@ static int ipr_reset_alert(struct ipr_cm
 		writel(IPR_UPROCI_RESET_ALERT, ioa_cfg->regs.set_uproc_interrupt_reg);
 		ipr_cmd->job_step = ipr_reset_wait_to_start_bist;
 	} else {
-		ipr_cmd->job_step = ipr_reset_start_bist;
+		ipr_cmd->job_step = ioa_cfg->reset;
 	}
 
 	ipr_cmd->u.time_left = IPR_WAIT_FOR_RESET_TIMEOUT;
@@ -6748,8 +6790,11 @@ static pci_ers_result_t ipr_pci_slot_res
 	struct ipr_ioa_cfg *ioa_cfg = pci_get_drvdata(pdev);
 
 	spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
-	_ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_restore_cfg_space,
-	                                 IPR_SHUTDOWN_NONE);
+	if (ioa_cfg->needs_warm_reset)
+		ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
+	else
+		_ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_restore_cfg_space,
+					IPR_SHUTDOWN_NONE);
 	spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags);
 	return PCI_ERS_RESULT_RECOVERED;
 }
@@ -7313,6 +7358,12 @@ static int __devinit ipr_probe_ioa(struc
 		goto cleanup_nolog;
 	}
 
+	if (dev_id->driver_data & IPR_USE_PCI_WARM_RESET) {
+		ioa_cfg->needs_warm_reset = 1;
+		ioa_cfg->reset = ipr_reset_slot_reset;
+	} else
+		ioa_cfg->reset = ipr_reset_start_bist;
+
 	spin_lock(&ipr_driver_lock);
 	list_add_tail(&ioa_cfg->queue, &ipr_ioa_head);
 	spin_unlock(&ipr_driver_lock);
@@ -7553,7 +7604,7 @@ static struct pci_device_id ipr_pci_tabl
 	{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
 	      PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C, 0, 0, 0 },
 	{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E,
-	      PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7, 0, 0, 0 },
+	      PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7, 0, 0, IPR_USE_PCI_WARM_RESET},
 	{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE,
 		PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780, 0, 0, 0 },
 	{ PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
_

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] pci: New PCI-E reset API
  2007-02-19 14:47 [PATCH 1/3] pci: New PCI-E reset API Brian King
@ 2007-03-08 20:44   ` Brian King
  2007-02-19 14:47   ` Brian King
  2007-03-08 20:44   ` Brian King
  2 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-03-08 20:44 UTC (permalink / raw)
  To: greg; +Cc: linux-pci, paulus, linuxppc-dev, James.Bottomley, linux-scsi

Greg,

I saw you pulled this into your gregkh-2.6 tree. Does that mean
it is queued for 2.6.22?

Thanks,

Brian

Brian King wrote:
> Adds a new API which can be used to issue various types
> of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
> This is needed for an ipr PCI-E adapter which does not properly
> implement BIST. Running BIST on this adapter results in PCI-E
> errors. The only reliable reset mechanism that exists on this
> hardware is PCI Fundamental reset (warm reset). Since driving
> this type of reset is architecture unique, this provides the
> necessary hooks for architectures to add this support.
> 
> Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
> ---
> 
>  linux-2.6-bjking1/drivers/pci/pci.c   |   29 +++++++++++++++++++++++++++++
>  linux-2.6-bjking1/include/linux/pci.h |   14 ++++++++++++++
>  2 files changed, 43 insertions(+)
> 
> diff -puN drivers/pci/pci.c~pci_pci_reset_api drivers/pci/pci.c
> --- linux-2.6/drivers/pci/pci.c~pci_pci_reset_api	2007-02-16 10:10:30.000000000 -0600
> +++ linux-2.6-bjking1/drivers/pci/pci.c	2007-02-16 10:10:30.000000000 -0600
> @@ -893,6 +893,34 @@ pci_disable_device(struct pci_dev *dev)
>  }
> 
>  /**
> + * pcibios_set_pcie_reset_state - set reset state for device dev
> + * @dev: the PCI-E device reset
> + * @state: Reset state to enter into
> + *
> + *
> + * Sets the PCI-E reset state for the device. This is the default
> + * implementation. Architecture implementations can override this.
> + */
> +int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
> +							enum pcie_reset_state state)
> +{
> +	return -EINVAL;
> +}
> +
> +/**
> + * pci_set_pcie_reset_state - set reset state for device dev
> + * @dev: the PCI-E device reset
> + * @state: Reset state to enter into
> + *
> + *
> + * Sets the PCI reset state for the device.
> + */
> +int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
> +{
> +	return pcibios_set_pcie_reset_state(dev, state);
> +}
> +
> +/**
>   * pci_enable_wake - enable device to generate PME# when suspended
>   * @dev: - PCI device to operate on
>   * @state: - Current state of device.
> @@ -1374,4 +1402,5 @@ EXPORT_SYMBOL(pci_set_power_state);
>  EXPORT_SYMBOL(pci_save_state);
>  EXPORT_SYMBOL(pci_restore_state);
>  EXPORT_SYMBOL(pci_enable_wake);
> +EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
> 
> diff -puN include/linux/pci.h~pci_pci_reset_api include/linux/pci.h
> --- linux-2.6/include/linux/pci.h~pci_pci_reset_api	2007-02-16 10:10:30.000000000 -0600
> +++ linux-2.6-bjking1/include/linux/pci.h	2007-02-16 10:10:30.000000000 -0600
> @@ -96,6 +96,19 @@ enum pci_channel_state {
>  	pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
>  };
> 
> +typedef unsigned int __bitwise pcie_reset_state_t;
> +
> +enum pcie_reset_state {
> +	/* Reset is NOT asserted (Use to deassert reset) */
> +	pci_reset_normal = (__force pcie_reset_state_t) 1,
> +
> +	/* Use #PERST to reset PCI-E device */
> +	pci_reset_pcie_warm_reset = (__force pcie_reset_state_t) 2,
> +
> +	/* Use PCI-E Hot Reset to reset device */
> +	pci_reset_pcie_hot_reset = (__force pcie_reset_state_t) 3
> +};
> +
>  typedef unsigned short __bitwise pci_bus_flags_t;
>  enum pci_bus_flags {
>  	PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
> @@ -539,6 +552,7 @@ static inline int pci_is_managed(struct 
> 
>  void pci_disable_device(struct pci_dev *dev);
>  void pci_set_master(struct pci_dev *dev);
> +int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
>  #define HAVE_PCI_SET_MWI
>  int __must_check pci_set_mwi(struct pci_dev *dev);
>  void pci_clear_mwi(struct pci_dev *dev);
> _


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] pci: New PCI-E reset API
@ 2007-03-08 20:44   ` Brian King
  0 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-03-08 20:44 UTC (permalink / raw)
  To: greg; +Cc: James.Bottomley, linuxppc-dev, linux-pci, paulus, linux-scsi

Greg,

I saw you pulled this into your gregkh-2.6 tree. Does that mean
it is queued for 2.6.22?

Thanks,

Brian

Brian King wrote:
> Adds a new API which can be used to issue various types
> of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
> This is needed for an ipr PCI-E adapter which does not properly
> implement BIST. Running BIST on this adapter results in PCI-E
> errors. The only reliable reset mechanism that exists on this
> hardware is PCI Fundamental reset (warm reset). Since driving
> this type of reset is architecture unique, this provides the
> necessary hooks for architectures to add this support.
> 
> Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
> ---
> 
>  linux-2.6-bjking1/drivers/pci/pci.c   |   29 +++++++++++++++++++++++++++++
>  linux-2.6-bjking1/include/linux/pci.h |   14 ++++++++++++++
>  2 files changed, 43 insertions(+)
> 
> diff -puN drivers/pci/pci.c~pci_pci_reset_api drivers/pci/pci.c
> --- linux-2.6/drivers/pci/pci.c~pci_pci_reset_api	2007-02-16 10:10:30.000000000 -0600
> +++ linux-2.6-bjking1/drivers/pci/pci.c	2007-02-16 10:10:30.000000000 -0600
> @@ -893,6 +893,34 @@ pci_disable_device(struct pci_dev *dev)
>  }
> 
>  /**
> + * pcibios_set_pcie_reset_state - set reset state for device dev
> + * @dev: the PCI-E device reset
> + * @state: Reset state to enter into
> + *
> + *
> + * Sets the PCI-E reset state for the device. This is the default
> + * implementation. Architecture implementations can override this.
> + */
> +int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
> +							enum pcie_reset_state state)
> +{
> +	return -EINVAL;
> +}
> +
> +/**
> + * pci_set_pcie_reset_state - set reset state for device dev
> + * @dev: the PCI-E device reset
> + * @state: Reset state to enter into
> + *
> + *
> + * Sets the PCI reset state for the device.
> + */
> +int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
> +{
> +	return pcibios_set_pcie_reset_state(dev, state);
> +}
> +
> +/**
>   * pci_enable_wake - enable device to generate PME# when suspended
>   * @dev: - PCI device to operate on
>   * @state: - Current state of device.
> @@ -1374,4 +1402,5 @@ EXPORT_SYMBOL(pci_set_power_state);
>  EXPORT_SYMBOL(pci_save_state);
>  EXPORT_SYMBOL(pci_restore_state);
>  EXPORT_SYMBOL(pci_enable_wake);
> +EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
> 
> diff -puN include/linux/pci.h~pci_pci_reset_api include/linux/pci.h
> --- linux-2.6/include/linux/pci.h~pci_pci_reset_api	2007-02-16 10:10:30.000000000 -0600
> +++ linux-2.6-bjking1/include/linux/pci.h	2007-02-16 10:10:30.000000000 -0600
> @@ -96,6 +96,19 @@ enum pci_channel_state {
>  	pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
>  };
> 
> +typedef unsigned int __bitwise pcie_reset_state_t;
> +
> +enum pcie_reset_state {
> +	/* Reset is NOT asserted (Use to deassert reset) */
> +	pci_reset_normal = (__force pcie_reset_state_t) 1,
> +
> +	/* Use #PERST to reset PCI-E device */
> +	pci_reset_pcie_warm_reset = (__force pcie_reset_state_t) 2,
> +
> +	/* Use PCI-E Hot Reset to reset device */
> +	pci_reset_pcie_hot_reset = (__force pcie_reset_state_t) 3
> +};
> +
>  typedef unsigned short __bitwise pci_bus_flags_t;
>  enum pci_bus_flags {
>  	PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
> @@ -539,6 +552,7 @@ static inline int pci_is_managed(struct 
> 
>  void pci_disable_device(struct pci_dev *dev);
>  void pci_set_master(struct pci_dev *dev);
> +int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
>  #define HAVE_PCI_SET_MWI
>  int __must_check pci_set_mwi(struct pci_dev *dev);
>  void pci_clear_mwi(struct pci_dev *dev);
> _


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] pci: New PCI-E reset API
  2007-03-08 20:44   ` Brian King
@ 2007-03-09  0:32     ` Greg KH
  -1 siblings, 0 replies; 20+ messages in thread
From: Greg KH @ 2007-03-09  0:32 UTC (permalink / raw)
  To: Brian King; +Cc: linux-pci, paulus, linuxppc-dev, James.Bottomley, linux-scsi

On Thu, Mar 08, 2007 at 02:44:26PM -0600, Brian King wrote:
> Greg,
> 
> I saw you pulled this into your gregkh-2.6 tree. Does that mean
> it is queued for 2.6.22?

Yes it is.  Is that a problem?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] pci: New PCI-E reset API
@ 2007-03-09  0:32     ` Greg KH
  0 siblings, 0 replies; 20+ messages in thread
From: Greg KH @ 2007-03-09  0:32 UTC (permalink / raw)
  To: Brian King; +Cc: James.Bottomley, linuxppc-dev, linux-pci, paulus, linux-scsi

On Thu, Mar 08, 2007 at 02:44:26PM -0600, Brian King wrote:
> Greg,
> 
> I saw you pulled this into your gregkh-2.6 tree. Does that mean
> it is queued for 2.6.22?

Yes it is.  Is that a problem?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] pci: New PCI-E reset API
  2007-03-09  0:32     ` Greg KH
  (?)
@ 2007-03-09 14:53     ` Brian King
  -1 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-03-09 14:53 UTC (permalink / raw)
  To: Greg KH; +Cc: James.Bottomley, linuxppc-dev, linux-pci, paulus, linux-scsi

Greg KH wrote:
> On Thu, Mar 08, 2007 at 02:44:26PM -0600, Brian King wrote:
>> Greg,
>>
>> I saw you pulled this into your gregkh-2.6 tree. Does that mean
>> it is queued for 2.6.22?
> 
> Yes it is.  Is that a problem?

No problem at all. 

Thanks,

Brian

-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/3] pci: New PCI-E reset API
@ 2007-02-19 14:47 Brian King
  0 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-19 14:47 UTC (permalink / raw)
  To: greg; +Cc: linux-pci, paulus, linuxppc-dev, James.Bottomley, linux-scsi, brking


Adds a new API which can be used to issue various types
of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
This is needed for an ipr PCI-E adapter which does not properly
implement BIST. Running BIST on this adapter results in PCI-E
errors. The only reliable reset mechanism that exists on this
hardware is PCI Fundamental reset (warm reset). Since driving
this type of reset is architecture unique, this provides the
necessary hooks for architectures to add this support.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 linux-2.6-bjking1/drivers/pci/pci.c   |   29 +++++++++++++++++++++++++++++
 linux-2.6-bjking1/include/linux/pci.h |   14 ++++++++++++++
 2 files changed, 43 insertions(+)

diff -puN drivers/pci/pci.c~pci_pci_reset_api drivers/pci/pci.c
--- linux-2.6/drivers/pci/pci.c~pci_pci_reset_api	2007-02-16 10:10:30.000000000 -0600
+++ linux-2.6-bjking1/drivers/pci/pci.c	2007-02-16 10:10:30.000000000 -0600
@@ -893,6 +893,34 @@ pci_disable_device(struct pci_dev *dev)
 }
 
 /**
+ * pcibios_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI-E reset state for the device. This is the default
+ * implementation. Architecture implementations can override this.
+ */
+int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
+							enum pcie_reset_state state)
+{
+	return -EINVAL;
+}
+
+/**
+ * pci_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI reset state for the device.
+ */
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
+{
+	return pcibios_set_pcie_reset_state(dev, state);
+}
+
+/**
  * pci_enable_wake - enable device to generate PME# when suspended
  * @dev: - PCI device to operate on
  * @state: - Current state of device.
@@ -1374,4 +1402,5 @@ EXPORT_SYMBOL(pci_set_power_state);
 EXPORT_SYMBOL(pci_save_state);
 EXPORT_SYMBOL(pci_restore_state);
 EXPORT_SYMBOL(pci_enable_wake);
+EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
 
diff -puN include/linux/pci.h~pci_pci_reset_api include/linux/pci.h
--- linux-2.6/include/linux/pci.h~pci_pci_reset_api	2007-02-16 10:10:30.000000000 -0600
+++ linux-2.6-bjking1/include/linux/pci.h	2007-02-16 10:10:30.000000000 -0600
@@ -96,6 +96,19 @@ enum pci_channel_state {
 	pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
 };
 
+typedef unsigned int __bitwise pcie_reset_state_t;
+
+enum pcie_reset_state {
+	/* Reset is NOT asserted (Use to deassert reset) */
+	pci_reset_normal = (__force pcie_reset_state_t) 1,
+
+	/* Use #PERST to reset PCI-E device */
+	pci_reset_pcie_warm_reset = (__force pcie_reset_state_t) 2,
+
+	/* Use PCI-E Hot Reset to reset device */
+	pci_reset_pcie_hot_reset = (__force pcie_reset_state_t) 3
+};
+
 typedef unsigned short __bitwise pci_bus_flags_t;
 enum pci_bus_flags {
 	PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
@@ -539,6 +552,7 @@ static inline int pci_is_managed(struct 
 
 void pci_disable_device(struct pci_dev *dev);
 void pci_set_master(struct pci_dev *dev);
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
 #define HAVE_PCI_SET_MWI
 int __must_check pci_set_mwi(struct pci_dev *dev);
 void pci_clear_mwi(struct pci_dev *dev);
_

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/3] pci: New PCI-E reset API
@ 2007-02-19 14:47 Brian King
  0 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-19 14:47 UTC (permalink / raw)
  To: greg; +Cc: James.Bottomley, linux-scsi, linuxppc-dev, paulus, brking, linux-pci


Adds a new API which can be used to issue various types
of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
This is needed for an ipr PCI-E adapter which does not properly
implement BIST. Running BIST on this adapter results in PCI-E
errors. The only reliable reset mechanism that exists on this
hardware is PCI Fundamental reset (warm reset). Since driving
this type of reset is architecture unique, this provides the
necessary hooks for architectures to add this support.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 linux-2.6-bjking1/drivers/pci/pci.c   |   29 +++++++++++++++++++++++++++++
 linux-2.6-bjking1/include/linux/pci.h |   14 ++++++++++++++
 2 files changed, 43 insertions(+)

diff -puN drivers/pci/pci.c~pci_pci_reset_api drivers/pci/pci.c
--- linux-2.6/drivers/pci/pci.c~pci_pci_reset_api	2007-02-16 10:10:30.000000000 -0600
+++ linux-2.6-bjking1/drivers/pci/pci.c	2007-02-16 10:10:30.000000000 -0600
@@ -893,6 +893,34 @@ pci_disable_device(struct pci_dev *dev)
 }
 
 /**
+ * pcibios_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI-E reset state for the device. This is the default
+ * implementation. Architecture implementations can override this.
+ */
+int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
+							enum pcie_reset_state state)
+{
+	return -EINVAL;
+}
+
+/**
+ * pci_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI reset state for the device.
+ */
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
+{
+	return pcibios_set_pcie_reset_state(dev, state);
+}
+
+/**
  * pci_enable_wake - enable device to generate PME# when suspended
  * @dev: - PCI device to operate on
  * @state: - Current state of device.
@@ -1374,4 +1402,5 @@ EXPORT_SYMBOL(pci_set_power_state);
 EXPORT_SYMBOL(pci_save_state);
 EXPORT_SYMBOL(pci_restore_state);
 EXPORT_SYMBOL(pci_enable_wake);
+EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
 
diff -puN include/linux/pci.h~pci_pci_reset_api include/linux/pci.h
--- linux-2.6/include/linux/pci.h~pci_pci_reset_api	2007-02-16 10:10:30.000000000 -0600
+++ linux-2.6-bjking1/include/linux/pci.h	2007-02-16 10:10:30.000000000 -0600
@@ -96,6 +96,19 @@ enum pci_channel_state {
 	pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
 };
 
+typedef unsigned int __bitwise pcie_reset_state_t;
+
+enum pcie_reset_state {
+	/* Reset is NOT asserted (Use to deassert reset) */
+	pci_reset_normal = (__force pcie_reset_state_t) 1,
+
+	/* Use #PERST to reset PCI-E device */
+	pci_reset_pcie_warm_reset = (__force pcie_reset_state_t) 2,
+
+	/* Use PCI-E Hot Reset to reset device */
+	pci_reset_pcie_hot_reset = (__force pcie_reset_state_t) 3
+};
+
 typedef unsigned short __bitwise pci_bus_flags_t;
 enum pci_bus_flags {
 	PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
@@ -539,6 +552,7 @@ static inline int pci_is_managed(struct 
 
 void pci_disable_device(struct pci_dev *dev);
 void pci_set_master(struct pci_dev *dev);
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
 #define HAVE_PCI_SET_MWI
 int __must_check pci_set_mwi(struct pci_dev *dev);
 void pci_clear_mwi(struct pci_dev *dev);
_

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] pci: New PCI-E reset API
  2007-02-01 22:14     ` Brian King
  (?)
@ 2007-02-09 15:20     ` Brian King
  -1 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-09 15:20 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: James.Bottomley, linux-scsi, gregkh, linuxppc-dev, paulus, linux-pci

Matthew,

Any further comments on this?

Thanks,

Brian

Brian King wrote:
> Matthew Wilcox wrote:
>> On Thu, Feb 01, 2007 at 11:30:21AM -0600, Brian King wrote:
>>> Adds a new API which can be used to issue various types
>>> of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
>>> This is needed for an ipr PCI-E adapter which does not properly
>>> implement BIST. Running BIST on this adapter results in PCI-E
>>> errors. The only reliable reset mechanism that exists on this
>>> hardware is PCI Fundamental reset (warm reset). Since driving
>>> this type of reset is architecture unique, this provides the
>>> necessary hooks for architectures to add this support.
>> A few points ...
>>
>>  - When doing a warm reset, you reset the entire device not just the
>>    function (== pci_dev) that gets passed in.  How happy are drivers for
>>    the other functions going to be about this?
> 
> I guess I don't see how a warm reset could be issued to a single function
> of a PCI device. I would argue that for a multi-function device, you would
> have to use function level reset. 
> 
> 
>>  - You've missed the requirement:
>>
>> "To allow components to perform internal initialization, system software
>> must wait for at least 100 ms from the end of a Conventional Reset of one
>> or more devices before it is permitted to issue Configuration Requests
>> to those devices."
>>
>>    To fix this, we need to call pci_block_user_cfg_access() before
>>    calling the pcibios function, then msleep(100) after calling it, then
>>    call pci_unblock_user_cfg_access().
> 
> What I've done is to provide a very low-level API that can be used to
> accomplish this. In my implementation, the ipr driver is the one doing
> all the required delays and calling pci_block_user_cfg_access, since it
> already was doing that in order to run BIST on the adapter.
> 
>>  - There's no attempt to support either cold or function-level reset in
>>    this patch.
> 
> Correct. I had no requirement to implement this. It can always be added
> if there is a need. A function level reset can be performed by simply
> writing a bit in config space, so *technically* we wouldn't need an
> API to do that for us, but it could certainly be added here.
> 
>> I suspect the Right Way of handling hot/warm/cold reset is going to be
>> some kind of integration with error handling.  This driver understands
>> about slots being different from functions, and has the ability to
>> notify drivers of other functions that a reset is happening.
> 
> Perhaps. It would require a way for the adapter device driver to
> indicate what type of reset(s) will work for a particular pci device.
> It would also require a method for a device driver to invoke a reset,
> which does not currently exist today. I think it would be the first
> case of the device driver invoking pci error recovery, so I'm not sure
> how difficult that would be to do with the current code.
> 
> I actually thought this API might be used by PCI error recovery
> code, since it may need to perform these sorts of functions.
> 
> CC'ing Linas Vepstas since he wrote the powerpc pci recovery code.
> 
> Brian
> 
> 


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] pci: New PCI-E reset API
  2007-02-01 19:12   ` Matthew Wilcox
@ 2007-02-01 22:14     ` Brian King
  -1 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-01 22:14 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: gregkh, linux-pci, paulus, linuxppc-dev, James.Bottomley,
	linux-scsi, hch, Linas Vepstas

Matthew Wilcox wrote:
> On Thu, Feb 01, 2007 at 11:30:21AM -0600, Brian King wrote:
>> Adds a new API which can be used to issue various types
>> of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
>> This is needed for an ipr PCI-E adapter which does not properly
>> implement BIST. Running BIST on this adapter results in PCI-E
>> errors. The only reliable reset mechanism that exists on this
>> hardware is PCI Fundamental reset (warm reset). Since driving
>> this type of reset is architecture unique, this provides the
>> necessary hooks for architectures to add this support.
> 
> A few points ...
> 
>  - When doing a warm reset, you reset the entire device not just the
>    function (== pci_dev) that gets passed in.  How happy are drivers for
>    the other functions going to be about this?

I guess I don't see how a warm reset could be issued to a single function
of a PCI device. I would argue that for a multi-function device, you would
have to use function level reset. 


>  - You've missed the requirement:
> 
> "To allow components to perform internal initialization, system software
> must wait for at least 100 ms from the end of a Conventional Reset of one
> or more devices before it is permitted to issue Configuration Requests
> to those devices."
> 
>    To fix this, we need to call pci_block_user_cfg_access() before
>    calling the pcibios function, then msleep(100) after calling it, then
>    call pci_unblock_user_cfg_access().

What I've done is to provide a very low-level API that can be used to
accomplish this. In my implementation, the ipr driver is the one doing
all the required delays and calling pci_block_user_cfg_access, since it
already was doing that in order to run BIST on the adapter.

>  - There's no attempt to support either cold or function-level reset in
>    this patch.

Correct. I had no requirement to implement this. It can always be added
if there is a need. A function level reset can be performed by simply
writing a bit in config space, so *technically* we wouldn't need an
API to do that for us, but it could certainly be added here.

> I suspect the Right Way of handling hot/warm/cold reset is going to be
> some kind of integration with error handling.  This driver understands
> about slots being different from functions, and has the ability to
> notify drivers of other functions that a reset is happening.

Perhaps. It would require a way for the adapter device driver to
indicate what type of reset(s) will work for a particular pci device.
It would also require a method for a device driver to invoke a reset,
which does not currently exist today. I think it would be the first
case of the device driver invoking pci error recovery, so I'm not sure
how difficult that would be to do with the current code.

I actually thought this API might be used by PCI error recovery
code, since it may need to perform these sorts of functions.

CC'ing Linas Vepstas since he wrote the powerpc pci recovery code.

Brian


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] pci: New PCI-E reset API
@ 2007-02-01 22:14     ` Brian King
  0 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-01 22:14 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: James.Bottomley, linux-scsi, gregkh, linuxppc-dev, paulus, linux-pci

Matthew Wilcox wrote:
> On Thu, Feb 01, 2007 at 11:30:21AM -0600, Brian King wrote:
>> Adds a new API which can be used to issue various types
>> of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
>> This is needed for an ipr PCI-E adapter which does not properly
>> implement BIST. Running BIST on this adapter results in PCI-E
>> errors. The only reliable reset mechanism that exists on this
>> hardware is PCI Fundamental reset (warm reset). Since driving
>> this type of reset is architecture unique, this provides the
>> necessary hooks for architectures to add this support.
> 
> A few points ...
> 
>  - When doing a warm reset, you reset the entire device not just the
>    function (== pci_dev) that gets passed in.  How happy are drivers for
>    the other functions going to be about this?

I guess I don't see how a warm reset could be issued to a single function
of a PCI device. I would argue that for a multi-function device, you would
have to use function level reset. 


>  - You've missed the requirement:
> 
> "To allow components to perform internal initialization, system software
> must wait for at least 100 ms from the end of a Conventional Reset of one
> or more devices before it is permitted to issue Configuration Requests
> to those devices."
> 
>    To fix this, we need to call pci_block_user_cfg_access() before
>    calling the pcibios function, then msleep(100) after calling it, then
>    call pci_unblock_user_cfg_access().

What I've done is to provide a very low-level API that can be used to
accomplish this. In my implementation, the ipr driver is the one doing
all the required delays and calling pci_block_user_cfg_access, since it
already was doing that in order to run BIST on the adapter.

>  - There's no attempt to support either cold or function-level reset in
>    this patch.

Correct. I had no requirement to implement this. It can always be added
if there is a need. A function level reset can be performed by simply
writing a bit in config space, so *technically* we wouldn't need an
API to do that for us, but it could certainly be added here.

> I suspect the Right Way of handling hot/warm/cold reset is going to be
> some kind of integration with error handling.  This driver understands
> about slots being different from functions, and has the ability to
> notify drivers of other functions that a reset is happening.

Perhaps. It would require a way for the adapter device driver to
indicate what type of reset(s) will work for a particular pci device.
It would also require a method for a device driver to invoke a reset,
which does not currently exist today. I think it would be the first
case of the device driver invoking pci error recovery, so I'm not sure
how difficult that would be to do with the current code.

I actually thought this API might be used by PCI error recovery
code, since it may need to perform these sorts of functions.

CC'ing Linas Vepstas since he wrote the powerpc pci recovery code.

Brian


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] pci: New PCI-E reset API
  2007-02-01 17:30 Brian King
@ 2007-02-01 19:12   ` Matthew Wilcox
  0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2007-02-01 19:12 UTC (permalink / raw)
  To: Brian King
  Cc: gregkh, linux-pci, paulus, linuxppc-dev, James.Bottomley,
	linux-scsi, hch

On Thu, Feb 01, 2007 at 11:30:21AM -0600, Brian King wrote:
> Adds a new API which can be used to issue various types
> of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
> This is needed for an ipr PCI-E adapter which does not properly
> implement BIST. Running BIST on this adapter results in PCI-E
> errors. The only reliable reset mechanism that exists on this
> hardware is PCI Fundamental reset (warm reset). Since driving
> this type of reset is architecture unique, this provides the
> necessary hooks for architectures to add this support.

A few points ...

 - When doing a warm reset, you reset the entire device not just the
   function (== pci_dev) that gets passed in.  How happy are drivers for
   the other functions going to be about this?

 - You've missed the requirement:

"To allow components to perform internal initialization, system software
must wait for at least 100 ms from the end of a Conventional Reset of one
or more devices before it is permitted to issue Configuration Requests
to those devices."

   To fix this, we need to call pci_block_user_cfg_access() before
   calling the pcibios function, then msleep(100) after calling it, then
   call pci_unblock_user_cfg_access().

 - There's no attempt to support either cold or function-level reset in
   this patch.

I suspect the Right Way of handling hot/warm/cold reset is going to be
some kind of integration with error handling.  This driver understands
about slots being different from functions, and has the ability to
notify drivers of other functions that a reset is happening.

To a certain extent, what's going on with IPR here *is* an error
condition, it's just that we can recover from it with a warm reset
rather than a hot reset.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] pci: New PCI-E reset API
@ 2007-02-01 19:12   ` Matthew Wilcox
  0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2007-02-01 19:12 UTC (permalink / raw)
  To: Brian King
  Cc: James.Bottomley, linux-scsi, gregkh, linuxppc-dev, paulus, linux-pci

On Thu, Feb 01, 2007 at 11:30:21AM -0600, Brian King wrote:
> Adds a new API which can be used to issue various types
> of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
> This is needed for an ipr PCI-E adapter which does not properly
> implement BIST. Running BIST on this adapter results in PCI-E
> errors. The only reliable reset mechanism that exists on this
> hardware is PCI Fundamental reset (warm reset). Since driving
> this type of reset is architecture unique, this provides the
> necessary hooks for architectures to add this support.

A few points ...

 - When doing a warm reset, you reset the entire device not just the
   function (== pci_dev) that gets passed in.  How happy are drivers for
   the other functions going to be about this?

 - You've missed the requirement:

"To allow components to perform internal initialization, system software
must wait for at least 100 ms from the end of a Conventional Reset of one
or more devices before it is permitted to issue Configuration Requests
to those devices."

   To fix this, we need to call pci_block_user_cfg_access() before
   calling the pcibios function, then msleep(100) after calling it, then
   call pci_unblock_user_cfg_access().

 - There's no attempt to support either cold or function-level reset in
   this patch.

I suspect the Right Way of handling hot/warm/cold reset is going to be
some kind of integration with error handling.  This driver understands
about slots being different from functions, and has the ability to
notify drivers of other functions that a reset is happening.

To a certain extent, what's going on with IPR here *is* an error
condition, it's just that we can recover from it with a warm reset
rather than a hot reset.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/3] pci: New PCI-E reset API
@ 2007-02-01 17:30 Brian King
  0 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-01 17:30 UTC (permalink / raw)
  To: gregkh
  Cc: James.Bottomley, linux-scsi, linuxppc-dev, paulus, brking, linux-pci


Adds a new API which can be used to issue various types
of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
This is needed for an ipr PCI-E adapter which does not properly
implement BIST. Running BIST on this adapter results in PCI-E
errors. The only reliable reset mechanism that exists on this
hardware is PCI Fundamental reset (warm reset). Since driving
this type of reset is architecture unique, this provides the
necessary hooks for architectures to add this support.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 linux-2.6-bjking1/drivers/pci/pci.c   |   29 +++++++++++++++++++++++++++++
 linux-2.6-bjking1/include/linux/pci.h |   14 ++++++++++++++
 2 files changed, 43 insertions(+)

diff -puN drivers/pci/pci.c~pci_pci_reset_api drivers/pci/pci.c
--- linux-2.6/drivers/pci/pci.c~pci_pci_reset_api	2007-01-30 12:48:54.000000000 -0600
+++ linux-2.6-bjking1/drivers/pci/pci.c	2007-01-30 12:48:54.000000000 -0600
@@ -791,6 +791,34 @@ pci_disable_device(struct pci_dev *dev)
 }
 
 /**
+ * pcibios_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI-E reset state for the device. This is the default
+ * implementation. Architecture implementations can override this.
+ */
+int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
+							enum pcie_reset_state state)
+{
+	return -EINVAL;
+}
+
+/**
+ * pci_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI reset state for the device.
+ */
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
+{
+	return pcibios_set_pcie_reset_state(dev, state);
+}
+
+/**
  * pci_enable_wake - enable device to generate PME# when suspended
  * @dev: - PCI device to operate on
  * @state: - Current state of device.
@@ -1210,6 +1238,7 @@ EXPORT_SYMBOL(pci_set_power_state);
 EXPORT_SYMBOL(pci_save_state);
 EXPORT_SYMBOL(pci_restore_state);
 EXPORT_SYMBOL(pci_enable_wake);
+EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
 
 /* Quirk info */
 
diff -puN include/linux/pci.h~pci_pci_reset_api include/linux/pci.h
--- linux-2.6/include/linux/pci.h~pci_pci_reset_api	2007-01-30 12:48:54.000000000 -0600
+++ linux-2.6-bjking1/include/linux/pci.h	2007-01-30 12:48:54.000000000 -0600
@@ -96,6 +96,19 @@ enum pci_channel_state {
 	pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
 };
 
+typedef unsigned int __bitwise pcie_reset_state_t;
+
+enum pcie_reset_state {
+	/* Reset is NOT asserted (Use to deassert reset) */
+	pci_reset_normal = (__force pcie_reset_state_t) 1,
+
+	/* Use #PERST to reset PCI-E device */
+	pci_reset_pcie_warm_reset = (__force pcie_reset_state_t) 2,
+
+	/* Use PCI-E Hot Reset to reset device */
+	pci_reset_pcie_hot_reset = (__force pcie_reset_state_t) 3
+};
+
 typedef unsigned short __bitwise pci_bus_flags_t;
 enum pci_bus_flags {
 	PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
@@ -523,6 +536,7 @@ int __must_check pci_enable_device(struc
 int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask);
 void pci_disable_device(struct pci_dev *dev);
 void pci_set_master(struct pci_dev *dev);
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
 #define HAVE_PCI_SET_MWI
 int __must_check pci_set_mwi(struct pci_dev *dev);
 void pci_clear_mwi(struct pci_dev *dev);
_

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/3] pci: New PCI-E reset API
@ 2007-02-01 17:30 Brian King
  0 siblings, 0 replies; 20+ messages in thread
From: Brian King @ 2007-02-01 17:30 UTC (permalink / raw)
  To: gregkh
  Cc: linux-pci, paulus, linuxppc-dev, James.Bottomley, linux-scsi,
	hch, brking


Adds a new API which can be used to issue various types
of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
This is needed for an ipr PCI-E adapter which does not properly
implement BIST. Running BIST on this adapter results in PCI-E
errors. The only reliable reset mechanism that exists on this
hardware is PCI Fundamental reset (warm reset). Since driving
this type of reset is architecture unique, this provides the
necessary hooks for architectures to add this support.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 linux-2.6-bjking1/drivers/pci/pci.c   |   29 +++++++++++++++++++++++++++++
 linux-2.6-bjking1/include/linux/pci.h |   14 ++++++++++++++
 2 files changed, 43 insertions(+)

diff -puN drivers/pci/pci.c~pci_pci_reset_api drivers/pci/pci.c
--- linux-2.6/drivers/pci/pci.c~pci_pci_reset_api	2007-01-30 12:48:54.000000000 -0600
+++ linux-2.6-bjking1/drivers/pci/pci.c	2007-01-30 12:48:54.000000000 -0600
@@ -791,6 +791,34 @@ pci_disable_device(struct pci_dev *dev)
 }
 
 /**
+ * pcibios_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI-E reset state for the device. This is the default
+ * implementation. Architecture implementations can override this.
+ */
+int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
+							enum pcie_reset_state state)
+{
+	return -EINVAL;
+}
+
+/**
+ * pci_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI reset state for the device.
+ */
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
+{
+	return pcibios_set_pcie_reset_state(dev, state);
+}
+
+/**
  * pci_enable_wake - enable device to generate PME# when suspended
  * @dev: - PCI device to operate on
  * @state: - Current state of device.
@@ -1210,6 +1238,7 @@ EXPORT_SYMBOL(pci_set_power_state);
 EXPORT_SYMBOL(pci_save_state);
 EXPORT_SYMBOL(pci_restore_state);
 EXPORT_SYMBOL(pci_enable_wake);
+EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
 
 /* Quirk info */
 
diff -puN include/linux/pci.h~pci_pci_reset_api include/linux/pci.h
--- linux-2.6/include/linux/pci.h~pci_pci_reset_api	2007-01-30 12:48:54.000000000 -0600
+++ linux-2.6-bjking1/include/linux/pci.h	2007-01-30 12:48:54.000000000 -0600
@@ -96,6 +96,19 @@ enum pci_channel_state {
 	pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
 };
 
+typedef unsigned int __bitwise pcie_reset_state_t;
+
+enum pcie_reset_state {
+	/* Reset is NOT asserted (Use to deassert reset) */
+	pci_reset_normal = (__force pcie_reset_state_t) 1,
+
+	/* Use #PERST to reset PCI-E device */
+	pci_reset_pcie_warm_reset = (__force pcie_reset_state_t) 2,
+
+	/* Use PCI-E Hot Reset to reset device */
+	pci_reset_pcie_hot_reset = (__force pcie_reset_state_t) 3
+};
+
 typedef unsigned short __bitwise pci_bus_flags_t;
 enum pci_bus_flags {
 	PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
@@ -523,6 +536,7 @@ int __must_check pci_enable_device(struc
 int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask);
 void pci_disable_device(struct pci_dev *dev);
 void pci_set_master(struct pci_dev *dev);
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
 #define HAVE_PCI_SET_MWI
 int __must_check pci_set_mwi(struct pci_dev *dev);
 void pci_clear_mwi(struct pci_dev *dev);
_

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/3] pci: New PCI-E reset API
@ 2007-02-01 17:30 Brian King
  2007-02-01 19:12   ` Matthew Wilcox
  0 siblings, 1 reply; 20+ messages in thread
From: Brian King @ 2007-02-01 17:30 UTC (permalink / raw)
  To: gregkh
  Cc: James.Bottomley, linux-scsi, linuxppc-dev, paulus, brking, linux-pci


Adds a new API which can be used to issue various types
of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
This is needed for an ipr PCI-E adapter which does not properly
implement BIST. Running BIST on this adapter results in PCI-E
errors. The only reliable reset mechanism that exists on this
hardware is PCI Fundamental reset (warm reset). Since driving
this type of reset is architecture unique, this provides the
necessary hooks for architectures to add this support.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
---

 linux-2.6-bjking1/drivers/pci/pci.c   |   29 +++++++++++++++++++++++++++++
 linux-2.6-bjking1/include/linux/pci.h |   14 ++++++++++++++
 2 files changed, 43 insertions(+)

diff -puN drivers/pci/pci.c~pci_pci_reset_api drivers/pci/pci.c
--- linux-2.6/drivers/pci/pci.c~pci_pci_reset_api	2007-01-30 12:48:54.000000000 -0600
+++ linux-2.6-bjking1/drivers/pci/pci.c	2007-01-30 12:48:54.000000000 -0600
@@ -791,6 +791,34 @@ pci_disable_device(struct pci_dev *dev)
 }
 
 /**
+ * pcibios_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI-E reset state for the device. This is the default
+ * implementation. Architecture implementations can override this.
+ */
+int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
+							enum pcie_reset_state state)
+{
+	return -EINVAL;
+}
+
+/**
+ * pci_set_pcie_reset_state - set reset state for device dev
+ * @dev: the PCI-E device reset
+ * @state: Reset state to enter into
+ *
+ *
+ * Sets the PCI reset state for the device.
+ */
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
+{
+	return pcibios_set_pcie_reset_state(dev, state);
+}
+
+/**
  * pci_enable_wake - enable device to generate PME# when suspended
  * @dev: - PCI device to operate on
  * @state: - Current state of device.
@@ -1210,6 +1238,7 @@ EXPORT_SYMBOL(pci_set_power_state);
 EXPORT_SYMBOL(pci_save_state);
 EXPORT_SYMBOL(pci_restore_state);
 EXPORT_SYMBOL(pci_enable_wake);
+EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
 
 /* Quirk info */
 
diff -puN include/linux/pci.h~pci_pci_reset_api include/linux/pci.h
--- linux-2.6/include/linux/pci.h~pci_pci_reset_api	2007-01-30 12:48:54.000000000 -0600
+++ linux-2.6-bjking1/include/linux/pci.h	2007-01-30 12:48:54.000000000 -0600
@@ -96,6 +96,19 @@ enum pci_channel_state {
 	pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
 };
 
+typedef unsigned int __bitwise pcie_reset_state_t;
+
+enum pcie_reset_state {
+	/* Reset is NOT asserted (Use to deassert reset) */
+	pci_reset_normal = (__force pcie_reset_state_t) 1,
+
+	/* Use #PERST to reset PCI-E device */
+	pci_reset_pcie_warm_reset = (__force pcie_reset_state_t) 2,
+
+	/* Use PCI-E Hot Reset to reset device */
+	pci_reset_pcie_hot_reset = (__force pcie_reset_state_t) 3
+};
+
 typedef unsigned short __bitwise pci_bus_flags_t;
 enum pci_bus_flags {
 	PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
@@ -523,6 +536,7 @@ int __must_check pci_enable_device(struc
 int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask);
 void pci_disable_device(struct pci_dev *dev);
 void pci_set_master(struct pci_dev *dev);
+int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
 #define HAVE_PCI_SET_MWI
 int __must_check pci_set_mwi(struct pci_dev *dev);
 void pci_clear_mwi(struct pci_dev *dev);
_

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2007-03-09 14:53 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-19 14:47 [PATCH 1/3] pci: New PCI-E reset API Brian King
2007-02-19 14:47 ` [PATCH 2/3] powerpc: Add powerpc PCI-E reset API implementation Brian King
2007-02-19 14:47   ` Brian King
2007-02-19 14:47 ` [PATCH 3/3] ipr: Use PCI-E reset API for new ipr adapter Brian King
2007-02-19 14:47   ` Brian King
2007-03-08 20:44 ` [PATCH 1/3] pci: New PCI-E reset API Brian King
2007-03-08 20:44   ` Brian King
2007-03-09  0:32   ` Greg KH
2007-03-09  0:32     ` Greg KH
2007-03-09 14:53     ` Brian King
  -- strict thread matches above, loose matches on Subject: below --
2007-02-19 14:47 Brian King
2007-02-19 14:47 Brian King
2007-02-01 17:30 Brian King
2007-02-01 17:30 Brian King
2007-02-01 19:12 ` Matthew Wilcox
2007-02-01 19:12   ` Matthew Wilcox
2007-02-01 22:14   ` Brian King
2007-02-01 22:14     ` Brian King
2007-02-09 15:20     ` Brian King
2007-02-01 17:30 Brian King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.