From patchwork Wed Jun 21 08:06:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shilpasri G Bhat X-Patchwork-Id: 779235 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wtPWR5Xz4z9s0m for ; Thu, 22 Jun 2017 11:44:03 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wtPWR4kDRzDrBS for ; Thu, 22 Jun 2017 11:44:03 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wsy3b3fpfzDq88 for ; Wed, 21 Jun 2017 18:06:51 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v5L83g0B121395 for ; Wed, 21 Jun 2017 04:06:49 -0400 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) by mx0a-001b2d01.pphosted.com with ESMTP id 2b7jxgdm7e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 21 Jun 2017 04:06:48 -0400 Received: from localhost by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Jun 2017 18:06:46 +1000 Received: from d23relay09.au.ibm.com (202.81.31.228) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Jun 2017 18:06:44 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v5L86i1F52691156 for ; Wed, 21 Jun 2017 18:06:44 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v5L86ZsK023086 for ; Wed, 21 Jun 2017 18:06:36 +1000 Received: from oc4502181600.ibm.com ([9.79.216.87]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v5L86Occ022756; Wed, 21 Jun 2017 18:06:31 +1000 From: Shilpasri G Bhat To: linuxppc-dev@lists.ozlabs.org, cyrilbur@gmail.com Subject: [PATCH V4 1/2] powerpc/powernv: Get a unique token for async completions Date: Wed, 21 Jun 2017 13:36:26 +0530 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1498032387-26010-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> References: <1498032387-26010-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17062108-0044-0000-0000-000002715BA9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17062108-0045-0000-0000-000007010E33 Message-Id: <1498032387-26010-2-git-send-email-shilpa.bhat@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-21_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706210135 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ego@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, paulus@samba.org, Shilpasri G Bhat Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This patch adds support to get a unique token for async completion requests. This will be used for creating non-repititive request handles for consecutive requests in OPAL-OCC command/response interface. Signed-off-by: Shilpasri G Bhat --- - No changes from V3 arch/powerpc/include/asm/opal.h | 1 + arch/powerpc/platforms/powernv/opal-async.c | 46 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index 588fb1c..03ed493 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h @@ -293,6 +293,7 @@ extern int opal_message_notifier_unregister(enum opal_msg_type msg_type, extern int __opal_async_get_token(void); extern int opal_async_get_token_interruptible(void); +extern int opal_async_get_unique_token_interruptible(int last_token); extern int __opal_async_release_token(int token); extern int opal_async_release_token(int token); extern int opal_async_wait_response(uint64_t token, struct opal_msg *msg); diff --git a/arch/powerpc/platforms/powernv/opal-async.c b/arch/powerpc/platforms/powernv/opal-async.c index 83bebee..8caeea2 100644 --- a/arch/powerpc/platforms/powernv/opal-async.c +++ b/arch/powerpc/platforms/powernv/opal-async.c @@ -73,6 +73,52 @@ int opal_async_get_token_interruptible(void) } EXPORT_SYMBOL_GPL(opal_async_get_token_interruptible); +static int __opal_async_get_new_token(int last_token) +{ + unsigned long flags; + int token; + + spin_lock_irqsave(&opal_async_comp_lock, flags); + token = find_next_bit(opal_async_complete_map, opal_max_async_tokens, + last_token + 1); + if (token >= opal_max_async_tokens) { + token = find_first_bit(opal_async_complete_map, + opal_max_async_tokens); + if (token >= opal_max_async_tokens || token == last_token) { + token = -EBUSY; + goto out; + } + } + + pr_debug("%s token = %d\n", __func__, token); + if (__test_and_set_bit(token, opal_async_token_map)) { + token = -EBUSY; + goto out; + } + + __clear_bit(token, opal_async_complete_map); + +out: + spin_unlock_irqrestore(&opal_async_comp_lock, flags); + return token; +} + +int opal_async_get_unique_token_interruptible(int last_token) +{ + int token; + + /* Wait until a token is available */ + if (down_interruptible(&opal_async_sem)) + return -ERESTARTSYS; + + token = __opal_async_get_new_token(last_token); + if (token < 0) + up(&opal_async_sem); + + return token; +} +EXPORT_SYMBOL_GPL(opal_async_get_unique_token_interruptible); + int __opal_async_release_token(int token) { unsigned long flags;