hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/acpi/acpi_memhotplug.c
....@@ -1,20 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2004, 2013 Intel Corporation
34 * Author: Naveen B S <naveen.b.s@intel.com>
45 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
56 *
67 * All rights reserved.
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or (at
11
- * your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful, but
14
- * WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
16
- * NON INFRINGEMENT. See the GNU General Public License for more
17
- * details.
188 *
199 * ACPI based HotPlug driver that supports Memory Hotplug
2010 * This driver fields notifications from firmware for memory add
....@@ -32,24 +22,12 @@
3222 #define ACPI_MEMORY_DEVICE_HID "PNP0C80"
3323 #define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device"
3424
35
-#define _COMPONENT ACPI_MEMORY_DEVICE_COMPONENT
36
-
37
-#undef PREFIX
38
-#define PREFIX "ACPI:memory_hp:"
39
-
40
-ACPI_MODULE_NAME("acpi_memhotplug");
41
-
4225 static const struct acpi_device_id memory_device_ids[] = {
4326 {ACPI_MEMORY_DEVICE_HID, 0},
4427 {"", 0},
4528 };
4629
4730 #ifdef CONFIG_ACPI_HOTPLUG_MEMORY
48
-
49
-/* Memory Device States */
50
-#define MEMORY_INVALID_STATE 0
51
-#define MEMORY_POWER_ON_STATE 1
52
-#define MEMORY_POWER_OFF_STATE 2
5331
5432 static int acpi_memory_device_add(struct acpi_device *device,
5533 const struct acpi_device_id *not_used);
....@@ -74,8 +52,7 @@
7452 };
7553
7654 struct acpi_memory_device {
77
- struct acpi_device * device;
78
- unsigned int state; /* State of the memory device */
55
+ struct acpi_device *device;
7956 struct list_head res_list;
8057 };
8158
....@@ -165,16 +142,6 @@
165142 return 0;
166143 }
167144
168
-static unsigned long acpi_meminfo_start_pfn(struct acpi_memory_info *info)
169
-{
170
- return PFN_DOWN(info->start_addr);
171
-}
172
-
173
-static unsigned long acpi_meminfo_end_pfn(struct acpi_memory_info *info)
174
-{
175
- return PFN_UP(info->start_addr + info->length-1);
176
-}
177
-
178145 static int acpi_bind_memblk(struct memory_block *mem, void *arg)
179146 {
180147 return acpi_bind_one(&mem->dev, arg);
....@@ -183,9 +150,8 @@
183150 static int acpi_bind_memory_blocks(struct acpi_memory_info *info,
184151 struct acpi_device *adev)
185152 {
186
- return walk_memory_range(acpi_meminfo_start_pfn(info),
187
- acpi_meminfo_end_pfn(info), adev,
188
- acpi_bind_memblk);
153
+ return walk_memory_blocks(info->start_addr, info->length, adev,
154
+ acpi_bind_memblk);
189155 }
190156
191157 static int acpi_unbind_memblk(struct memory_block *mem, void *arg)
....@@ -196,8 +162,8 @@
196162
197163 static void acpi_unbind_memory_blocks(struct acpi_memory_info *info)
198164 {
199
- walk_memory_range(acpi_meminfo_start_pfn(info),
200
- acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk);
165
+ walk_memory_blocks(info->start_addr, info->length, NULL,
166
+ acpi_unbind_memblk);
201167 }
202168
203169 static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
....@@ -228,7 +194,8 @@
228194 if (node < 0)
229195 node = memory_add_physaddr_to_nid(info->start_addr);
230196
231
- result = __add_memory(node, info->start_addr, info->length);
197
+ result = __add_memory(node, info->start_addr, info->length,
198
+ MHP_NONE);
232199
233200 /*
234201 * If the memory block has been used by the kernel, add_memory()
....@@ -254,7 +221,6 @@
254221 }
255222 if (!num_enabled) {
256223 dev_err(&mem_device->device->dev, "add_memory failed\n");
257
- mem_device->state = MEMORY_INVALID_STATE;
258224 return -EINVAL;
259225 }
260226 /*
....@@ -324,9 +290,6 @@
324290 kfree(mem_device);
325291 return result;
326292 }
327
-
328
- /* Set the device state */
329
- mem_device->state = MEMORY_POWER_ON_STATE;
330293
331294 result = acpi_memory_check_device(mem_device);
332295 if (result) {