From patchwork Wed Aug 5 18:12:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foley X-Patchwork-Id: 247457 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp760121ilo; Wed, 5 Aug 2020 11:21:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxj3duTllduihOD74wMkTXoAS/9XDWuZjTuSAZyM1aqvGyf9Kh02vDSoCjXOBovcsDQvvpV X-Received: by 2002:a25:32c8:: with SMTP id y191mr6902837yby.273.1596651670788; Wed, 05 Aug 2020 11:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596651670; cv=none; d=google.com; s=arc-20160816; b=Q+86No+8oqjSrqXvVk25B8fASztVS2ekqjNINkZfGubpQixM2DPkCqckezTtMMjPzq BE6ENIL8BIzYsQ4yQhW9MzmQ/3OE3ZB1BhBZCiJdmSIEDbxWxq9/xYXeYYjwsLcfWu6T zPQoLcMiuyuvbosryqt6RgqTy4YjM2FSDrk//lUvRYWGU+poE/+6D6iwDGp0vYDlDkfr WqEqxrXKB9FWvpFRnDISbna+5k8/0kqURv0kADM9EZGsz5HMGqOX73njta4Dx1oonliQ 6+Cdm70cEYgJLv6um/R3fes2BUBUD0HzbmgAl+D9Mx1pgId1g9wREY79TL2SVhTgackG aHLw== 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=TQf+kUTKaJ/snZqXoVWLiq9osz3e4ZNpxcetm6dWt8I=; b=anH37laQuiN7j8NdO9BsTlyaHc+mHoTUDIoESIfGAYWv6SN+YVmjxVQ7Z7u8z6Kh/J SKJb1tAhNI2knRM1GHziLxHfx9WGwuy+10p7SeXDdSd4WeO3Y4mKHLNY1QJw7E7sse3Q IqoEQ3FDKmZr1G8CGOlkftkdQ3Dh9nplWQp08XA1WsuOvVGxsgJIhTLG+AxtsDI0TN/y J1b7kxdul3xtpL6yX34oYX1UfBmiXfUGc3DQBFfBpo/nfEvhXakgylZ5WB7zoAPWHndh YkAguYbCdUwV1b51pm9pHiMVQVH3S4IJ0rFfU4hZDHtlfzgQ2TEQkU33p711WFjDZinQ i/tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xTjpRxu7; 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 a12si2249667ybk.64.2020.08.05.11.21.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Aug 2020 11:21: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=xTjpRxu7; 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]:59904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k3O2I-0002Bx-75 for patch@linaro.org; Wed, 05 Aug 2020 14:21:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k3Nyo-0004Qw-9S for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:34 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:51543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k3Nym-0006U5-91 for qemu-devel@nongnu.org; Wed, 05 Aug 2020 14:17:33 -0400 Received: by mail-pj1-x102d.google.com with SMTP id c6so5024195pje.1 for ; Wed, 05 Aug 2020 11:17:31 -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=TQf+kUTKaJ/snZqXoVWLiq9osz3e4ZNpxcetm6dWt8I=; b=xTjpRxu7HKdV2Bz9nOANpvgfUs9av4+RyFPXe/KiNgkf7fgIrqz9/1F52zNNifoO5f 82J3UKbwrNjZUAa3+jG7R6TK2xl1OPijHaBNqyZGNb+oBoZQMR+rSVNYhGasTOkAmB6h UZcx2UZJWcXND+tXFwFmlkOjU4VfohT24F+Vs4MmWuZFq34ldRn/JSjO+zAvcKl83rCm u99vaeu/IrDe2qTMOyIGKnneHTo25v/7F2af1L/V15i5RVW4hjMyHosssy4LNpPFuvcx 0lbHALvPRUHLpSotwcs5eDXV3pPmC8mYunvhI1d+RUIFmxP8eZQJ91cSreFrZ7xiJPJ4 fX1A== 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=TQf+kUTKaJ/snZqXoVWLiq9osz3e4ZNpxcetm6dWt8I=; b=MWosaawdH3GfZ84Ma3jf4+IBirjZ0itduZq8qx6J+FMP30mim8PAQv6D93MgvBLubd zoQtnY6KVW85Ip1gAlR82Kf6SWQA6YQQtqvsR26gU3emEON5Xw/VOsQspgtkLNK88Pjr oF4A6NkNx28FpXLliWbhHJJt849VkFcXD9yqV7d5ynouJGE9hE0NYSs4CXo9F6c736oU pF5VFx8ZT6+ZyidauIeqkIKZfpP+fh+xVBwXiJ1zMaYFM9W4NPS1yva7J3eqv20dUl9w VLWSFInS+xOCpIU2XKR/KcMfHLVKKQp0nMkF3vYUgH/JzU4B40tU+cwPjuc9EQ5FzPTR FotA== X-Gm-Message-State: AOAM531Zn7+QxSpB63DTYrG+KUI5Yew2ivskWzMEGM78HgE/EPgrA6KF AwiLs+RuMiuGwQ8v9ld6KOB3ovb8uXQ= X-Received: by 2002:a17:90a:3488:: with SMTP id p8mr4695488pjb.211.1596651450623; Wed, 05 Aug 2020 11:17:30 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:17:29 -0700 (PDT) From: Robert Foley To: qemu-devel@nongnu.org Subject: [PATCH v1 11/21] target/mips: add BQL to do_interrupt and cpu_exec_interrupt Date: Wed, 5 Aug 2020 14:12:53 -0400 Message-Id: <20200805181303.7822-12-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::102d; envelope-from=robert.foley@linaro.org; helo=mail-pj1-x102d.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: Aleksandar Rikalo , robert.foley@linaro.org, Aleksandar Markovic , cota@braap.org, peter.puhov@linaro.org, pbonzini@redhat.com, alex.bennee@linaro.org, Aurelien Jarno 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/mips/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.17.1 diff --git a/target/mips/helper.c b/target/mips/helper.c index afd78b1990..6595d18702 100644 --- a/target/mips/helper.c +++ b/target/mips/helper.c @@ -1085,6 +1085,10 @@ static inline void set_badinstr_registers(CPUMIPSState *env) void mips_cpu_do_interrupt(CPUState *cs) { + bool bql = !qemu_mutex_iothread_locked(); + if (bql) { + qemu_mutex_lock_iothread(); + } #if !defined(CONFIG_USER_ONLY) MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &cpu->env; @@ -1396,10 +1400,14 @@ void mips_cpu_do_interrupt(CPUState *cs) } #endif cs->exception_index = EXCP_NONE; + if (bql) { + qemu_mutex_unlock_iothread(); + } } bool mips_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { + qemu_mutex_lock_iothread(); if (interrupt_request & CPU_INTERRUPT_HARD) { MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &cpu->env; @@ -1410,9 +1418,11 @@ bool mips_cpu_exec_interrupt(CPUState *cs, int interrupt_request) cs->exception_index = EXCP_EXT_INTERRUPT; env->error_code = 0; mips_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); return true; } } + qemu_mutex_unlock_iothread(); return false; }