Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2016904ybg; Sun, 27 Oct 2019 09:19:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiiFEKjdpIi586owKoucS2ywYoaRq1AStyfiNT6JVkc+YpxH5Z2heldKXOHHBmmpxTq4CH X-Received: by 2002:a05:6402:304c:: with SMTP id bu12mr14634763edb.230.1572193160359; Sun, 27 Oct 2019 09:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572193160; cv=none; d=google.com; s=arc-20160816; b=dxgAlqj4rwzl+83KYR0/8LOV2Q6W5d0yIipzf/YWx+jlbG+1K8uoGeBLffcRoeMsoc JkFUYF5izPDJGvbAeSdXoGSWQN/gv82L8PyTxEN2VYZG+m2pP0u8hYsPWT3XFM5kvmDY 96Ohv+nb0Lc9+5FUFIsv2oUp/RIQmn6oPP+BLyZbpHhs8qCaaPO2AAqqGyYMvuUBDXvj /T1LRylR9qFQ1nV3aDl0d75FZR97dvfGAbakUQ05sS8rMzL+XuLMxXSdRaQRXMz58B8R 7saW/G42CMUIe98aOHfYgYXoS+XgIwPmNEpg0RWDoeZyKxGUdALLYMEzHRJygZy39eHz FzpA== 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=ueIsSkyFLHhGwJzRXy0bTNpHbp5HNYQT4S4vAADxmnc=; b=uQYhi0oCmX5xpJbcVgwJbyYeHOTTZ2sOtYSdijx4Yv/oEY747NDl+O3fu85js9VZco 3q65mfxeR3+fA74jJC1VZlqFQCGdh5l9ZXh7pvSHfXl/6xsseTRQRFVah+kNBNJIMLNp zv4QP5ty4pNcnuvg9IxLAFodUjQmRKMO4h8UgVbMHGynRcwuQ/R1Plt2YSbv9Olre+pk VoiML9ocZcvqcAOtdr3tAw4jbpVjCdRLzHoxmmpfb69NVmmbKi6E5Tw2eOUOpNe8EErk d1nmU4MZ/PZIqvVCWdWtuepYGzlCX3aUaddsdBcMi2mhWtYE0maC4J+cRcJOsrhHYRih r1cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=atHehoOB; 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 t8si3592934edd.373.2019.10.27.09.18.28; Sun, 27 Oct 2019 09:19:20 -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=atHehoOB; 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 S1727358AbfJ0OpC (ORCPT + 99 others); Sun, 27 Oct 2019 10:45:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:38022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727216AbfJ0OpC (ORCPT ); Sun, 27 Oct 2019 10:45:02 -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 A002621E6F; Sun, 27 Oct 2019 14:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572187501; bh=H3GAI5vLVjtZJ1aQlZsIHRQHBYBwQ2NuourT2ApKXvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=atHehoOBYndYpOWXv2VccG2C/Os7y7E0HQ2js6n4bCydxMuiTRvl+joyzst4XNgPO WOBdjfmmuve/nvXVXb3makrzdD49iQ2O2dZCks6o/C5DqGgMy/xKyKFaKdBhME3Smi xMtgQBV0MtSUulPn05Ev/ghPANxcb9NiyQahDmYA= 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 18/36] irqchip/gic-v4.1: Add VPE eviction callback Date: Sun, 27 Oct 2019 14:42:16 +0000 Message-Id: <20191027144234.8395-19-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 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. 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 d45e9b4e5622..f7effd453729 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2487,7 +2487,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; @@ -2495,6 +2495,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 { @@ -2507,6 +2509,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; } @@ -2615,7 +2622,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); } @@ -3293,16 +3300,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) @@ -3481,6 +3482,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); @@ -3492,6 +3522,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