linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Vaibhav Jain <vaibhav@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, Frederic Barrat <fbarrat@linux.ibm.com>
Cc: Philippe Bergheaud <philippe.bergheaud@fr.ibm.com>,
	Vaibhav Jain <vaibhav@linux.ibm.com>,
	Alastair D'Silva <alastair@linux.ibm.com>,
	Christophe Lombard <christophe_lombard@fr.ibm.com>,
	Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Subject: [RFC PATCH 2/2] cxl: Force a CAPP reset when unloading CXL module
Date: Fri, 25 Jan 2019 10:41:31 +0530	[thread overview]
Message-ID: <20190125051131.29351-3-vaibhav@linux.ibm.com> (raw)
In-Reply-To: <20190125051131.29351-1-vaibhav@linux.ibm.com>

This patch forces shutdown of CAPP when CXL module is unloaded. This
is accomplished via a call to pnv_phb_to_cxl_mode() with mode ==
OPAL_PHB_CAPI_MODE_PCIE.

Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 drivers/misc/cxl/cxl.h  |  1 +
 drivers/misc/cxl/main.c |  3 +++
 drivers/misc/cxl/pci.c  | 25 ++++++++++++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index d1d927ccb589..e545c2b81faf 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -1136,4 +1136,5 @@ void cxl_context_mm_count_get(struct cxl_context *ctx);
 /* Decrements the reference count to "struct mm_struct" */
 void cxl_context_mm_count_put(struct cxl_context *ctx);
 
+void cxl_pci_shutdown_capp(void);
 #endif
diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c
index f35406be465a..f14ff0dcf231 100644
--- a/drivers/misc/cxl/main.c
+++ b/drivers/misc/cxl/main.c
@@ -372,6 +372,9 @@ static void exit_cxl(void)
 	if (cxl_is_power8())
 		unregister_cxl_calls(&cxl_calls);
 	idr_destroy(&cxl_adapter_idr);
+
+	if (cpu_has_feature(CPU_FTR_HVMODE))
+		cxl_pci_shutdown_capp();
 }
 
 module_init(init_cxl);
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index c79ba1c699ad..01be2e2d1069 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -25,7 +25,7 @@
 
 #include "cxl.h"
 #include <misc/cxl.h>
-
+#include <misc/cxllib.h>
 
 #define CXL_PCI_VSEC_ID	0x1280
 #define CXL_VSEC_MIN_SIZE 0x80
@@ -2065,6 +2065,29 @@ static void cxl_pci_resume(struct pci_dev *pdev)
 	}
 }
 
+void cxl_pci_shutdown_capp(void)
+{
+	struct pci_dev *pdev;
+	struct pci_bus *root_bus;
+	int rc;
+
+	/* Iterate over all CAPP supported PHB's and force them to PCI mode */
+	list_for_each_entry(root_bus, &pci_root_buses, node) {
+		for_each_pci_bridge(pdev, root_bus) {
+
+			if (!cxllib_slot_is_supported(pdev, 0))
+				continue;
+
+			rc = pnv_phb_to_cxl_mode(pdev,
+						 OPAL_PHB_CAPI_MODE_PCIE);
+			if (rc)
+				dev_err(&pdev->dev,
+					"cxl: Error resetting CAPP. Err=%d\n",
+					rc);
+		}
+	}
+}
+
 static const struct pci_error_handlers cxl_err_handler = {
 	.error_detected = cxl_pci_error_detected,
 	.slot_reset = cxl_pci_slot_reset,
-- 
2.20.1


  parent reply	other threads:[~2019-01-25  5:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25  5:11 [RFC PATCH 0/2] cxl: Add support for disabling CAPP when unloading CXL Vaibhav Jain
2019-01-25  5:11 ` [RFC PATCH 1/2] powerpc/powernv: Add support for CXL mode switch that need PHB reset Vaibhav Jain
2019-01-28 13:34   ` Frederic Barrat
2019-01-29  7:00     ` Vaibhav Jain
2019-01-28 16:06   ` christophe lombard
2019-01-29  5:13     ` Vaibhav Jain
2019-01-25  5:11 ` Vaibhav Jain [this message]
2019-01-28 13:34   ` [RFC PATCH 2/2] cxl: Force a CAPP reset when unloading CXL module Frederic Barrat
2019-01-28 13:34 ` [RFC PATCH 0/2] cxl: Add support for disabling CAPP when unloading CXL Frederic Barrat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190125051131.29351-3-vaibhav@linux.ibm.com \
    --to=vaibhav@linux.ibm.com \
    --cc=alastair@linux.ibm.com \
    --cc=andrew.donnellan@au1.ibm.com \
    --cc=christophe_lombard@fr.ibm.com \
    --cc=fbarrat@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=philippe.bergheaud@fr.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).