region.c (e82a82c19f4272ea5437cc76e5711b98e2ee6223) region.c (f0c98ebc57c2d5e535bc4f9167f35650d2ba3c90)
1/*
2 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but

--- 6 unchanged lines hidden (view full) ---

15#include <linux/device.h>
16#include <linux/nd.h>
17#include "nd.h"
18
19static int nd_region_probe(struct device *dev)
20{
21 int err, rc;
22 static unsigned long once;
1/*
2 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but

--- 6 unchanged lines hidden (view full) ---

15#include <linux/device.h>
16#include <linux/nd.h>
17#include "nd.h"
18
19static int nd_region_probe(struct device *dev)
20{
21 int err, rc;
22 static unsigned long once;
23 struct nd_region_namespaces *num_ns;
23 struct nd_region_data *ndrd;
24 struct nd_region *nd_region = to_nd_region(dev);
25
26 if (nd_region->num_lanes > num_online_cpus()
27 && nd_region->num_lanes < num_possible_cpus()
28 && !test_and_set_bit(0, &once)) {
29 dev_info(dev, "online cpus (%d) < concurrent i/o lanes (%d) < possible cpus (%d)\n",
30 num_online_cpus(), nd_region->num_lanes,
31 num_possible_cpus());
32 dev_info(dev, "setting nr_cpus=%d may yield better libnvdimm device performance\n",
33 nd_region->num_lanes);
34 }
35
24 struct nd_region *nd_region = to_nd_region(dev);
25
26 if (nd_region->num_lanes > num_online_cpus()
27 && nd_region->num_lanes < num_possible_cpus()
28 && !test_and_set_bit(0, &once)) {
29 dev_info(dev, "online cpus (%d) < concurrent i/o lanes (%d) < possible cpus (%d)\n",
30 num_online_cpus(), nd_region->num_lanes,
31 num_possible_cpus());
32 dev_info(dev, "setting nr_cpus=%d may yield better libnvdimm device performance\n",
33 nd_region->num_lanes);
34 }
35
36 rc = nd_region_activate(nd_region);
37 if (rc)
38 return rc;
39
36 rc = nd_blk_region_init(nd_region);
37 if (rc)
38 return rc;
39
40 rc = nd_region_register_namespaces(nd_region, &err);
40 rc = nd_blk_region_init(nd_region);
41 if (rc)
42 return rc;
43
44 rc = nd_region_register_namespaces(nd_region, &err);
41 num_ns = devm_kzalloc(dev, sizeof(*num_ns), GFP_KERNEL);
42 if (!num_ns)
43 return -ENOMEM;
44
45 if (rc < 0)
46 return rc;
47
45 if (rc < 0)
46 return rc;
47
48 num_ns->active = rc;
49 num_ns->count = rc + err;
50 dev_set_drvdata(dev, num_ns);
48 ndrd = dev_get_drvdata(dev);
49 ndrd->ns_active = rc;
50 ndrd->ns_count = rc + err;
51
52 if (rc && err && rc == err)
53 return -ENODEV;
54
55 nd_region->btt_seed = nd_btt_create(nd_region);
56 nd_region->pfn_seed = nd_pfn_create(nd_region);
57 nd_region->dax_seed = nd_dax_create(nd_region);
58 if (err == 0)

--- 18 unchanged lines hidden (view full) ---

77 nd_device_unregister(dev, ND_SYNC);
78 return 0;
79}
80
81static int nd_region_remove(struct device *dev)
82{
83 struct nd_region *nd_region = to_nd_region(dev);
84
51
52 if (rc && err && rc == err)
53 return -ENODEV;
54
55 nd_region->btt_seed = nd_btt_create(nd_region);
56 nd_region->pfn_seed = nd_pfn_create(nd_region);
57 nd_region->dax_seed = nd_dax_create(nd_region);
58 if (err == 0)

--- 18 unchanged lines hidden (view full) ---

77 nd_device_unregister(dev, ND_SYNC);
78 return 0;
79}
80
81static int nd_region_remove(struct device *dev)
82{
83 struct nd_region *nd_region = to_nd_region(dev);
84
85 device_for_each_child(dev, NULL, child_unregister);
86
85 /* flush attribute readers and disable */
86 nvdimm_bus_lock(dev);
87 nd_region->ns_seed = NULL;
88 nd_region->btt_seed = NULL;
89 nd_region->pfn_seed = NULL;
90 nd_region->dax_seed = NULL;
91 dev_set_drvdata(dev, NULL);
92 nvdimm_bus_unlock(dev);
93
87 /* flush attribute readers and disable */
88 nvdimm_bus_lock(dev);
89 nd_region->ns_seed = NULL;
90 nd_region->btt_seed = NULL;
91 nd_region->pfn_seed = NULL;
92 nd_region->dax_seed = NULL;
93 dev_set_drvdata(dev, NULL);
94 nvdimm_bus_unlock(dev);
95
94 device_for_each_child(dev, NULL, child_unregister);
95 return 0;
96}
97
98static int child_notify(struct device *dev, void *data)
99{
100 nd_device_notify(dev, *(enum nvdimm_event *) data);
101 return 0;
102}

--- 28 unchanged lines hidden ---
96 return 0;
97}
98
99static int child_notify(struct device *dev, void *data)
100{
101 nd_device_notify(dev, *(enum nvdimm_event *) data);
102 return 0;
103}

--- 28 unchanged lines hidden ---