* [RFC:PATCH(001/003)] Memory add to onlined node.(Node id search by acpi's dsdt)
@ 2006-02-06 13:37 Yasunori Goto
2006-02-09 7:06 ` [RFC:PATCH(001/003)] Memory add to onlined node (ver. 2) (Node " Yasunori Goto
0 siblings, 1 reply; 2+ messages in thread
From: Yasunori Goto @ 2006-02-06 13:37 UTC (permalink / raw)
To: Tolentino, Matthew E, Brown, Len, naveen.b.s, Luck, Tony,
Andi Kleen
Cc: Linux Kernel ML, ACPI-ML, linux-ia64, x86-64 Discuss
This is to find node id from physical address via acpi's DSDT.
The acpi_memhotplug driver searches its handle of memory block
in DSDT by paddr, and gets pxm.
Then it translates pxm to node id.
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Index: node_add2/drivers/acpi/acpi_memhotplug.c
=================================--- node_add2.orig/drivers/acpi/acpi_memhotplug.c 2006-02-03 19:25:39.000000000 +0900
+++ node_add2/drivers/acpi/acpi_memhotplug.c 2006-02-03 21:23:46.000000000 +0900
@@ -471,6 +471,78 @@ acpi_memory_deregister_notify_handler(ac
return_ACPI_STATUS(status);
}
+struct find_memdevice_arg{
+ u64 start_addr;
+ u64 size;
+};
+
+acpi_status
+acpi_memory_match_paddr_to_memdevice(acpi_handle handle, u32 lvl, void *context, void **retv)
+{
+ acpi_status status;
+ struct acpi_device *device = NULL;
+ struct find_memdevice_arg *arg = context;
+ struct acpi_memory_device *mem_device = NULL;
+
+ ACPI_FUNCTION_TRACE("acpi_memory_match_paddr_to_memdevice\n");
+
+ status = is_memory_device(handle);
+ if (ACPI_FAILURE(status))
+ return_ACPI_STATUS(AE_OK); /* Not memory device. continue */
+
+ if (acpi_bus_get_device(handle, &device) || !device)
+ return_ACPI_STATUS(AE_OK); /* Device is not attached. continue */
+
+ mem_device = acpi_driver_data(device);
+ if ((status = acpi_memory_check_device(mem_device)) < 0)
+ return_ACPI_STATUS(AE_OK); /* Not online. continue */
+
+ if (mem_device->start_addr > arg->start_addr ||
+ mem_device->end_addr + 1 < arg->start_addr + arg->size)
+ return_ACPI_STATUS(AE_OK); /* Not match. continue */
+
+ *retv = (void *)mem_device;
+
+ return_ACPI_STATUS(AE_CTRL_TERMINATE);
+}
+
+static int
+acpi_memory_find_memdevice(u64 start_addr, u64 size,
+ struct acpi_memory_device **mem_device)
+{
+ acpi_status status;
+ struct find_memdevice_arg arg;
+
+ ACPI_FUNCTION_TRACE("acpi_memory_find_memdevice\n");
+
+ arg.start_addr = start_addr;
+ arg.size = size;
+
+ status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX,
+ acpi_memory_match_paddr_to_memdevice,
+ (void *)&arg, (void **)mem_device);
+
+ if (ACPI_FAILURE(status)) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace_failed at acpi_memory_fine_memdevice\n"));
+ return_VALUE(-ENODEV);
+ }
+ return_VALUE(0);
+}
+
+int
+acpi_paddr_to_node(u64 start_addr, u64 size)
+{
+ struct acpi_memory_device *mem_device;
+ int node = -1;
+ ACPI_FUNCTION_TRACE("acpi_paddr_to_node\n");
+
+ if (!acpi_memory_find_memdevice(start_addr, size, &mem_device))
+ node = acpi_get_node(mem_device->handle);
+
+ return_VALUE(node);
+}
+
static int __init acpi_memory_device_init(void)
{
int result;
Index: node_add2/drivers/acpi/numa.c
=================================--- node_add2.orig/drivers/acpi/numa.c 2006-02-03 19:25:39.000000000 +0900
+++ node_add2/drivers/acpi/numa.c 2006-02-03 21:10:25.000000000 +0900
@@ -258,3 +258,18 @@ int acpi_get_pxm(acpi_handle h)
}
EXPORT_SYMBOL(acpi_get_pxm);
+
+int acpi_get_node(acpi_handle *handle)
+{
+ int pxm, node = -1;
+
+ ACPI_FUNCTION_TRACE("acpi_get_node");
+
+ pxm = acpi_get_pxm(handle);
+ if (pxm >= 0)
+ node = acpi_map_pxm_to_node(pxm);
+
+ return_VALUE(node);
+}
+
+EXPORT_SYMBOL(acpi_get_node);
Index: node_add2/include/linux/acpi.h
=================================--- node_add2.orig/include/linux/acpi.h 2006-02-03 19:25:45.000000000 +0900
+++ node_add2/include/linux/acpi.h 2006-02-03 21:34:58.000000000 +0900
@@ -529,12 +529,18 @@ static inline void acpi_set_cstate_limit
#ifdef CONFIG_ACPI_NUMA
int acpi_get_pxm(acpi_handle handle);
+int acpi_get_node(acpi_handle *handle);
#else
static inline int acpi_get_pxm(acpi_handle handle)
{
return 0;
}
+static inline int acpi_get_node(acpi_handle *handle)
+{
+ return 0;
+}
#endif
+extern int acpi_paddr_to_node(u64 start_addr, u64 size);
extern int pnpacpi_disabled;
--
Yasunori Goto
^ permalink raw reply [flat|nested] 2+ messages in thread
* [RFC:PATCH(001/003)] Memory add to onlined node (ver. 2) (Node id search by acpi's dsdt)
2006-02-06 13:37 [RFC:PATCH(001/003)] Memory add to onlined node.(Node id search by acpi's dsdt) Yasunori Goto
@ 2006-02-09 7:06 ` Yasunori Goto
0 siblings, 0 replies; 2+ messages in thread
From: Yasunori Goto @ 2006-02-09 7:06 UTC (permalink / raw)
To: Andi Kleen, Luck, Tony, Brown, Len, Tolentino, Matthew E,
naveen.b.s, Bjorn Helgaas
Cc: Linux Hotplug Memory Support, Linux Kernel ML, linux-ia64,
ACPI-ML, x86-64 Discuss
This is to find node id from physical address via acpi's DSDT.
The acpi_memhotplug driver searches its handle of memory block
in DSDT by paddr, and gets pxm.
Then it translates pxm to node id.
Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Index: node_simple3/drivers/acpi/acpi_memhotplug.c
=================================--- node_simple3.orig/drivers/acpi/acpi_memhotplug.c 2006-02-08 16:27:43.000000000 +0900
+++ node_simple3/drivers/acpi/acpi_memhotplug.c 2006-02-09 14:02:14.000000000 +0900
@@ -469,6 +469,93 @@ acpi_memory_deregister_notify_handler(ac
return_ACPI_STATUS(status);
}
+struct find_memdevice_arg{
+ u64 start_addr;
+ u64 size;
+};
+
+acpi_status
+acpi_memory_match_paddr_to_memdevice(acpi_handle handle, u32 lvl,
+ void *context, void **retv)
+{
+ acpi_status status;
+ struct acpi_device *device = NULL;
+ struct find_memdevice_arg *arg = context;
+ struct acpi_memory_device *mem_device = NULL;
+ unsigned long mem_dev_end, arg_end;
+
+ ACPI_FUNCTION_TRACE("acpi_memory_match_paddr_to_memdevice");
+
+ /* If this device is NOT memory device, continue to walk name space.*/
+ status = is_memory_device(handle);
+ if (ACPI_FAILURE(status))
+ return_ACPI_STATUS(AE_OK);
+
+ /* If the device is not attached. continue */
+ if (acpi_bus_get_device(handle, &device) || !device)
+ return_ACPI_STATUS(AE_OK);
+
+ /* If this mem_device is NOT online. continue */
+ mem_device = acpi_driver_data(device);
+ if ((status = acpi_memory_check_device(mem_device)) < 0)
+ return_ACPI_STATUS(AE_OK);
+
+ /* If this mem_device doesn't match target, continue.*/
+ mem_dev_end = mem_device->start_addr + mem_device->length;
+ arg_end = arg->start_addr + arg->size;
+ if (mem_device->start_addr > arg->start_addr || mem_dev_end < arg_end)
+ return_ACPI_STATUS(AE_OK);
+
+ /* Ok. We could get mem_device for this physical memory. */
+ *retv = (void *)mem_device;
+
+ return_ACPI_STATUS(AE_CTRL_TERMINATE);
+}
+
+static int
+acpi_memory_find_memdevice(u64 start_addr, u64 size,
+ struct acpi_memory_device **mem_device)
+{
+ acpi_status status;
+ struct find_memdevice_arg arg;
+
+ ACPI_FUNCTION_TRACE("acpi_memory_find_memdevice");
+
+ arg.start_addr = start_addr;
+ arg.size = size;
+
+ status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX,
+ acpi_memory_match_paddr_to_memdevice,
+ (void *)&arg, (void **)mem_device);
+
+ if (ACPI_FAILURE(status)) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "walk_namespace_failed at acpi_memory_fine_memdevice"));
+ return_VALUE(-ENODEV);
+ }
+ return_VALUE(0);
+}
+
+/*
+ * acpi_paddr_to_node():
+ * Helper function to find which node the physical memory
+ * belongs to via DSDT.
+ */
+
+int
+acpi_paddr_to_node(u64 start_addr, u64 size)
+{
+ struct acpi_memory_device *mem_device;
+ int node = -1;
+ ACPI_FUNCTION_TRACE("acpi_paddr_to_node");
+
+ if (!acpi_memory_find_memdevice(start_addr, size, &mem_device))
+ node = acpi_get_node(mem_device->handle);
+
+ return_VALUE(node);
+}
+
static int __init acpi_memory_device_init(void)
{
int result;
Index: node_simple3/drivers/acpi/numa.c
=================================--- node_simple3.orig/drivers/acpi/numa.c 2006-02-08 16:27:43.000000000 +0900
+++ node_simple3/drivers/acpi/numa.c 2006-02-09 15:17:25.000000000 +0900
@@ -258,3 +258,18 @@ int acpi_get_pxm(acpi_handle h)
}
EXPORT_SYMBOL(acpi_get_pxm);
+
+int acpi_get_node(acpi_handle *handle)
+{
+ int pxm, node = -1;
+
+ ACPI_FUNCTION_TRACE("acpi_get_node");
+
+ pxm = acpi_get_pxm(handle);
+ if (pxm >= 0)
+ node = pxm_to_node(pxm);
+
+ return_VALUE(node);
+}
+
+EXPORT_SYMBOL(acpi_get_node);
Index: node_simple3/include/linux/acpi.h
=================================--- node_simple3.orig/include/linux/acpi.h 2006-02-08 16:27:45.000000000 +0900
+++ node_simple3/include/linux/acpi.h 2006-02-08 16:28:17.000000000 +0900
@@ -529,12 +529,18 @@ static inline void acpi_set_cstate_limit
#ifdef CONFIG_ACPI_NUMA
int acpi_get_pxm(acpi_handle handle);
+int acpi_get_node(acpi_handle *handle);
#else
static inline int acpi_get_pxm(acpi_handle handle)
{
return 0;
}
+static inline int acpi_get_node(acpi_handle *handle)
+{
+ return 0;
+}
#endif
+extern int acpi_paddr_to_node(u64 start_addr, u64 size);
extern int pnpacpi_disabled;
--
Yasunori Goto
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-09 7:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-06 13:37 [RFC:PATCH(001/003)] Memory add to onlined node.(Node id search by acpi's dsdt) Yasunori Goto
2006-02-09 7:06 ` [RFC:PATCH(001/003)] Memory add to onlined node (ver. 2) (Node " Yasunori Goto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox