From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
mikey@neuling.org, hbabu@us.ibm.com, linuxppc-dev@ozlabs.org,
<linux-kernel@vger.kernel.org>
Subject: [PATCH 08/10] powerpc/vas: poll for return of window credits
Date: Sat, 16 Sep 2017 21:05:26 -0700 [thread overview]
Message-ID: <1505621128-23877-9-git-send-email-sukadev@linux.vnet.ibm.com> (raw)
In-Reply-To: <1505621128-23877-1-git-send-email-sukadev@linux.vnet.ibm.com>
Normally, the NX driver waits for the CRBs to be processed before closing
the window. But it is better to ensure that the credits are returned before
the window gets reassigned later.
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
arch/powerpc/platforms/powernv/vas-window.c | 45 +++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c
index a59a187..8e14ce1 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -1063,6 +1063,49 @@ int vas_paste_crb(struct vas_window *txwin, int offset, bool re)
EXPORT_SYMBOL_GPL(vas_paste_crb);
/*
+ * If credit checking is enabled for this window, poll for the return
+ * of window credits (i.e for NX engines to process any outstanding CRBs).
+ * Since NX-842 waits for the CRBs to be processed before closing the
+ * window, we should not have to wait for too long.
+ *
+ * TODO: We retry in 10ms intervals now. We could/should probably peek at
+ * the VAS_LRFIFO_PUSH_OFFSET register to get an estimate of pending
+ * CRBs on the FIFO and compute the delay dynamically on each retry.
+ * But that is not really needed until we support NX-GZIP access from
+ * user space. (NX-842 driver waits for CSB and Fast thread-wakeup
+ * doesn't use credit checking).
+ */
+static void poll_window_credits(struct vas_window *window)
+{
+ u64 val;
+ int creds, mode;
+
+ val = read_hvwc_reg(window, VREG(WINCTL));
+ if (window->tx_win)
+ mode = GET_FIELD(VAS_WINCTL_TX_WCRED_MODE, val);
+ else
+ mode = GET_FIELD(VAS_WINCTL_RX_WCRED_MODE, val);
+
+ if (!mode)
+ return;
+retry:
+ if (window->tx_win) {
+ val = read_hvwc_reg(window, VREG(TX_WCRED));
+ creds = GET_FIELD(VAS_TX_WCRED, val);
+ } else {
+ val = read_hvwc_reg(window, VREG(LRX_WCRED));
+ creds = GET_FIELD(VAS_LRX_WCRED, val);
+ }
+
+ if (creds < window->wcreds_max) {
+ val = 0;
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(msecs_to_jiffies(10));
+ goto retry;
+ }
+}
+
+/*
* Wait for the window to go to "not-busy" state. It should only take a
* short time to queue a CRB, so window should not be busy for too long.
* Trying 5ms intervals.
@@ -1149,6 +1192,8 @@ int vas_win_close(struct vas_window *window)
unpin_close_window(window);
+ poll_window_credits(window);
+
poll_window_castout(window);
/* if send window, drop reference to matching receive window */
--
2.7.4
next prev parent reply other threads:[~2017-09-17 4:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-17 4:05 [PATCH 00/10] powerpc/vas: cleanup and optimizations Sukadev Bhattiprolu
2017-09-17 4:05 ` [PATCH 01/10] powerpc/vas: init missing fields from [rt]xattr Sukadev Bhattiprolu
2017-09-17 4:05 ` [PATCH 02/10] powerpc/vas: Validate window credits Sukadev Bhattiprolu
2017-09-17 4:05 ` [PATCH 03/10] powerpc/vas: Cleanup some debug code Sukadev Bhattiprolu
2017-09-17 4:05 ` [PATCH 04/10] powerpc/vas: Drop poll_window_cast_out() Sukadev Bhattiprolu
2017-09-17 4:05 ` [PATCH 05/10] powerpc/vas: Use helper to unpin/close window Sukadev Bhattiprolu
2017-09-17 4:05 ` [PATCH 06/10] powerpc/vas: Reduce polling interval for busy state Sukadev Bhattiprolu
2017-09-17 4:05 ` [PATCH 07/10] powerpc/vas: Save configured window credits Sukadev Bhattiprolu
2017-09-17 4:05 ` Sukadev Bhattiprolu [this message]
2017-09-17 4:05 ` [PATCH 09/10] powerpc/vas: Create cpu to vas id mapping Sukadev Bhattiprolu
2017-09-17 4:05 ` [PATCH 10/10] powerpc/vas, nx-842: Define and use chip_to_vas_id() Sukadev Bhattiprolu
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=1505621128-23877-9-git-send-email-sukadev@linux.vnet.ibm.com \
--to=sukadev@linux.vnet.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=hbabu@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mikey@neuling.org \
--cc=mpe@ellerman.id.au \
/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).