From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C866CD6E75 for ; Fri, 5 Jun 2026 02:19:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK85-0005P9-Jl; Thu, 04 Jun 2026 22:17:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK80-0005I1-Db; Thu, 04 Jun 2026 22:17:44 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7x-0001m7-O7; Thu, 04 Jun 2026 22:17:44 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6550EM7S2061758; Fri, 5 Jun 2026 02:17:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=sp03wwf9BkZT3FkYF 5OTBqZYQ0HnN+j6Vfu+FLoJaDo=; b=CeFVwHJzYG6P4jsYXqfhmUsP02QQcPwLv O00mLh24bmB0ZkYgUsxgZZ6U5QcN0kxkoeXonRFFgsM8JXa0pOXuDvdEsQP/f/Er bZR2xmfr8tkoZ08m9HjzoacDAnK9ZTgcz9nAqegfjI0jSO/5mKG/L2hDy3bSmqm4 e49Mj2TnmWZIbE3WFYqp/hehDSmEEAiyrg9Ic53n3jI0iJkgQhCRo1q/G/UBrUyf sZdHfhU14AKe/6AloSwJTRvzD8HUXD7YS/oOSE+mJadkqbGYNTL59Mi16AScv22r LZlBGASe7hi6QfbBOl0rR08Yx1Fde2PPYtZk5V4nZSTDBXMzgsNWA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqm5aem7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 655296T0010132; Fri, 5 Jun 2026 02:17:35 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4egb7kfsps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HY6S24838676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:34 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2FDE158052; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 05B2958065; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 05/15] s390x/pci: Move iotlb from S390PCIIOMMU to S390PCIBusDevice Date: Thu, 4 Jun 2026 21:17:18 -0500 Message-Id: <20260605021728.1125090-6-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ruXMDHoogNZpMyxZ_HxZVAtwvx_Bn7qq X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfXwCBlGMJ2WXtT QY/bujg/iVwKnmQ6/ZxCCzjDQfGT8keDPlhSAncRw3Zm3nt021JSk0AAY49A4cc21Y6TICzM9Qn 5Llldj99pi7c1ql39Q3LVGCptsIYOTMgIvMOCl/wNjb5arMPXXYcuWOj1cNKAV29uK+YHEba2Wt iFVfefxJLXRb1zkO48TswknCidBqEo+OW6cwmizpxfZhGOJyi/ZAEemK3R7AVSlDBYgHS2X9YyA inA5QIKoMnYqzDXD5I3mS1DLMg4A1VNK+hvCo+G8pKw7ZrwzTQtHNuqYNDB0Jzv6UZhA70quUdT /m/ryFMHbA1IIHINTiJzI/L6SbjYwqnrGH0e/KN7YfKblKvs3bHK8w3RyKfs/OK7Utzi3JnHT3t jCKht1MMoxHfL4goxIiXmI3CZ3NrOOkvwD/aGYjWv+beeta7w3d+DGseomwx2UPnLdtO6lapPPt cvRH2q8PfZFDROUIjxA== X-Proofpoint-ORIG-GUID: ruXMDHoogNZpMyxZ_HxZVAtwvx_Bn7qq X-Authority-Analysis: v=2.4 cv=Vf3H+lp9 c=1 sm=1 tr=0 ts=6a2231c0 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=frKy0Gi9Nncm8Rs_nZ4A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU which purpose is just to store the "root" AddressSpace. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 10 +++++----- hw/s390x/s390-pci-inst.c | 6 +++--- include/hw/s390x/s390-pci-bus.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index f09d85da8f..34dcc7c3bd 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -569,7 +569,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr, goto err; } - entry = g_hash_table_lookup(iommu->iotlb, &iova); + entry = g_hash_table_lookup(pbdev->iotlb, &iova); if (entry) { ret.iova = entry->iova; ret.translated_addr = entry->translated_addr; @@ -681,8 +681,6 @@ static S390PCIIOMMU *s390_pci_get_iommu(S390pciState *s, PCIBus *bus, PCI_FUNC(devfn)); memory_region_init(&iommu->mr, OBJECT(iommu), mr_name, UINT64_MAX); address_space_init(&iommu->as, &iommu->mr, as_name); - iommu->iotlb = g_hash_table_new_full(g_int64_hash, g_int64_equal, - NULL, g_free); table->iommu[PCI_SLOT(devfn)] = iommu; g_free(mr_name); @@ -817,7 +815,7 @@ void s390_pci_iommu_disable(S390PCIBusDevice *pbdev) { S390PCIIOMMU *iommu = pbdev->iommu; iommu->enabled = false; - g_hash_table_remove_all(iommu->iotlb); + g_hash_table_remove_all(pbdev->iotlb); if (pbdev->dm_mr) { memory_region_del_subregion(&iommu->mr, pbdev->dm_mr); object_unparent(OBJECT(pbdev->dm_mr)); @@ -841,7 +839,6 @@ static void s390_pci_iommu_free(S390pciState *s, PCIBus *bus, int32_t devfn) } table->iommu[PCI_SLOT(devfn)] = NULL; - g_hash_table_destroy(iommu->iotlb); /* * An attached PCI device may have memory listeners, eg. VFIO PCI. * The associated subregion will already have been unmapped in @@ -1263,6 +1260,8 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev, /* the allocated idx is actually getting used */ s->next_idx = (pbdev->idx + 1) & FH_MASK_INDEX; pbdev->fh = pbdev->idx; + pbdev->iotlb = g_hash_table_new_full(g_int64_hash, g_int64_equal, + NULL, g_free); QTAILQ_INSERT_TAIL(&s->zpci_devs, pbdev, link); g_hash_table_insert(s->zpci_table, &pbdev->idx, pbdev); } else { @@ -1305,6 +1304,7 @@ static void s390_pcihost_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, if (pbdev->iommu && pbdev->iommu->dma_limit) { s390_pci_end_dma_count(s, pbdev->iommu->dma_limit); } + g_hash_table_destroy(pbdev->iotlb); qdev_unrealize(dev); } } diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 834a0aec95..8349b44dd4 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -617,7 +617,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, S390IOTLBEntry *entry) { S390PCIIOMMU *iommu = pbdev->iommu; - S390IOTLBEntry *cache = g_hash_table_lookup(iommu->iotlb, &entry->iova); + S390IOTLBEntry *cache = g_hash_table_lookup(pbdev->iotlb, &entry->iova); IOMMUTLBEvent event = { .type = entry->perm ? IOMMU_NOTIFIER_MAP : IOMMU_NOTIFIER_UNMAP, .entry = { @@ -633,7 +633,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, if (!cache) { goto out; } - g_hash_table_remove(iommu->iotlb, &entry->iova); + g_hash_table_remove(pbdev->iotlb, &entry->iova); inc_dma_avail(iommu); /* Don't notify the iommu yet, maybe we can bundle contiguous unmaps */ goto out; @@ -656,7 +656,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, cache->translated_addr = entry->translated_addr; cache->len = TARGET_PAGE_SIZE; cache->perm = entry->perm; - g_hash_table_replace(iommu->iotlb, &cache->iova, cache); + g_hash_table_replace(pbdev->iotlb, &cache->iova, cache); dec_dma_avail(iommu); } diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bus.h index f310672584..d9bafd6859 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -281,7 +281,6 @@ struct S390PCIIOMMU { uint64_t pba; uint64_t pal; uint64_t max_dma_limit; - GHashTable *iotlb; S390PCIDMACount *dma_limit; }; @@ -354,6 +353,7 @@ struct S390PCIBusDevice { S390PCIIOMMU *iommu; IOMMUMemoryRegion iommu_mr; MemoryRegion *dm_mr; + GHashTable *iotlb; MemoryRegion msix_notify_mr; IndAddr *summary_ind; IndAddr *indicator; -- 2.34.1