Received: by 10.223.164.202 with SMTP id h10csp1020815wrb; Tue, 7 Nov 2017 19:59:22 -0800 (PST) X-Google-Smtp-Source: ABhQp+QiIXJe7jy1HYclPAwdYPXUTw6389noJZKtnl2mfKRauqPp5yGer0btMDN8jj69B1+K7nXy X-Received: by 10.101.85.72 with SMTP id t8mr937900pgr.211.1510113562679; Tue, 07 Nov 2017 19:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510113562; cv=none; d=google.com; s=arc-20160816; b=meNw3DDdO1Ckt71XOnfIIhKZfJEFOEcnjppd4rwEkLkzYEb26SlAyMnAwHblSAdAEC uJwxDuuxGT9tO2vnqORIWzFEWE6N6yjGuIR9N8OvNM9EINqzPfy+tnoCJoy/c2t/PNEA DeqZDqpEbN3F6461i9PskQSR+f1D3m9yBpfZ2kxhRHDOlCiXUDxkTv5F29Ba5Ybdxzbj SCRyO8DmvifAsXuipOfghAzqyTdNBVI9eGtbLSwurqgWQ+NbQ/spZZzv6wJLQeskfJMA +P7AwAD+HehK2p9sUkeDrfFsf289weWHeeb5LEEbRGysTzYgZ4Nqin5oB2LpENrQxbqH xZng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=b8N2z9Voj7CWBNV226piRXVEFnH1LkKA/Uhyqaoh/ls=; b=vrhUCnIg2RpwGJLyzjX8ASbTr2GkhWNMB7Vsdr4rt+1h1iBXtAfa0C3ZxgMRXM++BB Ikh19LXzGiuWTk0oCKW6UjcnjdIQ8lTLC21gv6ppkvDug2B+K9mJh1Fj8zugpoTdBRi9 bsbPTDL39uUAdfxRvHW4PVm/aZ/QIxD6gga2VMgJA9saj6U0lbs+BKUZ3fwedRpec8i3 UT0VQZI6Uq7zbDvuVrh51ad9jWvfuDJhq5JGz/IaRqzffqKMZ5zjJjQMLuFxpOSWPjCo g0uXpyyq803PqEA19ssjNszy1ESXuSDj9zS0lXALBAXwodSwdWJItNCksAqeHvFw7XF4 5YmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si2678202pgt.286.2017.11.07.19.59.10; Tue, 07 Nov 2017 19:59:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753935AbdKHC1E (ORCPT + 90 others); Tue, 7 Nov 2017 21:27:04 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33760 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753097AbdKHCYQ (ORCPT ); Tue, 7 Nov 2017 21:24:16 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA82Nv71133685 for ; Tue, 7 Nov 2017 21:24:15 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2e3p8gf6wb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Nov 2017 21:24:15 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Nov 2017 19:24:14 -0700 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Nov 2017 19:24:12 -0700 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vA82OC4T51773638; Tue, 7 Nov 2017 19:24:12 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E31D66A041; Tue, 7 Nov 2017 19:24:11 -0700 (MST) Received: from suka-w540.usor.ibm.com (unknown [9.70.94.25]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 703136A043; Tue, 7 Nov 2017 19:24:11 -0700 (MST) From: Sukadev Bhattiprolu To: Michael Ellerman Cc: Benjamin Herrenschmidt , mikey@neuling.org, hbabu@us.ibm.com, nicholas.piggin@gmail.com, linuxppc-dev@ozlabs.org, Subject: [PATCH v3 08/18] powerpc/vas: poll for return of window credits Date: Tue, 7 Nov 2017 18:23:48 -0800 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510107838-15181-1-git-send-email-sukadev@linux.vnet.ibm.com> References: <1510107838-15181-1-git-send-email-sukadev@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17110802-0020-0000-0000-00000CF6A951 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008029; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00942691; UDB=6.00475552; IPR=6.00722979; BA=6.00005677; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017903; XFM=3.00000015; UTC=2017-11-08 02:24:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110802-0021-0000-0000-00005ED1531F Message-Id: <1510107838-15181-9-git-send-email-sukadev@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-07_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1711080027 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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..23c13a7 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 From 1585446708923655091@xxx Wed Nov 29 23:56:46 +0000 2017 X-GM-THRID: 1585445620006137629 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread