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
Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
	Oliver O'Halloran <oohall@gmail.com>,
	Vaibhav Jain <vaibhav@linux.ibm.com>,
	Laurent Dufour <ldufour@linux.vnet.ibm.com>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 2/2] powerpc/papr_scm: Force a scm-unbind if initial scm-bind fails
Date: Mon, 24 Jun 2019 20:29:13 +0530	[thread overview]
Message-ID: <20190624145913.20122-3-vaibhav@linux.ibm.com> (raw)
In-Reply-To: <20190624145913.20122-1-vaibhav@linux.ibm.com>

In some cases initial bind of scm memory for an lpar can fail if
previously it wasn't released using a scm-unbind hcall. This situation
can arise due to panic of the previous kernel or forced lpar reset. In
such cases the H_SCM_BIND_MEM return a H_OVERLAP error.

To mitigate such cases the patch updates drc_pmem_bind() to force a
call to drc_pmem_unbind() in case the initial bind of scm memory fails
with H_OVERLAP error. In case scm-bind operation again fails after the
forced scm-unbind then we follow the existing error path.

Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 arch/powerpc/platforms/pseries/papr_scm.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c
index d790e4e4ffb3..049d7927c0a4 100644
--- a/arch/powerpc/platforms/pseries/papr_scm.c
+++ b/arch/powerpc/platforms/pseries/papr_scm.c
@@ -44,19 +44,26 @@ struct papr_scm_priv {
 	struct nd_interleave_set nd_set;
 };
 
+/* Forward declaration */
+static int drc_pmem_unbind(struct papr_scm_priv *);
+
 static int drc_pmem_bind(struct papr_scm_priv *p)
 {
 	unsigned long ret[PLPAR_HCALL_BUFSIZE];
 	uint64_t rc, token;
-	uint64_t saved = 0;
+	uint64_t saved;
+	bool tried_unbind = false;
 
+	dev_dbg(&p->pdev->dev, "bind drc %x\n", p->drc_index);
 	/*
 	 * When the hypervisor cannot map all the requested memory in a single
 	 * hcall it returns H_BUSY and we call again with the token until
 	 * we get H_SUCCESS. Aborting the retry loop before getting H_SUCCESS
 	 * leave the system in an undefined state, so we wait.
 	 */
+retry:
 	token = 0;
+	saved = 0;
 
 	do {
 		rc = plpar_hcall(H_SCM_BIND_MEM, ret, p->drc_index, 0,
@@ -68,8 +75,18 @@ static int drc_pmem_bind(struct papr_scm_priv *p)
 	} while (rc == H_BUSY);
 
 	if (rc) {
-		dev_err(&p->pdev->dev, "bind err: %lld\n", rc);
-		return -ENXIO;
+		/* retry after unbinding */
+		if (rc == H_OVERLAP &&  !tried_unbind) {
+			dev_warn(&p->pdev->dev, "Un-binding and retrying\n");
+			/* Try unbind and ignore any errors */
+			tried_unbind = true;
+			drc_pmem_unbind(p);
+			goto retry;
+
+		} else {
+			dev_err(&p->pdev->dev, "bind err: %lld\n", rc);
+			return -ENXIO;
+		}
 	}
 
 	p->bound_addr = saved;
-- 
2.21.0


  parent reply	other threads:[~2019-06-24 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24 14:59 [PATCH 0/2] powerpc/papr_scm: Workaround for failure of drc bind after kexec Vaibhav Jain
2019-06-24 14:59 ` [PATCH 1/2] powerpc/papr_scm: Update drc_pmem_unbind() to use H_SCM_UNBIND_ALL Vaibhav Jain
2019-06-25  0:58   ` Oliver O'Halloran
2019-06-24 14:59 ` Vaibhav Jain [this message]
2019-06-25  1:23   ` [PATCH 2/2] powerpc/papr_scm: Force a scm-unbind if initial scm-bind fails Oliver O'Halloran

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=20190624145913.20122-3-vaibhav@linux.ibm.com \
    --to=vaibhav@linux.ibm.com \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=ldufour@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=oohall@gmail.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).