From: Matthew Rosato <mjrosato@linux.ibm.com>
To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com,
gerald.schaefer@linux.ibm.com, schnelle@linux.ibm.com
Cc: hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com,
svens@linux.ibm.com, borntraeger@linux.ibm.com,
clegoate@redhat.com, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH 5/7] iommu/s390: support iova_to_phys for additional table regions
Date: Mon, 9 Dec 2024 14:25:47 -0500 [thread overview]
Message-ID: <20241209192549.107226-6-mjrosato@linux.ibm.com> (raw)
In-Reply-To: <20241209192549.107226-1-mjrosato@linux.ibm.com>
The origin_type of the dma_table is used to determine how many table
levels must be traversed for the translation.
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
drivers/iommu/s390-iommu.c | 42 +++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c
index 5782f329cae9..cea528bf61db 100644
--- a/drivers/iommu/s390-iommu.c
+++ b/drivers/iommu/s390-iommu.c
@@ -744,6 +744,43 @@ static int s390_iommu_map_pages(struct iommu_domain *domain,
return rc;
}
+static unsigned long *get_rto_from_iova(struct s390_domain *domain,
+ dma_addr_t iova)
+{
+ unsigned long *rfo, *rso, *rto;
+ unsigned long rfe, rse;
+ unsigned int rfx, rsx;
+
+ switch (domain->origin_type) {
+ case ZPCI_TABLE_TYPE_RFX:
+ rfo = domain->dma_table;
+ goto itp_rf;
+ case ZPCI_TABLE_TYPE_RSX:
+ rso = domain->dma_table;
+ goto itp_rs;
+ case ZPCI_TABLE_TYPE_RTX:
+ return domain->dma_table;
+ default:
+ return NULL;
+ }
+
+itp_rf:
+ rfx = calc_rfx(iova);
+ rfe = READ_ONCE(rfo[rfx]);
+ if (!reg_entry_isvalid(rfe))
+ return NULL;
+ rso = get_rf_rso(rfe);
+
+itp_rs:
+ rsx = calc_rsx(iova);
+ rse = READ_ONCE(rso[rsx]);
+ if (!reg_entry_isvalid(rse))
+ return NULL;
+ rto = get_rs_rto(rse);
+
+ return rto;
+}
+
static phys_addr_t s390_iommu_iova_to_phys(struct iommu_domain *domain,
dma_addr_t iova)
{
@@ -757,10 +794,13 @@ static phys_addr_t s390_iommu_iova_to_phys(struct iommu_domain *domain,
iova > domain->geometry.aperture_end)
return 0;
+ rto = get_rto_from_iova(s390_domain, iova);
+ if (!rto)
+ return 0;
+
rtx = calc_rtx(iova);
sx = calc_sx(iova);
px = calc_px(iova);
- rto = s390_domain->dma_table;
rte = READ_ONCE(rto[rtx]);
if (reg_entry_isvalid(rte)) {
--
2.47.0
next prev parent reply other threads:[~2024-12-09 19:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 19:25 [PATCH 0/7] iommu/s390: support " Matthew Rosato
2024-12-09 19:25 ` [PATCH 1/7] iommu/s390: add initial fields to track table size Matthew Rosato
2024-12-09 19:25 ` [PATCH 2/7] s390/pci: set appropriate IOTA region type Matthew Rosato
2024-12-09 19:25 ` [PATCH 3/7] iommu/s390: add basic routines for region 1st and 2nd tables Matthew Rosato
2024-12-11 10:57 ` Thomas Huth
2024-12-09 19:25 ` [PATCH 4/7] iommu/s390: support cleanup of additional table regions Matthew Rosato
2024-12-09 19:25 ` Matthew Rosato [this message]
2024-12-09 19:25 ` [PATCH 6/7] iommu/s390: support map/unmap for " Matthew Rosato
2024-12-09 19:25 ` [PATCH 7/7] iommu/s390: allow larger region tables Matthew Rosato
2024-12-09 19:27 ` [PATCH 0/7] iommu/s390: support additional table regions Matthew Rosato
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241209192549.107226-6-mjrosato@linux.ibm.com \
--to=mjrosato@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=clegoate@redhat.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=schnelle@linux.ibm.com \
--cc=svens@linux.ibm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®