From patchwork Mon Feb 3 06:11:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 11362109 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A98621398 for ; Mon, 3 Feb 2020 06:23:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 809632082E for ; Mon, 3 Feb 2020 06:23:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="nt31yBQi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 809632082E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyV8v-0000TP-ML for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Feb 2020 01:23:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57698) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyUxo-0003ZU-6v for qemu-devel@nongnu.org; Mon, 03 Feb 2020 01:12:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyUxn-0003Qs-48 for qemu-devel@nongnu.org; Mon, 03 Feb 2020 01:12:04 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:47751 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iyUxm-0002gw-Pb; Mon, 03 Feb 2020 01:12:03 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 489yBr3YFMz9sSs; Mon, 3 Feb 2020 17:11:32 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1580710292; bh=YIdqK1tRx6Js2Yz0nu83Aa0ByFCx7euikjoqWW8kzKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nt31yBQi7frFFtM/k2bYI/kJ0qvMnP9Ubrg3Eg0mOWU2AWPYcXzHmPFI58ficmFFs WLMUDWrswdE24BKzfwMqraVPre1Pt07HmTQT5M4UEGyIWZwawsrPoGAA1b7o+Tqk59 j8rLfaMFa1LBAYAlYHRpOzNuj3SZ7HGtwJcgy0WM= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 24/35] Wrapper function to wait on condition for the main loop mutex Date: Mon, 3 Feb 2020 17:11:12 +1100 Message-Id: <20200203061123.59150-25-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200203061123.59150-1-david@gibson.dropbear.id.au> References: <20200203061123.59150-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Aravinda Prasad , qemu-devel@nongnu.org, groug@kaod.org, Ganesh Goudar , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Aravinda Prasad Introduce a wrapper function to wait on condition for the main loop mutex. This function atomically releases the main loop mutex and causes the calling thread to block on the condition. This wrapper is required because qemu_global_mutex is a static variable. Signed-off-by: Aravinda Prasad Signed-off-by: Ganesh Goudar Reviewed-by: David Gibson Reviewed-by: Greg Kurz Message-Id: <20200130184423.20519-2-ganeshgr@linux.ibm.com> Signed-off-by: David Gibson --- cpus.c | 5 +++++ include/qemu/main-loop.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/cpus.c b/cpus.c index b612116f95..b4f8b84b61 100644 --- a/cpus.c +++ b/cpus.c @@ -1839,6 +1839,11 @@ void qemu_mutex_unlock_iothread(void) qemu_mutex_unlock(&qemu_global_mutex); } +void qemu_cond_wait_iothread(QemuCond *cond) +{ + qemu_cond_wait(cond, &qemu_global_mutex); +} + static bool all_vcpus_paused(void) { CPUState *cpu; diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index f6ba78ea73..a6d20b0719 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -295,6 +295,14 @@ void qemu_mutex_lock_iothread_impl(const char *file, int line); */ void qemu_mutex_unlock_iothread(void); +/* + * qemu_cond_wait_iothread: Wait on condition for the main loop mutex + * + * This function atomically releases the main loop mutex and causes + * the calling thread to block on the condition. + */ +void qemu_cond_wait_iothread(QemuCond *cond); + /* internal interfaces */ void qemu_fd_register(int fd);