resource: Add System RAM resource type
Subsystems (24)
PATCH v3 1/17 resource: Add System RAM resource type
I/O resource type, IORESOURCE_MEM, is used for all types of memory-mapped ranges, ex. System RAM, System ROM, Video RAM, Persistent Memory, PCI Bus, PCI MMCONFIG, ACPI Tables, IOAPIC, reserved, and so on. This requires walk_system_ram_range(), walk_system_ram_res(), and region_intersects() to use strcmp() against string "System RAM" to search for System RAM ranges in the iomem table, which is inefficient. __ioremap_caller() and reserve_memtype() on x86, for instance, call walk_system_ram_range() for every request to check if a given range is in System RAM ranges.
However, adding a new I/O resource type for System RAM is not a viable option [1]. There are approx. 3800 references to IORESOURCE_MEM in the kernel/drivers, which make it very difficult to distinguish their usages between new type and IORESOURCE_MEM. The I/O resource types are also used by the PNP subsystem. Therefore, this patch introduces an extended I/O resource type, IORESOURCE_SYSTEM_RAM, which consists of IORESOURCE_MEM and a new modifier flag IORESOURCE_SYSRAM [2].
To keep the code 'if (resource_type(r) == IORESOURCE_MEM)' to work continuously for System RAM, resource_ext_type() is added for extracting extended type bits.
Link[1]: http://lkml.kernel.org/r/<[email protected]>
Link[2]: http://lkml.kernel.org/r/<CA+55aFy4WQrWexC4u2LxX9Mw2NVoznw7p3Yh=iF4Xtf7zKWnRw@mail.gmail.com>
--- include/linux/ioport.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/ioport.h +11 -0
@@ -49,12 +49,19 @@ struct resource {#define IORESOURCE_WINDOW 0x00200000/* forwarded by bridge */ #define IORESOURCE_MUXED 0x00400000/* Resource is software muxed */ +#define IORESOURCE_EXT_TYPE_BITS 0x01000000/* Resource extended types */ +#define IORESOURCE_SYSRAM 0x01000000/* System RAM (modifier) */ +#define IORESOURCE_EXCLUSIVE 0x08000000/* Userland may not map this resource */ +#define IORESOURCE_DISABLED 0x10000000#define IORESOURCE_UNSET 0x20000000/* No address assigned yet */ #define IORESOURCE_AUTO 0x40000000#define IORESOURCE_BUSY 0x80000000/* Driver has marked this resource busy */ +/* I/O resource extended types */ +#define IORESOURCE_SYSTEM_RAM (IORESOURCE_MEM|IORESOURCE_SYSRAM) +/* PnP IRQ specific bits (IORESOURCE_BITS) */ #define IORESOURCE_IRQ_HIGHEDGE (1<<0)#define IORESOURCE_IRQ_LOWEDGE (1<<1)
@@ -170,6 +177,10 @@ static inline unsigned long resource_type(const struct resource *res) {return res->flags &IORESOURCE_TYPE_BITS ; } +static inline unsigned long resource_ext_type (const struct resource *res) +{ +return res->flags &IORESOURCE_EXT_TYPE_BITS ; +}/* True iff r1 completely contains r2 */ static inline bool resource_contains (struct resource *r1,struct resource *r2) {
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 2/17 resource: make resource flags handled properly
I/O resource flags consist of I/O resource types and modifier bits. Therefore, checking an I/O resource type in 'flags' must be performed with a bitwise operation.
Fix find_next_iomem_res() and region_intersects() that simply compare 'flags' against a given value.
Also change __request_region() to set 'res->flags' from resource_type() and resource_ext_type() of the parent, so that children nodes will inherit the extended I/O resource type.
--- kernel/resource.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/resource.c +4 -3
@@ -358,7 +358,7 @@ static int find_next_iomem_res(struct resource *res, char *name,read_lock (&resource_lock);for (p = iomem_resource.child; p; p =next_resource (p, sibling_only)) { -if (p->flags != res->flags) +if ((p->flags & res->flags) != res->flags)continue ;if (name &&strcmp (p->name, name))continue ;
@@ -519,7 +519,8 @@ int region_intersects(resource_size_t start, size_t size, const char *name)read_lock (&resource_lock);for (p = iomem_resource.child; p ; p = p->sibling) { -bool is_type =strcmp (p->name, name) ==0 && p->flags == flags; +bool is_type =strcmp (p->name, name) ==0 && + ((p->flags & flags) == flags);if (start >= p->start && start <= p->end) is_type ? type++ : other++;
@@ -1071,7 +1072,7 @@ struct resource * __request_region(struct resource *parent, res->name = name; res->start = start; res->end = start + n -1 ; - res->flags =resource_type (parent); + res->flags =resource_type (parent) |resource_ext_type (parent); res->flags |=IORESOURCE_BUSY | flags;write_lock (&resource_lock);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 3/17 resource: Add I/O resource descriptor
In reply to Toshi Kaniwalk_iomem_res() and region_intersects() still need to use strcmp() for searching a resource entry by @name in the iomem table.
This patch introduces I/O resource descriptor, 'desc' in struct resoruce, for the iomem search interfaces. Drivers can assign their unique descritor to a range when they support the search interfaces. Otherwise, 'desc' is set to IORES_DESC_NONE (0). This avoids changing most of the drivers as they typically allocate resource entries statically, or by calling alloc_resource(), kzalloc(), or alloc_bootmem_low(), which set the field to zero by default. A later patch will address some drivers that use kmalloc() without zero'ing the field.
Also change release_mem_region_adjustable() to set 'desc' when its resource entry gets separated. Other resource interfaces are also changed to initialize 'desc' explicitly although alloc_resource() sets it to 0.
--- include/linux/ioport.h | 18 ++++++++++++++++++ kernel/resource.c | 5 +++++ 2 files changed, 23 insertions(+)
include/linux/ioport.h +18 -0
@@ -20,6 +20,7 @@ struct resource {resource_size_t end;const char *name;unsigned long flags; +unsigned long desc;struct resource *parent, *sibling, *child; };
@@ -112,6 +113,22 @@ struct resource {/* PCI control bits. Shares IORESOURCE_BITS with above PCI ROM. */ #define IORESOURCE_PCI_FIXED (1<<4)/* Do not move resource */ +/* +* I/O Resource Descriptors +* +* Descriptors are used by walk_iomem_res_desc() and region_intersects() +* for searching a specific resource range in the iomem table. Assign +* a new descriptor when a resource range supports the search interfaces. +* Otherwise, resource.desc must be set to IORES_DESC_NONE (0). +*/ +enum { +IORES_DESC_NONE =0 , +IORES_DESC_CRASH_KERNEL =1 , +IORES_DESC_ACPI_TABLES =2 , +IORES_DESC_ACPI_NV_STORAGE =3 , +IORES_DESC_PERSISTENT_MEMORY =4 , +IORES_DESC_PERSISTENT_MEMORY_LEGACY =5 , +};/* helpers to define resources */ #define DEFINE_RES_NAMED (_start, _size, _name, _flags) \
@@ -120,6 +137,7 @@ struct resource { .end = (_start) + (_size) - 1, \ .name = (_name), \ .flags = (_flags), \ + .desc = IORES_DESC_NONE, \ }#define DEFINE_RES_IO_NAMED (_start, _size, _name) \
kernel/resource.c +5 -0
@@ -949,6 +949,7 @@ static void __init __reserve_region_with_split(struct resource *root, res->start = start; res->end = end; res->flags =IORESOURCE_BUSY ; + res->desc =IORES_DESC_NONE ;while (1 ) {
@@ -983,6 +984,7 @@ static void __init __reserve_region_with_split(struct resource *root, next_res->start = conflict->end +1 ; next_res->end = end; next_res->flags =IORESOURCE_BUSY ; + next_res->desc =IORES_DESC_NONE ; } }else { res->start = conflict->end +1 ;
@@ -1074,6 +1076,7 @@ struct resource * __request_region(struct resource *parent, res->end = start + n -1 ; res->flags =resource_type (parent) |resource_ext_type (parent); res->flags |=IORESOURCE_BUSY | flags; + res->desc =IORES_DESC_NONE ;write_lock (&resource_lock);
@@ -1238,6 +1241,7 @@ int release_mem_region_adjustable(struct resource *parent, new_res->start = end +1 ; new_res->end = res->end; new_res->flags = res->flags; + new_res->desc = res->desc; new_res->parent = res->parent; new_res->sibling = res->sibling; new_res->child =NULL ;
@@ -1413,6 +1417,7 @@ static int __init reserve_setup(char *str) res->start = io_start; res->end = io_start + io_num -1 ; res->flags =IORESOURCE_BUSY ; + res->desc =IORES_DESC_NONE ; res->child =NULL ;if (request_resource (res->start >=0x10000 ? &iomem_resource : &ioport_resource, res) ==0 ) reserved = x+1 ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 4/17 x86/e820: Set System RAM type and descriptor
In reply to Toshi KaniChange e820_reserve_resources() to set 'flags' and 'desc' from e820 types.
IORESOURCE_SYSTEM_RAM is set to 'flags' for System RAM, which are E820_RESERVED_KERN and E820_RAM. IORESOURCE_SYSTEM_RAM is also set to "Kernel data", "Kernel code", and "Kernel bss", which are child nodes of System RAM.
I/O resource descriptor is set to 'desc' for entries that are (and will be) target ranges of walk_iomem_res() and region_intersects().
--- arch/x86/kernel/e820.c | 38 +++++++++++++++++++++++++++++++++++++- arch/x86/kernel/setup.c | 6 +++--- 2 files changed, 40 insertions(+), 4 deletions(-)
arch/x86/kernel/e820.c +37 -1
@@ -925,6 +925,41 @@ static const char *e820_type_to_string(int e820_type) } } +static unsigned long e820_type_to_iomem_type (int e820_type) +{ +switch (e820_type) { +case E820_RESERVED_KERN : +case E820_RAM : +return IORESOURCE_SYSTEM_RAM ; +case E820_ACPI : +case E820_NVS : +case E820_UNUSABLE : +case E820_PRAM : +case E820_PMEM : +default : +return IORESOURCE_MEM ; + } +} + +static unsigned long e820_type_to_iores_desc (int e820_type) +{ +switch (e820_type) { +case E820_ACPI : +return IORES_DESC_ACPI_TABLES ; +case E820_NVS : +return IORES_DESC_ACPI_NV_STORAGE ; +case E820_PMEM : +return IORES_DESC_PERSISTENT_MEMORY ; +case E820_PRAM : +return IORES_DESC_PERSISTENT_MEMORY_LEGACY ; +case E820_RESERVED_KERN : +case E820_RAM : +case E820_UNUSABLE : +default : +return IORES_DESC_NONE ; + } +} +static bool do_mark_busy (u32 type,struct resource *res) {/* this is the legacy bios/dos rom-shadow + mmio region */
@@ -967,7 +1002,8 @@ void __init e820_reserve_resources(void) res->start = e820.map[i].addr; res->end = end; - res->flags =IORESOURCE_MEM ; + res->flags =e820_type_to_iomem_type (e820.map[i].type); + res->desc =e820_type_to_iores_desc (e820.map[i].type);/* * don't register the region that could be conflicted with
arch/x86/kernel/setup.c +3 -3
@@ -152,21 +152,21 @@ static struct resource data_resource = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM };static struct resource code_resource = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource bss_resource = { .name ="Kernel bss" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 5/17 ia64: Set System RAM type and descriptor
In reply to Toshi KaniChange efi_initialize_iomem_resources() to set 'flags' and 'desc' from EFI memory types. IORESOURCE_SYSRAM, a modifier bit, is set to 'flags' for System RAM as IORESOURCE_MEM is already set. IORESOURCE_SYSTEM_RAM is defined as (IORESOURCE_MEM|IORESOURCE_SYSRAM). I/O resource descritor is set to 'desc' for "ACPI Non-volatile Storage" and "Persistent Memory".
Also set IORESOURCE_SYSTEM_RAM to 'flags' for "Kernel code", "Kernel data", and "Kernel bss".
--- arch/ia64/kernel/efi.c | 13 ++++++++++--- arch/ia64/kernel/setup.c | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-)
arch/ia64/kernel/efi.c +10 -3
@@ -1178,7 +1178,7 @@ efi_initialize_iomem_resources(struct resource *code_resource,efi_memory_desc_t *md;u64 efi_desc_size;char *name; -unsigned long flags; +unsigned long flags, desc; efi_map_start =__va (ia64_boot_param->efi_memmap); efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
@@ -1193,6 +1193,8 @@ efi_initialize_iomem_resources(struct resource *code_resource,continue ; flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + desc =IORES_DESC_NONE ; +switch (md->type) {case EFI_MEMORY_MAPPED_IO :
@@ -1207,14 +1209,17 @@ efi_initialize_iomem_resources(struct resource *code_resource,if (md->attribute &EFI_MEMORY_WP ) { name ="System ROM" ; flags |=IORESOURCE_READONLY ; - }else if (md->attribute ==EFI_MEMORY_UC ) + }else if (md->attribute ==EFI_MEMORY_UC ) { name ="Uncached RAM" ; -else + }else { name ="System RAM" ; + flags |=IORESOURCE_SYSRAM ; + }break ;case EFI_ACPI_MEMORY_NVS : name ="ACPI Non-volatile Storage" ; + desc =IORES_DESC_ACPI_NV_STORAGE ;break ;case EFI_UNUSABLE_MEMORY :
@@ -1224,6 +1229,7 @@ efi_initialize_iomem_resources(struct resource *code_resource,case EFI_PERSISTENT_MEMORY : name ="Persistent Memory" ; + desc =IORES_DESC_PERSISTENT_MEMORY ;break ;case EFI_RESERVED_TYPE :
@@ -1246,6 +1252,7 @@ efi_initialize_iomem_resources(struct resource *code_resource, res->start = md->phys_addr; res->end = md->phys_addr +efi_md_size (md) -1 ; res->flags = flags; + res->desc = desc;if (insert_resource (&iomem_resource, res) <0 )kfree (res);
arch/ia64/kernel/setup.c +3 -3
@@ -80,17 +80,17 @@ unsigned long vga_console_membase;static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };unsigned long ia64_max_cacheline_size;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 05/17] ia64: Set System RAM type and descriptor
Quoted 10 lines · Toshi Kani
Change
efi_initialize_iomem_resources()to set 'flags' and 'desc' from EFI memory types.IORESOURCE_SYSRAM, a modifier bit, is set to 'flags' for System RAM asIORESOURCE_MEMis already set.IORESOURCE_SYSTEM_RAMis defined as (IORESOURCE_MEM|IORESOURCE_SYSRAM). I/O resource descritor is set to 'desc' for "ACPI Non-volatile Storage" and "Persistent Memory".Also set
IORESOURCE_SYSTEM_RAMto 'flags' for "Kernel code", "Kernel data", and "Kernel bss".
PATCH v3 6/17 arch: Set IORESOURCE_SYSTEM_RAM to System RAM
In reply to Toshi KaniSet IORESOURCE_SYSTEM_RAM to 'flags' of resource ranges with "System RAM", "Kernel code", "Kernel data", and "Kernel bss".
Note that:
- IORESOURCE_SYSRAM (i.e. modifier bit) is set to 'flags' when IORESOURCE_MEM is already set. IORESOURCE_SYSTEM_RAM is defined as (IORESOURCE_MEM|IORESOURCE_SYSRAM).
- Some archs do not set 'flags' for children nodes, such as "Kernel code". This patch does not change 'flags' in this case.
--- arch/arm/kernel/setup.c | 6 +++--- arch/arm64/kernel/setup.c | 6 +++--- arch/avr32/kernel/setup.c | 6 +++--- arch/m32r/kernel/setup.c | 4 ++-- arch/mips/kernel/setup.c | 10 ++++++---- arch/parisc/mm/init.c | 6 +++--- arch/powerpc/mm/mem.c | 2 +- arch/s390/kernel/setup.c | 8 ++++---- arch/score/kernel/setup.c | 2 +- arch/sh/kernel/setup.c | 8 ++++---- arch/sparc/mm/init_64.c | 8 ++++---- arch/tile/kernel/setup.c | 11 ++++++++--- arch/unicore32/kernel/setup.c | 6 +++--- 13 files changed, 45 insertions(+), 38 deletions(-)
arch/arm/kernel/setup.c +3 -3
@@ -173,13 +173,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } };
@@ -781,7 +781,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) res->name ="System RAM" ; res->start =__pfn_to_phys (memblock_region_memory_base_pfn (region)); res->end =__pfn_to_phys (memblock_region_memory_end_pfn (region)) -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);
arch/arm64/kernel/setup.c +3 -3
@@ -73,13 +73,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } };
@@ -210,7 +210,7 @@ static void __init request_standard_resources(void) res->name ="System RAM" ; res->start =__pfn_to_phys (memblock_region_memory_base_pfn (region)); res->end =__pfn_to_phys (memblock_region_memory_end_pfn (region)) -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);
arch/avr32/kernel/setup.c +3 -3
@@ -49,13 +49,13 @@ static struct resource __initdata kernel_data = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM, + .flags = IORESOURCE_SYSTEM_RAM, };static struct resource __initdata kernel_code = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_MEM , + .flags =IORESOURCE_SYSTEM_RAM , .sibling = &kernel_data, };
@@ -134,7 +134,7 @@ add_physical_memory(resource_size_t start, resource_size_t end) new->start = start; new->end = end; new->name ="System RAM" ; - new->flags =IORESOURCE_MEM ; + new->flags =IORESOURCE_SYSTEM_RAM ; *pprev = new; }
arch/m32r/kernel/setup.c +2 -2
@@ -70,14 +70,14 @@ static struct resource data_resource = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM };static struct resource code_resource = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };unsigned long memory_start;
arch/mips/kernel/setup.c +6 -4
@@ -732,21 +732,23 @@ static void __init resource_init(void) end =HIGHMEM_START -1 ; res =alloc_bootmem (sizeof (struct resource )); + + res->start = start; + res->end = end; + res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; +switch (boot_mem_map.map[i].type) {case BOOT_MEM_RAM :case BOOT_MEM_INIT_RAM :case BOOT_MEM_ROM_DATA : res->name ="System RAM" ; + res->flags |=IORESOURCE_SYSRAM ;break ;case BOOT_MEM_RESERVED :default : res->name ="reserved" ; } - res->start = start; - res->end = end; - - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);/*
arch/parisc/mm/init.c +3 -3
@@ -55,12 +55,12 @@ signed char pfnnid_map[PFNNID_MAP_MAX] __read_mostly;static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource pdcdata_resource = {
@@ -201,7 +201,7 @@ static void __init setup_bootmem(void) res->name ="System RAM" ; res->start = pmem_ranges[i].start_pfn <<PAGE_SHIFT ; res->end = res->start + (pmem_ranges[i].pages <<PAGE_SHIFT )-1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res); }
arch/powerpc/mm/mem.c +1 -1
@@ -541,7 +541,7 @@ static int __init add_system_ram_resources(void) res->name ="System RAM" ; res->start = base; res->end = base + size -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;WARN_ON (request_resource (&iomem_resource, res) <0 ); } }
arch/s390/kernel/setup.c +4 -4
@@ -376,17 +376,17 @@ static void __init setup_lowcore(void)static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource __initdata *standard_resources[] = {
@@ -410,7 +410,7 @@ static void __init setup_resources(void)for_each_memblock (memory, reg) { res =alloc_bootmem_low (sizeof (*res)); - res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; + res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ; res->name ="System RAM" ; res->start = reg->base;
arch/score/kernel/setup.c +1 -1
@@ -101,7 +101,7 @@ static void __init resource_init(void) res->name ="System RAM" ; res->start =MEMORY_START ; res->end =MEMORY_START +MEMORY_SIZE -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);request_resource (res, &code_resource);
arch/sh/kernel/setup.c +4 -4
@@ -78,17 +78,17 @@ static char __initdata command_line[COMMAND_LINE_SIZE] = { 0, };static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };unsigned long memory_start;
@@ -202,7 +202,7 @@ void __init __add_active_range(unsigned int nid, unsigned long start_pfn, res->name ="System RAM" ; res->start = start; res->end = end -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;if (request_resource (&iomem_resource, res)) { pr_err("unable to request memory_resource 0x%lx 0x%lx\n",
arch/sparc/mm/init_64.c +4 -4
@@ -2862,17 +2862,17 @@ void hugetlb_setup(struct pt_regs *regs)static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static inline resource_size_t compute_kern_paddr (void *addr)
@@ -2908,7 +2908,7 @@ static int __init report_memory(void) res->name ="System RAM" ; res->start = pavail[i].phys_addr; res->end = pavail[i].phys_addr + pavail[i].reg_size -1 ; - res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; + res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ;if (insert_resource (&iomem_resource, res) <0 ) {pr_warn ("Resource insertion failed.\n" );
arch/tile/kernel/setup.c +8 -3
@@ -1632,14 +1632,14 @@ static struct resource data_resource = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM };static struct resource code_resource = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };/*
@@ -1673,10 +1673,15 @@ insert_ram_resource(u64 start_pfn, u64 end_pfn, bool reserved)kzalloc (sizeof (struct resource ),GFP_ATOMIC );if (!res)return NULL ; - res->name = reserved ?"Reserved" :"System RAM" ; res->start = start_pfn <<PAGE_SHIFT ; res->end = (end_pfn <<PAGE_SHIFT ) -1 ; res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; +if (reserved) { + res->name ="Reserved" ; + }else { + res->name ="System RAM" ; + res->flags |=IORESOURCE_SYSRAM ; + }if (insert_resource (&iomem_resource, res)) {kfree (res);return NULL ;
arch/unicore32/kernel/setup.c +3 -3
@@ -72,13 +72,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } };
@@ -211,7 +211,7 @@ request_standard_resources(struct meminfo *mi) res->name ="System RAM" ; res->start = mi->bank[i].start; res->end = mi->bank[i].start + mi->bank[i].size -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Borislav Petkov
maintainerRe: [PATCH v3 06/17] arch: Set IORESOURCE_SYSTEM_RAM to System RAM
Adding the respective arch MLs to CC, as an FYI.
Quoted 393 lines · Toshi Kani
Set
IORESOURCE_SYSTEM_RAMto 'flags' of resource ranges with "System RAM", "Kernel code", "Kernel data", and "Kernel bss".Note that:
-IORESOURCE_SYSRAM(i.e. modifier bit) is set to 'flags' whenIORESOURCE_MEMis already set.IORESOURCE_SYSTEM_RAMis defined as (IORESOURCE_MEM|IORESOURCE_SYSRAM).
- Some archs do not set 'flags' for children nodes, such as "Kernel code". This patch does not change 'flags' in this case.Signed-off-by Toshi Kani <[email protected]>--- arch/arm/kernel/setup.c | 6 +++--- arch/arm64/kernel/setup.c | 6 +++--- arch/avr32/kernel/setup.c | 6 +++--- arch/m32r/kernel/setup.c | 4 ++-- arch/mips/kernel/setup.c | 10 ++++++---- arch/parisc/mm/init.c | 6 +++--- arch/powerpc/mm/mem.c | 2 +- arch/s390/kernel/setup.c | 8 ++++---- arch/score/kernel/setup.c | 2 +- arch/sh/kernel/setup.c | 8 ++++---- arch/sparc/mm/init_64.c | 8 ++++---- arch/tile/kernel/setup.c | 11 ++++++++--- arch/unicore32/kernel/setup.c | 6 +++--- 13 files changed, 45 insertions(+), 38 deletions(-)arch/arm/kernel/setup.c +3
-3@@ -173,13 +173,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } };@@ -781,7 +781,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) res->name ="System RAM" ; res->start =__pfn_to_phys (memblock_region_memory_base_pfn (region)); res->end =__pfn_to_phys (memblock_region_memory_end_pfn (region)) -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);arch/arm64/kernel/setup.c +3
-3@@ -73,13 +73,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } };@@ -210,7 +210,7 @@ static void __init request_standard_resources(void) res->name ="System RAM" ; res->start =__pfn_to_phys (memblock_region_memory_base_pfn (region)); res->end =__pfn_to_phys (memblock_region_memory_end_pfn (region)) -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);arch/avr32/kernel/setup.c +3
-3@@ -49,13 +49,13 @@ static struct resource __initdata kernel_data = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM, + .flags = IORESOURCE_SYSTEM_RAM, };static struct resource __initdata kernel_code = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_MEM , + .flags =IORESOURCE_SYSTEM_RAM , .sibling = &kernel_data, };@@ -134,7 +134,7 @@ add_physical_memory(resource_size_t start, resource_size_t end) new->start = start; new->end = end; new->name ="System RAM" ; - new->flags =IORESOURCE_MEM ; + new->flags =IORESOURCE_SYSTEM_RAM ; *pprev = new; }arch/m32r/kernel/setup.c +2
-2@@ -70,14 +70,14 @@ static struct resource data_resource = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM };static struct resource code_resource = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };unsigned long memory_start;arch/mips/kernel/setup.c +6
-4@@ -732,21 +732,23 @@ static void __init resource_init(void) end =HIGHMEM_START -1 ; res =alloc_bootmem (sizeof (struct resource )); + + res->start = start; + res->end = end; + res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; +switch (boot_mem_map.map[i].type) {case BOOT_MEM_RAM :case BOOT_MEM_INIT_RAM :case BOOT_MEM_ROM_DATA : res->name ="System RAM" ; + res->flags |=IORESOURCE_SYSRAM ;break ;case BOOT_MEM_RESERVED :default : res->name ="reserved" ; } - res->start = start; - res->end = end; - - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);/* arch/parisc/mm/init.c +3
-3@@ -55,12 +55,12 @@ signed char pfnnid_map[PFNNID_MAP_MAX] __read_mostly;static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource pdcdata_resource = {@@ -201,7 +201,7 @@ static void __init setup_bootmem(void) res->name ="System RAM" ; res->start = pmem_ranges[i].start_pfn <<PAGE_SHIFT ; res->end = res->start + (pmem_ranges[i].pages <<PAGE_SHIFT )-1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res); }arch/powerpc/mm/mem.c +1
-1@@ -541,7 +541,7 @@ static int __init add_system_ram_resources(void) res->name ="System RAM" ; res->start = base; res->end = base + size -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;WARN_ON (request_resource (&iomem_resource, res) <0 ); } }arch/s390/kernel/setup.c +4
-4@@ -376,17 +376,17 @@ static void __init setup_lowcore(void)static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource __initdata *standard_resources[] = {@@ -410,7 +410,7 @@ static void __init setup_resources(void)for_each_memblock (memory, reg) { res =alloc_bootmem_low (sizeof (*res)); - res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; + res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ; res->name ="System RAM" ; res->start = reg->base;arch/score/kernel/setup.c +1
-1@@ -101,7 +101,7 @@ static void __init resource_init(void) res->name ="System RAM" ; res->start =MEMORY_START ; res->end =MEMORY_START +MEMORY_SIZE -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);request_resource (res, &code_resource);arch/sh/kernel/setup.c +4
-4@@ -78,17 +78,17 @@ static char __initdata command_line[COMMAND_LINE_SIZE] = { 0, };static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };unsigned long memory_start;@@ -202,7 +202,7 @@ void __init __add_active_range(unsigned int nid, unsigned long start_pfn, res->name ="System RAM" ; res->start = start; res->end = end -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;if (request_resource (&iomem_resource, res)) { pr_err("unable to request memory_resource 0x%lx 0x%lx\n",arch/sparc/mm/init_64.c +4
-4@@ -2862,17 +2862,17 @@ void hugetlb_setup(struct pt_regs *regs)static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static inline resource_size_t compute_kern_paddr (void *addr)@@ -2908,7 +2908,7 @@ static int __init report_memory(void) res->name ="System RAM" ; res->start = pavail[i].phys_addr; res->end = pavail[i].phys_addr + pavail[i].reg_size -1 ; - res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; + res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ;if (insert_resource (&iomem_resource, res) <0 ) {pr_warn ("Resource insertion failed.\n" );arch/tile/kernel/setup.c +8
-3@@ -1632,14 +1632,14 @@ static struct resource data_resource = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM };static struct resource code_resource = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };/* @@ -1673,10 +1673,15 @@ insert_ram_resource(u64 start_pfn, u64 end_pfn, bool reserved)kzalloc (sizeof (struct resource ),GFP_ATOMIC );if (!res)return NULL ; - res->name = reserved ?"Reserved" :"System RAM" ; res->start = start_pfn <<PAGE_SHIFT ; res->end = (end_pfn <<PAGE_SHIFT ) -1 ; res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; +if (reserved) { + res->name ="Reserved" ; + }else { + res->name ="System RAM" ; + res->flags |=IORESOURCE_SYSRAM ; + }if (insert_resource (&iomem_resource, res)) {kfree (res);return NULL ;arch/unicore32/kernel/setup.c +3
-3@@ -72,13 +72,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } };@@ -211,7 +211,7 @@ request_standard_resources(struct meminfo *mi) res->name ="System RAM" ; res->start = mi->bank[i].start; res->end = mi->bank[i].start + mi->bank[i].size -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.PATCH v3 7/17 kexec: Set IORESOURCE_SYSTEM_RAM to System RAM
In reply to Toshi KaniSet IORESOURCE_SYSTEM_RAM to 'flags' and IORES_DESC_CRASH_KERNEL to 'desc' of "Crash kernel" resource ranges, which are child nodes of System RAM.
Change crash_shrink_memory() to set IORESOURCE_SYSTEM_RAM for a System RAM range.
Change kexec_add_buffer() to call walk_iomem_res() with IORESOURCE_SYSTEM_RAM type for "Crash kernel".
--- kernel/kexec_core.c | 8 +++++--- kernel/kexec_file.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)
kernel/kexec_core.c +5 -3
@@ -66,13 +66,15 @@ struct resource crashk_res = { .name = "Crash kernel", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, + .desc = IORES_DESC_CRASH_KERNEL };struct resource crashk_low_res = { .name ="Crash kernel" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , + .desc =IORES_DESC_CRASH_KERNEL };int kexec_should_crash (struct task_struct *p)
@@ -934,7 +936,7 @@ int crash_shrink_memory(unsigned long new_size) ram_res->start = end; ram_res->end = crashk_res.end; - ram_res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; + ram_res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ; ram_res->name ="System RAM" ; crashk_res.end = end -1 ;
kernel/kexec_file.c +1 -1
@@ -523,7 +523,7 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,/* Walk the RAM ranges and allocate a suitable range for the buffer */ if (image->type ==KEXEC_TYPE_CRASH ) ret =walk_iomem_res ("Crash kernel" , -IORESOURCE_MEM |IORESOURCE_BUSY , +IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , crashk_res.start, crashk_res.end, kbuf, locate_mem_hole_callback);else
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 07/17] kexec: Set IORESOURCE_SYSTEM_RAM to System RAM
Quoted 55 lines · Toshi Kani
Set
IORESOURCE_SYSTEM_RAMto 'flags' andIORES_DESC_CRASH_KERNELto 'desc' of "Crash kernel" resource ranges, which are child nodes of System RAM.Change
crash_shrink_memory()to setIORESOURCE_SYSTEM_RAMfor a System RAM range.Change
kexec_add_buffer()to callwalk_iomem_res()withIORESOURCE_SYSTEM_RAMtype for "Crash kernel".Cc Andrew Morton <[email protected]>Cc Dave Young <[email protected]>Signed-off-by Toshi Kani <[email protected]>--- kernel/kexec_core.c | 8 +++++--- kernel/kexec_file.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)kernel/kexec_core.c +5
-3@@ -66,13 +66,15 @@ struct resource crashk_res = { .name = "Crash kernel", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, + .desc = IORES_DESC_CRASH_KERNEL };struct resource crashk_low_res = { .name ="Crash kernel" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , + .desc =IORES_DESC_CRASH_KERNEL };int kexec_should_crash (struct task_struct *p)@@ -934,7 +936,7 @@ int crash_shrink_memory(unsigned long new_size) ram_res->start = end; ram_res->end = crashk_res.end; - ram_res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; + ram_res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ; ram_res->name ="System RAM" ; crashk_res.end = end -1 ;kernel/kexec_file.c +0
-0
kernel/kexec_file.c int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz, · line 529
Quoted 8 lines
kernel/kexec_file.c +1
-1@@ -523,7 +523,7 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,/* Walk the RAM ranges and allocate a suitable range for the buffer */ if (image->type ==KEXEC_TYPE_CRASH ) ret =walk_iomem_res ("Crash kernel" , -IORESOURCE_MEM |IORESOURCE_BUSY , +IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , crashk_res.start, crashk_res.end, kbuf, locate_mem_hole_callback);else
Thanks
Dave
PATCH v3 8/17 xen, mm: Set IORESOURCE_SYSTEM_RAM to System RAM
In reply to Toshi KaniSet IORESOURCE_SYSTEM_RAM to 'flags' of struct resource entries with "System RAM".
--- drivers/xen/balloon.c | 2 +- mm/memory_hotplug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/xen/balloon.c +1 -1
@@ -257,7 +257,7 @@ static struct resource *additional_memory_resource(phys_addr_t size)return NULL ; res->name ="System RAM" ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; ret = allocate_resource(&iomem_resource, res, size, 0, -1,
mm/memory_hotplug.c +1 -1
@@ -136,7 +136,7 @@ static struct resource *register_memory_resource(u64 start, u64 size) res->name ="System RAM" ; res->start = start; res->end = start + size -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;if (request_resource (&iomem_resource, res) <0 ) {pr_debug ("System RAM resource %pR cannot be added\n" , res);kfree (res);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 8/17 xen, mm: Set IORESOURCE_SYSTEM_RAM to System RAM
In reply to Toshi KaniSet IORESOURCE_SYSTEM_RAM to 'flags' of struct resource entries with "System RAM".
--- drivers/xen/balloon.c | 2 +- mm/memory_hotplug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/xen/balloon.c +1 -1
@@ -257,7 +257,7 @@ static struct resource *additional_memory_resource(phys_addr_t size)return NULL ; res->name ="System RAM" ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; ret = allocate_resource(&iomem_resource, res, size, 0, -1,
mm/memory_hotplug.c +1 -1
@@ -136,7 +136,7 @@ static struct resource *register_memory_resource(u64 start, u64 size) res->name ="System RAM" ; res->start = start; res->end = start + size -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;if (request_resource (&iomem_resource, res) <0 ) {pr_debug ("System RAM resource %pR cannot be added\n" , res);kfree (res);
PATCH v3 9/17 drivers: Initialize resource entry to zero
In reply to Toshi KaniI/O resource descriptor, 'desc' in struct resource, needs to be initialized to zero by default. Some drivers call kmalloc() to allocate a resource entry, but does not initialize it to zero by memset(). Change these drivers to call kzalloc(), instead.
--- drivers/acpi/acpi_platform.c | 2 +- drivers/parisc/eisa_enumerator.c | 4 ++-- drivers/rapidio/rio.c | 8 ++++---- drivers/sh/superhyway/superhyway.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
drivers/acpi/acpi_platform.c +1 -1
@@ -62,7 +62,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)if (count <0 ) {return NULL ; }else if (count >0 ) { - resources =kmalloc (count *sizeof (struct resource ), + resources =kzalloc (count *sizeof (struct resource ),GFP_KERNEL );if (!resources) {dev_err (&adev->dev,"No memory for resources\n" );
drivers/parisc/eisa_enumerator.c +2 -2
@@ -91,7 +91,7 @@ static int configure_memory(const unsigned char *buf,for (i=0 ;i<HPEE_MEMORY_MAX_ENT ;i++) { c =get_8 (buf+len); -if (NULL != (res =kmalloc (sizeof (struct resource ),GFP_KERNEL ))) { +if (NULL != (res =kzalloc (sizeof (struct resource ),GFP_KERNEL ))) {int result; res->name = name;
@@ -183,7 +183,7 @@ static int configure_port(const unsigned char *buf, struct resource *io_parent,for (i=0 ;i<HPEE_PORT_MAX_ENT ;i++) { c =get_8 (buf+len); -if (NULL != (res =kmalloc (sizeof (struct resource ),GFP_KERNEL ))) { +if (NULL != (res =kzalloc (sizeof (struct resource ),GFP_KERNEL ))) { res->name = board; res->start =get_16 (buf+len+1 ); res->end =get_16 (buf+len+1 )+(c&HPEE_PORT_SIZE_MASK )+1 ;
drivers/rapidio/rio.c +4 -4
@@ -117,7 +117,7 @@ int rio_request_inb_mbox(struct rio_mport *mport,if (mport->ops->open_inb_mbox ==NULL ) goto out; - res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); + res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_mbox_res (res, mbox, mbox);
@@ -185,7 +185,7 @@ int rio_request_outb_mbox(struct rio_mport *mport,if (mport->ops->open_outb_mbox ==NULL ) goto out; - res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); + res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_mbox_res (res, mbox, mbox);
@@ -285,7 +285,7 @@ int rio_request_inb_dbell(struct rio_mport *mport, {int rc =0 ; -struct resource *res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); +struct resource *res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_dbell_res (res, start, end);
@@ -360,7 +360,7 @@ int rio_release_inb_dbell(struct rio_mport *mport, u16 start, u16 end)struct resource *rio_request_outb_dbell (struct rio_dev *rdev,u16 start,u16 end) { -struct resource *res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); +struct resource *res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_dbell_res (res, start, end);
drivers/sh/superhyway/superhyway.c +1 -1
@@ -66,7 +66,7 @@ int superhyway_add_device(unsigned long base, struct superhyway_device *sdev,superhyway_read_vcr (dev, base, &dev->vcr);if (!dev->resource) { - dev->resource =kmalloc (sizeof (struct resource ),GFP_KERNEL ); + dev->resource =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (!dev->resource) {kfree (dev);return -ENOMEM ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 09/17] drivers: Initialize resource entry to zero
Quoted 5 lines · Toshi Kani
I/O resource descriptor, 'desc' in struct resource, needs to be initialized to zero by default. Some drivers call
kmalloc()to allocate a resource entry, but does not initialize it to zero bymemset(). Change these drivers to callkzalloc(), instead.
Quoted 8 lines
Signed-off-by Toshi Kani <[email protected]>--- drivers/acpi/acpi_platform.c | 2 +- drivers/parisc/eisa_enumerator.c | 4 ++--
The parisc changes look good. For those:
Quoted 93 lines
drivers/rapidio/rio.c | 8 ++++---- drivers/sh/superhyway/superhyway.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)drivers/acpi/acpi_platform.c +1
-1@@ -62,7 +62,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)if (count <0 ) {return NULL ; }else if (count >0 ) { - resources =kmalloc (count *sizeof (struct resource ), + resources =kzalloc (count *sizeof (struct resource ),GFP_KERNEL );if (!resources) {dev_err (&adev->dev,"No memory for resources\n" );drivers/parisc/eisa_enumerator.c +2
-2@@ -91,7 +91,7 @@ static int configure_memory(const unsigned char *buf,for (i=0 ;i<HPEE_MEMORY_MAX_ENT ;i++) { c =get_8 (buf+len); -if (NULL != (res =kmalloc (sizeof (struct resource ),GFP_KERNEL ))) { +if (NULL != (res =kzalloc (sizeof (struct resource ),GFP_KERNEL ))) {int result; res->name = name;@@ -183,7 +183,7 @@ static int configure_port(const unsigned char *buf, struct resource *io_parent,for (i=0 ;i<HPEE_PORT_MAX_ENT ;i++) { c =get_8 (buf+len); -if (NULL != (res =kmalloc (sizeof (struct resource ),GFP_KERNEL ))) { +if (NULL != (res =kzalloc (sizeof (struct resource ),GFP_KERNEL ))) { res->name = board; res->start =get_16 (buf+len+1 ); res->end =get_16 (buf+len+1 )+(c&HPEE_PORT_SIZE_MASK )+1 ;drivers/rapidio/rio.c +4
-4@@ -117,7 +117,7 @@ int rio_request_inb_mbox(struct rio_mport *mport,if (mport->ops->open_inb_mbox ==NULL ) goto out; - res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); + res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_mbox_res (res, mbox, mbox);@@ -185,7 +185,7 @@ int rio_request_outb_mbox(struct rio_mport *mport,if (mport->ops->open_outb_mbox ==NULL ) goto out; - res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); + res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_mbox_res (res, mbox, mbox);@@ -285,7 +285,7 @@ int rio_request_inb_dbell(struct rio_mport *mport, {int rc =0 ; -struct resource *res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); +struct resource *res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_dbell_res (res, start, end);@@ -360,7 +360,7 @@ int rio_release_inb_dbell(struct rio_mport *mport, u16 start, u16 end)struct resource *rio_request_outb_dbell (struct rio_dev *rdev,u16 start,u16 end) { -struct resource *res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); +struct resource *res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_dbell_res (res, start, end);drivers/sh/superhyway/superhyway.c +1
-2@@ -66,7 +66,7 @@ int superhyway_add_device(unsigned long base, struct superhyway_device *sdev,superhyway_read_vcr (dev, base, &dev->vcr);if (!dev->resource) { - dev->resource =kmalloc (sizeof (struct resource ),GFP_KERNEL ); + dev->resource =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (!dev->resource) {kfree (dev);return -ENOMEM ; --
Quoted 4 lines
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 10/17 resource: Change walk_system_ram to use System RAM type
In reply to Toshi KaniNow that all System RAM resource entries have been initialized to IORESOURCE_SYSTEM_RAM type, change walk_system_ram_res() and walk_system_ram_range() to call find_next_iomem_res() by setting IORESOURCE_SYSTEM_RAM to @res.flags and NULL to @name. With this change, they walk through the iomem table to find System RAM ranges without using strcmp().
No functional change is made to the interfaces.
--- kernel/resource.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
kernel/resource.c +11 -11
@@ -415,9 +415,9 @@ int walk_iomem_res(char *name, unsigned long flags, u64 start, u64 end, }/* -* This function calls callback against all memory range of "System RAM" -* which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. -* Now, this function is only for "System RAM". This function deals with +* This function calls callback against all memory range of System RAM +* which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY. +* Now, this function is only for System RAM. This function deals with * full ranges and not pfn. If resources are not pfn aligned, dealing * with pfn can truncate ranges. */
@@ -430,10 +430,10 @@ int walk_system_ram_res(u64 start, u64 end, void *arg, res.start = start; res.end = end; - res.flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res.flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; orig_end = res.end;while ((res.start < res.end) && - (!find_next_iomem_res (&res,"System RAM" , true))) { + (!find_next_iomem_res (&res,NULL , true))) { ret = (*func)(res.start, res.end, arg);if (ret)break ;
@@ -446,9 +446,9 @@ int walk_system_ram_res(u64 start, u64 end, void *arg,#if !defined(CONFIG_ARCH_HAS_WALK_MEMORY )/* -* This function calls callback against all memory range of "System RAM" -* which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. -* Now, this function is only for "System RAM". +* This function calls callback against all memory range of System RAM +* which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY. +* Now, this function is only for System RAM. */ int walk_system_ram_range (unsigned long start_pfn,unsigned long nr_pages,void *arg,int (*func)(unsigned long ,unsigned long ,void *))
@@ -460,10 +460,10 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, res.start = (u64 ) start_pfn <<PAGE_SHIFT ; res.end = ((u64)(start_pfn + nr_pages) <<PAGE_SHIFT ) -1 ; - res.flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res.flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; orig_end = res.end;while ((res.start < res.end) && - (find_next_iomem_res (&res,"System RAM" , true) >=0 )) { + (find_next_iomem_res (&res,NULL , true) >=0 )) { pfn = (res.start +PAGE_SIZE -1 ) >>PAGE_SHIFT ; end_pfn = (res.end +1 ) >>PAGE_SHIFT ;if (end_pfn > pfn)
@@ -484,7 +484,7 @@ static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) }/* * This generic page_is_ram() returns true if specified address is -* registered as "System RAM" in iomem_resource list. +* registered as System RAM in iomem_resource list. */ int __weak page_is_ram (unsigned long pfn) {
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 11/17 arm/samsung: Change s3c_pm_run_res() to use System RAM type
In reply to Toshi KaniChange s3c_pm_run_res() to check with IORESOURCE_SYSTEM_RAM, instead of strcmp() with "System RAM", to walk through System RAM ranges in the iomem table.
No functional change is made to the interface.
--- arch/arm/plat-samsung/pm-check.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/plat-samsung/pm-check.c +2 -2
@@ -53,8 +53,8 @@ static void s3c_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg)if (ptr->child !=NULL )s3c_pm_run_res (ptr->child, fn, arg); -if ((ptr->flags &IORESOURCE_MEM ) && -strcmp (ptr->name,"System RAM" ) ==0 ) { +if ((ptr->flags &IORESOURCE_SYSTEM_RAM ) + ==IORESOURCE_SYSTEM_RAM ) {S3C_PMDBG ("Found system RAM at %08lx..%08lx\n" , (unsigned long )ptr->start, (unsigned long )ptr->end);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 12/17 memremap: Change region_intersects() to take @flags and @desc
In reply to Toshi KaniChange region_intersects() to identify a target with @flags and @desc, instead of @name with strcmp().
Change the callers of region_intersects(), memremap() and devm_memremap(), to set IORESOURCE_SYSTEM_RAM to @flags and IORES_DESC_NONE to @desc for searching System RAM.
Also, export region_intersects() so that the EINJ driver can call this function in a later patch.
--- include/linux/mm.h | 3 ++- kernel/memremap.c | 13 +++++++------ kernel/resource.c | 26 +++++++++++++++----------- 3 files changed, 24 insertions(+), 18 deletions(-)
include/linux/mm.h +2 -1
@@ -362,7 +362,8 @@ enum { REGION_MIXED, }; -int region_intersects (resource_size_t offset,size_t size,const char *type); +int region_intersects (resource_size_t offset,size_t size,unsigned long flags, +unsigned long desc);/* Support for virtually mapped pages */ struct page *vmalloc_to_page (const void *addr);
kernel/memremap.c +7 -6
@@ -44,7 +44,7 @@ static void *try_ram_remap(resource_size_t offset, size_t size)* being mapped does not have i/o side effects and the __iomem * annotation is not applicable. * -* MEMREMAP_WB - matches the default mapping for "System RAM" on +* MEMREMAP_WB - matches the default mapping for System RAM on * the architecture. This is usually a read-allocate write-back cache. * Morever, if MEMREMAP_WB is specified and the requested remap region is RAM * memremap() will bypass establishing a new mapping and instead return
@@ -53,11 +53,12 @@ static void *try_ram_remap(resource_size_t offset, size_t size)* MEMREMAP_WT - establish a mapping whereby writes either bypass the * cache or are written through to memory and never exist in a * cache-dirty state with respect to program visibility. Attempts to -* map "System RAM" with this mapping type will fail. +* map System RAM with this mapping type will fail. */ void *memremap (resource_size_t offset,size_t size,unsigned long flags) { -int is_ram =region_intersects (offset, size,"System RAM" ); +int is_ram =region_intersects (offset, size, +IORESOURCE_SYSTEM_RAM ,IORES_DESC_NONE );void *addr =NULL ;if (is_ram ==REGION_MIXED ) {
@@ -73,7 +74,7 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)* MEMREMAP_WB is special in that it can be satisifed * from the direct map. Some archs depend on the * capability of memremap() to autodetect cases where -* the requested range is potentially in "System RAM" +* the requested range is potentially in System RAM. */ if (is_ram ==REGION_INTERSECTS ) addr =try_ram_remap (offset, size);
@@ -85,7 +86,7 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)* If we don't have a mapping yet and more request flags are * pending then we will be attempting to establish a new virtual * address mapping. Enforce that this mapping is not aliasing -* "System RAM" +* System RAM. */ if (!addr && is_ram ==REGION_INTERSECTS && flags) { WARN_ONCE(1, "memremap attempted on ram %pa size: %#lx\n",
@@ -163,7 +164,7 @@ static void devm_memremap_pages_release(struct device *dev, void *res)void *devm_memremap_pages (struct device *dev,struct resource *res) {int is_ram =region_intersects (res->start,resource_size (res), -"System RAM" ); +IORESOURCE_SYSTEM_RAM ,IORES_DESC_NONE );struct page_map *page_map;int error, nid;
kernel/resource.c +15 -11
@@ -496,31 +496,34 @@ EXPORT_SYMBOL_GPL(page_is_ram);* region_intersects() - determine intersection of region with known resources * @start: region start address * @size: size of region -* @name: name of resource (in iomem_resource) +* @flags: flags of resource (in iomem_resource) +* @desc: descriptor of resource (in iomem_resource) or IORES_DESC_NONE * * Check if the specified region partially overlaps or fully eclipses a -* resource identified by @name. Return REGION_DISJOINT if the region -* does not overlap @name, return REGION_MIXED if the region overlaps -* @type and another resource, and return REGION_INTERSECTS if the -* region overlaps @type and no other defined resource. Note, that -* REGION_INTERSECTS is also returned in the case when the specified -* region overlaps RAM and undefined memory holes. +* resource identified by @flags and @desc (optinal with IORES_DESC_NONE). +* Return REGION_DISJOINT if the region does not overlap @flags/@desc, +* return REGION_MIXED if the region overlaps @flags/@desc and another +* resource, and return REGION_INTERSECTS if the region overlaps @flags/@desc +* and no other defined resource. Note, that REGION_INTERSECTS is also +* returned in the case when the specified region overlaps RAM and undefined +* memory holes. * * region_intersect() is used by memory remapping functions to ensure * the user is not remapping RAM and is a vast speed up over walking * through the resource table page by page. */ -int region_intersects (resource_size_t start,size_t size,const char *name) +int region_intersects (resource_size_t start,size_t size,unsigned long flags, +unsigned long desc) { -unsigned long flags =IORESOURCE_MEM |IORESOURCE_BUSY ;resource_size_t end = start + size -1 ;int type =0 ;int other =0 ;struct resource *p;read_lock (&resource_lock);for (p = iomem_resource.child; p ; p = p->sibling) { -bool is_type =strcmp (p->name, name) ==0 && - ((p->flags & flags) == flags); +bool is_type = (((p->flags & flags) == flags) && + ((desc ==IORES_DESC_NONE ) || + (desc == p->desc)));if (start >= p->start && start <= p->end) is_type ? type++ : other++;
@@ -539,6 +542,7 @@ int region_intersects(resource_size_t start, size_t size, const char *name)return REGION_DISJOINT ; } +EXPORT_SYMBOL_GPL (region_intersects);void __weak arch_remove_reservations (struct resource *avail) {
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 13/17 resource: Add walk_iomem_res_desc()
In reply to Toshi KaniAdd a new interface, walk_iomem_res_desc(), which walks through the iomem table by identifying a target with @flags and @desc. This interface provides the same functionality as walk_iomem_res(), but does not use strcmp() to @name for better efficiency.
walk_iomem_res() is deprecated and will be removed in a later patch.
--- include/linux/ioport.h | 3 ++ kernel/resource.c | 58 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 7 deletions(-)
include/linux/ioport.h +3 -0
@@ -268,6 +268,9 @@ extern int walk_system_ram_res(u64 start, u64 end, void *arg, int (*func)(u64, u64, void *));extern int +walk_iomem_res_desc (unsigned long desc,unsigned long flags,u64 start,u64 end, +void *arg,int (*func)(u64 ,u64 ,void *)); +extern int walk_iomem_res (char *name,unsigned long flags,u64 start,u64 end,void *arg,int (*func)(u64 ,u64 ,void *));
kernel/resource.c +51 -7
103 lines not on this page · raw message
PATCH v3 14/17 x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
In reply to Toshi KaniChange the callers of walk_iomem_res() with the following names to use walk_iomem_res(), instead.
"ACPI Tables"
"ACPI Non-volatile Storage"
"Persistent Memory (legacy)"
"Crash kernel"
Note, the caller of walk_iomem_res() with "GART" will be removed in a later patch.
--- arch/x86/kernel/crash.c | 4 ++-- arch/x86/kernel/pmem.c | 4 ++-- drivers/nvdimm/e820.c | 2 +- kernel/kexec_file.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-)
arch/x86/kernel/crash.c +2 -2
@@ -588,12 +588,12 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params)/* Add ACPI tables */ cmd.type =E820_ACPI ; flags =IORESOURCE_MEM |IORESOURCE_BUSY ; -walk_iomem_res ("ACPI Tables" , flags,0 ,-1 , &cmd, +walk_iomem_res_desc (IORES_DESC_ACPI_TABLES , flags,0 ,-1 , &cmd, memmap_entry_callback);/* Add ACPI Non-volatile Storage */ cmd.type =E820_NVS ; -walk_iomem_res ("ACPI Non-volatile Storage" , flags,0 ,-1 , &cmd, +walk_iomem_res_desc (IORES_DESC_ACPI_NV_STORAGE , flags,0 ,-1 , &cmd, memmap_entry_callback);/* Add crashk_low_res region */
arch/x86/kernel/pmem.c +2 -2
@@ -13,11 +13,11 @@ static int found(u64 start, u64 end, void *data)static __init int register_e820_pmem (void ) { -char *pmem ="Persistent Memory (legacy)" ;struct platform_device *pdev;int rc; - rc =walk_iomem_res (pmem,IORESOURCE_MEM ,0 ,-1 ,NULL , found); + rc =walk_iomem_res_desc (IORES_DESC_PERSISTENT_MEMORY_LEGACY , +IORESOURCE_MEM ,0 ,-1 ,NULL , found);if (rc <=0 )return 0 ;
drivers/nvdimm/e820.c +1 -1
@@ -55,7 +55,7 @@ static int e820_pmem_probe(struct platform_device *pdev)for (p = iomem_resource.child; p ; p = p->sibling) {struct nd_region_desc ndr_desc; -if (strncmp (p->name,"Persistent Memory (legacy)" ,26 ) !=0 ) +if (p->desc !=IORES_DESC_PERSISTENT_MEMORY_LEGACY )continue ;memset (&ndr_desc,0 ,sizeof (ndr_desc));
kernel/kexec_file.c +4 -4
@@ -522,10 +522,10 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,/* Walk the RAM ranges and allocate a suitable range for the buffer */ if (image->type ==KEXEC_TYPE_CRASH ) - ret =walk_iomem_res ("Crash kernel" , -IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , - crashk_res.start, crashk_res.end, kbuf, - locate_mem_hole_callback); + ret =walk_iomem_res_desc (crashk_res.desc, +IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , + crashk_res.start, crashk_res.end, kbuf, + locate_mem_hole_callback);else ret =walk_system_ram_res (0 ,-1 , kbuf, locate_mem_hole_callback);
Re: [PATCH v3 14/17] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
Quoted 85 lines · Toshi Kani
Change the callers of
walk_iomem_res()with the following names to usewalk_iomem_res(), instead."ACPI Tables"
"ACPI Non-volatile Storage"
"Persistent Memory (legacy)"
"Crash kernel"Note, the caller of
walk_iomem_res()with "GART" will be removed in a later patch.Cc Borislav Petkov <[email protected]>Cc Dan Williams <[email protected]>Cc Dave Young <[email protected]>Cc Minfei Huang <[email protected]>Signed-off-by Toshi Kani <[email protected]>--- arch/x86/kernel/crash.c | 4 ++-- arch/x86/kernel/pmem.c | 4 ++-- drivers/nvdimm/e820.c | 2 +- kernel/kexec_file.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-)arch/x86/kernel/crash.c +2
-2@@ -588,12 +588,12 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params)/* Add ACPI tables */ cmd.type =E820_ACPI ; flags =IORESOURCE_MEM |IORESOURCE_BUSY ; -walk_iomem_res ("ACPI Tables" , flags,0 ,-1 , &cmd, +walk_iomem_res_desc (IORES_DESC_ACPI_TABLES , flags,0 ,-1 , &cmd, memmap_entry_callback);/* Add ACPI Non-volatile Storage */ cmd.type =E820_NVS ; -walk_iomem_res ("ACPI Non-volatile Storage" , flags,0 ,-1 , &cmd, +walk_iomem_res_desc (IORES_DESC_ACPI_NV_STORAGE , flags,0 ,-1 , &cmd, memmap_entry_callback);/* Add crashk_low_res region */ arch/x86/kernel/pmem.c +2
-2@@ -13,11 +13,11 @@ static int found(u64 start, u64 end, void *data)static __init int register_e820_pmem (void ) { -char *pmem ="Persistent Memory (legacy)" ;struct platform_device *pdev;int rc; - rc =walk_iomem_res (pmem,IORESOURCE_MEM ,0 ,-1 ,NULL , found); + rc =walk_iomem_res_desc (IORES_DESC_PERSISTENT_MEMORY_LEGACY , +IORESOURCE_MEM ,0 ,-1 ,NULL , found);if (rc <=0 )return 0 ;drivers/nvdimm/e820.c +1
-1@@ -55,7 +55,7 @@ static int e820_pmem_probe(struct platform_device *pdev)for (p = iomem_resource.child; p ; p = p->sibling) {struct nd_region_desc ndr_desc; -if (strncmp (p->name,"Persistent Memory (legacy)" ,26 ) !=0 ) +if (p->desc !=IORES_DESC_PERSISTENT_MEMORY_LEGACY )continue ;memset (&ndr_desc,0 ,sizeof (ndr_desc));kernel/kexec_file.c +0
-1@@ -522,10 +522,10 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,/* Walk the RAM ranges and allocate a suitable range for the buffer */ if (image->type ==KEXEC_TYPE_CRASH ) - ret = walk_iomem_res("Crash kernel",
kernel/kexec_file.c int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz, · line 531
Quoted 10 lines
kernel/kexec_file.c +4
-3-IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , - crashk_res.start, crashk_res.end, kbuf, - locate_mem_hole_callback); + ret =walk_iomem_res_desc (crashk_res.desc, +IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , + crashk_res.start, crashk_res.end, kbuf, + locate_mem_hole_callback); else ret =walk_system_ram_res (0 ,-1 , kbuf, locate_mem_hole_callback);
Thanks
Dave
PATCH v3 15/17 x86/kexec: Remove walk_iomem_res() call with GART
In reply to Toshi KaniThere is no longer any driver inserting a "GART" region in the kernel since 'commit 707d4eefbdb3 ("Revert "[PATCH] Insert GART region into resource map"")' was made.
Remove the call to walk_iomem_res() with "GART", its callback function, and GART-specific variables set by the callback.
--- arch/x86/kernel/crash.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
arch/x86/kernel/crash.c +1 -36
@@ -56,10 +56,9 @@ struct crash_elf_data {struct kimage *image;/* * Total number of ram ranges we have after various adjustments for -* GART, crash reserved region etc. +* crash reserved region, etc. */ unsigned int max_nr_ranges; -unsigned long gart_start, gart_end;/* Pointer to elf header */ void *ehdr;
@@ -190,17 +189,6 @@ static int get_nr_ram_ranges_callback(u64 start, u64 end, void *arg)return 0 ; } -static int get_gart_ranges_callback (u64 start,u64 end,void *arg) -{ -struct crash_elf_data *ced = arg; - - ced->gart_start = start; - ced->gart_end = end; - -/* Not expecting more than 1 gart aperture */ -return 1 ; -} -/* Gather all the required information to prepare elf headers for ram regions */ static void fill_up_crash_elf_data(struct crash_elf_data *ced,
@@ -215,22 +203,6 @@ static void fill_up_crash_elf_data(struct crash_elf_data *ced, ced->max_nr_ranges = nr_ranges; -/* -* We don't create ELF headers for GART aperture as an attempt -* to dump this memory in second kernel leads to hang/crash. -* If gart aperture is present, one needs to exclude that region -* and that could lead to need of extra phdr. -*/ -walk_iomem_res ("GART" ,IORESOURCE_MEM ,0 ,-1 , - ced, get_gart_ranges_callback); - -/* -* If we have gart region, excluding that could potentially split -* a memory range, resulting in extra header. Account for that. -*/ -if (ced->gart_end) - ced->max_nr_ranges++; -/* Exclusion of crash region could split memory ranges */ ced->max_nr_ranges++;
@@ -339,13 +311,6 @@ static int elf_header_exclude_ranges(struct crash_elf_data *ced,return ret; } -/* Exclude GART region */ -if (ced->gart_end) { - ret =exclude_mem_range (cmem, ced->gart_start, ced->gart_end); -if (ret) -return ret; - } -return ret; }
Re: [PATCH v3 15/17] x86/kexec: Remove walk_iomem_res() call with GART
Quoted 79 lines · Toshi Kani
There is no longer any driver inserting a "GART" region in the kernel since 'commit
707d4eefbdb3("Revert "[PATCH] Insert GART region into resource map"")' was made.Remove the call to
walk_iomem_res()with "GART", its callback function, and GART-specific variables set by the callback.Cc Borislav Petkov <[email protected]>Cc Dave Young <[email protected]>Cc Minfei Huang <[email protected]>Signed-off-by Toshi Kani <[email protected]>--- arch/x86/kernel/crash.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)arch/x86/kernel/crash.c +1
-29@@ -56,10 +56,9 @@ struct crash_elf_data {struct kimage *image;/* * Total number of ram ranges we have after various adjustments for -* GART, crash reserved region etc. +* crash reserved region, etc. */ unsigned int max_nr_ranges; -unsigned long gart_start, gart_end;/* Pointer to elf header */ void *ehdr;@@ -190,17 +189,6 @@ static int get_nr_ram_ranges_callback(u64 start, u64 end, void *arg)return 0 ; } -static int get_gart_ranges_callback (u64 start,u64 end,void *arg) -{ -struct crash_elf_data *ced = arg; - - ced->gart_start = start; - ced->gart_end = end; - -/* Not expecting more than 1 gart aperture */ -return 1 ; -} -/* Gather all the required information to prepare elf headers for ram regions */ static void fill_up_crash_elf_data(struct crash_elf_data *ced,@@ -215,22 +203,6 @@ static void fill_up_crash_elf_data(struct crash_elf_data *ced, ced->max_nr_ranges = nr_ranges; -/* -* We don't create ELF headers for GART aperture as an attempt -* to dump this memory in second kernel leads to hang/crash. -* If gart aperture is present, one needs to exclude that region -* and that could lead to need of extra phdr. -*/ -walk_iomem_res ("GART" ,IORESOURCE_MEM ,0 ,-1 , - ced, get_gart_ranges_callback); - -/* -* If we have gart region, excluding that could potentially split -* a memory range, resulting in extra header. Account for that. -*/ -if (ced->gart_end) - ced->max_nr_ranges++; -/* Exclusion of crash region could split memory ranges */ ced->max_nr_ranges++;@@ -339,13 +311,6 @@ static int elf_header_exclude_ranges(struct crash_elf_data *ced,return ret; }
arch/x86/kernel/crash.c static int elf_header_exclude_ranges(struct crash_elf_data *ced, · line 316
Quoted 10 lines
arch/x86/kernel/crash.c +0
-7-/* Exclude GART region */ -if (ced->gart_end) { - ret =exclude_mem_range (cmem, ced->gart_start, ced->gart_end); -if (ret) -return ret; - } -return ret; }
Thanks
Dave
PATCH v3 16/17 resource: Kill walk_iomem_res()
In reply to Toshi Kaniwalk_iomem_res_desc() replaced walk_iomem_res(), and there is no caller to walk_iomem_res() any more.
Kill walk_iomem_res(). Also remove @name from find_next_iomem_res() as it is no longer used.
--- include/linux/ioport.h | 3 --- kernel/resource.c | 49 +++++------------------------------------------- 2 files changed, 5 insertions(+), 47 deletions(-)
include/linux/ioport.h +0 -3
@@ -270,9 +270,6 @@ walk_system_ram_res(u64 start, u64 end, void *arg,extern int walk_iomem_res_desc (unsigned long desc,unsigned long flags,u64 start,u64 end,void *arg,int (*func)(u64 ,u64 ,void *)); -extern int -walk_iomem_res (char *name,unsigned long flags,u64 start,u64 end,void *arg, -int (*func)(u64 ,u64 ,void *));/* True if any part of r1 overlaps r2 */ static inline bool resource_overlaps (struct resource *r1,struct resource *r2)
kernel/resource.c +5 -44
89 lines not on this page · raw message
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v3 16/17] resource: Kill walk_iomem_res()
Quoted 121 lines · Toshi Kani
walk_iomem_res_desc()replacedwalk_iomem_res(), and there is no caller towalk_iomem_res()any more.Kill
walk_iomem_res(). Also remove @name fromfind_next_iomem_res()as it is no longer used.Cc Andrew Morton <[email protected]>Cc Borislav Petkov <[email protected]>Cc Dan Williams <[email protected]>Cc Dave Young <[email protected]>Signed-off-by Toshi Kani <[email protected]>--- include/linux/ioport.h | 3 --- kernel/resource.c | 49 +++++------------------------------------------- 2 files changed, 5 insertions(+), 47 deletions(-)include/linux/ioport.h +0
-3@@ -270,9 +270,6 @@ walk_system_ram_res(u64 start, u64 end, void *arg,extern int walk_iomem_res_desc (unsigned long desc,unsigned long flags,u64 start,u64 end,void *arg,int (*func)(u64 ,u64 ,void *)); -extern int -walk_iomem_res (char *name,unsigned long flags,u64 start,u64 end,void *arg, -int (*func)(u64 ,u64 ,void *));/* True if any part of r1 overlaps r2 */ static inline bool resource_overlaps (struct resource *r1,struct resource *r2)kernel/resource.c +4
-43@@ -335,13 +335,12 @@ EXPORT_SYMBOL(release_resource);/* * Finds the lowest iomem reosurce exists with-in [res->start.res->end) * the caller must specify res->start, res->end, res->flags, and optionally -* desc and "name". If found, returns 0, res is overwritten, if not found, -* returns -1. +* desc. If found, returns 0, res is overwritten, if not found, returns -1. * This walks through whole tree and not just first level children * until and unless first_level_children_only is true. */ static int find_next_iomem_res (struct resource *res,unsigned long desc, -char *name,bool first_level_children_only) +bool first_level_children_only) {resource_size_t start, end;struct resource *p;@@ -363,8 +362,6 @@ static int find_next_iomem_res(struct resource *res, unsigned long desc,continue ;if ((desc !=IORES_DESC_NONE ) && (desc != p->desc))continue ; -if (name &&strcmp (p->name, name)) -continue ;if (p->start > end) { p =NULL ;break ;@@ -411,7 +408,7 @@ int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, orig_end = res.end;while ((res.start < res.end) && - (!find_next_iomem_res (&res, desc,NULL , false))) { + (!find_next_iomem_res (&res, desc, false))) { ret = (*func)(res.start, res.end, arg);if (ret)break ;@@ -423,42 +420,6 @@ int walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, }/* -* Walks through iomem resources and calls func() with matching resource -* ranges. This walks through whole tree and not just first level children. -* All the memory ranges which overlap start,end and also match flags and -* name are valid candidates. -* -* @name: name of resource -* @flags: resource flags -* @start: start addr -* @end: end addr -* -* NOTE: This function is deprecated and should not be used in new code. -* Use walk_iomem_res_desc(), instead. -*/ -int walk_iomem_res (char *name,unsigned long flags,u64 start,u64 end, -void *arg,int (*func)(u64 ,u64 ,void *)) -{ -struct resource res; -u64 orig_end; -int ret =-1 ; - - res.start = start; - res.end = end; - res.flags = flags; - orig_end = res.end; -while ((res.start < res.end) && - (!find_next_iomem_res (&res,IORES_DESC_NONE , name, false))) { - ret = (*func)(res.start, res.end, arg); -if (ret) -break ; - res.start = res.end +1 ; - res.end = orig_end; - } -return ret; -} - -/* * This function calls callback against all memory range of System RAM * which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY. * Now, this function is only for System RAM. This function deals with @@ -477,7 +438,7 @@ int walk_system_ram_res(u64 start, u64 end, void *arg, res.flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; orig_end = res.end;while ((res.start < res.end) && - (!find_next_iomem_res (&res,IORES_DESC_NONE ,NULL , true))) { + (!find_next_iomem_res (&res,IORES_DESC_NONE , true))) { ret = (*func)(res.start, res.end, arg);if (ret)break ;
kernel/resource.c int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, · line 474
Quoted 8 lines
kernel/resource.c +1
-1@@ -507,7 +468,7 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, res.flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; orig_end = res.end;while ((res.start < res.end) && - (find_next_iomem_res (&res,IORES_DESC_NONE ,NULL , true) >=0 )) { + (find_next_iomem_res (&res,IORES_DESC_NONE , true) >=0 )) { pfn = (res.start +PAGE_SIZE -1 ) >>PAGE_SHIFT ; end_pfn = (res.end +1 ) >>PAGE_SHIFT ;if (end_pfn > pfn)
Thanks
Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v3 17/17 ACPI/EINJ: Allow memory error injection to NVDIMM
In reply to Toshi KaniIn the case of memory error injection, einj_error_inject() checks if a target address is System RAM. Change this check to allow injecting a memory error to NVDIMM by calling region_intersects() with IORES_DESC_PERSISTENT_MEMORY. This enables memory error testing on both System RAM and NVDIMM.
In addition, page_is_ram() is replaced with region_intersects() with IORESOURCE_SYSTEM_RAM, so that it can verify a target address range with the requested size.
--- drivers/acpi/apei/einj.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/acpi/apei/einj.c +11 -4
@@ -519,7 +519,7 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, u64 param4) { int rc; -unsigned long pfn; +u64 base_addr, size;/* If user manually set "flags", make sure it is legal */ if (flags && (flags &
@@ -545,10 +545,17 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,/* * Disallow crazy address masks that give BIOS leeway to pick * injection address almost anywhere. Insist on page or -* better granularity and that target address is normal RAM. +* better granularity and that target address is normal RAM or +* NVDIMM. */ - pfn =PFN_DOWN (param1 & param2); -if (!page_is_ram (pfn) || ((param2 &PAGE_MASK ) !=PAGE_MASK )) + base_addr = param1 & param2; + size = ~param2 +1 ; + +if (((param2 &PAGE_MASK ) !=PAGE_MASK ) || + ((region_intersects (base_addr, size,IORESOURCE_SYSTEM_RAM , +IORES_DESC_NONE ) !=REGION_INTERSECTS ) && + (region_intersects (base_addr, size,IORESOURCE_MEM , +IORES_DESC_PERSISTENT_MEMORY ) !=REGION_INTERSECTS )))return -EINVAL ; inject: