From patchwork Wed Aug 5 18:12:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 247467 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp763580ilo; Wed, 5 Aug 2020 11:26:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6it3ThqJYmH4mcOxHnVlcxRnbRWIA3az1ee7pXVSAXttYUDtQoT9NFIB5Y2zMSe9hIvO4 X-Received: by 2002:a25:2d5c:: with SMTP id s28mr7024102ybe.23.1596651970121; Wed, 05 Aug 2020 11:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596651970; cv=none; d=google.com; s=arc-20160816; b=ML6nw8ZwCxzcOPIiP/c+FrUcDZEl9u5dNRv2qCH3YgutM5/StEJUSxkWOgb7cwuk7S 7Ud13sqemSa/Hs5q1unPoyZhD1eQ165FvPVmko2GAo3Sjh081ROWhwC39bn0oFU2QC/h E/87YCUPFmjR1PPb05aXgMIfNLjVAH7SR/NBjxMI6AZ+Q6BRB/roIyKXUHJeq99QISj4 FleSeo55OBZxl44PSyeJnwJUCoL7afZ5Qo7mPM1pmT43xpRVxSMUL3MwYFdHACbVjIs4 VtZoKTwft7ZefhGYwfKXUM7c9S9a/h8CzDx8QcCCiiFBmHxI2mt+2B+IW56xaZimJIRB eJiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=sPSOE7FlbJqSNOCq29FKQeTA9v1eH7Mn/6Yq8WOQ91Q=; b=Stxr/xlgbOsjltN7wX2W49s126/OvqB5bpU7BzLsaA1Oy5AKOOQp4hRDWoBGxe7xRC xbAmok3syUxiMwBqB/sHog2eedh52wOKITZL8hZsCY4a9WHXhPYC20E4fLU4pybFJQ/p qBMCqj5H0W/cliqjLka9c0oar500XNFsZ/FY5al51AWxyXehK+eVlr/38G7WSJkK9QJv pYWQuVdU+ByBWYhzN7UeElMntetZqTF4DAl7Z1RQMcCcrTz2DMagbLSzptnkeWwIofOo zCqvTTsV7bKej58UbEIUrtZxI6v152+R9SmTWgABDDl0l2d29wnnuXTdYOIFNqSUth9S MJxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kXpbP+C2; 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=fail (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 j70si2466304ybg.320.2020.08.05.11.26.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Aug 2020 11:26:10 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=kXpbP+C2; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:50340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O77-0001SB-Jc for patch@linaro.org; Wed, 05 Aug 2020 14:26:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyh-0004F7-39 for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:27 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:35710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyf-0006TU-2K for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:26 -0400 Received: by mail-pl1-x644.google.com with SMTP id r4so15134267pls.2 for ; Wed, 05 Aug 2020 11:17:24 -0700 (PDT) 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; bh=sPSOE7FlbJqSNOCq29FKQeTA9v1eH7Mn/6Yq8WOQ91Q=; b=kXpbP+C2n9auaXiYPp+Eepc+/rRmw8U+C30wKtE2ujwOqJQ42A5YToUA29b835eoOm NlCqlIgtLVJ9DkqYSuGUaUlQfKH8pCwTkvKrRX2CvNXpH26YOsMSDtzvJ4f+rdthJkeQ w91ZUKT0reTrfrDWByWFl/Fmgu+xGROindsnV1xOI1B/aIWeXGwU5L/kMGEyd7lv/jCl TAyRCW99BtjAWsMnEoavx3aoHZfPvBttjDEc34wa5nR+cbpB4Drxv+2uJjGVhc64cXNr Q0v587VqLJj8Zk5Lo203XbczOIUpjEruNmb97Nwxb+jeHXjvhBfg/YA1XKwXiLMMtJ7D Lf9w== 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; bh=sPSOE7FlbJqSNOCq29FKQeTA9v1eH7Mn/6Yq8WOQ91Q=; b=sg0DwxdiQLWqyR1LF5A4MNttmeXVP/tlcNHNsQJI1MrXxjTcM0sAQoKY22Ze9qgSUz xOPD3PuY1xrkEWHz1p5ciw/C66repThQ5miwXjRpbvK6gRYdSZmHyWUhIazsj7TBJFnA yTuTJ2elZfwu5Rb8iw9FQsvsixc7kwFU5APCKATiVbKMsBSiVOoeCRoKxRHS4562me3G 97A+mVTV2dqOle/k8VuWqeNnzLGtG3+GKbjVyfaY30aIKTmSLsmev0KF9yjnoPNetPbg lwkJuP6s8g/RlLJOCH1HRpebXnmG5nHpH5hWWBijacfsfE3Krq5306ET9jPzl9ksBAgy qQFQ== X-Gm-Message-State: AOAM533ox/ymzTXZQdwsYzvjfTYDFx1VHpqLsPKgXdVNhbrEdsn+0iC0 HD64c7c+zEPuQLMwuqpn8klhVy52xA4= X-Received: by 2002:a17:902:a607:: with SMTP id u7mr4360104plq.45.1596651443512; Wed, 05 Aug 2020 11:17:23 -0700 (PDT) Received: from Rfoley-MA01.hsd1.ma.comcast.net ([2601:199:4480:60c0:38ab:50b1:ff8a:26ef]) by smtp.gmail.com with ESMTPSA id a15sm3670196pfo.185.2020.08.05.11.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:22 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 08/21] target/lm32: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:50 -0400 Message-Id: <20200805181303.7822-9-robert.foley@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805181303.7822-1-robert.foley@linaro.org> References: <20200805181303.7822-1-robert.foley@linaro.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=robert.foley@linaro.org; helo=mail-pl1-x644.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@linaro.org, Michael Walle , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is part of a series of changes to remove the implied BQL from the common code of cpu_handle_interrupt and cpu_handle_exception. As part of removing the implied BQL from the common code, we are pushing the BQL holding down into the per-arch implementation functions of do_interrupt and cpu_exec_interrupt. The purpose of this set of changes is to set the groundwork so that an arch could move towards removing the BQL from the cpu_handle_interrupt/exception paths. This approach was suggested by Paolo Bonzini. For reference, here are two key posts in the discussion, explaining the reasoning/benefits of this approach. https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg08731.html https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg00044.html Signed-off-by: Robert Foley --- target/lm32/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.17.1 diff --git a/target/lm32/helper.c b/target/lm32/helper.c index 1130fc8884..4439b06ecc 100644 --- a/target/lm32/helper.c +++ b/target/lm32/helper.c @@ -152,6 +152,10 @@ void lm32_cpu_do_interrupt(CPUState *cs) { LM32CPU *cpu = LM32_CPU(cs); CPULM32State *env = &cpu->env; + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } qemu_log_mask(CPU_LOG_INT, "exception at pc=%x type=%x\n", env->pc, cs->exception_index); @@ -196,18 +200,24 @@ void lm32_cpu_do_interrupt(CPUState *cs) cs->exception_index); break; } + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool lm32_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { LM32CPU *cpu = LM32_CPU(cs); CPULM32State *env = &cpu->env; + qemu_mutex_lock_iothread(); if ((interrupt_request & CPU_INTERRUPT_HARD) && (env->ie & IE_IE)) { cs->exception_index = EXCP_IRQ; lm32_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; }