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 v2 1/6] iommu/s390: add initial fields to track table size
Date: Fri, 24 Jan 2025 15:18:21 -0500 [thread overview]
Message-ID: <20250124201826.348848-2-mjrosato@linux.ibm.com> (raw)
In-Reply-To: <20250124201826.348848-1-mjrosato@linux.ibm.com>
In preparation for allowing for additional table levels, add the
necessary information to the zdev and s390 domain to track table
type. For now, these values will always be set to signify a
region third table which is what s390-iommu always uses today.
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
arch/s390/include/asm/pci.h | 2 ++
drivers/iommu/s390-iommu.c | 17 +++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index 474e1f8d1d3c..8f8ebaeec60a 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -189,6 +189,8 @@ struct zpci_dev {
struct kvm_zdev *kzdev;
struct mutex kzdev_lock;
spinlock_t dom_lock; /* protect s390_domain change */
+ u64 max_table_size;
+ u8 origin_type;
};
static inline bool zdev_enabled(struct zpci_dev *zdev)
diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c
index fbdeded3d48b..f6c27b6ab4c6 100644
--- a/drivers/iommu/s390-iommu.c
+++ b/drivers/iommu/s390-iommu.c
@@ -31,6 +31,7 @@ struct s390_domain {
unsigned long *dma_table;
spinlock_t list_lock;
struct rcu_head rcu;
+ u8 origin_type;
};
static struct iommu_domain blocking_domain;
@@ -331,6 +332,7 @@ static bool s390_iommu_capable(struct device *dev, enum iommu_cap cap)
static struct iommu_domain *s390_domain_alloc_paging(struct device *dev)
{
+ struct zpci_dev *zdev = to_zpci_dev(dev);
struct s390_domain *s390_domain;
s390_domain = kzalloc(sizeof(*s390_domain), GFP_KERNEL);
@@ -344,7 +346,8 @@ static struct iommu_domain *s390_domain_alloc_paging(struct device *dev)
}
s390_domain->domain.geometry.force_aperture = true;
s390_domain->domain.geometry.aperture_start = 0;
- s390_domain->domain.geometry.aperture_end = ZPCI_TABLE_SIZE_RT - 1;
+ s390_domain->domain.geometry.aperture_end = zdev->max_table_size;
+ s390_domain->origin_type = zdev->origin_type;
spin_lock_init(&s390_domain->list_lock);
INIT_LIST_HEAD_RCU(&s390_domain->devices);
@@ -450,9 +453,9 @@ static void s390_iommu_get_resv_regions(struct device *dev,
list_add_tail(®ion->list, list);
}
- if (zdev->end_dma < ZPCI_TABLE_SIZE_RT - 1) {
+ if (zdev->end_dma < zdev->max_table_size) {
region = iommu_alloc_resv_region(zdev->end_dma + 1,
- ZPCI_TABLE_SIZE_RT - zdev->end_dma - 1,
+ zdev->max_table_size - zdev->end_dma,
0, IOMMU_RESV_RESERVED, GFP_KERNEL);
if (!region)
return;
@@ -470,11 +473,11 @@ static struct iommu_device *s390_iommu_probe_device(struct device *dev)
zdev = to_zpci_dev(dev);
if (zdev->start_dma > zdev->end_dma ||
- zdev->start_dma > ZPCI_TABLE_SIZE_RT - 1)
+ zdev->start_dma > zdev->max_table_size)
return ERR_PTR(-EINVAL);
- if (zdev->end_dma > ZPCI_TABLE_SIZE_RT - 1)
- zdev->end_dma = ZPCI_TABLE_SIZE_RT - 1;
+ if (zdev->end_dma > zdev->max_table_size)
+ zdev->end_dma = zdev->max_table_size;
if (zdev->tlb_refresh)
dev->iommu->shadow_on_flush = 1;
@@ -732,6 +735,8 @@ int zpci_init_iommu(struct zpci_dev *zdev)
ZPCI_TABLE_SIZE_RT - zdev->start_dma,
zdev->end_dma - zdev->start_dma + 1);
zdev->end_dma = zdev->start_dma + aperture_size - 1;
+ zdev->origin_type = ZPCI_TABLE_TYPE_RTX;
+ zdev->max_table_size = ZPCI_TABLE_SIZE_RT - 1;
return 0;
--
2.48.1
next prev parent reply other threads:[~2025-01-24 20:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 20:18 [PATCH v2 0/6] iommu/s390: support additional table regions Matthew Rosato
2025-01-24 20:18 ` Matthew Rosato [this message]
2025-02-05 15:08 ` [PATCH v2 1/6] iommu/s390: add initial fields to track table size Niklas Schnelle
2025-01-24 20:18 ` [PATCH v2 2/6] s390/pci: set appropriate IOTA region type Matthew Rosato
2025-01-24 20:18 ` [PATCH v2 3/6] iommu/s390: support cleanup of additional table regions Matthew Rosato
2025-01-24 20:18 ` [PATCH v2 4/6] iommu/s390: support iova_to_phys for " Matthew Rosato
2025-01-24 20:18 ` [PATCH v2 5/6] iommu/s390: support map/unmap " Matthew Rosato
2025-01-24 20:18 ` [PATCH v2 6/6] iommu/s390: allow larger region tables 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=20250124201826.348848-2-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