From patchwork Fri Nov 9 11:29:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 995469 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42ryyP6DJ2z9sC7 for ; Fri, 9 Nov 2018 22:45:33 +1100 (AEDT) Received: from localhost ([::1]:33353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL5EB-0006fV-3V for incoming@patchwork.ozlabs.org; Fri, 09 Nov 2018 06:45:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL50b-00079V-Mx for qemu-devel@nongnu.org; Fri, 09 Nov 2018 06:31:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gL50U-0003Dt-5J for qemu-devel@nongnu.org; Fri, 09 Nov 2018 06:31:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51790) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gL50P-0002cl-29; Fri, 09 Nov 2018 06:31:18 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24B54308339B; Fri, 9 Nov 2018 11:31:16 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D68915C220; Fri, 9 Nov 2018 11:31:13 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, jean-philippe.brucker@arm.com Date: Fri, 9 Nov 2018 12:29:55 +0100 Message-Id: <20181109112957.10067-17-eric.auger@redhat.com> In-Reply-To: <20181109112957.10067-1-eric.auger@redhat.com> References: <20181109112957.10067-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 09 Nov 2018 11:31:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v8 16/18] hw/arm/virt-acpi-build: Introduce fill_iort_idmap helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tn@semihalf.com, kevin.tian@intel.com, bharat.bhushan@nxp.com, peterx@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" To avoid code duplication, let's introduce an helper that fills one IORT ID mappings array index. Signed-off-by: Eric Auger --- v8: new --- hw/arm/virt-acpi-build.c | 43 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 5785fb697c..ec7c4835fe 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -396,6 +396,17 @@ build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned xsdt_tbl_offset) return rsdp_table; } +static inline void +fill_iort_idmap(AcpiIortIdMapping *idmap, int i, + uint32_t input_base, uint32_t id_count, + uint32_t output_base, uint32_t output_reference) +{ + idmap[i].input_base = cpu_to_le32(input_base); + idmap[i].id_count = cpu_to_le32(id_count); + idmap[i].output_base = cpu_to_le32(output_base); + idmap[i].output_reference = cpu_to_le32(output_reference); +} + static void build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { @@ -453,13 +464,12 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) smmu->gerr_gsiv = cpu_to_le32(irq + 2); smmu->sync_gsiv = cpu_to_le32(irq + 3); - /* Identity RID mapping covering the whole input RID range */ - idmap = &smmu->id_mapping_array[0]; - idmap->input_base = 0; - idmap->id_count = cpu_to_le32(0xFFFF); - idmap->output_base = 0; - /* output IORT node is the ITS group node (the first node) */ - idmap->output_reference = cpu_to_le32(iort_node_offset); + /* + * Identity RID mapping covering the whole input RID range. + * The output IORT node is the ITS group node (the first node). + */ + fill_iort_idmap(smmu->id_mapping_array, 0, 0, 0xffff, 0, + iort_node_offset); } /* Root Complex Node */ @@ -477,18 +487,17 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) rc->memory_properties.memory_flags = 0x3; /* CCA = CPM = DCAS = 1 */ rc->pci_segment_number = 0; /* MCFG pci_segment */ - /* Identity RID mapping covering the whole input RID range */ - idmap = &rc->id_mapping_array[0]; - idmap->input_base = 0; - idmap->id_count = cpu_to_le32(0xFFFF); - idmap->output_base = 0; - if (vms->iommu == VIRT_IOMMU_SMMUV3) { - /* output IORT node is the smmuv3 node */ - idmap->output_reference = cpu_to_le32(smmu_offset); + /* Identity RID mapping and output IORT node is the iommu node */ + fill_iort_idmap(rc->id_mapping_array, 0, 0, 0xFFFF, 0, + smmu_offset); } else { - /* output IORT node is the ITS group node (the first node) */ - idmap->output_reference = cpu_to_le32(iort_node_offset); + /* + * Identity RID mapping and the output IORT node is the ITS group + * node (the first node). + */ + fill_iort_idmap(rc->id_mapping_array, 0, 0, 0xFFFF, 0, + iort_node_offset); } /*