Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1549252ybc; Wed, 13 Nov 2019 00:04:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxnf12Qp1zitz/bnBz7lHwybO4EdZFK4Xd2bTC1B1fi0U+aAaGAfcczU6DZ+LL101Za59cq X-Received: by 2002:a17:906:cb2:: with SMTP id k18mr1444578ejh.49.1573632280995; Wed, 13 Nov 2019 00:04:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573632280; cv=none; d=google.com; s=arc-20160816; b=y88ohu6gxF5b1c3Fb8xEGABnHVeK6hjNxGKkoijCrAiuP3BipWUKNFiP20KFUcYXVn iPmKJFBqXt5tMua0EI+7MF8MuFy7rA7uok84KPaC7bggmUeOloHfvnc+VPwI2RRTAtMk AGAHT1SqijxidTml1UERpfLhOTEGx2RDPFqYyox2WnkyqL0JXlXLKYMte/rIRK490xf/ 01PEgkT8DHvt1GepDR2jdpsrRtt1yprVgFNKLtZHvLovHwglOn6hxLidpC76jXDlfx5f TIp2hqZuIqAVCzYIVzd55JdSyh3ewf35NYkUp+Q9AIBZDpx+1BZmz8flP3Knr279aLUp 69Cw== 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=uVZPfALkRPk+PlJo3jTXzqClGg8PysfI9A4V6nXCrlk=; b=xAGtRTB+D4PQdXrr6RE7e93oGYMee7CaUlhCkVmfCkJrbcHNtRUUCiwCrL3OJJZiAY tkZUU4SSynJH2tO2WRk61GHbcXWE1dtPgC13yavotYNZIJ1173pUpq0pscwwJ0faCmdb /jK7ZPLNJhUFDrHALw2YxncNOIhQoLmscGxl5U65Fp2i4n6GkmCWtAaAPTcEt4JzxQBl tbCb9Vx6NYNVIYrAsaxFj5JvG1yRwRA+5pKI5dcRXIgMlYg/uCLdo5HamngQ3KhhLwfz ll8N2Ran/WIWc9k241DTX0Z0OV5/hzKGGbcYFgLLAB7TkNtEIKD5DCRWXUl6afnF3C5V FiDQ== 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 p8si763312edq.55.2019.11.13.00.04.11; Wed, 13 Nov 2019 00:04:40 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726988AbfKMICu (ORCPT + 99 others); Wed, 13 Nov 2019 03:02:50 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:6216 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725996AbfKMICu (ORCPT ); Wed, 13 Nov 2019 03:02:50 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 333D7E05137A09BBC0E5; Wed, 13 Nov 2019 16:02:48 +0800 (CST) Received: from [127.0.0.1] (10.184.12.158) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Wed, 13 Nov 2019 16:02:38 +0800 Subject: Re: [PATCH v2 12/36] irqchip/gic-v4.1: Implement the v4.1 flavour of VMAPP To: Marc Zyngier , , CC: Eric Auger , James Morse , Julien Thierry , Suzuki K Poulose , Thomas Gleixner , Jason Cooper , Lorenzo Pieralisi , "Andrew Murray" , Jayachandran C , "Robert Richter" , "Wanghaibin (D)" , , References: <20191027144234.8395-1-maz@kernel.org> <20191027144234.8395-13-maz@kernel.org> From: Zenghui Yu Message-ID: Date: Wed, 13 Nov 2019 16:02:29 +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: <20191027144234.8395-13-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 Hi Marc, On 2019/10/27 22:42, Marc Zyngier wrote: > The ITS VMAPP command gains some new fields with GICv4.1: > - a default doorbell, which allows a single doorbell to be used for > all the VLPIs routed to a given VPE > - a pointer to the configuration table (instead of having it in a register > that gets context switched) > - a flag indicating whether this is the first map or the last unmap for > this particulat VPE > - a flag indicating whether the pending table is known to be zeroed, or not > > Plumb in the new fields in the VMAPP builder, and add the map/unmap > refcounting so that the ITS can do the right thing. > > Signed-off-by: Marc Zyngier [...] > @@ -605,19 +626,45 @@ static struct its_vpe *its_build_vmapp_cmd(struct its_node *its, > struct its_cmd_block *cmd, > struct its_cmd_desc *desc) > { > - unsigned long vpt_addr; > + unsigned long vpt_addr, vconf_addr; > u64 target; > - > - vpt_addr = virt_to_phys(page_address(desc->its_vmapp_cmd.vpe->vpt_page)); > - target = desc->its_vmapp_cmd.col->target_address + its->vlpi_redist_offset; > + bool alloc; > > its_encode_cmd(cmd, GITS_CMD_VMAPP); > its_encode_vpeid(cmd, desc->its_vmapp_cmd.vpe->vpe_id); > its_encode_valid(cmd, desc->its_vmapp_cmd.valid); > + > + if (!desc->its_vmapp_cmd.valid) { > + if (is_v4_1(its)) { > + alloc = !atomic_dec_return(&desc->its_vmapp_cmd.vpe->vmapp_count); > + its_encode_alloc(cmd, alloc); > + } > + > + goto out; > + } > + > + vpt_addr = virt_to_phys(page_address(desc->its_vmapp_cmd.vpe->vpt_page)); > + target = desc->its_vmapp_cmd.col->target_address + its->vlpi_redist_offset; > + > its_encode_target(cmd, target); > its_encode_vpt_addr(cmd, vpt_addr); > its_encode_vpt_size(cmd, LPI_NRBITS - 1); > > + if (!is_v4_1(its)) > + goto out; > + > + vconf_addr = virt_to_phys(page_address(desc->its_vmapp_cmd.vpe->its_vm->vprop_page)); > + > + alloc = atomic_inc_and_test(&desc->its_vmapp_cmd.vpe->vmapp_count); As the comment block on top of atomic_inc_and_test(atomic *v) says, * Atomically increments @v by 1 * and returns true if the result is zero, or false for all * other cases. */ We will always get the 'alloc' as false here, even if this is the first mapping of this vPE. This is not as expected, I think. And on the other hand, I wonder what is the reason for 'vmapp_count' to be atomic_t? Thanks, Zenghui > + > + its_encode_alloc(cmd, alloc); > + > + /* We can only signal PTZ when alloc==1. Why do we have two bits? */ > + its_encode_ptz(cmd, alloc); > + its_encode_vconf_addr(cmd, vconf_addr); > + its_encode_vmapp_default_db(cmd, desc->its_vmapp_cmd.vpe->vpe_db_lpi); > + > +out: > its_fixup_cmd(cmd); > > return valid_vpe(its, desc->its_vmapp_cmd.vpe); > @@ -3349,7 +3396,10 @@ static int its_vpe_init(struct its_vpe *vpe) > > vpe->vpe_id = vpe_id; > vpe->vpt_page = vpt_page; > - vpe->vpe_proxy_event = -1; > + if (gic_rdists->has_rvpeid) > + atomic_set(&vpe->vmapp_count, 0); > + else > + vpe->vpe_proxy_event = -1; > > return 0; > } > diff --git a/include/linux/irqchip/arm-gic-v4.h b/include/linux/irqchip/arm-gic-v4.h > index ab1396afe08a..6213ced6f199 100644 > --- a/include/linux/irqchip/arm-gic-v4.h > +++ b/include/linux/irqchip/arm-gic-v4.h > @@ -37,8 +37,20 @@ struct its_vpe { > irq_hw_number_t vpe_db_lpi; > /* VPE resident */ > bool resident; > - /* VPE proxy mapping */ > - int vpe_proxy_event; > + union { > + /* GICv4.0 implementations */ > + struct { > + /* VPE proxy mapping */ > + int vpe_proxy_event; > + /* Implementation Defined Area Invalid */ > + bool idai; > + }; > + /* GICv4.1 implementations */ > + struct { > + atomic_t vmapp_count; > + }; > + }; > + > /* > * This collection ID is used to indirect the target > * redistributor for this VPE. The ID itself isn't involved in > @@ -47,8 +59,6 @@ struct its_vpe { > u16 col_idx; > /* Unique (system-wide) VPE identifier */ > u16 vpe_id; > - /* Implementation Defined Area Invalid */ > - bool idai; > /* Pending VLPIs on schedule out? */ > bool pending_last; > }; >