Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755653AbcCTN74 (ORCPT ); Sun, 20 Mar 2016 09:59:56 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33415 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755970AbcCTN7k (ORCPT ); Sun, 20 Mar 2016 09:59:40 -0400 Date: Sun, 20 Mar 2016 13:59:37 +0000 From: Wei Yang To: Wei Yang Cc: joro@8bytes.org, jiang.liu@linux.intel.com, tglx@linutronix.de, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] iommu/vt-d: replace *hdr with hdr[0] in struct dmar_drhd_unit Message-ID: <20160320135937.GA7827@vultr.guest> Reply-To: Wei Yang References: <1457819859-28668-1-git-send-email-richard.weiyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1457819859-28668-1-git-send-email-richard.weiyang@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3603 Lines: 99 Obsolete this one. V2 is sent. On Sat, Mar 12, 2016 at 09:57:38PM +0000, Wei Yang wrote: >hdr in struct dmar_drhd_unit is used to point the DMAR hardware unit copied >at the end of struct dmar_drhd_unit. One zero-sized array may be more >elegant for this purpose. > >This patch replace *hdr with hdr[0] in struct dmar_drhd_unit. > >Besides this, this patch includes other two changes: >1. remove unnecessary type cast in dmar_table_detect() >2. type cast from acpi_dmar_header to acpi_dmar_hardware_unit directly > >Signed-off-by: Wei Yang >--- > drivers/iommu/dmar.c | 15 ++++----------- > include/linux/dmar.h | 2 +- > 2 files changed, 5 insertions(+), 12 deletions(-) > >diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c >index 80e3c17..d6dd23f 100644 >--- a/drivers/iommu/dmar.c >+++ b/drivers/iommu/dmar.c >@@ -292,8 +292,7 @@ static int dmar_pci_bus_add_dev(struct dmar_pci_notify_info *info) > if (dmaru->include_all) > continue; > >- drhd = container_of(dmaru->hdr, >- struct acpi_dmar_hardware_unit, header); >+ drhd = (struct acpi_dmar_hardware_unit *)dmaru->hdr; > ret = dmar_insert_dev_scope(info, (void *)(drhd + 1), > ((void *)drhd) + drhd->header.length, > dmaru->segment, >@@ -390,7 +389,6 @@ static int dmar_parse_one_drhd(struct acpi_dmar_header *header, void *arg) > * If header is allocated from slab by ACPI _DSM method, we need to > * copy the content because the memory buffer will be freed on return. > */ >- dmaru->hdr = (void *)(dmaru + 1); > memcpy(dmaru->hdr, header, header->length); > dmaru->reg_base_addr = drhd->address; > dmaru->segment = drhd->segment; >@@ -529,8 +527,7 @@ static int __init dmar_table_detect(void) > > /* if we could find DMAR table, then there are DMAR devices */ > status = acpi_get_table_with_size(ACPI_SIG_DMAR, 0, >- (struct acpi_table_header **)&dmar_tbl, >- &dmar_tbl_size); >+ &dmar_tbl, &dmar_tbl_size); > > if (ACPI_SUCCESS(status) && !dmar_tbl) { > pr_warn("Unable to map DMAR\n"); >@@ -663,9 +660,7 @@ dmar_find_matched_drhd_unit(struct pci_dev *dev) > > rcu_read_lock(); > for_each_drhd_unit(dmaru) { >- drhd = container_of(dmaru->hdr, >- struct acpi_dmar_hardware_unit, >- header); >+ drhd = (struct acpi_dmar_hardware_unit *)dmaru->hdr; > > if (dmaru->include_all && > drhd->segment == pci_domain_nr(dev->bus)) >@@ -693,9 +688,7 @@ static void __init dmar_acpi_insert_dev_scope(u8 device_number, > struct acpi_dmar_pci_path *path; > > for_each_drhd_unit(dmaru) { >- drhd = container_of(dmaru->hdr, >- struct acpi_dmar_hardware_unit, >- header); >+ drhd = (struct acpi_dmar_hardware_unit *)dmaru->hdr; > > for (scope = (void *)(drhd + 1); > (unsigned long)scope < ((unsigned long)drhd) + drhd->header.length; >diff --git a/include/linux/dmar.h b/include/linux/dmar.h >index e9bc929..5f6da7e 100644 >--- a/include/linux/dmar.h >+++ b/include/linux/dmar.h >@@ -52,7 +52,6 @@ struct dmar_dev_scope { > extern struct acpi_table_header *dmar_tbl; > struct dmar_drhd_unit { > struct list_head list; /* list of drhd units */ >- struct acpi_dmar_header *hdr; /* ACPI header */ > u64 reg_base_addr; /* register base address*/ > struct dmar_dev_scope *devices;/* target device array */ > int devices_cnt; /* target device count */ >@@ -60,6 +59,7 @@ struct dmar_drhd_unit { > u8 ignored:1; /* ignore drhd */ > u8 include_all:1; > struct intel_iommu *iommu; >+ struct acpi_dmar_header hdr[0];/* ACPI header */ > }; > > struct dmar_pci_path { >-- >2.5.0 -- Wei Yang Help you, Help me