From patchwork Tue Nov 22 20:57:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 627521 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2724585pvb; Tue, 22 Nov 2022 13:00:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf5PokmIv7leOdsc0OiC6xAL5fx/TzTA60NlU/+hEZQCwfwADIyFeGi43xyUQMFPy4STikvB X-Received: by 2002:a0c:9b09:0:b0:4c6:10ee:b758 with SMTP id b9-20020a0c9b09000000b004c610eeb758mr23673881qve.130.1669150848908; Tue, 22 Nov 2022 13:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669150848; cv=none; d=google.com; s=arc-20160816; b=ZkGSDHdR0P5w1CwQstisFI+QYsGoWQrkv4/asEeRIAqs9xuGbQaTclC9vHH2pRvreS 0K8FKaipz42eMaS1/FSOe3i/xwMF/ex+kLOZWuS/56UfgqtCSo73/rf/kdxELM/bLev6 i8AYLnDFYhZo6aF85BHC6myTWSRDxSY9hFI/ixpa7pioJhyhCB1unN1Mv9hD4RqojHqi Da/VKWYTliooMnn7hGvxECsV8KvdfLglXrQR1JNMSWBj1vCFEYFenu6CiuMJdMfE0b5D Lvl86S98VWayUzFIouH78XTWoVh6QXpr/kVRW4dY/Bf25QlERG6iB0+RLuKwnbF6H8yT +ivg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ge+zCPNFiKtYpqCipG5MIx9PztOZ/CqH4Dogt2mrOwU=; b=wpSfRbgZi7iWSaeZmWe1WbCm5Wg6xe8neyK4pquPDEC0mMSjQ5P6rkoqP0DDwUPWfp a0xyhOGyT08V6liQ/dou6hVEGKMbfcd/loTGkG54dqK01VDZgpzjv+74AfDSOpGNk5xd DEiUCo+MwBzN2DAG9Iq+SdUbiHNPNP1jVhaKFOTSHCAjMcV3/Nzqfr7MzktdnbrDsMvR hH9jHVH2AWdRUEBq0rVBRfYS4t1se76ausBPpDTlsRmPpDy69TP4s/LEo+mxwX9cYVBT AVqqbYDrLhT2DZgV9LRcADpUYW/En5lzxH2mfPWJnmigPpnvwqoUoNTPo7wu8xpWk1QE E5Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JqQ7ViWJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d17-20020a05620a241100b006ecba5b7b24si8933895qkn.208.2022.11.22.13.00.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Nov 2022 13:00:48 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JqQ7ViWJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxaKy-0007Id-2E; Tue, 22 Nov 2022 15:57:48 -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 1oxaKw-0007G2-KP for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:46 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxaKu-0003Tr-Us for qemu-devel@nongnu.org; Tue, 22 Nov 2022 15:57:46 -0500 Received: by mail-pf1-x430.google.com with SMTP id c203so15462553pfc.11 for ; Tue, 22 Nov 2022 12:57:44 -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=Ge+zCPNFiKtYpqCipG5MIx9PztOZ/CqH4Dogt2mrOwU=; b=JqQ7ViWJud6iNe9dYaAMVbyhJoLEulzPMEr24zoWv1vG0rVGL/nJBWMzH4lDC4mZ/D iPWV4Igwi1QpgeGJKgnwia5PhtvoDdlmW7083w6N0hsgr7MiNHAwypowJBmHd3wnSN/G OIe895r5NGzFGTw8vGDHUjA9H74hvAqgjRf0SnWQVnkpskGBgiSb3T9HgnDDHr/X9eos LP8X82TLT582MHGIVyPJXNC0w6R6s0iGX/rjHOH/Z4Buu8LUe4bMH9jeep68qi/Sa3o1 /+75dNrIYrIPf45xkquhJOz/LHEdLft0OLOUF+V3+b2bfFHl6tqC4CY0LLVRULm8tVeq dkOA== 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=Ge+zCPNFiKtYpqCipG5MIx9PztOZ/CqH4Dogt2mrOwU=; b=GgdQ3NKT4Bu5LUEOR0StgvTIWi6C2m7SRYPaXtwgbYc5X6oNqw68GvsZqGTIvchJuj +c8tKi8pnOB4f49tb6RdLVcJQHX5iKG0zFhDF7tD7cYTu2oTmUpkb4bT8xE63Way0dWG QpN4zW7xqaDnRRU/lUBzSINxQRt6X99EBmVpgpTWD7StXNWiK2mXyv2u91I5+1KtN1rO Yk+3UcWLFJKf1+1RdWdbgSRKOAS2Rj5Iodt90iuXUVF9pvafWCZIy+Frj5fhNze9Bym/ 6FOF73UIbaIyOtJsU9ph1x8Sqcd3b9FGjV6WZ59feQwhdfLrVAqetxUanuU0wFBarVm4 l+pQ== X-Gm-Message-State: ANoB5plDeJylT4FQWcOB8HAgz9OFIAz+ngStq5BXtIvWlTZ3aTE9yIhh Ho38ioRZU0qBALqR0aIhnkussiZzUzjlmw== X-Received: by 2002:a05:6a00:1f0f:b0:56e:7424:bc0f with SMTP id be15-20020a056a001f0f00b0056e7424bc0fmr15099952pfb.11.1669150663551; Tue, 22 Nov 2022 12:57:43 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:90f5:6f8b:e78a:4a0]) by smtp.gmail.com with ESMTPSA id d19-20020a170903209300b00186fa988a13sm12383807plc.166.2022.11.22.12.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 12:57:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, philmd@linaro.org, alex.bennee@linaro.org Subject: [PATCH v2 2/7] hw/mips: Use WITH_QEMU_IOTHREAD_LOCK in cpu_mips_irq_request Date: Tue, 22 Nov 2022 12:57:34 -0800 Message-Id: <20221122205739.603510-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221122205739.603510-1-richard.henderson@linaro.org> References: <20221122205739.603510-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- hw/mips/mips_int.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/hw/mips/mips_int.c b/hw/mips/mips_int.c index 2db5e10fe0..c22598d353 100644 --- a/hw/mips/mips_int.c +++ b/hw/mips/mips_int.c @@ -32,36 +32,27 @@ 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(); - } + WITH_QEMU_IOTHREAD_LOCK() { + if (level) { + env->CP0_Cause |= 1 << (irq + CP0Ca_IP); + } else { + env->CP0_Cause &= ~(1 << (irq + CP0Ca_IP)); + } - if (level) { - env->CP0_Cause |= 1 << (irq + CP0Ca_IP); - } else { - env->CP0_Cause &= ~(1 << (irq + CP0Ca_IP)); - } + if (kvm_enabled() && (irq == 2 || irq == 3)) { + kvm_mips_set_interrupt(cpu, irq, level); + } - if (kvm_enabled() && (irq == 2 || irq == 3)) { - kvm_mips_set_interrupt(cpu, irq, level); - } - - if (env->CP0_Cause & CP0Ca_IP_mask) { - cpu_interrupt(cs, CPU_INTERRUPT_HARD); - } else { - cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); - } - - if (locked) { - qemu_mutex_unlock_iothread(); + if (env->CP0_Cause & CP0Ca_IP_mask) { + cpu_interrupt(cs, CPU_INTERRUPT_HARD); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); + } } }