From patchwork Fri Apr 22 10:04:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 564783 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp332225map; Fri, 22 Apr 2022 03:19:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIoi119lVerugGr/tzuqxkZ+6tbtopatxtZQVN3dJVIWv3WA7AxR+PUlzZnJfdP3/w1AaY X-Received: by 2002:a05:622a:1716:b0:2f2:56d:c8a8 with SMTP id h22-20020a05622a171600b002f2056dc8a8mr2556250qtk.26.1650622791330; Fri, 22 Apr 2022 03:19:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650622791; cv=none; d=google.com; s=arc-20160816; b=tQ5t8YTIaJpLuvBS2uUgEeGo6qjsHGPVAhfPGNSKzlTA3wiXovHTuIiw5fG1CtoghR pWoCycAON+vYjS+PXvwYb4z3vhXdI+O8Nq77tXexIzwMyiEzh6WWSjZjaM4C+2wZP/x0 BbKHWjfYfYT/OAOe7BwHrUy9NqWJWhqICrwLtVSjCqjCBVf1XfaGkxmWYIgOU614QONB iml//52ayOojOx1rCiBbgyTxCoK0jFTvW+Jovg8Cza466C4Mz88BzytL93V+Bp2eN2t/ VcpQJSO1P33TlQl+vfFlyiStqpNWp00jCwAq3OqiacppXHQGwzMDCv62bsAw/VmS+nj+ 3eJQ== 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:to:from :dkim-signature; bh=PX0NLhcQng/vzkYLEUDXWQWxmx/78hsVtwkLTCrl74k=; b=mq68ucqGPFhRnUUDGo/k8+jVsGTEKsP6ZiqsG71pyuOI+tOm41ZQ9MsQ5MPfh5XBje E8RBomQeCD8Cx7j1ly4D0bjI1SiZiFFL+c7tpU+3HyuRltjX2XEYK3dcQX/bjCLWAp+v UvGEAllLL1Vaq0gRWGPGSx6doB1Wi00oTr1StChrmjZxEQ/wZzg7uCCXwyJntLsQ0zog ZwGipCPY/bBbEQO6Hj5aQYDSMrXPp/9bVUytL5N8ZlST7MnTuSrmYkrDaKq+jzCqO39B ejpvKNP0tHN36lfcVMdt+3+U2Ez6jtFIHXOP52saexPnekopMy1lV8ONC5nO+v9oVegL xXaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zwfq1Es7; 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 d8-20020ac85ac8000000b002e1fbf3bf63si2057874qtd.340.2022.04.22.03.19.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Apr 2022 03:19:51 -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=pass header.i=@linaro.org header.s=google header.b=zwfq1Es7; 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]:49874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhqOE-0002rK-Su for patch@linaro.org; Fri, 22 Apr 2022 06:19:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhq9x-0004m6-If for qemu-devel@nongnu.org; Fri, 22 Apr 2022 06:05:05 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:44911) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhq9v-0002f5-NJ for qemu-devel@nongnu.org; Fri, 22 Apr 2022 06:05:05 -0400 Received: by mail-wr1-x430.google.com with SMTP id b19so10280649wrh.11 for ; Fri, 22 Apr 2022 03:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PX0NLhcQng/vzkYLEUDXWQWxmx/78hsVtwkLTCrl74k=; b=zwfq1Es7nurcUCHl/O7JMglGaIgN9lkvHmtImvbdg3RGjxz4LehQHhS/pPeYXzE27l PujXVj0//2Fex81DEkrS5tYYMBJxyNk/x5y+Zo47dnaRmUbgA9Nt1F30xSDncjt9rAuJ WDBY6gdYKLO6ZKylqN5VF1X6D8pXtZpfF3GlgOY9v991FPbCOwBkol/C3YJvqYmGIU/x TYufT1TgYvanddheOzu6chJMhN70/fP3edJzHdJ3TpgUpvwernsHdcJqrM1bvRIesWXJ Elgj0CSsyugIAbsPbSeNBbKxfEM5kOS7RwmWmhL7XbqeJmqKuE50xF7JNhMQAnAqpo7v fSOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PX0NLhcQng/vzkYLEUDXWQWxmx/78hsVtwkLTCrl74k=; b=XPExODtDuxmG3Ik2xYuocTlRfiqCrMQWq/P0xX4xSw/GQT+Xu/g4VJtJFFPuMu8drv b3FEHHW7y6GsQ1zowxTSYkrDtAqYnd9sVs70x9aePrWrhqBLN94Cr/Pw1QFaiDLUHg5T 1xJbN2Rahiuu7eoXI+q1P+aa7T7yoZgO1Fy35PZnXaITi4RFmA79ABMBYQJzOTcl+4t0 7b6J3sir65/QmeAKgGeNTr/gqoZ8kmllZA8RUmZdFyLQFTQpsIlJ5fbXMMblCTzlc4oq PIGjESvT9ijKQKiNIBJh4sMe0fEVXvbEDppFu11yL+SGr1NimYxpDShGJQDpbC60d3Wk JKmw== X-Gm-Message-State: AOAM533E7X7CMHP7MTMqv21exSAKo+JYPlOQ3d7zMRp3HkCy6kMyVlLx WZRwuyfCkCtRLlPQz3L3jzgfz8LWQZE4fw== X-Received: by 2002:a5d:6e87:0:b0:206:452:5b87 with SMTP id k7-20020a5d6e87000000b0020604525b87mr2987799wrz.473.1650621902288; Fri, 22 Apr 2022 03:05:02 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id e16-20020a05600c2dd000b0038ed449cbdbsm4312148wmh.3.2022.04.22.03.05.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 03:05:01 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 30/61] hw/intc/arm_gicv3_redist: Factor out "update bit in pending table" code Date: Fri, 22 Apr 2022 11:04:01 +0100 Message-Id: <20220422100432.2288247-31-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220422100432.2288247-1-peter.maydell@linaro.org> References: <20220422100432.2288247-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-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, T_SCC_BODY_TEXT_LINE=-0.01 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" Factor out the code which sets a single bit in an LPI pending table. We're going to need this for handling vLPI tables, not just the physical LPI table. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20220408141550.1271295-31-peter.maydell@linaro.org --- hw/intc/arm_gicv3_redist.c | 49 +++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c index bfdde36a206..d54ed9a0332 100644 --- a/hw/intc/arm_gicv3_redist.c +++ b/hw/intc/arm_gicv3_redist.c @@ -145,6 +145,34 @@ static void update_for_all_lpis(GICv3CPUState *cs, uint64_t ptbase, } } +/** + * set_lpi_pending_bit: Set or clear pending bit for an LPI + * + * @cs: GICv3CPUState + * @ptbase: physical address of LPI Pending table + * @irq: LPI to change pending state for + * @level: false to clear pending state, true to set + * + * Returns true if we needed to do something, false if the pending bit + * was already at @level. + */ +static bool set_pending_table_bit(GICv3CPUState *cs, uint64_t ptbase, + int irq, bool level) +{ + AddressSpace *as = &cs->gic->dma_as; + uint64_t addr = ptbase + irq / 8; + uint8_t pend; + + address_space_read(as, addr, MEMTXATTRS_UNSPECIFIED, &pend, 1); + if (extract32(pend, irq % 8, 1) == level) { + /* Bit already at requested state, no action required */ + return false; + } + pend = deposit32(pend, irq % 8, 1, level ? 1 : 0); + address_space_write(as, addr, MEMTXATTRS_UNSPECIFIED, &pend, 1); + return true; +} + static uint8_t gicr_read_ipriorityr(GICv3CPUState *cs, MemTxAttrs attrs, int irq) { @@ -809,30 +837,13 @@ void gicv3_redist_lpi_pending(GICv3CPUState *cs, int irq, int level) * This function updates the pending bit in lpi pending table for * the irq being activated or deactivated. */ - AddressSpace *as = &cs->gic->dma_as; uint64_t lpipt_baddr; - bool ispend = false; - uint8_t pend; - /* - * get the bit value corresponding to this irq in the - * lpi pending table - */ lpipt_baddr = cs->gicr_pendbaser & R_GICR_PENDBASER_PHYADDR_MASK; - - address_space_read(as, lpipt_baddr + ((irq / 8) * sizeof(pend)), - MEMTXATTRS_UNSPECIFIED, &pend, sizeof(pend)); - - ispend = extract32(pend, irq % 8, 1); - - /* no change in the value of pending bit, return */ - if (ispend == level) { + if (!set_pending_table_bit(cs, lpipt_baddr, irq, level)) { + /* no change in the value of pending bit, return */ return; } - pend = deposit32(pend, irq % 8, 1, level ? 1 : 0); - - address_space_write(as, lpipt_baddr + ((irq / 8) * sizeof(pend)), - MEMTXATTRS_UNSPECIFIED, &pend, sizeof(pend)); /* * check if this LPI is better than the current hpplpi, if yes