From patchwork Fri Nov 18 09:18:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13047904 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 73D76C4332F for ; Fri, 18 Nov 2022 09:21:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovxX0-0001LE-A8; Fri, 18 Nov 2022 04:19:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovxWt-0001Dh-0x for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:26 -0500 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovxWp-0005vm-Pg for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:22 -0500 Received: by mail-pg1-x52f.google.com with SMTP id 62so4458901pgb.13 for ; Fri, 18 Nov 2022 01:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wu9PcznBR0A4AHwT/zVDuaCr78FXrib5Istu/+EU5u8=; b=jBolwQebOAI0U5A5p1qT0j2Gz91+wZDUGpDg9ygjGnMhpQ2CZVp17SkyG4+TtFENEA xY7O2RoRscH777GwlOYczf9AzH/1amNyMkrzHoIjMIygMilftM95T9AmtvfH8B52QWry jmgDPA20zKKjzHHRZ4a4EuHO4/slLDrRpAay5ADQwS9rqfDM/jTG66KxQF4xr5RwmvuC jVh1w60sbuR3uol6kFTskhxWKV4b6EUrzOeBCfhliab/2hCpn4Y1j7/ruWwKSRj7LHaj OZDu7NNoMtCoFhPHU6lf1yUe7EK3jq9NRsocrW5MPCGJ8gOX1Ydci9nQaKIGMkDbHYsF r3Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wu9PcznBR0A4AHwT/zVDuaCr78FXrib5Istu/+EU5u8=; b=4lf4Qa63eny/5v1LpAxscvfb4MaDT1daiMpA/TbIns1zN0XxmhJUzeV0JkuT95N25f 4Aca/lNEmfh7FFzsXFcMFu+n/WOvKF53IlNeN4ettwuuQM9pOCkGZe2SfgYAGPC9mqt9 MzI31Q8FDkxkOg8Tkh93a6IzGg31h4oi9vZJtWyukDIGMOzL022/1IvMI9eEFuhbVy9m iA2bR3pBbIF5FtyipBuQHulyFulQEukmLz6y1yaL29dtHHnhYe3ZpW6BA6e05qpDVj3k KgpX+n34rlSpMLczRzm+WoYRncdJeuHZicFsFYxH77kaQNvqC8hmy6qpg6wEz1OXGVhm 1i/A== X-Gm-Message-State: ANoB5plJgNJgVjFBEfrraCCJ10+M5veBl0JwCjJL/e4COxVDcT/tD/ST fFq5EYJp8MjSXiEkJR6LLdMdwfFgZXP1CA== X-Google-Smtp-Source: AA0mqf5gLPiA+g2yNpd7+0G1gsim10kYnqseeizKSm0G9xMrlSDTdb1Kga0vapDzDRXT/QLKZAHObA== X-Received: by 2002:a05:6a00:27a3:b0:56d:6450:9e49 with SMTP id bd35-20020a056a0027a300b0056d64509e49mr6902260pfb.54.1668763142989; Fri, 18 Nov 2022 01:19:02 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90b2:345f:bf0a:c412]) by smtp.gmail.com with ESMTPSA id a27-20020aa794bb000000b0056e8eb09d57sm2672305pfl.63.2022.11.18.01.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 01:19:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Paolo Bonzini Subject: [PATCH for-8.0 1/7] qemu/main-loop: Introduce QEMU_IOTHREAD_LOCK_GUARD Date: Fri, 18 Nov 2022 01:18:52 -0800 Message-Id: <20221118091858.242569-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118091858.242569-1-richard.henderson@linaro.org> References: <20221118091858.242569-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Create a wrapper for locking/unlocking the iothread lock. Signed-off-by: Richard Henderson --- Cc: Paolo Bonzini (maintainer:Main loop) --- include/qemu/main-loop.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index 3c9a9a982d..c25f390696 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -343,6 +343,35 @@ void qemu_mutex_lock_iothread_impl(const char *file, int line); */ void qemu_mutex_unlock_iothread(void); +/** + * QEMU_IOTHREAD_LOCK_GUARD + * + * Wrap a block of code in a conditional qemu_mutex_{lock,unlock}_iothread. + */ +typedef struct IOThreadLockAuto IOThreadLockAuto; + +static inline IOThreadLockAuto *qemu_iothread_auto_lock(const char *file, + int line) +{ + if (qemu_mutex_iothread_locked()) { + return NULL; + } + qemu_mutex_lock_iothread_impl(file, line); + /* Anything non-NULL causes the cleanup function to be called */ + return (IOThreadLockAuto *)(uintptr_t)1; +} + +static inline void qemu_iothread_auto_unlock(IOThreadLockAuto *l) +{ + qemu_mutex_unlock_iothread(); +} + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(IOThreadLockAuto, qemu_iothread_auto_unlock) + +#define QEMU_IOTHREAD_LOCK_GUARD() \ + g_autoptr(IOThreadLockAuto) _iothread_lock_auto __attribute__((unused)) \ + = qemu_iothread_auto_lock(__FILE__, __LINE__) + /* * qemu_cond_wait_iothread: Wait on condition for the main loop mutex * From patchwork Fri Nov 18 09:18:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13047903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 06295C4332F for ; Fri, 18 Nov 2022 09:20:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovxWx-0001HY-LD; Fri, 18 Nov 2022 04:19:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovxWr-00019T-EV for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:21 -0500 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovxWp-0005vw-On for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:21 -0500 Received: by mail-pg1-x533.google.com with SMTP id v3so4508298pgh.4 for ; Fri, 18 Nov 2022 01:19:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GkJjrCQQJwPeH4gDLby1aBlAc88p7sFhkRIPIWXnOA8=; b=al5f4wZmJVQkrZ9d7PV6xuoJ2zITXsE+V+X/SNZoWioCN0zsnOt0VgFO2xjbmgY5h1 yspRKTqbMuKAKnBPyiyl2keDGMExR5K8sNevTzb5i7Ay25ROCA8I+rTaDYJV0X6setFP 558rFG9Gu+eR7yb8FWevVwlNYkaItprRpv3WEQp96z7b8piC9IBliZvtnkr8oh+lK7tY 9J5P4TraGMY8KzPH5HfbuThnzwh0sjc1WSX57U+db469/G6NK9bKhCt6qRVtSrwIYkBQ 4gSRTcRXvgdAcTRPw81OqRb3fni6aRSD3pi+iLJi4EXtpO/g0epelk3wwIX5qJS9KCz1 JAug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GkJjrCQQJwPeH4gDLby1aBlAc88p7sFhkRIPIWXnOA8=; b=Q8xwK4Tqh8+nWnYDWtna/8flR/q33NHIvBzXiWjjALApZL2xCrQ04Z2nWH88apa24j q1jprfVIwMUEuc99UkX/6VhX0A9eAM7vND8Eb+wqcReIEnVgUa1SpAfrAr/hsKvA/8JK Y9lZdrMYrtOdjPHwFkxK56iMV7xnnplhSMsqLS7+/iPlkj6ZagNE886WYF4OH2z90Sbp pMlXrTvZgt08/eoX63A3PcgXpOS2e2+r/NAAVBLvIZ+Rk6je59WWrMcWW5TwCHSj1VSN Y6/FmI/Y0GgvAJ+bCgxeLPZVrhhNq3KAkBWyXtjrrth/86zH5Ros0NA2J3u+j327LzI6 PAew== X-Gm-Message-State: ANoB5pkPnTC0qiOfRVpe7TBz1FPqBHmG2QDK7/x4qNLbc6y0qBBD6pw9 3FWfg8pRDeWs7UZml7jnI2G0VBsGYN/Uog== X-Google-Smtp-Source: AA0mqf7w9+dc5WuqZVmragBi1DDHommy8HoaDZiICY2rMAyoCugOStRh/pPLEzmOLAqWg2G03rFMnQ== X-Received: by 2002:a63:7143:0:b0:46f:918e:7338 with SMTP id b3-20020a637143000000b0046f918e7338mr5937213pgn.8.1668763144801; Fri, 18 Nov 2022 01:19:04 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90b2:345f:bf0a:c412]) by smtp.gmail.com with ESMTPSA id a27-20020aa794bb000000b0056e8eb09d57sm2672305pfl.63.2022.11.18.01.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 01:19:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PATCH for-8.0 2/7] hw/mips: Use QEMU_IOTHREAD_LOCK_GUARD in cpu_mips_irq_request Date: Fri, 18 Nov 2022 01:18:53 -0800 Message-Id: <20221118091858.242569-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118091858.242569-1-richard.henderson@linaro.org> References: <20221118091858.242569-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- Cc: Philippe Mathieu-Daudé Cc: Jiaxun Yang --- hw/mips/mips_int.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/hw/mips/mips_int.c b/hw/mips/mips_int.c index 2db5e10fe0..73437cd90f 100644 --- a/hw/mips/mips_int.c +++ b/hw/mips/mips_int.c @@ -32,17 +32,12 @@ static void cpu_mips_irq_request(void *opaque, int irq, int level) MIPSCPU *cpu = opaque; CPUMIPSState *env = &cpu->env; CPUState *cs = CPU(cpu); - bool locked = false; if (irq < 0 || irq > 7) { return; } - /* Make sure locking works even if BQL is already held by the caller */ - if (!qemu_mutex_iothread_locked()) { - locked = true; - qemu_mutex_lock_iothread(); - } + QEMU_IOTHREAD_LOCK_GUARD(); if (level) { env->CP0_Cause |= 1 << (irq + CP0Ca_IP); @@ -59,10 +54,6 @@ static void cpu_mips_irq_request(void *opaque, int irq, int level) } else { cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); } - - if (locked) { - qemu_mutex_unlock_iothread(); - } } void cpu_mips_irq_init_cpu(MIPSCPU *cpu) From patchwork Fri Nov 18 09:18:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13047902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8F83AC433FE for ; Fri, 18 Nov 2022 09:20:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovxWx-0001HX-Kd; Fri, 18 Nov 2022 04:19:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovxWt-0001EM-Sm for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:26 -0500 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovxWp-0005w3-QG for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:23 -0500 Received: by mail-pg1-x532.google.com with SMTP id 6so4493426pgm.6 for ; Fri, 18 Nov 2022 01:19:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gbukfi2lhvW+PuRANNKhuCpHW9NS0bt15N8zWXxqRno=; b=cspZu4R9G/AOykvKay12p6+YkI8KgGbsEPogDxLSet8fbj04DNVaRVZZkk8um9Xj68 GZA4Co9/NwFLNbiVvsmaBthe2Baa2PSNx4dHNweUxTI+Z5soU4XycjFTad4WoScvHGoA yzGQ1THpKfb/4gxVoZiOqYE4WHpfBlVU2OAsacgqxNT/6ZTKkd7SH82bKLMQ0/waUeb6 MJaW0LHTbkfyy3hvVeRmlfqN/qyaT/af66tdnfQcX1vMT8IdfKVSkORHuh7sy0nfcRaD OXbjenNtptA8fMB35/MJH6xqoW7EJfTTpmUK/vn+t7sy5NUsVmVoxqxg4BryRHTNLaUE kZwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gbukfi2lhvW+PuRANNKhuCpHW9NS0bt15N8zWXxqRno=; b=KPEMvG4gr0C8WiKSap8c617COZtAvCDuSyoK/QfjS+2aRzSWQLwESghm8evnpoJZ6A 5BXrI/BSg3UiiEcMF7Ksvbp8ptlPy6Noo8OUbiUtYq7pL51bkOGa8sxJcwUKJlI7xsnb 7g0cQ8oTxCqE8N03Nv8jUJqht2vSV2G1rgjlIfT9bFNdLLapZ42PPirZrsks1bMCbSZQ MIzde3pAgnXizKoGuRwStMitBPvBePc7TIpPKwlI6cd5oupViNIr3P1pM0GHSO1quxBB zOsHdRWiZVLr4yoUca9g8H5ncuDt488EA4LBUY4J/TN+cPydyaxPxtmN+8UtZe/DXkKB mY7A== X-Gm-Message-State: ANoB5pk/Q7SyZgUxlJ/9yeXa66FO07F1bL9InpXY4318wzikezWtwDV7 viB9ndIDKTJmDg8R9z+SyV5h7N+ReR4oIg== X-Google-Smtp-Source: AA0mqf5HBIaK6WYbohPawFwq06ntK/A4AwgbKOiZXlb3a+/i8SlMfURgYtcOY0vxE+HQoHHMr7JuDg== X-Received: by 2002:a63:a54d:0:b0:46f:8466:745c with SMTP id r13-20020a63a54d000000b0046f8466745cmr5945622pgu.87.1668763146611; Fri, 18 Nov 2022 01:19:06 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90b2:345f:bf0a:c412]) by smtp.gmail.com with ESMTPSA id a27-20020aa794bb000000b0056e8eb09d57sm2672305pfl.63.2022.11.18.01.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 01:19:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org Subject: [PATCH for-8.0 3/7] target/ppc: Use QEMU_IOTHREAD_LOCK_GUARD in ppc_maybe_interrupt Date: Fri, 18 Nov 2022 01:18:54 -0800 Message-Id: <20221118091858.242569-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118091858.242569-1-richard.henderson@linaro.org> References: <20221118091858.242569-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé --- Cc: qemu-ppc@nongnu.org --- target/ppc/excp_helper.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 94adcb766b..8591bb3f73 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -2163,22 +2163,13 @@ static int ppc_next_unmasked_interrupt(CPUPPCState *env) void ppc_maybe_interrupt(CPUPPCState *env) { CPUState *cs = env_cpu(env); - bool locked = false; - - if (!qemu_mutex_iothread_locked()) { - locked = true; - qemu_mutex_lock_iothread(); - } + QEMU_IOTHREAD_LOCK_GUARD(); if (ppc_next_unmasked_interrupt(env)) { cpu_interrupt(cs, CPU_INTERRUPT_HARD); } else { cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); } - - if (locked) { - qemu_mutex_unlock_iothread(); - } } #if defined(TARGET_PPC64) From patchwork Fri Nov 18 09:18:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13047900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5292BC4332F for ; Fri, 18 Nov 2022 09:20:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovxWz-0001Km-Ri; Fri, 18 Nov 2022 04:19:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovxWt-0001Dd-1D for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:26 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovxWp-0005wJ-P7 for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:22 -0500 Received: by mail-pl1-x635.google.com with SMTP id io19so4047259plb.8 for ; Fri, 18 Nov 2022 01:19:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pFfgs3OCmiINOoIxkAFBJxh98qGAkPlN373hocZd7nU=; b=SraggbNbOXppVluWWPdaxMnqM0dBKiF87StwDWA9shT2a1i0pxlII16CmLLimS8ez1 udbroKWCGLBb+1OMtIKUejsPkK3W/bjnZWV5LCB4bID7cLDXqgoWRecHj11zqIcJioO7 /4JtVtdeCsQxB/JuIm2kt8RdufMrqMFbnBpxQHenSdH5o0vgtbCZh0LyJoq25zUBXDM9 GC3OGj6IaGHipO6wcofw4cvCELq5e3Sa0H/MSCKUyKGNgH5Cspm4CQod9zJN3UL5xAEX O3Se3HTW2r+nWsWKIMCgv/9k4/m9Fuiin4xQpPPr/FiA1/1RPUN5+LCsOaOhthv5HH5l P/oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pFfgs3OCmiINOoIxkAFBJxh98qGAkPlN373hocZd7nU=; b=uPlW7xT0VFoT0/U66lgtccNEV+dlYncrcAw4F3bXTZrVwmuJBrDWjsnh79Qc2hgAH5 ip4/L2kl1eYM4a+hAJQZnVc6ZHEURSuSDhHs3pSSLMcDYYgDObjbDao26XXklDLirmgd 3vG/9Tn8+XwOUaqNN9jkN7+Cxe5NWAsVXOTphDT8vLWUpQ1syVcYbupX+ZCnDWg3ck8f Cs1i9U75ABD23ontRGKKtyJO1MPx/gr9QGh9QUtN1IA6WcGPEv6A7xZhUcLAP+P+H4Fh 0xWEKCv7ZrRjV0hLd/GaqkcnsAbes+S9ylNOohBl0zxUtYa3YB3A2hr62bkkqfmy5V2M eRrg== X-Gm-Message-State: ANoB5plwW/XWvh5zUmmXObGDsAZsuUUASKpI6M9aStq5k/3mzHDuTjiY 3QqpDj21ng1Bs+XykJ5WiuTHb/7XqTMRtQ== X-Google-Smtp-Source: AA0mqf5TQPHZITuWKf24CSYstsRAWjZVTlq3FK726nX7iG4C+8t81JDBNCRFakDGqjZrmEi8vVf0cA== X-Received: by 2002:a17:903:1351:b0:186:5f82:3812 with SMTP id jl17-20020a170903135100b001865f823812mr6859173plb.51.1668763148770; Fri, 18 Nov 2022 01:19:08 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90b2:345f:bf0a:c412]) by smtp.gmail.com with ESMTPSA id a27-20020aa794bb000000b0056e8eb09d57sm2672305pfl.63.2022.11.18.01.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 01:19:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org Subject: [PATCH for-8.0 4/7] target/ppc: Use QEMU_IOTHREAD_LOCK_GUARD in cpu_interrupt_exittb Date: Fri, 18 Nov 2022 01:18:55 -0800 Message-Id: <20221118091858.242569-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118091858.242569-1-richard.henderson@linaro.org> References: <20221118091858.242569-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In addition, use tcg_enabled instead of !kvm_enabled. Signed-off-by: Richard Henderson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé --- Cc: qemu-ppc@nongnu.org --- target/ppc/helper_regs.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index c0aee5855b..779e7db513 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -22,6 +22,7 @@ #include "qemu/main-loop.h" #include "exec/exec-all.h" #include "sysemu/kvm.h" +#include "sysemu/tcg.h" #include "helper_regs.h" #include "power8-pmu.h" #include "cpu-models.h" @@ -203,17 +204,10 @@ void cpu_interrupt_exittb(CPUState *cs) { /* * We don't need to worry about translation blocks - * when running with KVM. + * unless running with TCG. */ - if (kvm_enabled()) { - return; - } - - if (!qemu_mutex_iothread_locked()) { - qemu_mutex_lock_iothread(); - cpu_interrupt(cs, CPU_INTERRUPT_EXITTB); - qemu_mutex_unlock_iothread(); - } else { + if (tcg_enabled()) { + QEMU_IOTHREAD_LOCK_GUARD(); cpu_interrupt(cs, CPU_INTERRUPT_EXITTB); } } From patchwork Fri Nov 18 09:18:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13047899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E8235C4332F for ; Fri, 18 Nov 2022 09:20:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovxWx-0001I1-Si; Fri, 18 Nov 2022 04:19:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovxWt-0001EN-TJ for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:26 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovxWp-0005wR-QE for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:23 -0500 Received: by mail-pl1-x631.google.com with SMTP id b21so4042953plc.9 for ; Fri, 18 Nov 2022 01:19:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0xEXkQ8t+tq1lZA75jL8hUMTdx4hxvqmTCVjHKWZivA=; b=bFyuS2eSwPGJ2PMx1G/fpfeSpJ7zOYg8fWV6/oxtKSgVrtVkZuOiSSxz0Mo5SQxY72 p8qbwchwtaDHKaAuHz7J2tQZ+TlCSXzYZe0jPHipZaJ02A7P5E4r+NyICKWplg4xk/9E ZcTHBza+Ex8VHez5h4Nm3j7QXhCbp9b9fV30xccniQzNkc6YhHdT6S8Ch5L1VKGKecWn 2wdM+0ZmTY+vWGB71ncyuialBpXTXlAPYkQEwEwMfpXXiejgdbWYBESo/hu/ETlE8bvw csAQgFLPjkWDysdUGdkrxkXslJP2Walk3gYJCoYUM8Bwc0ogAZEsEoeMaYrXkklb37OV WWpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0xEXkQ8t+tq1lZA75jL8hUMTdx4hxvqmTCVjHKWZivA=; b=dSXqh6u4KLz4ejBmKNcXGyVP4ZBwYmeVdnSqvJAKkPqhOCF11vCwR+iYaD5oYVYAtq BHUT+ImU0IBUD+jiJGXmFT30KETugFOJabCIJmDAC0lPh1KLsVTI+/dGJ6cabo3cWtoq CW+dXKqxnRePgBN+TfqR74+R5htpzpygs1xMoj+DDlkFRe8lf+X7vdrnOT6xl2LpIBNN HKolucf63LfXKkEvnMjjv0Xh+4z9Q2XX/JWfA8WHQCXkPoxPqYNf38UUjMjc+11VGn9W CmrjTfo1EH8rJ+yWIt4FiEbPnyqTwqHNhmGypu2N58CP7uxbKk2CI/S4tseGngoLOvPY 5n+A== X-Gm-Message-State: ANoB5pnb46lt9t9CJc/zG5neTSCLqbnMIeIZlEJel/+3Qxlz8MalRKBe i5fXr8CW3s1HeQBPXgGtMYRm9JFXh2iXkQ== X-Google-Smtp-Source: AA0mqf4/9L6mFTiuUIMSUzbH0eonZ3nlt1wDMd1dUlRXNp3GXpRsXzoAUhJYxVCOxUtoGPMVQVAK9g== X-Received: by 2002:a17:903:2614:b0:188:635d:4b43 with SMTP id jd20-20020a170903261400b00188635d4b43mr6746807plb.69.1668763150487; Fri, 18 Nov 2022 01:19:10 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90b2:345f:bf0a:c412]) by smtp.gmail.com with ESMTPSA id a27-20020aa794bb000000b0056e8eb09d57sm2672305pfl.63.2022.11.18.01.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 01:19:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alistair Francis , Bin Meng , qemu-riscv@nongnu.org Subject: [PATCH for-8.0 5/7] target/riscv: Use QEMU_IOTHREAD_LOCK_GUARD in riscv_cpu_update_mip Date: Fri, 18 Nov 2022 01:18:56 -0800 Message-Id: <20221118091858.242569-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118091858.242569-1-richard.henderson@linaro.org> References: <20221118091858.242569-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé --- Cc: Alistair Francis Cc: Bin Meng Cc: qemu-riscv@nongnu.org --- target/riscv/cpu_helper.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 278d163803..241d06bab8 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -610,7 +610,6 @@ uint64_t riscv_cpu_update_mip(RISCVCPU *cpu, uint64_t mask, uint64_t value) CPURISCVState *env = &cpu->env; CPUState *cs = CPU(cpu); uint64_t gein, vsgein = 0, vstip = 0, old = env->mip; - bool locked = false; if (riscv_cpu_virt_enabled(env)) { gein = get_field(env->hstatus, HSTATUS_VGEIN); @@ -621,10 +620,7 @@ uint64_t riscv_cpu_update_mip(RISCVCPU *cpu, uint64_t mask, uint64_t value) mask = ((mask == MIP_VSTIP) && env->vstime_irq) ? 0 : mask; vstip = env->vstime_irq ? MIP_VSTIP : 0; - if (!qemu_mutex_iothread_locked()) { - locked = true; - qemu_mutex_lock_iothread(); - } + QEMU_IOTHREAD_LOCK_GUARD(); env->mip = (env->mip & ~mask) | (value & mask); @@ -634,10 +630,6 @@ uint64_t riscv_cpu_update_mip(RISCVCPU *cpu, uint64_t mask, uint64_t value) cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); } - if (locked) { - qemu_mutex_unlock_iothread(); - } - return old; } From patchwork Fri Nov 18 09:18:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13047898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D5711C433FE for ; Fri, 18 Nov 2022 09:19:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovxWz-0001KS-Bi; Fri, 18 Nov 2022 04:19:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovxWt-0001EP-W5 for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:26 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovxWp-0005wa-Ql for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:23 -0500 Received: by mail-pj1-x102a.google.com with SMTP id k2-20020a17090a4c8200b002187cce2f92so2577677pjh.2 for ; Fri, 18 Nov 2022 01:19:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=klMV9QcwxtW012k58NMnkKEYmz5AJ4MFhRIGSfHup4Y=; b=JXozbtKbs72AyOGMZJoXbfa/EJoyArSa+5fH/65HcnasY/JEmLkOWLG4DDwUOJfN88 f+CgQTbVD3HMi9Mux6VCv+/r5ojYfu0m8NZVLFdl6fj+OoXjtc5vtJ9Y7OCthVcrRCxV +JBkq6aWT/+DHnbyeyfDlBgVxB6RIQZoAKAcTW8TYjyOBDPF79w/UCNayz+PnMPPuisa 3z6Il0OUMqL/DekcuigUlIF6DfY9POhnirEvqXDaLDzpQ/zxF78WJaWigk4xNOi31nwB PgbOzVc955842mG5ya/KeEJyPyoBi0oPxTtx2dwknYagztRGK5Ypttu98H4JEPo81UTJ bSgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=klMV9QcwxtW012k58NMnkKEYmz5AJ4MFhRIGSfHup4Y=; b=pai7Gs+h7uY71ISarRnk0OOio0yOrUh/UJGkSegujLiAonOAqn4PQz5OfY82ypw233 dW3E8huiFxK7j8f4uPuz8vERWCv6vbGvfWzacY4YOOX/uEEUKdEpMMkJ4LjWApfZqy9n IUTvuEvpuzZFiyW6Sj5IH6DpJcoSHZqa2VYns6LBfmtOID1X9Di51reygLPNzOvAjCyi UbhIh4eK69xOj8awQwsea7GXEPYDEIP1JIhMXincEGzvCSM5DSo9GWX/J9sq23Nfnd9v 5ub4u5Y5Ztz0HzNCZbRDSNMq3s+3SUZU1Cuj7ZFMC4HyEVab7wUEkv7XMN6Jtsr8kEF3 SAww== X-Gm-Message-State: ANoB5pk+OE8t0ZfL3+XgCGIGggW31PIPBSBovVhoIziEKmkSr56P6W/G BFfky8vaWIfdfboo+pmkBxmDwq9mxG6cog== X-Google-Smtp-Source: AA0mqf5AWh4QZsl2JIw6QUW3CUBbLjWE4FDPTrY/abDF+M10Cd7EU4KaRnUxvFZFz6YBakcXrUcOyQ== X-Received: by 2002:a17:90b:4d0b:b0:214:1329:dec7 with SMTP id mw11-20020a17090b4d0b00b002141329dec7mr12947722pjb.91.1668763151823; Fri, 18 Nov 2022 01:19:11 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90b2:345f:bf0a:c412]) by smtp.gmail.com with ESMTPSA id a27-20020aa794bb000000b0056e8eb09d57sm2672305pfl.63.2022.11.18.01.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 01:19:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org Subject: [PATCH for-8.0 6/7] hw/ppc: Use QEMU_IOTHREAD_LOCK_GUARD in ppc_set_irq Date: Fri, 18 Nov 2022 01:18:57 -0800 Message-Id: <20221118091858.242569-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118091858.242569-1-richard.henderson@linaro.org> References: <20221118091858.242569-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daudé --- Cc: qemu-ppc@nongnu.org --- hw/ppc/ppc.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index dc86c1c7db..4e816c68c7 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -44,13 +44,9 @@ void ppc_set_irq(PowerPCCPU *cpu, int irq, int level) { CPUPPCState *env = &cpu->env; unsigned int old_pending; - bool locked = false; /* We may already have the BQL if coming from the reset path */ - if (!qemu_mutex_iothread_locked()) { - locked = true; - qemu_mutex_lock_iothread(); - } + QEMU_IOTHREAD_LOCK_GUARD(); old_pending = env->pending_interrupts; @@ -67,10 +63,6 @@ void ppc_set_irq(PowerPCCPU *cpu, int irq, int level) trace_ppc_irq_set_exit(env, irq, level, env->pending_interrupts, CPU(cpu)->interrupt_request); - - if (locked) { - qemu_mutex_unlock_iothread(); - } } /* PowerPC 6xx / 7xx internal IRQ controller */ From patchwork Fri Nov 18 09:18:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 13047901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1D56BC4332F for ; Fri, 18 Nov 2022 09:20:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovxX3-0001RL-LI; Fri, 18 Nov 2022 04:19:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovxWu-0001EQ-4n for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:26 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovxWp-0005wh-R8 for qemu-devel@nongnu.org; Fri, 18 Nov 2022 04:19:23 -0500 Received: by mail-pl1-x62b.google.com with SMTP id y10so2865315plp.3 for ; Fri, 18 Nov 2022 01:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xTLomTDMGtupPpPOgZN/MPA3hVB5xteqtzEufUeeVc4=; b=nBWVdlfG6jGTS4BPabqBGsFnyN8T/2fIUjbvNY5uhj45+YS35FEr7D7/CHU6CTxast VYDALSnmODgbS4TbnsvC+Pzl0b6D2khMDzlO1Bmg+wb+v5xUMA0jYiuEdMoJ6hohvcPi ZZNy4hWgoaAED25vEWCSmTVPFd4uuQIBHLf+uk8iBCR1sBpGVTR+h8+BdOmUtuQ2c+uk L+v/cFlIGtGf0QoaFI0phmDfbvYkyV0mjxFRYzLym1h1IHISP4vi3qygUN3KEDD5uxCK 3eYMbma2V8xbybp/3Ff+OqlkB1my8z2/DknrznzDy42iqveEZ+NrBR7WEpzjULriyZWl 7Zuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xTLomTDMGtupPpPOgZN/MPA3hVB5xteqtzEufUeeVc4=; b=EZmDsLk/UX4RO2AN6Ykhy6Rz+ygADHovoKuUOKeOCP74QG1zdiZu4knbIoUeq1IXBo 4086QzeDbtaHsGEJepow+sDHpxgiGDv2N8PUsY17hhLBG6PtKX6tJsDU4+V44dK6oqqT j235OdRssLPEZ93of6WpE+IVSsC/9zXr/2VCZphlNxGCM95hW2inNCfp0VSgsSaK5ort sIzOa+dZjN9hD6xhJ3kPjihEGYXqaBGs2LFn7d7Qq7ubzLAv0FHFmOCAt7vlVDR10aBN N+GRVKUalPWVuhwgdNpSQWeqp0gsR7A2aHEE3ibRHjhl+v2aQkPYLrUHkxSsPXmFCh5K znsw== X-Gm-Message-State: ANoB5pkUU01eHDIeAaDgJSl0Ekd1RDxtxMDdCj/TAzpPVP9ArcQ2Nsnr MrcDNh+EYhxlW8RjuFpCvCLuLqfgAy6AbA== X-Google-Smtp-Source: AA0mqf5BXFsWKVCUOQsEf9R1UDXJwuhjjKdyeLWl2KK9Hnlx3b92tVnAQE4OnV4lxlbumWCcYt36eQ== X-Received: by 2002:a17:902:70c3:b0:186:ba52:1dc7 with SMTP id l3-20020a17090270c300b00186ba521dc7mr6670895plt.41.1668763153253; Fri, 18 Nov 2022 01:19:13 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90b2:345f:bf0a:c412]) by smtp.gmail.com with ESMTPSA id a27-20020aa794bb000000b0056e8eb09d57sm2672305pfl.63.2022.11.18.01.19.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 01:19:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-8.0 7/7] accel/tcg: Use QEMU_IOTHREAD_LOCK_GUARD in io_readx/io_writex Date: Fri, 18 Nov 2022 01:18:58 -0800 Message-Id: <20221118091858.242569-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221118091858.242569-1-richard.henderson@linaro.org> References: <20221118091858.242569-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Narrow the scope of the lock to the actual read/write, moving the cpu_transation_failed call outside the lock. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/cputlb.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 517b599c5f..d177afcad6 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1356,7 +1356,6 @@ static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full, MemoryRegionSection *section; MemoryRegion *mr; uint64_t val; - bool locked = false; MemTxResult r; section = iotlb_to_section(cpu, full->xlat_section, full->attrs); @@ -1367,11 +1366,11 @@ static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full, cpu_io_recompile(cpu, retaddr); } - if (!qemu_mutex_iothread_locked()) { - qemu_mutex_lock_iothread(); - locked = true; + { + QEMU_IOTHREAD_LOCK_GUARD(); + r = memory_region_dispatch_read(mr, mr_offset, &val, op, full->attrs); } - r = memory_region_dispatch_read(mr, mr_offset, &val, op, full->attrs); + if (r != MEMTX_OK) { hwaddr physaddr = mr_offset + section->offset_within_address_space - @@ -1380,10 +1379,6 @@ static uint64_t io_readx(CPUArchState *env, CPUTLBEntryFull *full, cpu_transaction_failed(cpu, physaddr, addr, memop_size(op), access_type, mmu_idx, full->attrs, r, retaddr); } - if (locked) { - qemu_mutex_unlock_iothread(); - } - return val; } @@ -1410,7 +1405,6 @@ static void io_writex(CPUArchState *env, CPUTLBEntryFull *full, hwaddr mr_offset; MemoryRegionSection *section; MemoryRegion *mr; - bool locked = false; MemTxResult r; section = iotlb_to_section(cpu, full->xlat_section, full->attrs); @@ -1427,11 +1421,11 @@ static void io_writex(CPUArchState *env, CPUTLBEntryFull *full, */ save_iotlb_data(cpu, section, mr_offset); - if (!qemu_mutex_iothread_locked()) { - qemu_mutex_lock_iothread(); - locked = true; + { + QEMU_IOTHREAD_LOCK_GUARD(); + r = memory_region_dispatch_write(mr, mr_offset, val, op, full->attrs); } - r = memory_region_dispatch_write(mr, mr_offset, val, op, full->attrs); + if (r != MEMTX_OK) { hwaddr physaddr = mr_offset + section->offset_within_address_space - @@ -1441,9 +1435,6 @@ static void io_writex(CPUArchState *env, CPUTLBEntryFull *full, MMU_DATA_STORE, mmu_idx, full->attrs, r, retaddr); } - if (locked) { - qemu_mutex_unlock_iothread(); - } } static inline target_ulong tlb_read_ofs(CPUTLBEntry *entry, size_t ofs)