Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7495636ybl; Tue, 24 Dec 2019 03:41:43 -0800 (PST) X-Google-Smtp-Source: APXvYqxEqnlLyNHQIY+weXzS0KOdByEU8wTjOu8207T4Je1zqXk+sOmf4saCuih1ZXRo2KyyoSIa X-Received: by 2002:a9d:65cf:: with SMTP id z15mr39606583oth.238.1577187703041; Tue, 24 Dec 2019 03:41:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577187703; cv=none; d=google.com; s=arc-20160816; b=e0j9n6fmtOxH4yBPhWAsdMT2wx9RG7ldFfB5VfE7on6BraC8GrwOZRMYlzJsoXH8Tm qxfs4r0Vx4gjEqy9s80l69fsSOZYN+TJynYU4kF5qYdMJuC83xBSBE8/TzCsp3CT7uhD asTgnMkH/SRfowynzD1fij5o7oBh6SYIW1//xvcQZ+eMH8iYFgpyxD1w7wAD6iQscX+N OFMszfklob8ezyfmG5uH9f/JUUGUk39SNudS+XBsJRPARPrDzcZV+TxtpbuakOwNSbIQ 5W8gXdaf/T1psCftjreWn9BWlHN/4+a69pioZuuo2JINt7PXzJvNXaa7StquQDmzbNmt 11aQ== 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=/WBud7O/j+zE24A7OAeBjYlMSdDeuInjPK8bj2r1TCE=; b=AH7JdBoefe5saqjEFSustCxTFoAqL1okY1/Uk4QWeHflff8hYvJEMa9ZjdPpfAaLju ZCETZKUgsfMR2CP+S8ms1xaLT8BvopUVipmr8+m0JVSSg4l6BFvOk9Xl3v25dg5U0cHr VhAgYlhlhfEpEbSQ9GBhh1CIQeZvyGFJtdLnveGxlFyBZknWo0MuxzNPKeBqw6I5ntJ3 Ih1I2nl/Qp1hQ4W0QDgItKbEprfEZOgDq/mEOp7C8QL2GxS+VYuBeSlnOMR8ikOmbDKB pOBeF2QYCdF8gRYu8moE9IjmGdnAFykx5KA91IS0qplVfPm208QQfQTRiESZt3LfEJgV 6zHA== 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 b12si9020906otl.229.2019.12.24.03.41.31; Tue, 24 Dec 2019 03:41:43 -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 S1726353AbfLXLkg (ORCPT + 99 others); Tue, 24 Dec 2019 06:40:36 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:34136 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbfLXLkf (ORCPT ); Tue, 24 Dec 2019 06:40:35 -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 1iji5z-000169-E5; Tue, 24 Dec 2019 12:11:23 +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 15/32] irqchip/gic-v4.1: Allow direct invalidation of VLPIs Date: Tue, 24 Dec 2019 11:10:38 +0000 Message-Id: <20191224111055.11836-16-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 Just like for INVALL, GICv4.1 has grown a VPE-aware INVLPI register. Let's plumb it in and make use of the DirectLPI code in that case. Reviewed-by: Zenghui Yu Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its.c | 53 ++++++++++++++++++++---------- include/linux/irqchip/arm-gic-v3.h | 1 + 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index f00c8ddd3798..360ca2c1533f 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -228,11 +228,26 @@ static struct its_vlpi_map *dev_event_to_vlpi_map(struct its_device *its_dev, return &its_dev->event_map.vlpi_maps[event]; } -static struct its_collection *irq_to_col(struct irq_data *d) +static struct its_vlpi_map *get_vlpi_map(struct irq_data *d) { struct its_device *its_dev = irq_data_get_irq_chip_data(d); + u32 event = its_get_event_id(d); + + if (!irqd_is_forwarded_to_vcpu(d)) + return NULL; - return dev_event_to_col(its_dev, its_get_event_id(d)); + return dev_event_to_vlpi_map(its_dev, event); +} + +static int irq_to_cpuid(struct irq_data *d) +{ + struct its_device *its_dev = irq_data_get_irq_chip_data(d); + struct its_vlpi_map *map = get_vlpi_map(d); + + if (map) + return map->vpe->col_idx; + + return its_dev->event_map.col_map[its_get_event_id(d)]; } static struct its_collection *valid_col(struct its_collection *col) @@ -1270,17 +1285,6 @@ static void its_send_invdb(struct its_node *its, struct its_vpe *vpe) /* * irqchip functions - assumes MSI, mostly. */ -static struct its_vlpi_map *get_vlpi_map(struct irq_data *d) -{ - struct its_device *its_dev = irq_data_get_irq_chip_data(d); - u32 event = its_get_event_id(d); - - if (!irqd_is_forwarded_to_vcpu(d)) - return NULL; - - return dev_event_to_vlpi_map(its_dev, event); -} - static void lpi_write_config(struct irq_data *d, u8 clr, u8 set) { struct its_vlpi_map *map = get_vlpi_map(d); @@ -1323,13 +1327,25 @@ static void wait_for_syncr(void __iomem *rdbase) static void direct_lpi_inv(struct irq_data *d) { - struct its_collection *col; + struct its_vlpi_map *map = get_vlpi_map(d); void __iomem *rdbase; + u64 val; + + if (map) { + struct its_device *its_dev = irq_data_get_irq_chip_data(d); + + WARN_ON(!is_v4_1(its_dev->its)); + + val = GICR_INVLPIR_V; + val |= FIELD_PREP(GICR_INVLPIR_VPEID, map->vpe->vpe_id); + val |= FIELD_PREP(GICR_INVLPIR_INTID, map->vintid); + } else { + val = d->hwirq; + } /* Target the redistributor this LPI is currently routed to */ - col = irq_to_col(d); - rdbase = per_cpu_ptr(gic_rdists->rdist, col->col_id)->rd_base; - gic_write_lpir(d->hwirq, rdbase + GICR_INVLPIR); + rdbase = per_cpu_ptr(gic_rdists->rdist, irq_to_cpuid(d))->rd_base; + gic_write_lpir(val, rdbase + GICR_INVLPIR); wait_for_syncr(rdbase); } @@ -1339,7 +1355,8 @@ static void lpi_update_config(struct irq_data *d, u8 clr, u8 set) struct its_device *its_dev = irq_data_get_irq_chip_data(d); lpi_write_config(d, clr, set); - if (gic_rdists->has_direct_lpi && !irqd_is_forwarded_to_vcpu(d)) + if (gic_rdists->has_direct_lpi && + (is_v4_1(its_dev->its) || !irqd_is_forwarded_to_vcpu(d))) direct_lpi_inv(d); else if (!irqd_is_forwarded_to_vcpu(d)) its_send_inv(its_dev, its_get_event_id(d)); diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index 37b14fb82773..a30ea5294784 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -249,6 +249,7 @@ #define GICR_TYPER_COMMON_LPI_AFF GENMASK_ULL(25, 24) #define GICR_TYPER_AFFINITY GENMASK_ULL(63, 32) +#define GICR_INVLPIR_INTID GENMASK_ULL(31, 0) #define GICR_INVLPIR_VPEID GENMASK_ULL(47, 32) #define GICR_INVLPIR_V GENMASK_ULL(63, 63) -- 2.20.1