Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[linux-2.6-microblaze.git] / kernel / resource.c
index b0fbf68..915c02e 100644 (file)
@@ -1256,6 +1256,21 @@ int release_mem_region_adjustable(struct resource *parent,
                        continue;
                }
 
+               /*
+                * All memory regions added from memory-hotplug path have the
+                * flag IORESOURCE_SYSTEM_RAM. If the resource does not have
+                * this flag, we know that we are dealing with a resource coming
+                * from HMM/devm. HMM/devm use another mechanism to add/release
+                * a resource. This goes via devm_request_mem_region and
+                * devm_release_mem_region.
+                * HMM/devm take care to release their resources when they want,
+                * so if we are dealing with them, let us just back off here.
+                */
+               if (!(res->flags & IORESOURCE_SYSRAM)) {
+                       ret = 0;
+                       break;
+               }
+
                if (!(res->flags & IORESOURCE_MEM))
                        break;