From patchwork Thu Sep 19 13:24:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11152389 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE61E76 for ; Thu, 19 Sep 2019 13:25:37 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3889217D6 for ; Thu, 19 Sep 2019 13:25:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3889217D6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAwPm-0008GC-4l; Thu, 19 Sep 2019 13:24:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iAwPk-0008Fi-Cn for xen-devel@lists.xenproject.org; Thu, 19 Sep 2019 13:24:04 +0000 X-Inumbo-ID: bf84d8a0-dae0-11e9-b299-bc764e2007e4 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id bf84d8a0-dae0-11e9-b299-bc764e2007e4; Thu, 19 Sep 2019 13:24:03 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F0F81AB9B; Thu, 19 Sep 2019 13:24:02 +0000 (UTC) From: Jan Beulich To: "xen-devel@lists.xenproject.org" References: Message-ID: <6de11867-b872-a2a1-7c26-af004164bfea@suse.com> Date: Thu, 19 Sep 2019 15:24:11 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Subject: [Xen-devel] [PATCH v6 6/8] AMD/IOMMU: tidy struct ivrs_mappings X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Suravee Suthikulpanit Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Move the device flags field up into an unused hole, thus shrinking overall structure size by 8 bytes. Use bool and uint_t as appropriate. Drop pointless (redundant) initializations. Signed-off-by: Jan Beulich Reviewed-by: Paul Durrant Acked-by: Andrew Cooper --- v6: New. --- xen/drivers/passthrough/amd/iommu_acpi.c | 6 +++--- xen/drivers/passthrough/amd/iommu_init.c | 6 ------ xen/include/asm-x86/amd-iommu.h | 17 +++++++++-------- 3 files changed, 12 insertions(+), 17 deletions(-) --- a/xen/drivers/passthrough/amd/iommu_acpi.c +++ b/xen/drivers/passthrough/amd/iommu_acpi.c @@ -165,7 +165,7 @@ static void __init reserve_unity_map_for /* extend r/w permissioms and keep aggregate */ ivrs_mappings[bdf].write_permission = iw; ivrs_mappings[bdf].read_permission = ir; - ivrs_mappings[bdf].unity_map_enable = IOMMU_CONTROL_ENABLED; + ivrs_mappings[bdf].unity_map_enable = true; ivrs_mappings[bdf].addr_range_start = base; ivrs_mappings[bdf].addr_range_length = length; } @@ -242,8 +242,8 @@ static int __init register_exclusion_ran if ( limit >= iommu_top ) { reserve_iommu_exclusion_range(iommu, base, limit); - ivrs_mappings[bdf].dte_allow_exclusion = IOMMU_CONTROL_ENABLED; - ivrs_mappings[req].dte_allow_exclusion = IOMMU_CONTROL_ENABLED; + ivrs_mappings[bdf].dte_allow_exclusion = true; + ivrs_mappings[req].dte_allow_exclusion = true; } return 0; --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -1222,12 +1222,6 @@ static int __init alloc_ivrs_mappings(u1 for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ ) { ivrs_mappings[bdf].dte_requestor_id = bdf; - ivrs_mappings[bdf].dte_allow_exclusion = IOMMU_CONTROL_DISABLED; - ivrs_mappings[bdf].unity_map_enable = IOMMU_CONTROL_DISABLED; - ivrs_mappings[bdf].iommu = NULL; - - ivrs_mappings[bdf].intremap_table = NULL; - ivrs_mappings[bdf].device_flags = 0; if ( amd_iommu_perdev_intremap ) spin_lock_init(&ivrs_mappings[bdf].intremap_lock); --- a/xen/include/asm-x86/amd-iommu.h +++ b/xen/include/asm-x86/amd-iommu.h @@ -106,12 +106,16 @@ struct amd_iommu { }; struct ivrs_mappings { - u16 dte_requestor_id; - u8 dte_allow_exclusion; - u8 unity_map_enable; - u8 write_permission; - u8 read_permission; + uint16_t dte_requestor_id; bool valid; + bool dte_allow_exclusion; + bool unity_map_enable; + bool write_permission; + bool read_permission; + + /* ivhd device data settings */ + uint8_t device_flags; + unsigned long addr_range_start; unsigned long addr_range_length; struct amd_iommu *iommu; @@ -120,9 +124,6 @@ struct ivrs_mappings { void *intremap_table; unsigned long *intremap_inuse; spinlock_t intremap_lock; - - /* ivhd device data settings */ - u8 device_flags; }; extern unsigned int ivrs_bdf_entries;