All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] CXL: Use image state defaults for reloading FPGA
@ 2015-01-19 17:52 Ryan Grimm
  2015-01-19 17:52 ` [PATCH 2/4] CXL: Add image control to sysfs Ryan Grimm
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Ryan Grimm @ 2015-01-19 17:52 UTC (permalink / raw)
  To: imunsie, mikey; +Cc: Ryan Grimm, linuxppc-dev

Select defaults such that a PERST causes flash image reload.  Select which
image based on what the card is set up to load.

CXL_VSEC_PERST_LOADS_IMAGE selects whether PERST assertion causes flash image
load.

CXL_VSEC_PERST_SELECT_USER selects which image is loaded on the next PERST.

cxl_update_image_control writes these bits into the VSEC.

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
---

Please consider this patch for stable.  Without these defaults, the card could
get in a bad state and require a power cycle to the box.

 drivers/misc/cxl/cxl.h |  1 +
 drivers/misc/cxl/pci.c | 42 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 0df0438..518c4c6 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -488,6 +488,7 @@ void cxl_release_one_irq(struct cxl *adapter, int hwirq);
 int cxl_alloc_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter, unsigned int num);
 void cxl_release_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter);
 int cxl_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq);
+int cxl_update_image_control(struct cxl *adapter);
 
 /* common == phyp + powernv */
 struct cxl_process_element_common {
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index f801c28..5e71ef9 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -362,6 +362,41 @@ int cxl_setup_irq(struct cxl *adapter, unsigned int hwirq,
 	return pnv_cxl_ioda_msi_setup(dev, hwirq, virq);
 }
 
+int cxl_update_image_control(struct cxl *adapter)
+{
+	struct pci_dev *dev = to_pci_dev(adapter->dev.parent);
+	int rc;
+	int vsec;
+	u8 image_state;
+
+	if (!(vsec = find_cxl_vsec(dev))) {
+		dev_err(&dev->dev, "ABORTING: CXL VSEC not found!\n");
+		return -ENODEV;
+	}
+
+	if ((rc = CXL_READ_VSEC_IMAGE_STATE(dev, vsec, &image_state))) {
+		dev_err(&dev->dev, "failed to read image state: %i\n", rc);
+		return rc;
+	}
+
+	if (adapter->perst_loads_image)
+		image_state |= CXL_VSEC_PERST_LOADS_IMAGE;
+	else
+		image_state &= ~CXL_VSEC_PERST_LOADS_IMAGE;
+
+	if (adapter->perst_select_user)
+		image_state |= CXL_VSEC_PERST_SELECT_USER;
+	else
+		image_state &= ~CXL_VSEC_PERST_SELECT_USER;
+
+	if ((rc = CXL_WRITE_VSEC_IMAGE_STATE(dev, vsec, image_state))) {
+		dev_err(&dev->dev, "failed to update image control: %i\n", rc);
+		return rc;
+	}
+
+	return 0;
+}
+
 int cxl_alloc_one_irq(struct cxl *adapter)
 {
 	struct pci_dev *dev = to_pci_dev(adapter->dev.parent);
@@ -771,8 +806,8 @@ static int cxl_read_vsec(struct cxl *adapter, struct pci_dev *dev)
 	CXL_READ_VSEC_BASE_IMAGE(dev, vsec, &adapter->base_image);
 	CXL_READ_VSEC_IMAGE_STATE(dev, vsec, &image_state);
 	adapter->user_image_loaded = !!(image_state & CXL_VSEC_USER_IMAGE_LOADED);
-	adapter->perst_loads_image = !!(image_state & CXL_VSEC_PERST_LOADS_IMAGE);
-	adapter->perst_select_user = !!(image_state & CXL_VSEC_PERST_SELECT_USER);
+	adapter->perst_loads_image = true;
+	adapter->perst_select_user = !!(image_state & CXL_VSEC_USER_IMAGE_LOADED);
 
 	CXL_READ_VSEC_NAFUS(dev, vsec, &adapter->slices);
 	CXL_READ_VSEC_AFU_DESC_OFF(dev, vsec, &afu_desc_off);
@@ -880,6 +915,9 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
 	if ((rc = cxl_vsec_looks_ok(adapter, dev)))
 		goto err2;
 
+	if ((rc = cxl_update_image_control(adapter)))
+		goto err2;
+
 	if ((rc = cxl_map_adapter_regs(adapter, dev)))
 		goto err2;
 
-- 
1.9.1

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

* [PATCH 2/4] CXL: Add image control to sysfs
  2015-01-19 17:52 [PATCH 1/4] CXL: Use image state defaults for reloading FPGA Ryan Grimm
@ 2015-01-19 17:52 ` Ryan Grimm
  2015-01-20  2:10   ` Ian Munsie
  2015-01-19 17:52 ` [PATCH 3/4] CXL: Enable CAPP recovery Ryan Grimm
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Ryan Grimm @ 2015-01-19 17:52 UTC (permalink / raw)
  To: imunsie, mikey; +Cc: Ryan Grimm, linuxppc-dev

load_image_on_perst identifies whether a PERST will cause the image to be
flashed to the card.  And if so, which image.

Valid entries are: "none", "user" and "factory".

A value of "none" means PERST will not cause the image to be flashed.  A power
cycle to the pcie slot is required to load the image.

"user" loads the user provided image and "factory" loads the factory image upon
PERST.

sysfs updates the cxl struct in the driver then calls cxl_update_image_control
to write the vals in the VSEC.

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
---
 Documentation/ABI/testing/sysfs-class-cxl | 14 +++++++++++
 drivers/misc/cxl/sysfs.c                  | 39 +++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-cxl b/Documentation/ABI/testing/sysfs-class-cxl
index 554405e..6fcc631 100644
--- a/Documentation/ABI/testing/sysfs-class-cxl
+++ b/Documentation/ABI/testing/sysfs-class-cxl
@@ -127,3 +127,17 @@ Contact:        linuxppc-dev@lists.ozlabs.org
 Description:    read only
                 Will return "user" or "factory" depending on the image loaded
                 onto the card.
+
+What:           /sys/class/cxl/<card>/load_image_on_perst
+Date:           December 2014
+Contact:        linuxppc-dev@lists.ozlabs.org
+Description:    read/write
+                Valid entries are "none", "user", and "factory".
+                "none" means PERST will not cause image to be loaded to the
+                card.  A power cycle is required to load the image.
+                "none" could be useful for debugging because the trace arrays
+                are preserved.
+                "user" and "factory" means PERST will cause either the user or
+                user or factory image to be loaded.
+                Default is to reload on PERST whichever image the card has
+                loaded.
diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c
index 461bdbd..ed4ad46 100644
--- a/drivers/misc/cxl/sysfs.c
+++ b/drivers/misc/cxl/sysfs.c
@@ -56,11 +56,50 @@ static ssize_t image_loaded_show(struct device *device,
 	return scnprintf(buf, PAGE_SIZE, "factory\n");
 }
 
+static ssize_t load_image_on_perst_show(struct device *device,
+				 struct device_attribute *attr,
+				 char *buf)
+{
+	struct cxl *adapter = to_cxl_adapter(device);
+
+	if (!adapter->perst_loads_image)
+		return scnprintf(buf, PAGE_SIZE, "none\n");
+
+	if (adapter->perst_select_user)
+		return scnprintf(buf, PAGE_SIZE, "user\n");
+	return scnprintf(buf, PAGE_SIZE, "factory\n");
+}
+
+static ssize_t load_image_on_perst_store(struct device *device,
+				 struct device_attribute *attr,
+				 const char *buf, size_t count)
+{
+	struct cxl *adapter = to_cxl_adapter(device);
+	int rc;
+
+	if (!strncmp(buf, "none", 4))
+		adapter->perst_loads_image = false;
+	else if (!strncmp(buf, "user", 4)) {
+		adapter->perst_select_user = true;
+		adapter->perst_loads_image = true;
+	} else if (!strncmp(buf, "factory", 7)) {
+		adapter->perst_select_user = false;
+		adapter->perst_loads_image = true;
+	} else
+		return -EINVAL;
+
+	if ((rc = cxl_update_image_control(adapter)))
+		return rc;
+
+	return count;
+}
+
 static struct device_attribute adapter_attrs[] = {
 	__ATTR_RO(caia_version),
 	__ATTR_RO(psl_revision),
 	__ATTR_RO(base_image),
 	__ATTR_RO(image_loaded),
+	__ATTR_RW(load_image_on_perst),
 };
 
 
-- 
1.9.1

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

* [PATCH 3/4] CXL: Enable CAPP recovery
  2015-01-19 17:52 [PATCH 1/4] CXL: Use image state defaults for reloading FPGA Ryan Grimm
  2015-01-19 17:52 ` [PATCH 2/4] CXL: Add image control to sysfs Ryan Grimm
@ 2015-01-19 17:52 ` Ryan Grimm
  2015-01-20  2:10   ` Ian Munsie
  2015-01-19 17:52 ` [PATCH 4/4] CXL: Add ability to reset the card Ryan Grimm
  2015-01-20  2:10 ` [PATCH 1/4] CXL: Use image state defaults for reloading FPGA Ian Munsie
  3 siblings, 1 reply; 12+ messages in thread
From: Ryan Grimm @ 2015-01-19 17:52 UTC (permalink / raw)
  To: imunsie, mikey; +Cc: Ryan Grimm, linuxppc-dev

Turning snoops on is the last step in CAPP recovery.  Sapphire is expected to
have reinitialized the PHB and done the previous recovery steps.

Add mode argument to opal call to do this.  Driver can turn snoops off although
it does not currently.

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/opal.h           | 8 ++++++++
 arch/powerpc/include/asm/pnv-pci.h        | 2 +-
 arch/powerpc/platforms/powernv/pci-ioda.c | 6 +++---
 drivers/misc/cxl/pci.c                    | 8 +++++++-
 4 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index eb95b67..2baf8a5 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -595,6 +595,14 @@ enum {
 	OPAL_PHB3_NUM_PEST_REGS = 256
 };
 
+/* CAPI modes for PHB */
+enum {
+	OPAL_PHB_CAPI_MODE_PCIE         = 0,
+	OPAL_PHB_CAPI_MODE_CAPI         = 1,
+	OPAL_PHB_CAPI_MODE_SNOOP_OFF    = 2,
+	OPAL_PHB_CAPI_MODE_SNOOP_ON     = 3,
+};
+
 struct OpalIoPhbErrorCommon {
 	__be32 version;
 	__be32 ioType;
diff --git a/arch/powerpc/include/asm/pnv-pci.h b/arch/powerpc/include/asm/pnv-pci.h
index f09a22f..3c00d64 100644
--- a/arch/powerpc/include/asm/pnv-pci.h
+++ b/arch/powerpc/include/asm/pnv-pci.h
@@ -13,7 +13,7 @@
 #include <linux/pci.h>
 #include <misc/cxl.h>
 
-int pnv_phb_to_cxl(struct pci_dev *dev);
+int pnv_phb_to_cxl_mode(struct pci_dev *dev, uint64_t mode);
 int pnv_cxl_ioda_msi_setup(struct pci_dev *dev, unsigned int hwirq,
 			   unsigned int virq);
 int pnv_cxl_alloc_hwirqs(struct pci_dev *dev, int num);
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index fac88ed..5d52d6f 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1468,7 +1468,7 @@ struct device_node *pnv_pci_to_phb_node(struct pci_dev *dev)
 }
 EXPORT_SYMBOL(pnv_pci_to_phb_node);
 
-int pnv_phb_to_cxl(struct pci_dev *dev)
+int pnv_phb_to_cxl_mode(struct pci_dev *dev, uint64_t mode)
 {
 	struct pci_controller *hose = pci_bus_to_host(dev->bus);
 	struct pnv_phb *phb = hose->private_data;
@@ -1481,13 +1481,13 @@ int pnv_phb_to_cxl(struct pci_dev *dev)
 
 	pe_info(pe, "Switching PHB to CXL\n");
 
-	rc = opal_pci_set_phb_cxl_mode(phb->opal_id, 1, pe->pe_number);
+	rc = opal_pci_set_phb_cxl_mode(phb->opal_id, mode, pe->pe_number);
 	if (rc)
 		dev_err(&dev->dev, "opal_pci_set_phb_cxl_mode failed: %i\n", rc);
 
 	return rc;
 }
-EXPORT_SYMBOL(pnv_phb_to_cxl);
+EXPORT_SYMBOL(pnv_phb_to_cxl_mode);
 
 /* Find PHB for cxl dev and allocate MSI hwirqs?
  * Returns the absolute hardware IRQ number
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 5e71ef9..b4aa4f1 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -927,9 +927,15 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
 	if ((rc = init_implementation_adapter_regs(adapter, dev)))
 		goto err3;
 
-	if ((rc = pnv_phb_to_cxl(dev)))
+	if ((rc = pnv_phb_to_cxl_mode(dev, OPAL_PHB_CAPI_MODE_CAPI)))
 		goto err3;
 
+	/* If recovery happened, the last step is to turn on snooping.
+	 * In the non-recovery case this has no effect */
+	if ((rc = pnv_phb_to_cxl_mode(dev, OPAL_PHB_CAPI_MODE_SNOOP_ON))) {
+		goto err3;
+	}
+
 	if ((rc = cxl_register_psl_err_irq(adapter)))
 		goto err3;
 
-- 
1.9.1

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

* [PATCH 4/4] CXL: Add ability to reset the card
  2015-01-19 17:52 [PATCH 1/4] CXL: Use image state defaults for reloading FPGA Ryan Grimm
  2015-01-19 17:52 ` [PATCH 2/4] CXL: Add image control to sysfs Ryan Grimm
  2015-01-19 17:52 ` [PATCH 3/4] CXL: Enable CAPP recovery Ryan Grimm
@ 2015-01-19 17:52 ` Ryan Grimm
  2015-01-20  2:10   ` Ian Munsie
  2015-01-20  2:10 ` [PATCH 1/4] CXL: Use image state defaults for reloading FPGA Ian Munsie
  3 siblings, 1 reply; 12+ messages in thread
From: Ryan Grimm @ 2015-01-19 17:52 UTC (permalink / raw)
  To: imunsie, mikey; +Cc: Ryan Grimm, linuxppc-dev

Adds reset to sysfs which will PERST the card.  If load_image_on_perst is set
to "user" or "factory", the PERST will cause that image to be loaded.

load_image_on_perst is set to "user" for production.

"none" could be used for debugging.  The PSL trace arrays are preserved which
then can be read through debugfs.

PERST also triggers CAPP recovery.  An HMI comes in, which is handled by EEH.
EEH unbinds the driver, calls into Sapphire to reinitialize the PHB, then
rebinds the driver.

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
---
 Documentation/ABI/testing/sysfs-class-cxl |  7 ++++++
 drivers/misc/cxl/cxl.h                    |  1 +
 drivers/misc/cxl/pci.c                    | 37 +++++++++++++++++++++++++++++++
 drivers/misc/cxl/sysfs.c                  | 18 +++++++++++++++
 4 files changed, 63 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-cxl b/Documentation/ABI/testing/sysfs-class-cxl
index 6fcc631..db31176 100644
--- a/Documentation/ABI/testing/sysfs-class-cxl
+++ b/Documentation/ABI/testing/sysfs-class-cxl
@@ -141,3 +141,10 @@ Description:    read/write
                 user or factory image to be loaded.
                 Default is to reload on PERST whichever image the card has
                 loaded.
+
+What:           /sys/class/cxl/<card>/reset
+Date:           October 2014
+Contact:        linuxppc-dev@lists.ozlabs.org
+Description:    write only
+                Writing 1 will issue a PERST to card which may cause the card
+                to reload the FPGA depending on load_image_on_perst.
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 518c4c6..6a6a487 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -489,6 +489,7 @@ int cxl_alloc_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter, unsig
 void cxl_release_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter);
 int cxl_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq);
 int cxl_update_image_control(struct cxl *adapter);
+int cxl_reset(struct cxl *adapter);
 
 /* common == phyp + powernv */
 struct cxl_process_element_common {
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index b4aa4f1..5137ee5 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -21,6 +21,7 @@
 #include <asm/msi_bitmap.h>
 #include <asm/pci-bridge.h> /* for struct pci_controller */
 #include <asm/pnv-pci.h>
+#include <asm/io.h>
 
 #include "cxl.h"
 
@@ -742,6 +743,42 @@ static void cxl_remove_afu(struct cxl_afu *afu)
 	device_unregister(&afu->dev);
 }
 
+int cxl_reset(struct cxl *adapter)
+{
+	struct pci_dev *dev = to_pci_dev(adapter->dev.parent);
+	int rc;
+	int i;
+	u32 val;
+
+	dev_info(&dev->dev, "CXL reset\n");
+
+	for (i = 0; i < adapter->slices; i++)
+		cxl_remove_afu(adapter->afu[i]);
+
+	/* pcie_warm_reset requests a fundamental pci reset which includes a
+	 * PERST assert/deassert.  PERST triggers a loading of the image
+	 * if "user" or "factory" is selected in sysfs */
+	if ((rc = pci_set_pcie_reset_state(dev, pcie_warm_reset))) {
+		dev_err(&dev->dev, "cxl: pcie_warm_reset failed\n");
+		return rc;
+	}
+
+	/* the PERST done above fences the PHB.  So, reset depends on EEH
+	 * to unbind the driver, tell Sapphire to reinit the PHB, and rebind
+	 * the driver.  Do an mmio read explictly to ensure EEH notices the
+	 * fenced PHB.  Retry for a few seconds before giving up. */
+	i = 0;
+	while (((val = mmio_read32be(adapter->p1_mmio)) != 0xffffffff) &&
+		(i < 5)) {
+		msleep(500);
+		i++;
+	}
+
+	if (val != 0xffffffff)
+		dev_err(&dev->dev, "cxl: PERST failed to trigger EEH\n");
+
+	return rc;
+}
 
 static int cxl_map_adapter_regs(struct cxl *adapter, struct pci_dev *dev)
 {
diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c
index ed4ad46..adf1f6d 100644
--- a/drivers/misc/cxl/sysfs.c
+++ b/drivers/misc/cxl/sysfs.c
@@ -56,6 +56,23 @@ static ssize_t image_loaded_show(struct device *device,
 	return scnprintf(buf, PAGE_SIZE, "factory\n");
 }
 
+static ssize_t reset_adapter_store(struct device *device,
+				   struct device_attribute *attr,
+				   const char *buf, size_t count)
+{
+	struct cxl *adapter = to_cxl_adapter(device);
+	int rc;
+	int val;
+
+	rc = sscanf(buf, "%i", &val);
+	if ((rc != 1) || (val != 1))
+		return -EINVAL;
+
+	if ((rc = cxl_reset(adapter)))
+		return rc;
+	return count;
+}
+
 static ssize_t load_image_on_perst_show(struct device *device,
 				 struct device_attribute *attr,
 				 char *buf)
@@ -100,6 +117,7 @@ static struct device_attribute adapter_attrs[] = {
 	__ATTR_RO(base_image),
 	__ATTR_RO(image_loaded),
 	__ATTR_RW(load_image_on_perst),
+	__ATTR(reset, S_IWUSR, NULL, reset_adapter_store),
 };
 
 
-- 
1.9.1

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

* Re: [PATCH 1/4] CXL: Use image state defaults for reloading FPGA
  2015-01-19 17:52 [PATCH 1/4] CXL: Use image state defaults for reloading FPGA Ryan Grimm
                   ` (2 preceding siblings ...)
  2015-01-19 17:52 ` [PATCH 4/4] CXL: Add ability to reset the card Ryan Grimm
@ 2015-01-20  2:10 ` Ian Munsie
  3 siblings, 0 replies; 12+ messages in thread
From: Ian Munsie @ 2015-01-20  2:10 UTC (permalink / raw)
  To: Ryan Grimm; +Cc: mikey, linuxppc-dev

Acked-by: Ian Munsie <imunsie@au1.ibm.com>

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

* Re: [PATCH 2/4] CXL: Add image control to sysfs
  2015-01-19 17:52 ` [PATCH 2/4] CXL: Add image control to sysfs Ryan Grimm
@ 2015-01-20  2:10   ` Ian Munsie
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Munsie @ 2015-01-20  2:10 UTC (permalink / raw)
  To: Ryan Grimm; +Cc: mikey, linuxppc-dev

Acked-by: Ian Munsie <imunsie@au1.ibm.com>

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

* Re: [PATCH 3/4] CXL: Enable CAPP recovery
  2015-01-19 17:52 ` [PATCH 3/4] CXL: Enable CAPP recovery Ryan Grimm
@ 2015-01-20  2:10   ` Ian Munsie
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Munsie @ 2015-01-20  2:10 UTC (permalink / raw)
  To: Ryan Grimm; +Cc: mikey, linuxppc-dev

Acked-by: Ian Munsie <imunsie@au1.ibm.com>

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

* Re: [PATCH 4/4] CXL: Add ability to reset the card
  2015-01-19 17:52 ` [PATCH 4/4] CXL: Add ability to reset the card Ryan Grimm
@ 2015-01-20  2:10   ` Ian Munsie
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Munsie @ 2015-01-20  2:10 UTC (permalink / raw)
  To: Ryan Grimm; +Cc: mikey, linuxppc-dev

Acked-by: Ian Munsie <imunsie@au1.ibm.com>

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

* Re: [PATCH 1/4] CXL: Use image state defaults for reloading FPGA
  2015-01-19  5:03 ` Ian Munsie
  2015-01-19  6:26   ` Michael Ellerman
@ 2015-01-19 17:02   ` Ryan Grimm
  1 sibling, 0 replies; 12+ messages in thread
From: Ryan Grimm @ 2015-01-19 17:02 UTC (permalink / raw)
  To: Ian Munsie; +Cc: mikey, linuxppc-dev, Michael Ellerman

On 01/19/2015 12:03 AM, Ian Munsie wrote:
> Acked-by: Ian Munsie <imunsie@au1.ibm.com>
>
> Looks like you forgot your Signed-off-by line - mpe, do you want Ryan to
> resend the whole patch (maybe with the below explanation included), or
> just reply with a Signed-off-by?

OK resending.

-Ryan

>
> This would also be good to CC: Stable, as these new defaults mean that
> the card will be fully reset when sapphire PERSTs them on reboot,
> whereas before it was left up to the default value of this register in
> each card, and could lead to a card getting into a bad state requiring a
> full power cycle to recover. The symptoms we saw was the tlbia / slbia
> we do on boot timing out and the driver init aborting.
>
> Cheers,
> -Ian
>

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

* Re: [PATCH 1/4] CXL: Use image state defaults for reloading FPGA
  2015-01-19  5:03 ` Ian Munsie
@ 2015-01-19  6:26   ` Michael Ellerman
  2015-01-19 17:02   ` Ryan Grimm
  1 sibling, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2015-01-19  6:26 UTC (permalink / raw)
  To: Ian Munsie; +Cc: Ryan Grimm, mikey, linuxppc-dev

On Mon, 2015-01-19 at 16:03 +1100, Ian Munsie wrote:
> Acked-by: Ian Munsie <imunsie@au1.ibm.com>
> 
> Looks like you forgot your Signed-off-by line - mpe, do you want Ryan to
> resend the whole patch (maybe with the below explanation included), or
> just reply with a Signed-off-by?

Just resend the series please.

> This would also be good to CC: Stable, as these new defaults mean that
> the card will be fully reset when sapphire PERSTs them on reboot,
> whereas before it was left up to the default value of this register in
> each card, and could lead to a card getting into a bad state requiring a
> full power cycle to recover. The symptoms we saw was the tlbia / slbia
> we do on boot timing out and the driver init aborting.

OK.

I've decided I'm going to handle stable patches differently for the next cycle,
we've been sending too many and then sending fixups and reverts.

So please just note that you'd like it to be considered for stable, under the
--- line, and I'll add it to my list and if it's still good to go in a few
weeks then I'll send it to stable.

cheers

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

* Re: [PATCH 1/4] CXL: Use image state defaults for reloading FPGA
  2015-01-16 19:48 Ryan Grimm
@ 2015-01-19  5:03 ` Ian Munsie
  2015-01-19  6:26   ` Michael Ellerman
  2015-01-19 17:02   ` Ryan Grimm
  0 siblings, 2 replies; 12+ messages in thread
From: Ian Munsie @ 2015-01-19  5:03 UTC (permalink / raw)
  To: Ryan Grimm; +Cc: mikey, linuxppc-dev, Michael Ellerman

Acked-by: Ian Munsie <imunsie@au1.ibm.com>

Looks like you forgot your Signed-off-by line - mpe, do you want Ryan to
resend the whole patch (maybe with the below explanation included), or
just reply with a Signed-off-by?

This would also be good to CC: Stable, as these new defaults mean that
the card will be fully reset when sapphire PERSTs them on reboot,
whereas before it was left up to the default value of this register in
each card, and could lead to a card getting into a bad state requiring a
full power cycle to recover. The symptoms we saw was the tlbia / slbia
we do on boot timing out and the driver init aborting.

Cheers,
-Ian

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

* [PATCH 1/4] CXL: Use image state defaults for reloading FPGA
@ 2015-01-16 19:48 Ryan Grimm
  2015-01-19  5:03 ` Ian Munsie
  0 siblings, 1 reply; 12+ messages in thread
From: Ryan Grimm @ 2015-01-16 19:48 UTC (permalink / raw)
  To: imunsie, mikey; +Cc: Ryan Grimm, linuxppc-dev

Select defaults such that a PERST causes flash image reload.  Select which
image based on what the card is set up to load.

CXL_VSEC_PERST_LOADS_IMAGE selects whether PERST assertion causes flash image
load.

CXL_VSEC_PERST_SELECT_USER selects which image is loaded on the next PERST.

cxl_update_image_control writes these bits into the VSEC.
---
 drivers/misc/cxl/cxl.h |  1 +
 drivers/misc/cxl/pci.c | 42 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 0df0438..518c4c6 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -488,6 +488,7 @@ void cxl_release_one_irq(struct cxl *adapter, int hwirq);
 int cxl_alloc_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter, unsigned int num);
 void cxl_release_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter);
 int cxl_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq);
+int cxl_update_image_control(struct cxl *adapter);
 
 /* common == phyp + powernv */
 struct cxl_process_element_common {
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index f801c28..5e71ef9 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -362,6 +362,41 @@ int cxl_setup_irq(struct cxl *adapter, unsigned int hwirq,
 	return pnv_cxl_ioda_msi_setup(dev, hwirq, virq);
 }
 
+int cxl_update_image_control(struct cxl *adapter)
+{
+	struct pci_dev *dev = to_pci_dev(adapter->dev.parent);
+	int rc;
+	int vsec;
+	u8 image_state;
+
+	if (!(vsec = find_cxl_vsec(dev))) {
+		dev_err(&dev->dev, "ABORTING: CXL VSEC not found!\n");
+		return -ENODEV;
+	}
+
+	if ((rc = CXL_READ_VSEC_IMAGE_STATE(dev, vsec, &image_state))) {
+		dev_err(&dev->dev, "failed to read image state: %i\n", rc);
+		return rc;
+	}
+
+	if (adapter->perst_loads_image)
+		image_state |= CXL_VSEC_PERST_LOADS_IMAGE;
+	else
+		image_state &= ~CXL_VSEC_PERST_LOADS_IMAGE;
+
+	if (adapter->perst_select_user)
+		image_state |= CXL_VSEC_PERST_SELECT_USER;
+	else
+		image_state &= ~CXL_VSEC_PERST_SELECT_USER;
+
+	if ((rc = CXL_WRITE_VSEC_IMAGE_STATE(dev, vsec, image_state))) {
+		dev_err(&dev->dev, "failed to update image control: %i\n", rc);
+		return rc;
+	}
+
+	return 0;
+}
+
 int cxl_alloc_one_irq(struct cxl *adapter)
 {
 	struct pci_dev *dev = to_pci_dev(adapter->dev.parent);
@@ -771,8 +806,8 @@ static int cxl_read_vsec(struct cxl *adapter, struct pci_dev *dev)
 	CXL_READ_VSEC_BASE_IMAGE(dev, vsec, &adapter->base_image);
 	CXL_READ_VSEC_IMAGE_STATE(dev, vsec, &image_state);
 	adapter->user_image_loaded = !!(image_state & CXL_VSEC_USER_IMAGE_LOADED);
-	adapter->perst_loads_image = !!(image_state & CXL_VSEC_PERST_LOADS_IMAGE);
-	adapter->perst_select_user = !!(image_state & CXL_VSEC_PERST_SELECT_USER);
+	adapter->perst_loads_image = true;
+	adapter->perst_select_user = !!(image_state & CXL_VSEC_USER_IMAGE_LOADED);
 
 	CXL_READ_VSEC_NAFUS(dev, vsec, &adapter->slices);
 	CXL_READ_VSEC_AFU_DESC_OFF(dev, vsec, &afu_desc_off);
@@ -880,6 +915,9 @@ static struct cxl *cxl_init_adapter(struct pci_dev *dev)
 	if ((rc = cxl_vsec_looks_ok(adapter, dev)))
 		goto err2;
 
+	if ((rc = cxl_update_image_control(adapter)))
+		goto err2;
+
 	if ((rc = cxl_map_adapter_regs(adapter, dev)))
 		goto err2;
 
-- 
1.9.1

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

end of thread, other threads:[~2015-01-20  2:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-19 17:52 [PATCH 1/4] CXL: Use image state defaults for reloading FPGA Ryan Grimm
2015-01-19 17:52 ` [PATCH 2/4] CXL: Add image control to sysfs Ryan Grimm
2015-01-20  2:10   ` Ian Munsie
2015-01-19 17:52 ` [PATCH 3/4] CXL: Enable CAPP recovery Ryan Grimm
2015-01-20  2:10   ` Ian Munsie
2015-01-19 17:52 ` [PATCH 4/4] CXL: Add ability to reset the card Ryan Grimm
2015-01-20  2:10   ` Ian Munsie
2015-01-20  2:10 ` [PATCH 1/4] CXL: Use image state defaults for reloading FPGA Ian Munsie
  -- strict thread matches above, loose matches on Subject: below --
2015-01-16 19:48 Ryan Grimm
2015-01-19  5:03 ` Ian Munsie
2015-01-19  6:26   ` Michael Ellerman
2015-01-19 17:02   ` Ryan Grimm

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.