[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241209192403.107090-3-mjrosato@linux.ibm.com>
Date: Mon, 9 Dec 2024 14:23:59 -0500
From: Matthew Rosato <mjrosato@...ux.ibm.com>
To: joro@...tes.org, will@...nel.org, robin.murphy@....com,
gerald.schaefer@...ux.ibm.com, schnelle@...ux.ibm.com
Cc: hca@...ux.ibm.com, gor@...ux.ibm.com, agordeev@...ux.ibm.com,
svens@...ux.ibm.com, borntraeger@...ux.ibm.com, farman@...ux.ibm.com,
clegoate@...hat.com, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org
Subject: [PATCH 2/6] s390: enable ARCH_HAS_PHYS_TO_DMA
PCI devices on s390 have a DMA offset that is reported via CLP. In
preparation for allowing identity domains, enable ARCH_HAS_PHYS_TO_DMA
for s390 and get the dma offset for all PCI devices from the reported
CLP value.
Reviewed-by: Niklas Schnelle <schnelle@...ux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@...ux.ibm.com>
---
arch/s390/Kconfig | 1 +
arch/s390/include/asm/device.h | 12 ++++++++++++
arch/s390/include/asm/dma-direct.h | 14 ++++++++++++++
arch/s390/pci/pci_bus.c | 2 ++
4 files changed, 29 insertions(+)
create mode 100644 arch/s390/include/asm/device.h
create mode 100644 arch/s390/include/asm/dma-direct.h
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 0077969170e8..5746d8abc8a7 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -83,6 +83,7 @@ config S390
select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_GCOV_PROFILE_ALL
select ARCH_HAS_GIGANTIC_PAGE
+ select ARCH_HAS_PHYS_TO_DMA
select ARCH_HAS_KCOV
select ARCH_HAS_MEMBARRIER_SYNC_CORE
select ARCH_HAS_MEM_ENCRYPT
diff --git a/arch/s390/include/asm/device.h b/arch/s390/include/asm/device.h
new file mode 100644
index 000000000000..a6bf5e137a17
--- /dev/null
+++ b/arch/s390/include/asm/device.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_S390_DEVICE_H
+#define _ASM_S390_DEVICE_H
+
+struct dev_archdata {
+ dma_addr_t dma_offset;
+};
+
+struct pdev_archdata {
+};
+
+#endif /* _ASM_S390_DEVICE_H */
diff --git a/arch/s390/include/asm/dma-direct.h b/arch/s390/include/asm/dma-direct.h
new file mode 100644
index 000000000000..9391820fca2c
--- /dev/null
+++ b/arch/s390/include/asm/dma-direct.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef ASM_S390_DMA_DIRECT_H
+#define ASM_S390_DMA_DIRECT_H 1
+
+static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+ return paddr + dev->archdata.dma_offset;
+}
+
+static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
+{
+ return daddr - dev->archdata.dma_offset;
+}
+#endif /* ASM_S390_DMA_DIRECT_H */
diff --git a/arch/s390/pci/pci_bus.c b/arch/s390/pci/pci_bus.c
index d5ace00d10f0..ec874ba858c6 100644
--- a/arch/s390/pci/pci_bus.c
+++ b/arch/s390/pci/pci_bus.c
@@ -288,6 +288,8 @@ void pcibios_bus_add_device(struct pci_dev *pdev)
{
struct zpci_dev *zdev = to_zpci(pdev);
+ pdev->dev.archdata.dma_offset = zdev->start_dma;
+
/*
* With pdev->no_vf_scan the common PCI probing code does not
* perform PF/VF linking.
--
2.47.0
Powered by blists - more mailing lists