Merge tag 'dma-mapping-5.3-1' of git://git.infradead.org/users/hch/dma-mapping
[sfrench/cifs-2.6.git] / arch / s390 / mm / init.c
index f0bee6af39601717f9fce160d800643ddb4cf941..20340a03ad90c5d7c21d4dbb1588db30abc1c129 100644 (file)
@@ -30,7 +30,7 @@
 #include <linux/export.h>
 #include <linux/cma.h>
 #include <linux/gfp.h>
-#include <linux/dma-mapping.h>
+#include <linux/dma-direct.h>
 #include <asm/processor.h>
 #include <linux/uaccess.h>
 #include <asm/pgtable.h>
@@ -161,6 +161,11 @@ bool sev_active(void)
        return is_prot_virt_guest();
 }
 
+bool force_dma_unencrypted(struct device *dev)
+{
+       return sev_active();
+}
+
 /* protected virtualization */
 static void pv_init(void)
 {
@@ -273,6 +278,9 @@ int arch_add_memory(int nid, u64 start, u64 size,
        unsigned long size_pages = PFN_DOWN(size);
        int rc;
 
+       if (WARN_ON_ONCE(restrictions->altmap))
+               return -EINVAL;
+
        rc = vmem_add_mapping(start, size);
        if (rc)
                return rc;
@@ -283,16 +291,15 @@ int arch_add_memory(int nid, u64 start, u64 size,
        return rc;
 }
 
-#ifdef CONFIG_MEMORY_HOTREMOVE
 void arch_remove_memory(int nid, u64 start, u64 size,
                        struct vmem_altmap *altmap)
 {
-       /*
-        * There is no hardware or firmware interface which could trigger a
-        * hot memory remove on s390. So there is nothing that needs to be
-        * implemented.
-        */
-       BUG();
+       unsigned long start_pfn = start >> PAGE_SHIFT;
+       unsigned long nr_pages = size >> PAGE_SHIFT;
+       struct zone *zone;
+
+       zone = page_zone(pfn_to_page(start_pfn));
+       __remove_pages(zone, start_pfn, nr_pages, altmap);
+       vmem_remove_mapping(start, size);
 }
-#endif
 #endif /* CONFIG_MEMORY_HOTPLUG */