static bool lmb_is_removable(struct of_drconf_cell *lmb) { int i, scns_per_block; int rc = 1; unsigned long pfn, block_sz; u64 phys_addr; if (!(lmb->flags & DRCONF_MEM_ASSIGNED)) return false; block_sz = memory_block_size_bytes(); scns_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE; phys_addr = lmb->base_addr; for (i = 0; i < scns_per_block; i++) { pfn = PFN_DOWN(phys_addr); if (!pfn_present(pfn)) continue; rc &= is_mem_section_removable(pfn, PAGES_PER_SECTION); phys_addr += MIN_MEMORY_BLOCK_SIZE; } return rc ? true : false; }
/* * Show whether the section of memory is likely to be hot-removable */ static ssize_t show_mem_removable(struct sys_device *dev, struct sysdev_attribute *attr, char *buf) { unsigned long start_pfn; int ret; struct memory_block *mem = container_of(dev, struct memory_block, sysdev); start_pfn = section_nr_to_pfn(mem->phys_index); ret = is_mem_section_removable(start_pfn, PAGES_PER_SECTION); return sprintf(buf, "%d\n", ret); }
/* * Show whether the section of memory is likely to be hot-removable */ static ssize_t show_mem_removable(struct sys_device *dev, struct sysdev_attribute *attr, char *buf) { unsigned long i, pfn; int ret = 1; struct memory_block *mem = container_of(dev, struct memory_block, sysdev); for (i = 0; i < sections_per_block; i++) { pfn = section_nr_to_pfn(mem->start_section_nr + i); ret &= is_mem_section_removable(pfn, PAGES_PER_SECTION); } return sprintf(buf, "%d\n", ret); }
/* * Show whether the section of memory is likely to be hot-removable */ static ssize_t show_mem_removable(struct device *dev, struct device_attribute *attr, char *buf) { unsigned long i, pfn; int ret = 1; struct memory_block *mem = to_memory_block(dev); for (i = 0; i < sections_per_block; i++) { if (!present_section_nr(mem->start_section_nr + i)) continue; pfn = section_nr_to_pfn(mem->start_section_nr + i); ret &= is_mem_section_removable(pfn, PAGES_PER_SECTION); } return sprintf(buf, "%d\n", ret); }