Received: by 10.223.164.202 with SMTP id h10csp1016822wrb; Tue, 7 Nov 2017 19:53:23 -0800 (PST) X-Google-Smtp-Source: ABhQp+SN1SuK2yxnPzO1+Dd0zDl7wWER0OxhtfVRiInVAJRUWNUUZ6bjjyOmHd/vU67PebKntkQV X-Received: by 10.84.131.197 with SMTP id d63mr927618pld.414.1510113203477; Tue, 07 Nov 2017 19:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510113203; cv=none; d=google.com; s=arc-20160816; b=OaSwKPpCUkQy4Yn3brgT3bxbxz6q/86HlsANJpoZs0LLg/Okv5nV13pz4ZISgezgd9 ROlQfCjFHzHnGb7s8vZ9qEv2a2P3GJCZC5GFMwQ2pyME6J3K2naoBtjYouil2a0GV255 7GkGc5QESMC/8QMd5//KabOci98JPITrHhy7LdA6nLAMRCJBhG0wxiqOxWGFEEf06aM3 SUma5QGOjnNo+/hDa7boJAr/Tgg9iIc21YBBFV76Kz0eBWA68wDkd1OBWD/je8ph5v0F fcZSfIi7IJeLApbKciyZUhRVxBuT3Foam8d5rXp4gqkUSaQZo5aLLa280Xe3cUGKo1u+ ZJ4g== 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=5MoTTXUgbrvHaxg3cukxYTKHYQV9wcbUzJLdFEVlJBw=; b=Dff0TTF3nEaSGZRbGDfKoiryHM66yNDpzaUECaPgrGDq4ftib53cypl4CfbbQ4I1sC RH8N5XDcdOb1sR97lrOAc6RRQgz78PeQWvvjD7H1C3Z8If2/YkwFQbmtgBIHgMWu9vqM gooxpYm4V+RuTLWbAxjTYecPIAhWRWdumj/SJVa2XfSxe5LfwLULqTJShXZULfrG262c 6ujYjXm0O6DIdChr2O69mgfxXvpLcK7LA6xjKd5rBcWXDSX2FuNWzi8tGw9Uwl8payTq ouC6vfsi0gZORcUS53w2XEUkhdJw1vXHEGNk/TLBOJs+vco7fkLPks/hZwcBq3bkioCF ksTw== 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 o5si2553029plh.660.2017.11.07.19.53.11; Tue, 07 Nov 2017 19:53:23 -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 S1753469AbdKHCYh (ORCPT + 90 others); Tue, 7 Nov 2017 21:24:37 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50558 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753304AbdKHCYc (ORCPT ); Tue, 7 Nov 2017 21:24:32 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA82O0wO193822 for ; Tue, 7 Nov 2017 21:24:31 -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 2e3m26n0j4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Nov 2017 21:24:31 -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:30 -0700 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) 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:27 -0700 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vA82ORJl63701040; Tue, 7 Nov 2017 19:24:27 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D0F96A03C; Tue, 7 Nov 2017 19:24:27 -0700 (MST) Received: from suka-w540.usor.ibm.com (unknown [9.70.94.25]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id AEDFF6A03B; Tue, 7 Nov 2017 19:24:26 -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 18/18] powerpc/vas: Add support for user receive window Date: Tue, 7 Nov 2017 18:23:58 -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-00000CF6A95E 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.00722980; 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:29 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110802-0021-0000-0000-00005ED15343 Message-Id: <1510107838-15181-19-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=2 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 Add support for user space receive window (for the Fast thread-wakeup coprocessor type) Signed-off-by: Sukadev Bhattiprolu --- Changelog[v3] - [Nick Piggin] Drop CP_ABORT since set_thread_uses_vas() does that now (in earlier patch) and add a check for return value. --- arch/powerpc/platforms/powernv/vas-window.c | 56 +++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c index 8275492..2b3eb01 100644 --- a/arch/powerpc/platforms/powernv/vas-window.c +++ b/arch/powerpc/platforms/powernv/vas-window.c @@ -16,7 +16,8 @@ #include #include #include - +#include +#include #include "vas.h" #include "copy-paste.h" @@ -598,6 +599,32 @@ static void put_rx_win(struct vas_window *rxwin) } /* + * Find the user space receive window given the @pswid. + * - We must have a valid vasid and it must belong to this instance. + * (so both send and receive windows are on the same VAS instance) + * - The window must refer to an OPEN, FTW, RECEIVE window. + * + * NOTE: We access ->windows[] table and assume that vinst->mutex is held. + */ +static struct vas_window *get_user_rxwin(struct vas_instance *vinst, u32 pswid) +{ + int vasid, winid; + struct vas_window *rxwin; + + decode_pswid(pswid, &vasid, &winid); + + if (vinst->vas_id != vasid) + return ERR_PTR(-EINVAL); + + rxwin = vinst->windows[winid]; + + if (!rxwin || rxwin->tx_win || rxwin->cop != VAS_COP_TYPE_FTW) + return ERR_PTR(-EINVAL); + + return rxwin; +} + +/* * Get the VAS receive window associated with NX engine identified * by @cop and if applicable, @pswid. * @@ -610,10 +637,10 @@ static struct vas_window *get_vinst_rxwin(struct vas_instance *vinst, mutex_lock(&vinst->mutex); - if (cop == VAS_COP_TYPE_842 || cop == VAS_COP_TYPE_842_HIPRI) - rxwin = vinst->rxwin[cop] ?: ERR_PTR(-EINVAL); + if (cop == VAS_COP_TYPE_FTW) + rxwin = get_user_rxwin(vinst, pswid); else - rxwin = ERR_PTR(-EINVAL); + rxwin = vinst->rxwin[cop] ?: ERR_PTR(-EINVAL); if (!IS_ERR(rxwin)) atomic_inc(&rxwin->num_txwins); @@ -937,10 +964,9 @@ static void init_winctx_for_txwin(struct vas_window *txwin, winctx->tx_word_mode = txattr->tx_win_ord_mode; winctx->rsvd_txbuf_count = txattr->rsvd_txbuf_count; - if (winctx->nx_win) { + winctx->intr_disable = true; + if (winctx->nx_win) winctx->data_stamp = true; - winctx->intr_disable = true; - } winctx->lpid = txattr->lpid; winctx->pidr = txattr->pidr; @@ -985,6 +1011,14 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop, if (!tx_win_args_valid(cop, attr)) return ERR_PTR(-EINVAL); + /* + * If caller did not specify a vasid but specified the PSWID of a + * receive window (applicable only to FTW windows), use the vasid + * from that receive window. + */ + if (vasid == -1 && attr->pswid) + decode_pswid(attr->pswid, &vasid, NULL); + vinst = find_vas_instance(vasid); if (!vinst) { pr_devel("vasid %d not found!\n", vasid); @@ -1031,6 +1065,14 @@ struct vas_window *vas_tx_win_open(int vasid, enum vas_cop_type cop, } } + /* + * Now that we have a send window, ensure context switch issues + * CP_ABORT for this thread. + */ + rc = -EINVAL; + if (set_thread_uses_vas() < 0) + goto free_window; + set_vinst_win(vinst, txwin); return txwin; -- 2.7.4 From 1583581165387493624@xxx Thu Nov 09 09:44:45 +0000 2017 X-GM-THRID: 1583483451461525087 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread