From patchwork Wed Mar 21 23:23:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 10300641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D488B60349 for ; Wed, 21 Mar 2018 23:23:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C361A29908 for ; Wed, 21 Mar 2018 23:23:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7CBE29917; Wed, 21 Mar 2018 23:23:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41E7229908 for ; Wed, 21 Mar 2018 23:23:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754185AbeCUXXl (ORCPT ); Wed, 21 Mar 2018 19:23:41 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:48828 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754050AbeCUXXk (ORCPT ); Wed, 21 Mar 2018 19:23:40 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2LND3uk047678; Wed, 21 Mar 2018 23:23:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=nXjcInDuLilqlIqkE3srE+IRma9PqWJ5Bk/raQrzI9I=; b=O7XA+P/r13F5I+z4wHfIxFzSh1FQWeqhxL0wFtgkYN9fN7HvOSd0Vk/WrdGj5FQDEetj gCoLG04RPhf9GzU9bjHnqDJMR+xFrjP19NR/kwvdg6gnsKlQHphyR3ycxIYj/5QV6Hm2 rv+SUhxn/PFvXieJJfB678Lklq0y9UOA0sPe1pNbuL8TOfHHhz4sfNjZXB/grjSlXAeb 5mJsaqLp6T8YmgvIkSuDoGX0zPcW7hB9eRk8Rhr+yJfDWxyDfy39eJ/W+PI2gC29FfW2 DShv9AyqbYSAM5arPiJO/OObReAQo7h0ohHSIbDd0aFaKI3V6dl/SMUHV+zpnIYHo+u/ 5g== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2gv0vdr0sv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Mar 2018 23:23:37 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2LNNaUK014117 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 21 Mar 2018 23:23:37 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w2LNNak4012564; Wed, 21 Mar 2018 23:23:36 GMT Received: from liran-pc.Home (/109.66.44.151) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Mar 2018 16:23:35 -0700 From: Liran Alon To: pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org Cc: idan.brown@oracle.com, Arbel Moshe , Liran Alon , Krish Sadhukhan Subject: [PATCH 1/7] x86: lib: Add busy-loop delay util Date: Thu, 22 Mar 2018 01:23:08 +0200 Message-Id: <1521674594-12085-2-git-send-email-liran.alon@oracle.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521674594-12085-1-git-send-email-liran.alon@oracle.com> References: <1521674594-12085-1-git-send-email-liran.alon@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8839 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=748 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803200127 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Arbel Moshe Add a delay utility to x86 arch. The delay is in number of busy-loop iterations running 'pause'. Signed-off-by: Arbel Moshe Signed-off-by: Liran Alon Signed-off-by: Krish Sadhukhan --- lib/x86/delay.c | 8 ++++++++ lib/x86/delay.h | 8 ++++++++ x86/Makefile.common | 1 + 3 files changed, 17 insertions(+) create mode 100644 lib/x86/delay.c create mode 100644 lib/x86/delay.h diff --git a/lib/x86/delay.c b/lib/x86/delay.c new file mode 100644 index 000000000000..595ad24fec69 --- /dev/null +++ b/lib/x86/delay.c @@ -0,0 +1,8 @@ +#include "delay.h" + +void delay(u64 count) +{ + while (count--) + asm volatile("pause"); +} + diff --git a/lib/x86/delay.h b/lib/x86/delay.h new file mode 100644 index 000000000000..a9bf89485509 --- /dev/null +++ b/lib/x86/delay.h @@ -0,0 +1,8 @@ +#ifndef __X86_DELAY__ +#define __X86_DELAY__ + +#include "libcflat.h" + +void delay(u64 count); + +#endif diff --git a/x86/Makefile.common b/x86/Makefile.common index 5f7eac4a26be..57f0bc7d16c3 100644 --- a/x86/Makefile.common +++ b/x86/Makefile.common @@ -19,6 +19,7 @@ cflatobjs += lib/x86/desc.o cflatobjs += lib/x86/isr.o cflatobjs += lib/x86/acpi.o cflatobjs += lib/x86/stack.o +cflatobjs += lib/x86/delay.o OBJDIRS += lib/x86