Skip to content

Commit 6085bc9

Browse files
committed
Merge tag 'dax-fixes-6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull dax fixes from Dan Williams: "A few bug fixes around the handling of "Soft Reserved" memory and memory tiering information. Linux is starting to enounter more real world systems that deploy an ACPI HMAT to describe different performance classes of memory, as well the "special purpose" (Linux "Soft Reserved") designation from EFI. These fixes result from that testing. It has all appeared in -next for a while with no known issues. - Fix duplicate overlapping device-dax instances for HMAT described "Soft Reserved" Memory - Fix missing node targets in the sysfs representation of memory tiers - Remove a confusing variable initialization" * tag 'dax-fixes-6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: device-dax: Fix duplicate 'hmem' device registration ACPI: HMAT: Fix initiator registration for single-initiator systems ACPI: HMAT: remove unnecessary variable initialization
2 parents 97ee9d1 + 472faf7 commit 6085bc9

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

drivers/acpi/numa/hmat.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -562,17 +562,26 @@ static int initiator_cmp(void *priv, const struct list_head *a,
562562
{
563563
struct memory_initiator *ia;
564564
struct memory_initiator *ib;
565-
unsigned long *p_nodes = priv;
566565

567566
ia = list_entry(a, struct memory_initiator, node);
568567
ib = list_entry(b, struct memory_initiator, node);
569568

570-
set_bit(ia->processor_pxm, p_nodes);
571-
set_bit(ib->processor_pxm, p_nodes);
572-
573569
return ia->processor_pxm - ib->processor_pxm;
574570
}
575571

572+
static int initiators_to_nodemask(unsigned long *p_nodes)
573+
{
574+
struct memory_initiator *initiator;
575+
576+
if (list_empty(&initiators))
577+
return -ENXIO;
578+
579+
list_for_each_entry(initiator, &initiators, node)
580+
set_bit(initiator->processor_pxm, p_nodes);
581+
582+
return 0;
583+
}
584+
576585
static void hmat_register_target_initiators(struct memory_target *target)
577586
{
578587
static DECLARE_BITMAP(p_nodes, MAX_NUMNODES);
@@ -609,7 +618,10 @@ static void hmat_register_target_initiators(struct memory_target *target)
609618
* initiators.
610619
*/
611620
bitmap_zero(p_nodes, MAX_NUMNODES);
612-
list_sort(p_nodes, &initiators, initiator_cmp);
621+
list_sort(NULL, &initiators, initiator_cmp);
622+
if (initiators_to_nodemask(p_nodes) < 0)
623+
return;
624+
613625
if (!access0done) {
614626
for (i = WRITE_LATENCY; i <= READ_BANDWIDTH; i++) {
615627
loc = localities_types[i];
@@ -643,8 +655,9 @@ static void hmat_register_target_initiators(struct memory_target *target)
643655

644656
/* Access 1 ignores Generic Initiators */
645657
bitmap_zero(p_nodes, MAX_NUMNODES);
646-
list_sort(p_nodes, &initiators, initiator_cmp);
647-
best = 0;
658+
if (initiators_to_nodemask(p_nodes) < 0)
659+
return;
660+
648661
for (i = WRITE_LATENCY; i <= READ_BANDWIDTH; i++) {
649662
loc = localities_types[i];
650663
if (!loc)

drivers/dax/hmem/device.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
static bool nohmem;
99
module_param_named(disable, nohmem, bool, 0444);
1010

11+
static struct resource hmem_active = {
12+
.name = "HMEM devices",
13+
.start = 0,
14+
.end = -1,
15+
.flags = IORESOURCE_MEM,
16+
};
17+
1118
void hmem_register_device(int target_nid, struct resource *r)
1219
{
1320
/* define a clean / non-busy resource for the platform device */
@@ -41,6 +48,12 @@ void hmem_register_device(int target_nid, struct resource *r)
4148
goto out_pdev;
4249
}
4350

51+
if (!__request_region(&hmem_active, res.start, resource_size(&res),
52+
dev_name(&pdev->dev), 0)) {
53+
dev_dbg(&pdev->dev, "hmem range %pr already active\n", &res);
54+
goto out_active;
55+
}
56+
4457
pdev->dev.numa_node = numa_map_to_online_node(target_nid);
4558
info = (struct memregion_info) {
4659
.target_node = target_nid,
@@ -66,22 +79,15 @@ void hmem_register_device(int target_nid, struct resource *r)
6679
return;
6780

6881
out_resource:
82+
__release_region(&hmem_active, res.start, resource_size(&res));
83+
out_active:
6984
platform_device_put(pdev);
7085
out_pdev:
7186
memregion_free(id);
7287
}
7388

7489
static __init int hmem_register_one(struct resource *res, void *data)
7590
{
76-
/*
77-
* If the resource is not a top-level resource it was already
78-
* assigned to a device by the HMAT parsing.
79-
*/
80-
if (res->parent != &iomem_resource) {
81-
pr_info("HMEM: skip %pr, already claimed\n", res);
82-
return 0;
83-
}
84-
8591
hmem_register_device(phys_to_target_node(res->start), res);
8692

8793
return 0;

0 commit comments

Comments
 (0)