From owner-svn-src-all@freebsd.org Tue Sep 3 14:06:24 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 70EEADC2D0; Tue, 3 Sep 2019 14:06:04 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (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 "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46N7yz5BMtz4P8Z; Tue, 3 Sep 2019 14:06:03 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1452) id 7F1881A060; Tue, 3 Sep 2019 14:05:56 +0000 (UTC) X-Original-To: yuripv@localmail.freebsd.org Delivered-To: yuripv@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id 9266D1AFF2; Tue, 2 Apr 2019 04:03:02 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (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 "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4078E70DC1; Tue, 2 Apr 2019 04:03:02 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 538) id 287311AFF1; Tue, 2 Apr 2019 04:03:02 +0000 (UTC) Delivered-To: src-committers@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id 16D061AFEF for ; Tue, 2 Apr 2019 04:02:59 +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 B1BD570DBE; Tue, 2 Apr 2019 04:02:58 +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 5F445209F5; Tue, 2 Apr 2019 04:02:58 +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 x3242wir081561; Tue, 2 Apr 2019 04:02:58 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3242woQ081560; Tue, 2 Apr 2019 04:02:58 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201904020402.x3242woQ081560@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345790 - 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: 345790 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Loop: FreeBSD.org Sender: owner-src-committers@freebsd.org X-Rspamd-Queue-Id: 4078E70DC1 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.94)[-0.941,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] Status: O X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 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: , Date: Tue, 03 Sep 2019 14:06:24 -0000 X-Original-Date: Tue, 2 Apr 2019 04:02:58 +0000 (UTC) X-List-Received-Date: Tue, 03 Sep 2019 14:06:24 -0000 Author: jhibbits Date: Tue Apr 2 04:02:57 2019 New Revision: 345790 URL: https://svnweb.freebsd.org/changeset/base/345790 Log: powernv: Port OPAL asynchronous framework to use the new message framework Since OPAL_GET_MSG does not discriminate between message types, asynchronous completion events may be received in the OPAL_GET_MSG call, which dequeues them from the list, thus preventing OPAL_CHECK_ASYNC_COMPLETION from succeeding. Handle this case by integrating with the messaging framework. Modified: head/sys/powerpc/powernv/opal_async.c Modified: head/sys/powerpc/powernv/opal_async.c ============================================================================== --- head/sys/powerpc/powernv/opal_async.c Tue Apr 2 04:00:01 2019 (r345789) +++ head/sys/powerpc/powernv/opal_async.c Tue Apr 2 04:02:57 2019 (r345790) @@ -35,6 +35,8 @@ #include #include "opal.h" +#include + /* * Manage asynchronous tokens for the OPAL abstraction layer. * @@ -45,6 +47,15 @@ */ static vmem_t *async_token_pool; +static void opal_handle_async_completion(void *, struct opal_msg *); + +struct async_completion { + uint64_t rval; + bool completed; +}; + +struct async_completion *completions; + /* Setup the token pool. */ int opal_init_async_tokens(int count) @@ -55,7 +66,12 @@ opal_init_async_tokens(int count) async_token_pool = vmem_create("OPAL Async", 0, count, 1, 1, M_WAITOK | M_FIRSTFIT); + completions = malloc(count * sizeof(struct async_completion), + M_DEVBUF, M_WAITOK | M_ZERO); + EVENTHANDLER_REGISTER(OPAL_ASYNC_COMP, opal_handle_async_completion, + NULL, EVENTHANDLER_PRI_ANY); + return (0); } @@ -65,6 +81,7 @@ opal_alloc_async_token(void) vmem_addr_t token; vmem_alloc(async_token_pool, 1, M_FIRSTFIT | M_WAITOK, &token); + completions[token].completed = false; return (token); } @@ -88,7 +105,20 @@ opal_wait_completion(void *buf, uint64_t size, uint64_ do { err = opal_call(OPAL_CHECK_ASYNC_COMPLETION, vtophys(buf), size, token); + if (err == OPAL_BUSY) + if (completions[token].completed) + return (completions[token].rval); } while (err == OPAL_BUSY); return (err); +} + +static void opal_handle_async_completion(void *arg, struct opal_msg *msg) +{ + int token; + + token = msg->params[0]; + completions[token].rval = msg->params[1]; + isync(); + completions[token].completed = true; }