@@ -15,6 +15,10 @@ extern void __iomem *pci_iomap_wc(struct pci_dev *dev, int bar, unsigned long ma
extern void __iomem *pci_iomap_range(struct pci_dev *dev, int bar,
unsigned long offset,
unsigned long maxlen);
+extern void __iomem *pci_iomap_range_encrypted(struct pci_dev *dev,
+ int bar,
+ unsigned long offset,
+ unsigned long maxlen);
extern void __iomem *pci_iomap_wc_range(struct pci_dev *dev, int bar,
unsigned long offset,
unsigned long maxlen);
@@ -52,6 +52,30 @@ void __iomem *pci_iomap_range(struct pci_dev *dev,
}
EXPORT_SYMBOL(pci_iomap_range);
+void __iomem *pci_iomap_range_encrypted(struct pci_dev *dev,
+ int bar,
+ unsigned long offset,
+ unsigned long maxlen)
+{
+ resource_size_t start = pci_resource_start(dev, bar);
+ resource_size_t len = pci_resource_len(dev, bar);
+ unsigned long flags = pci_resource_flags(dev, bar);
+
+ if (len <= offset || !start)
+ return NULL;
+ len -= offset;
+ start += offset;
+ if (maxlen && len > maxlen)
+ len = maxlen;
+ if (flags & IORESOURCE_IO)
+ return NULL;
+ if (flags & IORESOURCE_MEM)
+ return ioremap_encrypted(start, len);
+ /* What? */
+ return NULL;
+}
+EXPORT_SYMBOL(pci_iomap_range_encrypted);
+
/**
* pci_iomap_wc_range - create a virtual WC mapping cookie for a PCI BAR
* @dev: PCI device that owns the BAR
So far PCI BARs could not be mapped as encrypted so there was no need in API supporting encrypted mappings. TDISP is adding such support so add pci_iomap_range_encrypted() to allow PCI drivers do the encrypted mapping when needed. Signed-off-by: Alexey Kardashevskiy <aik@amd.com> --- include/asm-generic/pci_iomap.h | 4 ++++ drivers/pci/iomap.c | 24 ++++++++++++++++++++ 2 files changed, 28 insertions(+)