Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7496469ybl; Tue, 24 Dec 2019 03:42:52 -0800 (PST) X-Google-Smtp-Source: APXvYqy7nAyFxUwmvHWLrIAsbrpsMkEyJXJEyps1pQ8q8hEfy1kPOTz+GRp62KkR7/nC74HZGBvz X-Received: by 2002:a9d:6a41:: with SMTP id h1mr6308604otn.279.1577187772346; Tue, 24 Dec 2019 03:42:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577187772; cv=none; d=google.com; s=arc-20160816; b=ar6xFjSFwzFAg8kLLJ85lC9yR+fnEeexfJRi3JkqTW7qkDE6rc4jHuZJBMG2UcqbUu ld3fq9dW+Imb+z07fuVzT7dUNmvszgPxU+VycFwFBL5pN+tvOJy4QtshGnvzlJ1s/0pS hXNt9+yRhAmr3luAUJZvLgllOuAkg5d5Nd474nQxhwqMqSZ/qCROBqEvuwFOOwHEnwT/ NwUK1Cb8WJY8URU+y4+s4ki2f6cU1DYWXBZjeJnTHyNlbfEiiQih8vShls6UVV11+Zhz CuITX/zTBvMA42goyb0Q8Ug8mOVprd/9epxYFcq93smuuzRAmydtaPI8vB5EtRPjSsWJ qa+Q== 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; bh=6wm89kdpR4yCy2DksyCy9DWOU9j6F8eT7MGImUgGxcY=; b=VOjn85GanakAjH0hOsDpDGMLNKHs/1jXOxbnxQbQWIEZdHf5txmlXJ5kdjmAKu6rrF ceqtY+La9TUlYV25/WgRY0ZwweANaBzDr3C9r50tXfCPHXUXs8RoGjwNcnRtQb5hJpwI 1HHsbRt9aln8AZslNf0LaKd7EXPpQ3wm/nyGhXH9UWC8uEXdHU1kEfglIommVYqsh+2D LgaCI6qhIz4x7LpBv4TRaisgtOjTaZ64beFdx+ydlyswfBB2I8vPog2yBbf8anJm02cL J77575bPFOiqKYjQ7okHmhKa88mBHHZPm+BnGm4fNOeVQb/Jkc4+J/ApIFhpJRMSDl2y WxZg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 e3si6396036otr.245.2019.12.24.03.42.41; Tue, 24 Dec 2019 03:42:52 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726933AbfLXLk4 (ORCPT + 99 others); Tue, 24 Dec 2019 06:40:56 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:43178 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726407AbfLXLk4 (ORCPT ); Tue, 24 Dec 2019 06:40:56 -0500 Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by cheepnis.misterjones.org with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.80) (envelope-from ) id 1iji5u-000169-TW; Tue, 24 Dec 2019 12:11:19 +0100 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 , Robert Richter Subject: [PATCH v3 11/32] irqchip/gic-v4.1: Add VPE residency callback Date: Tue, 24 Dec 2019 11:10:34 +0000 Message-Id: <20191224111055.11836-12-maz@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191224111055.11836-1-maz@kernel.org> References: <20191224111055.11836-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, eric.auger@redhat.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, tglx@linutronix.de, jason@lakedaemon.net, lorenzo.pieralisi@arm.com, Andrew.Murray@arm.com, yuzenghui@huawei.com, rrichter@marvell.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Making a VPE resident on GICv4.1 is pretty simple, as it is just a single write to the local redistributor. We just need extra information about which groups to enable, which the KVM code will have to provide. Reviewed-by: Zenghui Yu Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its.c | 17 +++++++++++++++++ include/linux/irqchip/arm-gic-v3.h | 9 +++++++++ include/linux/irqchip/arm-gic-v4.h | 5 +++++ 3 files changed, 31 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 0da6baa48153..49850297fe56 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3625,12 +3625,29 @@ static void its_vpe_4_1_unmask_irq(struct irq_data *d) its_vpe_4_1_send_inv(d); } +static void its_vpe_4_1_schedule(struct its_vpe *vpe, + struct its_cmd_info *info) +{ + void __iomem *vlpi_base = gic_data_rdist_vlpi_base(); + u64 val = 0; + + /* Schedule the VPE */ + val |= GICR_VPENDBASER_Valid; + val |= info->g0en ? GICR_VPENDBASER_4_1_VGRP0EN : 0; + val |= info->g1en ? GICR_VPENDBASER_4_1_VGRP1EN : 0; + val |= FIELD_PREP(GICR_VPENDBASER_4_1_VPEID, vpe->vpe_id); + + gits_write_vpendbaser(val, vlpi_base + GICR_VPENDBASER); +} + static int its_vpe_4_1_set_vcpu_affinity(struct irq_data *d, void *vcpu_info) { + struct its_vpe *vpe = irq_data_get_irq_chip_data(d); struct its_cmd_info *info = vcpu_info; switch (info->cmd_type) { case SCHEDULE_VPE: + its_vpe_4_1_schedule(vpe, info); return 0; case DESCHEDULE_VPE: diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index 33519b7c96cf..1c91dede7663 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -329,6 +329,15 @@ #define GICR_VPENDBASER_IDAI (1ULL << 62) #define GICR_VPENDBASER_Valid (1ULL << 63) +/* + * GICv4.1 VPENDBASER, used for VPE residency. On top of these fields, + * also use the above Valid, PendingLast and Dirty. + */ +#define GICR_VPENDBASER_4_1_DB (1ULL << 62) +#define GICR_VPENDBASER_4_1_VGRP0EN (1ULL << 59) +#define GICR_VPENDBASER_4_1_VGRP1EN (1ULL << 58) +#define GICR_VPENDBASER_4_1_VPEID GENMASK_ULL(15, 0) + /* * ITS registers, offsets from ITS_base */ diff --git a/include/linux/irqchip/arm-gic-v4.h b/include/linux/irqchip/arm-gic-v4.h index 498e523085a7..d9c34968467a 100644 --- a/include/linux/irqchip/arm-gic-v4.h +++ b/include/linux/irqchip/arm-gic-v4.h @@ -100,6 +100,11 @@ struct its_cmd_info { union { struct its_vlpi_map *map; u8 config; + bool req_db; + struct { + bool g0en; + bool g1en; + }; }; }; -- 2.20.1