Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Apr 2019 02:31:01 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r345974 - head/sys/powerpc/powernv
Message-ID:  <201904060231.x362V1BV014863@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Sat Apr  6 02:31:01 2019
New Revision: 345974
URL: https://svnweb.freebsd.org/changeset/base/345974

Log:
  powerpc/powernv: Fix issues in opal_async
  
  * Properly return the full opal_msg from an async completion.
  * Don't keep bugging OPAL, wait 100us or so.  With some minor changes to
    DELAY() to drop to very low priority, the thread won't hog the CPU while
    polling for the async completion.

Modified:
  head/sys/powerpc/powernv/opal.h
  head/sys/powerpc/powernv/opal_async.c

Modified: head/sys/powerpc/powernv/opal.h
==============================================================================
--- head/sys/powerpc/powernv/opal.h	Sat Apr  6 01:49:37 2019	(r345973)
+++ head/sys/powerpc/powernv/opal.h	Sat Apr  6 02:31:01 2019	(r345974)
@@ -201,7 +201,7 @@ struct opal_ipmi_msg {
 int	opal_init_async_tokens(int);
 int	opal_alloc_async_token(void);
 void	opal_free_async_token(int);
-int	opal_wait_completion(void *, uint64_t, uint64_t);
+int	opal_wait_completion(void *, uint64_t, int);
 
 typedef void (*opal_msg_handler_fn)(void *, struct opal_msg *);
 EVENTHANDLER_DECLARE(OPAL_ASYNC_COMP, opal_msg_handler_fn);

Modified: head/sys/powerpc/powernv/opal_async.c
==============================================================================
--- head/sys/powerpc/powernv/opal_async.c	Sat Apr  6 01:49:37 2019	(r345973)
+++ head/sys/powerpc/powernv/opal_async.c	Sat Apr  6 02:31:01 2019	(r345974)
@@ -50,8 +50,8 @@ static vmem_t *async_token_pool;
 static void opal_handle_async_completion(void *, struct opal_msg *);
 
 struct async_completion {
-	uint64_t rval;
-	bool completed;
+	volatile uint64_t 	completed;
+	struct opal_msg 	msg;
 };
 
 struct async_completion *completions;
@@ -98,16 +98,21 @@ opal_free_async_token(int token)
  * of the operation, error if it returns early.
  */
 int
-opal_wait_completion(void *buf, uint64_t size, uint64_t token)
+opal_wait_completion(void *buf, uint64_t size, int token)
 {
 	int err;
 
 	do {
 		err = opal_call(OPAL_CHECK_ASYNC_COMPLETION,
 		    vtophys(buf), size, token);
-		if (err == OPAL_BUSY)
-			if (completions[token].completed)
-				return (completions[token].rval);
+		if (err == OPAL_BUSY) {
+			if (completions[token].completed) {
+				atomic_thread_fence_acq();
+				memcpy(buf, &completions[token].msg, size);
+				return (OPAL_SUCCESS);
+			}
+		}
+		DELAY(100);
 	} while (err == OPAL_BUSY);
 
 	return (err);
@@ -118,7 +123,7 @@ static void opal_handle_async_completion(void *arg, st
 	int token;
 
 	token = msg->params[0];
-	completions[token].rval = msg->params[1];
-	isync();
+	memcpy(&completions[token].msg, msg, sizeof(*msg));
+	atomic_thread_fence_rel();
 	completions[token].completed = true;
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904060231.x362V1BV014863>