Blob Blame History Raw
From: Pierre Morel <pmorel@linux.ibm.com>
Date: Fri, 21 Feb 2020 17:20:46 +0100
Subject: s390/pci: adaptation of iommu to multifunction
Git-commit: d08d6f5d75242ceb410efbdf650efecc40d68c2d
Patch-mainline: v5.8-rc1
References: bsc#1179612

In the future the bus sysdata may not directly point to the
zpci_dev.

In preparation of upcoming patches let us abstract the
access to the zpci_dev from the device inside the pci device.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Acked-by: Joerg Roedel <jroedel@suse.de>
---
 arch/s390/include/asm/pci.h |    5 +++++
 drivers/iommu/s390-iommu.c  |    6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -217,6 +217,11 @@ static inline struct zpci_dev *to_zpci(s
 	return pdev->sysdata;
 }
 
+static inline struct zpci_dev *to_zpci_dev(struct device *dev)
+{
+	return to_zpci(to_pci_dev(dev));
+}
+
 struct zpci_dev *get_zdev_by_fid(u32);
 
 /* DMA */
--- a/drivers/iommu/s390-iommu.c
+++ b/drivers/iommu/s390-iommu.c
@@ -84,7 +84,7 @@ static int s390_iommu_attach_device(stru
 				    struct device *dev)
 {
 	struct s390_domain *s390_domain = to_s390_domain(domain);
-	struct zpci_dev *zdev = to_pci_dev(dev)->sysdata;
+	struct zpci_dev *zdev = to_zpci_dev(dev);
 	struct s390_domain_device *domain_device;
 	unsigned long flags;
 	int rc;
@@ -136,7 +136,7 @@ static void s390_iommu_detach_device(str
 				     struct device *dev)
 {
 	struct s390_domain *s390_domain = to_s390_domain(domain);
-	struct zpci_dev *zdev = to_pci_dev(dev)->sysdata;
+	struct zpci_dev *zdev = to_zpci_dev(dev);
 	struct s390_domain_device *domain_device, *tmp;
 	unsigned long flags;
 	int found = 0;
@@ -183,7 +183,7 @@ static int s390_iommu_add_device(struct
 
 static void s390_iommu_remove_device(struct device *dev)
 {
-	struct zpci_dev *zdev = to_pci_dev(dev)->sysdata;
+	struct zpci_dev *zdev = to_zpci_dev(dev);
 	struct iommu_domain *domain;
 
 	/*