From patchwork Wed Aug 5 18:12:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 247462 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp761997ilo; Wed, 5 Aug 2020 11:23:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIFdynzCSqhd+fCaTYOydhY/TsaOdxX86tpjH3ZK4MwYUWM5ORp3bmoBKWbSiaWpSlO00W X-Received: by 2002:a25:6b0f:: with SMTP id g15mr6232867ybc.119.1596651825265; Wed, 05 Aug 2020 11:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596651825; cv=none; d=google.com; s=arc-20160816; b=0L+tsJl6Q19LdwsrnzGcOYXNnKFLJ0trn7tioERfDzMGftEkLwc0jNcRdLhNFnxChv Oaxy3iOWyMAd4L5JbEX2maNkJub6gC5MrG/yFitj6jey0b4q8EzUOi5y4CQlizJxS9Sr lkvAbLM/xcwEqA7ueLndzeGgDJaeH6Dgyc6gPLn555ywypsJvwFq78N69lAy4pnl0NSP OKXvkviEej5UtTvQPfaY5xjYcfwL2Zw+eYS8jY3cV0ZoDWKDHYtYRACDHC9l5SjQTw8W ylYwKBoq4ovxYwVGf6W/DBQZjb8qgaJ/1AxX4gvyVW7tNBVNbP2lNozHTXkpfATbQRtK yktw== 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=JEsnnFYRnVZaq0i2DwuNSLaqhNKEKeJEaJl1TkjXWDY=; b=LQMrh6g7ObiPold15HtHHl5nuMUNyU7NBGxCoBgUe1aOHf+Z2wTO7uXwWm2+UJIdgk WJPKu+KI0lamK8VIxg3AQIAwknf1AyIycWm51SEs+4tdHbEzXXNq09f576cHfACleRZ9 a2S7pnyDrYHtgJjcts5kGTlO8IMYe2qj8LR9EkUz/yOW79b0WwcT83lqlO/PCln1GkA6 IlffdHZ3P1GVr0dBfVY2C0W0IDtDIhYnmysF0snBnKCPvjG6l4M5gozhymh47hABUDU5 3ioq4zJlxNcK7st+svFZub63OVKnoNpBrY9fSa3w76MVqGvtZ2XZ37VPUtTSfA86m5OZ 3Aow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PZrgCSmK; 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 a2si2555837ybo.134.2020.08.05.11.23.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Aug 2020 11:23:45 -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=PZrgCSmK; 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]:40166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O4m-0005dQ-NJ for patch@linaro.org; Wed, 05 Aug 2020 14:23:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyu-0004bc-Dy for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:41 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:33810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nyq-0006UW-W0 for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:39 -0400 Received: by mail-pg1-x532.google.com with SMTP id t6so24960072pgq.1 for ; Wed, 05 Aug 2020 11:17:36 -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=JEsnnFYRnVZaq0i2DwuNSLaqhNKEKeJEaJl1TkjXWDY=; b=PZrgCSmKb1oY1ZGeU/YExUk6KMJyebctyIkNwjN8iZl+GCeVQzj9zMnUA5xHiGm44R oui3/hc1hBukPsrDR2dKR4vOmAOq3rpMj1SyMSzH3ct6FJ8l6MqkUmygnWof8kI9k6FT 6wyxw/5G60uhr5zk4t5833ZbTvYPclMttmEcwDhNvHamf/QKHRgiIJqf3lrPtKGyTByT 0CQy5Nf+Xdm/MsbGmpnJLgV4BKBgimM9lgKLlWIXf32OCzIHzxsIfmbBcKTjc8483Igt 9rYH5KodW3ZHTfqgbc6wVmUUMmo7yrk/sgTZDw4OxvbeeojikP3ZKvphGx7ztAGWH8Yw l9lQ== 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=JEsnnFYRnVZaq0i2DwuNSLaqhNKEKeJEaJl1TkjXWDY=; b=tYmkpx7ZHhVJIY9omTY63KuiCLvR4reS2xyMbYwccCgiCDmYzsuWv69fWPYHBnqDS/ t52uL41N6TnYxtdkSqzrSrlhmvf+wIiKpXmUhLD1tj/CczhL4DWdPKX9dm4W+WeEWyf0 BhJxesenvK4D0fAeTCuH+ItrqDVEWLuawJ6AMs7Fjs/dQK2jK5bDzA9WnOZjiXQ07LJz EWDqPI6JGYwqr6w6kFTghXZ/VSOH7OhcBGSGvC/aQcTR2slas9458LvyJy2yzQUTgEF+ tMzFs2c/yJD2sMZS0ShE+H1Xam9pM4UMX3ii8N6H1Z3vYOA4yghOkmIkFDvNQQrra/R7 8QFg== X-Gm-Message-State: AOAM532Eq0PXyP6mBX4OdBVN2ZkQVkvwM9Bjl2RJ2hSX6sX1xsZeRe/K a8XKIhjR7nnDF49hwTwqLpHT7Vm/LYE= X-Received: by 2002:a63:5012:: with SMTP id e18mr4028460pgb.169.1596651455325; Wed, 05 Aug 2020 11:17:35 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:34 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 13/21] target/openrisc: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:55 -0400 Message-Id: <20200805181303.7822-14-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::532; envelope-from=robert.foley@linaro.org; helo=mail-pg1-x532.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, cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, Stafford Horne , 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/openrisc/interrupt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.17.1 diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 3eab771dcd..361f242954 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -28,6 +28,10 @@ void openrisc_cpu_do_interrupt(CPUState *cs) { + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu = OPENRISC_CPU(cs); CPUOpenRISCState *env = &cpu->env; @@ -99,6 +103,9 @@ void openrisc_cpu_do_interrupt(CPUState *cs) #endif cs->exception_index = -1; + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool openrisc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) @@ -106,6 +113,7 @@ bool openrisc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) OpenRISCCPU *cpu = OPENRISC_CPU(cs); CPUOpenRISCState *env = &cpu->env; int idx = -1; + qemu_mutex_lock_iothread(); if ((interrupt_request & CPU_INTERRUPT_HARD) && (env->sr & SR_IEE)) { idx = EXCP_INT; @@ -116,7 +124,9 @@ bool openrisc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) if (idx >= 0) { cs->exception_index = idx; openrisc_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } + qemu_mutex_unlock_iothread(); return false; }