Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7496107ybl; Tue, 24 Dec 2019 03:42:19 -0800 (PST) X-Google-Smtp-Source: APXvYqzPPdDrW04qFF9vpat+4hz9/VTAxh2Y5j/Z/0KwyreZjFO3iXYA8CLJG6Srui32Je62hLzB X-Received: by 2002:a9d:6b03:: with SMTP id g3mr38051503otp.200.1577187739615; Tue, 24 Dec 2019 03:42:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577187739; cv=none; d=google.com; s=arc-20160816; b=TdlxjMII+gUD5YyS2Qedj7QfswVMRwy4gcQac6SLjFALXhEzC2z1KTjcBBcBDflT+B tjyoqNHos4HPETaKjZsF0Tl+3J4tmTD40s3l/GMr3MflMnAf4D+N5A9w4ol+OXSaljgW vZzLdiLY8f6fo94ey9zNJ3zvIhZBnigm08UxVkruJihPRsHF9voWrq+6vRIcx9+HN91g Dw12012pYKLWyeZjxkK6vpA0tuUFutB89sYb052ZtPu0k9awbA0D1cf83oHrZrbdOu2b WE+VJbr4vv0TGv9t09VqwjUOVIPpDjKBXXemOf9D0jj8gKPkAM+2xE/5MBMNY2pWffI5 cQoQ== 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=FrgmoIumtQgOsjJ+qOX0DUwl2nvRuiXS44n59P35+Ns=; b=Mm5zjEfFZjCLxIH2UoadLzneG2t9vLveyM+c8WqfgUB5q3S/DdReMe4WiHb6x39nVE vPwzH9Bh6rf/444o9R/NG3cQYgxH693yyKxcgfBSlSsggGceaDVcRRn/ffiVgEFuEApm zCEsoYbgR/AXAFK2GGQYzrd+BieqTe8MUjW4Vcwa2SpVRLjuthmmwW4KThi3+2b8B56Z rjCvChKW1NNWgg+fWl/Jx+4iMKcxws1LKAGYJ5Bdw1awVsIbOHGnOa2HP6+hCA7lK/nG 52+0Csu25Xc9UgTZLiALmc/15hSomxl68zgTrBhFAkwQs5CaFvATcMuqR4XmAIVEO5/R WjMw== 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 e15si3452245oti.29.2019.12.24.03.42.08; Tue, 24 Dec 2019 03:42:19 -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 S1726375AbfLXLlN (ORCPT + 99 others); Tue, 24 Dec 2019 06:41:13 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:40775 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726184AbfLXLlL (ORCPT ); Tue, 24 Dec 2019 06:41:11 -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 1iji5v-000169-JX; Tue, 24 Dec 2019 12:11:20 +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 12/32] irqchip/gic-v4.1: Add VPE eviction callback Date: Tue, 24 Dec 2019 11:10:35 +0000 Message-Id: <20191224111055.11836-13-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 When descheduling a VPE, special care must be taken to tell the GIC about whether we want to receive a doorbell or not. This is a major improvement on GICv4.0, where the doorbell had to be separately enabled/disabled. Reviewed-by: Zenghui Yu Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its.c | 53 +++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 49850297fe56..a5567d099a3e 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2631,7 +2631,7 @@ static int __init allocate_lpi_tables(void) return 0; } -static u64 its_clear_vpend_valid(void __iomem *vlpi_base) +static u64 its_clear_vpend_valid(void __iomem *vlpi_base, u64 clr, u64 set) { u32 count = 1000000; /* 1s! */ bool clean; @@ -2639,6 +2639,8 @@ static u64 its_clear_vpend_valid(void __iomem *vlpi_base) val = gits_read_vpendbaser(vlpi_base + GICR_VPENDBASER); val &= ~GICR_VPENDBASER_Valid; + val &= ~clr; + val |= set; gits_write_vpendbaser(val, vlpi_base + GICR_VPENDBASER); do { @@ -2651,6 +2653,11 @@ static u64 its_clear_vpend_valid(void __iomem *vlpi_base) } } while (!clean && count); + if (unlikely(val & GICR_VPENDBASER_Dirty)) { + pr_err_ratelimited("ITS virtual pending table not cleaning\n"); + val |= GICR_VPENDBASER_PendingLast; + } + return val; } @@ -2759,7 +2766,7 @@ static void its_cpu_init_lpis(void) * ancient programming gets left in and has possibility of * corrupting memory. */ - val = its_clear_vpend_valid(vlpi_base); + val = its_clear_vpend_valid(vlpi_base, 0, 0); WARN_ON(val & GICR_VPENDBASER_Dirty); } @@ -3439,16 +3446,10 @@ static void its_vpe_deschedule(struct its_vpe *vpe) void __iomem *vlpi_base = gic_data_rdist_vlpi_base(); u64 val; - val = its_clear_vpend_valid(vlpi_base); + val = its_clear_vpend_valid(vlpi_base, 0, 0); - if (unlikely(val & GICR_VPENDBASER_Dirty)) { - pr_err_ratelimited("ITS virtual pending table not cleaning\n"); - vpe->idai = false; - vpe->pending_last = true; - } else { - vpe->idai = !!(val & GICR_VPENDBASER_IDAI); - vpe->pending_last = !!(val & GICR_VPENDBASER_PendingLast); - } + vpe->idai = !!(val & GICR_VPENDBASER_IDAI); + vpe->pending_last = !!(val & GICR_VPENDBASER_PendingLast); } static void its_vpe_invall(struct its_vpe *vpe) @@ -3640,6 +3641,35 @@ static void its_vpe_4_1_schedule(struct its_vpe *vpe, gits_write_vpendbaser(val, vlpi_base + GICR_VPENDBASER); } +static void its_vpe_4_1_deschedule(struct its_vpe *vpe, + struct its_cmd_info *info) +{ + void __iomem *vlpi_base = gic_data_rdist_vlpi_base(); + u64 val; + + if (info->req_db) { + /* + * vPE is going to block: make the vPE non-resident with + * PendingLast clear and DB set. The GIC guarantees that if + * we read-back PendingLast clear, then a doorbell will be + * delivered when an interrupt comes. + */ + val = its_clear_vpend_valid(vlpi_base, + GICR_VPENDBASER_PendingLast, + GICR_VPENDBASER_4_1_DB); + vpe->pending_last = !!(val & GICR_VPENDBASER_PendingLast); + } else { + /* + * We're not blocking, so just make the vPE non-resident + * with PendingLast set, indicating that we'll be back. + */ + val = its_clear_vpend_valid(vlpi_base, + 0, + GICR_VPENDBASER_PendingLast); + vpe->pending_last = true; + } +} + 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); @@ -3651,6 +3681,7 @@ static int its_vpe_4_1_set_vcpu_affinity(struct irq_data *d, void *vcpu_info) return 0; case DESCHEDULE_VPE: + its_vpe_4_1_deschedule(vpe, info); return 0; case INVALL_VPE: -- 2.20.1