Skip to content

Commit 83c1aec

Browse files
rosatomjjoergroedel
authored andcommitted
iommu/s390: set appropriate IOTA region type
When registering the I/O Translation Anchor, use the current table type stored in the s390_domain to set the appropriate region type indication. For the moment, the table type will always be stored as region third. Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com> Tested-by: Niklas Schnelle <schnelle@linux.ibm.com> Link: https://lore.kernel.org/r/20250411202433.181683-2-mjrosato@linux.ibm.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 8ffd015 commit 83c1aec

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

drivers/iommu/s390-iommu.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct s390_domain {
3131
unsigned long *dma_table;
3232
spinlock_t list_lock;
3333
struct rcu_head rcu;
34+
u8 origin_type;
3435
};
3536

3637
static struct iommu_domain blocking_domain;
@@ -345,6 +346,7 @@ static struct iommu_domain *s390_domain_alloc_paging(struct device *dev)
345346
s390_domain->domain.geometry.force_aperture = true;
346347
s390_domain->domain.geometry.aperture_start = 0;
347348
s390_domain->domain.geometry.aperture_end = ZPCI_TABLE_SIZE_RT - 1;
349+
s390_domain->origin_type = ZPCI_TABLE_TYPE_RTX;
348350

349351
spin_lock_init(&s390_domain->list_lock);
350352
INIT_LIST_HEAD_RCU(&s390_domain->devices);
@@ -381,6 +383,21 @@ static void zdev_s390_domain_update(struct zpci_dev *zdev,
381383
spin_unlock_irqrestore(&zdev->dom_lock, flags);
382384
}
383385

386+
static u64 get_iota_region_flag(struct s390_domain *domain)
387+
{
388+
switch (domain->origin_type) {
389+
case ZPCI_TABLE_TYPE_RTX:
390+
return ZPCI_IOTA_RTTO_FLAG;
391+
case ZPCI_TABLE_TYPE_RSX:
392+
return ZPCI_IOTA_RSTO_FLAG;
393+
case ZPCI_TABLE_TYPE_RFX:
394+
return ZPCI_IOTA_RFTO_FLAG;
395+
default:
396+
WARN_ONCE(1, "Invalid IOMMU table (%x)\n", domain->origin_type);
397+
return 0;
398+
}
399+
}
400+
384401
static int s390_iommu_domain_reg_ioat(struct zpci_dev *zdev,
385402
struct iommu_domain *domain, u8 *status)
386403
{
@@ -399,7 +416,7 @@ static int s390_iommu_domain_reg_ioat(struct zpci_dev *zdev,
399416
default:
400417
s390_domain = to_s390_domain(domain);
401418
iota = virt_to_phys(s390_domain->dma_table) |
402-
ZPCI_IOTA_RTTO_FLAG;
419+
get_iota_region_flag(s390_domain);
403420
rc = zpci_register_ioat(zdev, 0, zdev->start_dma,
404421
zdev->end_dma, iota, status);
405422
}

0 commit comments

Comments
 (0)