Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1936543ybg; Sun, 27 Oct 2019 07:46:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqHzy1NfjdBddMJiQQvLf4KWOtuikQzpN7sT8uKTcIr8ENueMS02a4Yej2Kqf1BrM7OTez X-Received: by 2002:a50:f783:: with SMTP id h3mr14620291edn.294.1572187571563; Sun, 27 Oct 2019 07:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572187571; cv=none; d=google.com; s=arc-20160816; b=YSbjYgtD0mseooYyAbzmXHDRh2hcNl/vasDcvjb/ftg2LFjNgIGGyuH7/bDZKXtnF9 hd9OuZ20WgvQznw2qzoaK6OhOYhKoRr/GfJexwaoN6NrsBWYiNB7EqwWcuuZ0PQPgzLc Zfc+Ru+5Hx77kNNW4Wt/oqZnqQf2N3LWoiO16UeMvL9RbSGEw5RD8siGtEkZMpeEESge nu+d/u3NOWi+7gnyEGVL0mssJ6SQ4qSzyNNs7H9ppR2Yb/QzBSkpFr81tEIfymevnabu ozLyFzFRpKUgHL2k3bnfxL5UmzEEqBOxxF0fDjkQUqjZHB5vJccKgdAQOprjFX0hl8tF yDuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S8Z7qWvWR44aY7ZrV+tqGYaMN8q+m2pVii6aVZk88Qo=; b=0iuXzxHMT/EH3XnAIT2ZBLPthQt7wi0WPbUv4I3B0pdbguP+ogU33FJ2DjrNnx7B2K sqADiYwNYqdtwn5ZQGZuh1WXiNVFW14qTKnKTBdH98HtUKjJx5R7J+ixk+Ng87e01Xzn Mhhq+fqcoVEowS31b/FSQNFHej3V/ACF69tpgjx+De64bhVGyFRKSiR3BOBOdyuwhOh7 cgFlzfEntW2HaVfAFtUJAoOs+uS7WO3EhzDIxKf/c2msxCq3+De+pwjkzL3TA+9oQNrq b0UktHHulLgSg/0EA06SjsWPBHUH90pJs7SE9s7uTXWEVqTV9qM+RQNniH57XwgnZS5q Rkng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mk7VxJ+n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si5904513edc.410.2019.10.27.07.45.48; Sun, 27 Oct 2019 07:46:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mk7VxJ+n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727289AbfJ0Oo1 (ORCPT + 99 others); Sun, 27 Oct 2019 10:44:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:37628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727244AbfJ0Oo0 (ORCPT ); Sun, 27 Oct 2019 10:44:26 -0400 Received: from localhost.localdomain (82-132-239-15.dab.02.net [82.132.239.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 03C7E222BD; Sun, 27 Oct 2019 14:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572187465; bh=2x+Mhma7LE5CoKshrPUx2pIg9ZgfaP4E7LPt6ESl7/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mk7VxJ+n9Kss3ZXA5NXoa3lOJaYcF1Mxo/gsnjxpwZ/He3uhjSxqy8u05aO73gagZ 2yREsS4g0e1zJOggMvI6dDut4HQB6SKmaBChO0Oq/jOAs4A5t7/CXQrZ4anuiPuSP6 15g731V6uS4wJddXkkd1tGr9m7UEkzfJZhEAwWFU= From: Marc Zyngier To: kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Cc: Eric Auger , James Morse , Julien Thierry , Suzuki K Poulose , Thomas Gleixner , Jason Cooper , Lorenzo Pieralisi , Andrew Murray , Zenghui Yu , Jayachandran C , Robert Richter Subject: [PATCH v2 12/36] irqchip/gic-v4.1: Implement the v4.1 flavour of VMAPP Date: Sun, 27 Oct 2019 14:42:10 +0000 Message-Id: <20191027144234.8395-13-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191027144234.8395-1-maz@kernel.org> References: <20191027144234.8395-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ITS VMAPP command gains some new fields with GICv4.1: - a default doorbell, which allows a single doorbell to be used for all the VLPIs routed to a given VPE - a pointer to the configuration table (instead of having it in a register that gets context switched) - a flag indicating whether this is the first map or the last unmap for this particulat VPE - a flag indicating whether the pending table is known to be zeroed, or not Plumb in the new fields in the VMAPP builder, and add the map/unmap refcounting so that the ITS can do the right thing. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its.c | 60 +++++++++++++++++++++++++++--- include/linux/irqchip/arm-gic-v4.h | 18 +++++++-- 2 files changed, 69 insertions(+), 9 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 478d3678850c..220d490d516e 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -422,6 +422,27 @@ static void its_encode_vpt_size(struct its_cmd_block *cmd, u8 vpt_size) its_mask_encode(&cmd->raw_cmd[3], vpt_size, 4, 0); } +static void its_encode_vconf_addr(struct its_cmd_block *cmd, u64 vconf_pa) +{ + its_mask_encode(&cmd->raw_cmd[0], vconf_pa >> 16, 51, 16); +} + +static void its_encode_alloc(struct its_cmd_block *cmd, bool alloc) +{ + its_mask_encode(&cmd->raw_cmd[0], alloc, 8, 8); +} + +static void its_encode_ptz(struct its_cmd_block *cmd, bool ptz) +{ + its_mask_encode(&cmd->raw_cmd[0], ptz, 9, 9); +} + +static void its_encode_vmapp_default_db(struct its_cmd_block *cmd, + u32 vpe_db_lpi) +{ + its_mask_encode(&cmd->raw_cmd[1], vpe_db_lpi, 31, 0); +} + static inline void its_fixup_cmd(struct its_cmd_block *cmd) { /* Let's fixup BE commands */ @@ -605,19 +626,45 @@ static struct its_vpe *its_build_vmapp_cmd(struct its_node *its, struct its_cmd_block *cmd, struct its_cmd_desc *desc) { - unsigned long vpt_addr; + unsigned long vpt_addr, vconf_addr; u64 target; - - vpt_addr = virt_to_phys(page_address(desc->its_vmapp_cmd.vpe->vpt_page)); - target = desc->its_vmapp_cmd.col->target_address + its->vlpi_redist_offset; + bool alloc; its_encode_cmd(cmd, GITS_CMD_VMAPP); its_encode_vpeid(cmd, desc->its_vmapp_cmd.vpe->vpe_id); its_encode_valid(cmd, desc->its_vmapp_cmd.valid); + + if (!desc->its_vmapp_cmd.valid) { + if (is_v4_1(its)) { + alloc = !atomic_dec_return(&desc->its_vmapp_cmd.vpe->vmapp_count); + its_encode_alloc(cmd, alloc); + } + + goto out; + } + + vpt_addr = virt_to_phys(page_address(desc->its_vmapp_cmd.vpe->vpt_page)); + target = desc->its_vmapp_cmd.col->target_address + its->vlpi_redist_offset; + its_encode_target(cmd, target); its_encode_vpt_addr(cmd, vpt_addr); its_encode_vpt_size(cmd, LPI_NRBITS - 1); + if (!is_v4_1(its)) + goto out; + + vconf_addr = virt_to_phys(page_address(desc->its_vmapp_cmd.vpe->its_vm->vprop_page)); + + alloc = atomic_inc_and_test(&desc->its_vmapp_cmd.vpe->vmapp_count); + + its_encode_alloc(cmd, alloc); + + /* We can only signal PTZ when alloc==1. Why do we have two bits? */ + its_encode_ptz(cmd, alloc); + its_encode_vconf_addr(cmd, vconf_addr); + its_encode_vmapp_default_db(cmd, desc->its_vmapp_cmd.vpe->vpe_db_lpi); + +out: its_fixup_cmd(cmd); return valid_vpe(its, desc->its_vmapp_cmd.vpe); @@ -3349,7 +3396,10 @@ static int its_vpe_init(struct its_vpe *vpe) vpe->vpe_id = vpe_id; vpe->vpt_page = vpt_page; - vpe->vpe_proxy_event = -1; + if (gic_rdists->has_rvpeid) + atomic_set(&vpe->vmapp_count, 0); + else + vpe->vpe_proxy_event = -1; return 0; } diff --git a/include/linux/irqchip/arm-gic-v4.h b/include/linux/irqchip/arm-gic-v4.h index ab1396afe08a..6213ced6f199 100644 --- a/include/linux/irqchip/arm-gic-v4.h +++ b/include/linux/irqchip/arm-gic-v4.h @@ -37,8 +37,20 @@ struct its_vpe { irq_hw_number_t vpe_db_lpi; /* VPE resident */ bool resident; - /* VPE proxy mapping */ - int vpe_proxy_event; + union { + /* GICv4.0 implementations */ + struct { + /* VPE proxy mapping */ + int vpe_proxy_event; + /* Implementation Defined Area Invalid */ + bool idai; + }; + /* GICv4.1 implementations */ + struct { + atomic_t vmapp_count; + }; + }; + /* * This collection ID is used to indirect the target * redistributor for this VPE. The ID itself isn't involved in @@ -47,8 +59,6 @@ struct its_vpe { u16 col_idx; /* Unique (system-wide) VPE identifier */ u16 vpe_id; - /* Implementation Defined Area Invalid */ - bool idai; /* Pending VLPIs on schedule out? */ bool pending_last; }; -- 2.20.1