.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2004, 2013 Intel Corporation |
---|
3 | 4 | * Author: Naveen B S <naveen.b.s@intel.com> |
---|
4 | 5 | * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> |
---|
5 | 6 | * |
---|
6 | 7 | * 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. |
---|
18 | 8 | * |
---|
19 | 9 | * ACPI based HotPlug driver that supports Memory Hotplug |
---|
20 | 10 | * This driver fields notifications from firmware for memory add |
---|
.. | .. |
---|
32 | 22 | #define ACPI_MEMORY_DEVICE_HID "PNP0C80" |
---|
33 | 23 | #define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device" |
---|
34 | 24 | |
---|
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 | | - |
---|
42 | 25 | static const struct acpi_device_id memory_device_ids[] = { |
---|
43 | 26 | {ACPI_MEMORY_DEVICE_HID, 0}, |
---|
44 | 27 | {"", 0}, |
---|
45 | 28 | }; |
---|
46 | 29 | |
---|
47 | 30 | #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 |
---|
53 | 31 | |
---|
54 | 32 | static int acpi_memory_device_add(struct acpi_device *device, |
---|
55 | 33 | const struct acpi_device_id *not_used); |
---|
.. | .. |
---|
74 | 52 | }; |
---|
75 | 53 | |
---|
76 | 54 | struct acpi_memory_device { |
---|
77 | | - struct acpi_device * device; |
---|
78 | | - unsigned int state; /* State of the memory device */ |
---|
| 55 | + struct acpi_device *device; |
---|
79 | 56 | struct list_head res_list; |
---|
80 | 57 | }; |
---|
81 | 58 | |
---|
.. | .. |
---|
165 | 142 | return 0; |
---|
166 | 143 | } |
---|
167 | 144 | |
---|
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 | | - |
---|
178 | 145 | static int acpi_bind_memblk(struct memory_block *mem, void *arg) |
---|
179 | 146 | { |
---|
180 | 147 | return acpi_bind_one(&mem->dev, arg); |
---|
.. | .. |
---|
183 | 150 | static int acpi_bind_memory_blocks(struct acpi_memory_info *info, |
---|
184 | 151 | struct acpi_device *adev) |
---|
185 | 152 | { |
---|
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); |
---|
189 | 155 | } |
---|
190 | 156 | |
---|
191 | 157 | static int acpi_unbind_memblk(struct memory_block *mem, void *arg) |
---|
.. | .. |
---|
196 | 162 | |
---|
197 | 163 | static void acpi_unbind_memory_blocks(struct acpi_memory_info *info) |
---|
198 | 164 | { |
---|
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); |
---|
201 | 167 | } |
---|
202 | 168 | |
---|
203 | 169 | static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) |
---|
.. | .. |
---|
228 | 194 | if (node < 0) |
---|
229 | 195 | node = memory_add_physaddr_to_nid(info->start_addr); |
---|
230 | 196 | |
---|
231 | | - result = __add_memory(node, info->start_addr, info->length); |
---|
| 197 | + result = __add_memory(node, info->start_addr, info->length, |
---|
| 198 | + MHP_NONE); |
---|
232 | 199 | |
---|
233 | 200 | /* |
---|
234 | 201 | * If the memory block has been used by the kernel, add_memory() |
---|
.. | .. |
---|
254 | 221 | } |
---|
255 | 222 | if (!num_enabled) { |
---|
256 | 223 | dev_err(&mem_device->device->dev, "add_memory failed\n"); |
---|
257 | | - mem_device->state = MEMORY_INVALID_STATE; |
---|
258 | 224 | return -EINVAL; |
---|
259 | 225 | } |
---|
260 | 226 | /* |
---|
.. | .. |
---|
324 | 290 | kfree(mem_device); |
---|
325 | 291 | return result; |
---|
326 | 292 | } |
---|
327 | | - |
---|
328 | | - /* Set the device state */ |
---|
329 | | - mem_device->state = MEMORY_POWER_ON_STATE; |
---|
330 | 293 | |
---|
331 | 294 | result = acpi_memory_check_device(mem_device); |
---|
332 | 295 | if (result) { |
---|