From owner-svn-src-all@freebsd.org Sat Apr 6 02:31:02 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F2D81569323; Sat, 6 Apr 2019 02:31:02 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2953089713; Sat, 6 Apr 2019 02:31:02 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DECBE1E10B; Sat, 6 Apr 2019 02:31:01 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x362V1IW014865; Sat, 6 Apr 2019 02:31:01 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x362V1BV014863; Sat, 6 Apr 2019 02:31:01 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201904060231.x362V1BV014863@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Sat, 6 Apr 2019 02:31:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345974 - head/sys/powerpc/powernv X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/powernv X-SVN-Commit-Revision: 345974 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 2953089713 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Apr 2019 02:31:02 -0000 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; }