From nobody Tue Feb 10 01:15:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149087817607513.034718403793022; Thu, 30 Mar 2017 05:49:36 -0700 (PDT) Received: from localhost ([::1]:35449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctZWA-0001zK-L2 for importer@patchew.org; Thu, 30 Mar 2017 08:49:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctZUT-0000m6-1d for qemu-devel@nongnu.org; Thu, 30 Mar 2017 08:47:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctZUQ-0006Am-U0 for qemu-devel@nongnu.org; Thu, 30 Mar 2017 08:47:49 -0400 Received: from ozlabs.ru ([107.173.13.209]:57982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctZUQ-0006AX-Kb; Thu, 30 Mar 2017 08:47:46 -0400 Received: from vpl2.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id F03CA3A6018E; Thu, 30 Mar 2017 08:47:20 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Thu, 30 Mar 2017 23:47:04 +1100 Message-Id: <20170330124707.28142-3-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170330124707.28142-1-aik@ozlabs.ru> References: <20170330124707.28142-1-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [RFC PATCH qemu 2/5] spapr-iommu: Subclass TYPE_IOMMU_MEMORY_REGION 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: Alexey Kardashevskiy , Paolo Bonzini , Alex Williamson , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Alexey Kardashevskiy --- include/hw/ppc/spapr.h | 22 ++++++++++++++++++++++ hw/ppc/spapr_iommu.c | 25 ++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 6997ed7e98..5d5ce4dd2b 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -573,11 +573,25 @@ void spapr_load_rtas(sPAPRMachineState *spapr, void *= fdt, hwaddr addr); #define RTAS_EVENT_SCAN_RATE 1 =20 typedef struct sPAPRTCETable sPAPRTCETable; +typedef struct sPAPRIOMMUMemoryRegionClass sPAPRIOMMUMemoryRegionClass; =20 #define TYPE_SPAPR_TCE_TABLE "spapr-tce-table" #define SPAPR_TCE_TABLE(obj) \ OBJECT_CHECK(sPAPRTCETable, (obj), TYPE_SPAPR_TCE_TABLE) =20 +#define TYPE_SPAPR_IOMMU_MEMORY_REGION "qemu:spapr_iommu-memory-region" +#define SPAPR_IOMMU_MEMORY_REGION(obj) \ + OBJECT_CHECK(IOMMUMemoryRegion, (obj), \ + TYPE_SPAPR_IOMMU_MEMORY_REGION) + +#define SPAPR_IOMMU_MEMORY_REGION_CLASS(k) \ + OBJECT_CLASS_CHECK(sPAPRIOMMUMemoryRegionClass, (k), \ + TYPE_SPAPR_IOMMU_MEMORY_REGION) + +#define SPAPR_IOMMU_MEMORY_REGION_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRIOMMUMemoryRegionClass, (obj), \ + TYPE_SPAPR_IOMMU_MEMORY_REGION) + struct sPAPRTCETable { DeviceState parent; uint32_t liobn; @@ -596,6 +610,14 @@ struct sPAPRTCETable { QLIST_ENTRY(sPAPRTCETable) list; }; =20 +struct sPAPRIOMMUMemoryRegionClass { + /*< private >*/ + ObjectClass parent_class; + /*< public >*/ + + int (*get_fd)(IOMMUMemoryRegion *iommu); +}; + sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn); =20 struct sPAPREventLogEntry { diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index 5051110b9d..5b0eee1be4 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -171,6 +171,13 @@ static void spapr_tce_notify_flag_changed(IOMMUMemoryR= egion *iommu, } } =20 +static int spapr_tce_get_fd(IOMMUMemoryRegion *iommu) +{ + sPAPRTCETable *tcet =3D container_of(iommu, sPAPRTCETable, iommu); + + return tcet->fd; +} + static int spapr_tce_table_post_load(void *opaque, int version_id) { sPAPRTCETable *tcet =3D SPAPR_TCE_TABLE(opaque); @@ -266,7 +273,7 @@ static int spapr_tce_table_realize(DeviceState *dev) memory_region_init(&tcet->root, tcetobj, tmp, UINT64_MAX); =20 snprintf(tmp, sizeof(tmp), "tce-iommu-%x", tcet->liobn); - memory_region_init_iommu_type(TYPE_IOMMU_MEMORY_REGION, + memory_region_init_iommu_type(TYPE_SPAPR_IOMMU_MEMORY_REGION, &tcet->iommu, tcetobj, &spapr_iommu_ops, tmp, 0); =20 @@ -634,9 +641,25 @@ static TypeInfo spapr_tce_table_info =3D { .class_init =3D spapr_tce_table_class_init, }; =20 +static void spapr_iommu_memory_region_class_init(ObjectClass *k, void *dat= a) +{ + sPAPRIOMMUMemoryRegionClass *smrc =3D SPAPR_IOMMU_MEMORY_REGION_CLASS(= k); + + smrc->get_fd =3D spapr_tce_get_fd; +} + +static const TypeInfo spapr_iommu_memory_region_info =3D { + .parent =3D TYPE_IOMMU_MEMORY_REGION, + .name =3D TYPE_SPAPR_IOMMU_MEMORY_REGION, + .instance_size =3D sizeof(IOMMUMemoryRegion), + .class_size =3D sizeof(sPAPRIOMMUMemoryRegionClass), + .class_init =3D spapr_iommu_memory_region_class_init, +}; + static void register_types(void) { type_register_static(&spapr_tce_table_info); + type_register_static(&spapr_iommu_memory_region_info); } =20 type_init(register_types); --=20 2.11.0