Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp4222429ybn; Fri, 27 Sep 2019 19:07:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxm4a1K1tpGoZNlpsUZsI85Ci8tyMD1H8xsRgQ8TdHF9JCuSu4aKu8m5ceVfZiUfozwb0DY X-Received: by 2002:a50:8a9a:: with SMTP id j26mr7957762edj.251.1569636436087; Fri, 27 Sep 2019 19:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569636436; cv=none; d=google.com; s=arc-20160816; b=UlzP7Mi4L9skSpbJu1wWf1e9QDi+OmWebOWcI/KpNiYTAnU1Vha5utgJA20l4KFEDM QfmVzsV2DK51IEK5M3S/TfFHaNlMdevy3q6aydlIfL5Pu0endryCmdx59CgMo7oI/N1D i5c4X2GH6/7V4fVYWUXHsWf+ZGaELiygIpOY4xHyxuEmgCP4ApwB16G/t/AD5OQ5SQj4 X9u07gFUUVM+k2jTdk8YfS6KD+BYnwX9GPcKMHQKwgLmxfONYMS2aZbfAlADpxQdp90+ U3pXZjGj+/FlB1hKn1o/wGvVQnfFU96oYgZq1m0LxEp5elYRuEc0pI44HwWimJkL9v68 OxoQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Izu7PgoH4do9+z40nl0RFnHKl7aBkLWR4Hir0JMnXW8=; b=Aa4ZxlPXluIQDzvNTG4FkczFfZ1VzdJmIm7K7T4iRB4OIDLvM9GJcysDLfDau1wKL5 6qniOh8+7hgl5Gne0lrr4gNEqkidcImZL8TU+CINfVOZ+pHbngjrHH5ood6D5clIolD4 w74A8vMJJXYi/cB9YCSw+p3pKFw4njcGl5EfmaGm86mMc1lZ2a7YL3jaMGUjdyphrfnq v2eS5Y/+L0V2yq+TdkSkPo7nga5uJCOVIlvrFGnJWsTZOwSTAGBSxA90WcWR7MLJA4Oo mRrpb2b8PFvZ/JKuYlxvdGdjd7J6Kt9+QkYoaE1u2mUP9a/FKrK3ZLA2scf/vLHwJHLX vlmQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g30si2896701eda.2.2019.09.27.19.06.37; Fri, 27 Sep 2019 19:07:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbfI1CFK (ORCPT + 99 others); Fri, 27 Sep 2019 22:05:10 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:58846 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725990AbfI1CFJ (ORCPT ); Fri, 27 Sep 2019 22:05:09 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9DDB44CD10C3886E974F; Sat, 28 Sep 2019 10:05:06 +0800 (CST) Received: from [127.0.0.1] (10.184.12.158) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Sat, 28 Sep 2019 10:04:57 +0800 Subject: Re: [PATCH 20/35] irqchip/gic-v4.1: Allow direct invalidation of VLPIs To: Marc Zyngier , , CC: Lorenzo Pieralisi , Jason Cooper , Thomas Gleixner References: <20190923182606.32100-1-maz@kernel.org> <20190923182606.32100-21-maz@kernel.org> From: Zenghui Yu Message-ID: Date: Sat, 28 Sep 2019 10:02:07 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Thunderbird/64.0 MIME-Version: 1.0 In-Reply-To: <20190923182606.32100-21-maz@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.184.12.158] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/9/24 2:25, Marc Zyngier wrote: > 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. > > Signed-off-by: Marc Zyngier > --- > drivers/irqchip/irq-gic-v3-its.c | 19 +++++++++++++++++-- > include/linux/irqchip/arm-gic-v3.h | 1 + > 2 files changed, 18 insertions(+), 2 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index b791c9beddf2..34595a7fcccb 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -1200,13 +1200,27 @@ static void wait_for_syncr(void __iomem *rdbase) > > static void direct_lpi_inv(struct irq_data *d) > { > + struct its_vlpi_map *map = get_vlpi_map(d); > struct its_collection *col; > 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); I think irq_to_col() may not work when GICv4.1 VLPIs are involved in. irq_to_col() gives us col_map[event] as the target redistributor, but the correct one for VLPIs should be vlpi_maps[event]->vpe->col_idx. These two are not always pointing to the same physical RD. For example, if guest issues a MOVI against a VLPI, we will update the corresponding vlpi_map->vpe and issue a VMOVI on ITS... but leave the col_map[event] unchanged. col_map[event] usually describes the physical LPI's CPU affinity, but when this physical LPI serves as something which the VLPI is backed by, we take really little care of it. Did I miss something here? Thanks, zenghui > rdbase = per_cpu_ptr(gic_rdists->rdist, col->col_id)->rd_base; > - gic_write_lpir(d->hwirq, rdbase + GICR_INVLPIR); > + gic_write_lpir(val, rdbase + GICR_INVLPIR); > > wait_for_syncr(rdbase); > } > @@ -1216,7 +1230,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 > 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 b69f60792554..5f3278cbf247 100644 > --- a/include/linux/irqchip/arm-gic-v3.h > +++ b/include/linux/irqchip/arm-gic-v3.h > @@ -247,6 +247,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) > >