From patchwork Thu Jan 19 17:05:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 92010 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp398209qgi; Thu, 19 Jan 2017 09:52:02 -0800 (PST) X-Received: by 10.55.207.67 with SMTP id e64mr8651579qkj.272.1484848322659; Thu, 19 Jan 2017 09:52:02 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o68si3062952qkf.288.2017.01.19.09.52.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Jan 2017 09:52:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUGsS-0006LY-3s for patch@linaro.org; Thu, 19 Jan 2017 12:52:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUGGU-0005Tv-QB for qemu-devel@nongnu.org; Thu, 19 Jan 2017 12:12:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cUGGT-0001fx-HR for qemu-devel@nongnu.org; Thu, 19 Jan 2017 12:12:46 -0500 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:34895) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cUGGT-0001fW-B1 for qemu-devel@nongnu.org; Thu, 19 Jan 2017 12:12:45 -0500 Received: by mail-wm0-x234.google.com with SMTP id r126so2706236wmr.0 for ; Thu, 19 Jan 2017 09:12:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/FQ0bNIQzLc1pO8btpl1ngB9PNmG3OsBYmDWGFhaBYI=; b=OVvK9NBzcTTcMu38iW/naj/+SVJAAnvDzHBqe6JukfJ0/0kJRmhmZBKhBLgD+/pthT PratG5PeWFBlnYsJo+layOd3QfZhwvNoRVMGlAQ81NJTux5cjF6FYxfW4H/XJPqg2xQt +8YHrb/p1Q4EG929U3wKCNV+ExB/IWKsjsOHc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/FQ0bNIQzLc1pO8btpl1ngB9PNmG3OsBYmDWGFhaBYI=; b=VEAU9qT5eHRFMxx05RPTdJo+4E34nW81Su5UNamzDN5WuHdiwZQUnCUZNfSxvykHwx EMsLrHGGDs9glsgMVYvbA08hkvmLkpwqg/JMfnCbXLQ4a23dzC7DO4uWQoiNHU82LNHz M9wYRSxli9z9I8rgSB651LbTbeihKdY9SbrHe3XVZT8/qld9xmrhJA/zpWZyD+V9AQZp VmE5indPyOzzXntI8HG6WXm2oxSukJzKeqApk+pXBzLe3B0CZAObGhMeZ3eihBucFxTh J+GRmZNQF7vOr2xoBkCPsZd+LSgmoLlvJQQHJ+X/D71hHtITO1Of5dfhHvUJoBDS1WlA M+Dw== X-Gm-Message-State: AIkVDXKSJTLZohtNStrTXgSOiDEOceDm4K2Sbgi5cwjzxW8kwUlnor22nXVwahrLa0/FajUj X-Received: by 10.28.206.136 with SMTP id e130mr3727182wmg.121.1484845964036; Thu, 19 Jan 2017 09:12:44 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g197sm54627514wmd.15.2017.01.19.09.12.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jan 2017 09:12:42 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id B90C13E2A49; Thu, 19 Jan 2017 17:05:09 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: mttcg@listserver.greensocs.com, qemu-devel@nongnu.org, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, bobby.prani@gmail.com, nikunj@linux.vnet.ibm.com Date: Thu, 19 Jan 2017 17:05:07 +0000 Message-Id: <20170119170507.16185-28-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170119170507.16185-1-alex.bennee@linaro.org> References: <20170119170507.16185-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 Subject: [Qemu-devel] [PATCH v7 27/27] target-ppc: take global mutex for set_irq X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, claudio.fontana@huawei.com, jan.kiszka@siemens.com, mark.burton@greensocs.com, Alexander Graf , "open list:PowerPC" , serge.fdrv@gmail.com, pbonzini@redhat.com, David Gibson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , bamvor.zhangjian@linaro.org, rth@twiddle.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have to do this conditionally as the reset paths can trigger IRQ setting when the machine is first brought up. Signed-off-by: Alex Bennée --- hw/ppc/ppc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.11.0 diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 8945869009..59c3faa6c8 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -62,7 +62,16 @@ void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level) { CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; - unsigned int old_pending = env->pending_interrupts; + 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(); + } + + old_pending = env->pending_interrupts; if (level) { env->pending_interrupts |= 1 << n_IRQ; @@ -80,9 +89,14 @@ void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level) #endif } + LOG_IRQ("%s: %p n_IRQ %d level %d => pending %08" PRIx32 "req %08x\n", __func__, env, n_IRQ, level, env->pending_interrupts, CPU(cpu)->interrupt_request); + + if (locked) { + qemu_mutex_unlock_iothread(); + } } /* PowerPC 6xx / 7xx internal IRQ controller */