Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2846836ybn; Thu, 26 Sep 2019 19:07:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEyD/z4tY6qDMJljYSaNN6oAPso23lQMMD8gdSAgQ/VL4/ok616pFZ8KRfr2Ox18sgGTgi X-Received: by 2002:a17:906:6d53:: with SMTP id a19mr5903946ejt.144.1569550031723; Thu, 26 Sep 2019 19:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569550031; cv=none; d=google.com; s=arc-20160816; b=zOOPoDuHfeRFOP0NWoWFa1oG/Y+8pHmuvAAu6IptV0bJZ7qgnbWziL0lIQbJhVvZCc b05mS0RbPCLdcjJ07aTxSpkUepEo540ujmSCYQR8EAWHQQF1iLmTzyrOmx2I0fLvzoG6 KdxhgZhi/rUxk9Ey7oqIM9al1OUE4AZJZ6vCxmr9ktsRmZV5DMwfYKvtUCO32rA8MUGU LfuC3lXG8/Fq59W7qYssTINo5f2CBHW7ptBy8Sk5i14dbB46lFhTH4EMT9kIOnMaXX/m d29V5F9bLvhxqowOwIF7oDNapOOTwUpGZGaNHcsaxSuUR+DpzZPjXHfyC1iMFMZglOVP qFbw== 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=1u3LirTypwkMaa3P/c9eeGvJGi1HjVmwvpcB8wmv7eM=; b=C2taWH0hm/c/QVklS7ysEXyjR1kqDIn7CaSs/ju2h7ilHkcM8F03hcPjE6VB+rdkkx 3iPQjcDDlh77eTTsoFV0/4y+vc9qB0++XIbLVhuwhwGbEMc6PKT2+sYD1yIbpLX39B31 e+nNBnyFk1uQzG77v+71w4Dqj9g3XyC1XFzwj8mrCdDK7RQ6KNWElGmYeNr/3STS/9OO aAOLb4UiHkR+uQQ4N3lpPfSQg4tIaPJF0yUFcV5U6wFjR70FZxMKHFbN7IZBXl+Xqau6 7WLHSvRhjNOe6xEpjYrFzeXfQktz8No075ZiL1fDhwzlpait9Qc+mwn+0DHwq0qqnKsW 8k/w== 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 q46si700466eda.44.2019.09.26.19.06.47; Thu, 26 Sep 2019 19:07:11 -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 S1728464AbfI0CEA (ORCPT + 99 others); Thu, 26 Sep 2019 22:04:00 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2729 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727794AbfI0CEA (ORCPT ); Thu, 26 Sep 2019 22:04:00 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 089539B626AC6B8ABFFF; Fri, 27 Sep 2019 10:03:58 +0800 (CST) Received: from [127.0.0.1] (10.184.12.158) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Fri, 27 Sep 2019 10:03:48 +0800 Subject: Re: [PATCH 10/35] irqchip/gic-v4.1: VPE table (aka GICR_VPROPBASER) allocation To: Marc Zyngier , , CC: Lorenzo Pieralisi , Jason Cooper , Thomas Gleixner References: <20190923182606.32100-1-maz@kernel.org> <20190923182606.32100-11-maz@kernel.org> <155660c2-7f30-e188-ca8d-c37fabea6d97@huawei.com> <6f4ccdfd-4b63-04cb-e7c0-f069e620127f@kernel.org> <14111988-74c9-12c3-1322-1580ff6ba11f@huawei.com> <5d915f55-785b-72f5-498b-8c17148dd3a9@kernel.org> From: Zenghui Yu Message-ID: <99e561dc-fe3c-ff8f-7e28-8fc4b66d1209@huawei.com> Date: Fri, 27 Sep 2019 10:01:40 +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: <5d915f55-785b-72f5-498b-8c17148dd3a9@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/27 0:27, Marc Zyngier wrote: > On 26/09/2019 16:57, Marc Zyngier wrote: >> On 26/09/2019 16:19, Zenghui Yu wrote: >>> Hi Marc, >>> >>> Two more questions below. >>> >>> On 2019/9/25 22:41, Marc Zyngier wrote: >>>> On 25/09/2019 14:04, Zenghui Yu wrote: >>>>> Hi Marc, >>>>> >>>>> Some questions about this patch, mostly to confirm that I would >>>>> understand things here correctly. >>>>> >>>>> On 2019/9/24 2:25, Marc Zyngier wrote: >>>>>> GICv4.1 defines a new VPE table that is potentially shared between >>>>>> both the ITSs and the redistributors, following complicated affinity >>>>>> rules. >>>>>> >>>>>> To make things more confusing, the programming of this table at >>>>>> the redistributor level is reusing the GICv4.0 GICR_VPROPBASER register >>>>>> for something completely different. >>>>>> >>>>>> The code flow is somewhat complexified by the need to respect the >>>>>> affinities required by the HW, meaning that tables can either be >>>>>> inherited from a previously discovered ITS or redistributor. >>>>>> >>>>>> Signed-off-by: Marc Zyngier >>>>>> --- >>>>> >>>>> [...] >>>>> >>>>>> @@ -1962,6 +1965,65 @@ static bool its_parse_indirect_baser(struct its_node *its, >>>>>> return indirect; >>>>>> } >>>>>> >>>>>> +static u32 compute_common_aff(u64 val) >>>>>> +{ >>>>>> + u32 aff, clpiaff; >>>>>> + >>>>>> + aff = FIELD_GET(GICR_TYPER_AFFINITY, val); >>>>>> + clpiaff = FIELD_GET(GICR_TYPER_COMMON_LPI_AFF, val); >>>>>> + >>>>>> + return aff & ~(GENMASK(31, 0) >> (clpiaff * 8)); >>>>>> +} >>>>>> + >>>>>> +static u32 compute_its_aff(struct its_node *its) >>>>>> +{ >>>>>> + u64 val; >>>>>> + u32 svpet; >>>>>> + >>>>>> + /* >>>>>> + * Reencode the ITS SVPET and MPIDR as a GICR_TYPER, and compute >>>>>> + * the resulting affinity. We then use that to see if this match >>>>>> + * our own affinity. >>>>>> + */ >>>>>> + svpet = FIELD_GET(GITS_TYPER_SVPET, its->typer); >>> >>> The spec says, ITS does not share vPE table with Redistributors when >>> SVPET==0. It seems that we miss this rule and simply regard SVPET as >>> GICR_TYPER_COMMON_LPI_AFF here. Am I wrong? >> >> Correct. I missed the case where the ITS doesn't share anything. That's >> pretty unlikely though (you loose all the benefit of v4.1, and I don't >> really see how you'd make it work reliably). > > Actually, this is already handled... > >> >>> >>>>>> + val = FIELD_PREP(GICR_TYPER_COMMON_LPI_AFF, svpet); >>>>>> + val |= FIELD_PREP(GICR_TYPER_AFFINITY, its->mpidr); >>>>>> + return compute_common_aff(val); >>>>>> +} >>>>>> + >>>>>> +static struct its_node *find_sibbling_its(struct its_node *cur_its) >>>>>> +{ >>>>>> + struct its_node *its; >>>>>> + u32 aff; >>>>>> + >>>>>> + if (!FIELD_GET(GITS_TYPER_SVPET, cur_its->typer)) >>>>>> + return NULL; > > ... here. If SVPET is 0, there is no sibling, and we'll allocate a VPE > table as usual. Yes, I see. So we can safely encode the non-zero SVPET as COMMON_LPI_AFF in a GICR_TYPER when computing the affinity. Thanks, zenghui