From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [cxl-cxl:pending 6/6] drivers/cxl/core/memdev.c:21:29: error: implicit declaration of function 'to_cxl_memdev'
Date: Sun, 01 Aug 2021 03:59:58 +0800 [thread overview]
Message-ID: <202108010356.p1fp7X3c-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 25608 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git pending
head: 13a47ea9e8feb1362eaf4601b5b40f7cea9174ff
commit: 13a47ea9e8feb1362eaf4601b5b40f7cea9174ff [6/6] cxl/core: Move memdev management to core
config: um-allmodconfig (attached as .config)
compiler: gcc-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git/commit/?id=13a47ea9e8feb1362eaf4601b5b40f7cea9174ff
git remote add cxl-cxl https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git
git fetch --no-tags cxl-cxl pending
git checkout 13a47ea9e8feb1362eaf4601b5b40f7cea9174ff
# save the attached .config to linux build tree
make W=1 ARCH=um
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All error/warnings (new ones prefixed by >>):
drivers/cxl/core/memdev.c: In function 'cxl_memdev_release':
>> drivers/cxl/core/memdev.c:21:29: error: implicit declaration of function 'to_cxl_memdev' [-Werror=implicit-function-declaration]
21 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
>> drivers/cxl/core/memdev.c:21:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
>> drivers/cxl/core/memdev.c:23:33: error: invalid use of undefined type 'struct cxl_memdev'
23 | ida_free(&cxl_memdev_ida, cxlmd->id);
| ^~
drivers/cxl/core/memdev.c: In function 'firmware_version_show':
drivers/cxl/core/memdev.c:36:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
36 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
drivers/cxl/core/memdev.c:37:30: error: invalid use of undefined type 'struct cxl_memdev'
37 | struct cxl_mem *cxlm = cxlmd->cxlm;
| ^~
>> drivers/cxl/core/memdev.c:39:40: error: invalid use of undefined type 'struct cxl_mem'
39 | return sysfs_emit(buf, "%.16s\n", cxlm->firmware_version);
| ^~
drivers/cxl/core/memdev.c: In function 'payload_max_show':
drivers/cxl/core/memdev.c:46:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
46 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
drivers/cxl/core/memdev.c:47:30: error: invalid use of undefined type 'struct cxl_memdev'
47 | struct cxl_mem *cxlm = cxlmd->cxlm;
| ^~
drivers/cxl/core/memdev.c:49:38: error: invalid use of undefined type 'struct cxl_mem'
49 | return sysfs_emit(buf, "%zu\n", cxlm->payload_size);
| ^~
drivers/cxl/core/memdev.c: In function 'label_storage_size_show':
drivers/cxl/core/memdev.c:56:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
56 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
drivers/cxl/core/memdev.c:57:30: error: invalid use of undefined type 'struct cxl_memdev'
57 | struct cxl_mem *cxlm = cxlmd->cxlm;
| ^~
drivers/cxl/core/memdev.c:59:38: error: invalid use of undefined type 'struct cxl_mem'
59 | return sysfs_emit(buf, "%zu\n", cxlm->lsa_size);
| ^~
drivers/cxl/core/memdev.c: In function 'ram_size_show':
drivers/cxl/core/memdev.c:66:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
66 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
drivers/cxl/core/memdev.c:67:30: error: invalid use of undefined type 'struct cxl_memdev'
67 | struct cxl_mem *cxlm = cxlmd->cxlm;
| ^~
drivers/cxl/core/memdev.c:68:42: error: invalid use of undefined type 'struct cxl_mem'
68 | unsigned long long len = range_len(&cxlm->ram_range);
| ^~
drivers/cxl/core/memdev.c: In function 'pmem_size_show':
drivers/cxl/core/memdev.c:79:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
79 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
drivers/cxl/core/memdev.c:80:30: error: invalid use of undefined type 'struct cxl_memdev'
80 | struct cxl_mem *cxlm = cxlmd->cxlm;
| ^~
drivers/cxl/core/memdev.c:81:42: error: invalid use of undefined type 'struct cxl_mem'
81 | unsigned long long len = range_len(&cxlm->pmem_range);
| ^~
drivers/cxl/core/memdev.c: In function 'cxl_memdev_unregister':
drivers/cxl/core/memdev.c:137:29: error: invalid use of undefined type 'struct cxl_memdev'
137 | struct device *dev = &cxlmd->dev;
| ^~
drivers/cxl/core/memdev.c:138:28: error: invalid use of undefined type 'struct cxl_memdev'
138 | struct cdev *cdev = &cxlmd->cdev;
| ^~
In file included from include/linux/list.h:9,
from include/linux/rculist.h:10,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/ratelimit.h:6,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from drivers/cxl/core/memdev.c:4:
>> drivers/cxl/core/memdev.c:141:32: error: invalid use of undefined type 'struct cdev'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~
include/linux/kernel.h:494:26: note: in definition of macro 'container_of'
494 | void *__mptr = (void *)(ptr); \
| ^~~
In file included from <command-line>:
>> drivers/cxl/core/memdev.c:141:32: error: invalid use of undefined type 'struct cdev'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~
include/linux/compiler_types.h:308:9: note: in definition of macro '__compiletime_assert'
308 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:328:2: note: in expansion of macro '_compiletime_assert'
328 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/kernel.h:495:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~~~~~~
include/linux/kernel.h:495:20: note: in expansion of macro '__same_type'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~
drivers/cxl/core/memdev.c:141:15: note: in expansion of macro 'container_of'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~~~~~~~~~~~
>> include/linux/kernel.h:495:51: error: invalid use of undefined type 'const struct cdevm_file_operations'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~
include/linux/compiler_types.h:308:9: note: in definition of macro '__compiletime_assert'
308 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:328:2: note: in expansion of macro '_compiletime_assert'
328 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/kernel.h:495:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~~~~~~
include/linux/kernel.h:495:20: note: in expansion of macro '__same_type'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~
drivers/cxl/core/memdev.c:141:15: note: in expansion of macro 'container_of'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~~~~~~~~~~~
>> drivers/cxl/core/memdev.c:141:32: error: invalid use of undefined type 'struct cdev'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~
include/linux/compiler_types.h:308:9: note: in definition of macro '__compiletime_assert'
308 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:328:2: note: in expansion of macro '_compiletime_assert'
328 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/kernel.h:495:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~~~~~~
include/linux/kernel.h:496:6: note: in expansion of macro '__same_type'
496 | !__same_type(*(ptr), void), \
| ^~~~~~~~~~~
drivers/cxl/core/memdev.c:141:15: note: in expansion of macro 'container_of'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~~~~~~~~~~~
>> include/linux/compiler_types.h:140:35: error: invalid use of undefined type 'const struct cdevm_file_operations'
140 | #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
| ^~~~~~~~~~~~~~~~~~
include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
17 | #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
| ^~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:498:21: note: in expansion of macro 'offsetof'
498 | ((type *)(__mptr - offsetof(type, member))); })
| ^~~~~~~~
drivers/cxl/core/memdev.c:141:15: note: in expansion of macro 'container_of'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~~~~~~~~~~~
>> drivers/cxl/core/memdev.c:142:12: error: invalid use of undefined type 'const struct cdevm_file_operations'
142 | cdevm_fops->shutdown(dev);
| ^~
>> drivers/cxl/core/memdev.c:144:2: error: implicit declaration of function 'cdev_device_del'; did you mean 'device_del'? [-Werror=implicit-function-declaration]
144 | cdev_device_del(&cxlmd->cdev, dev);
| ^~~~~~~~~~~~~~~
| device_del
drivers/cxl/core/memdev.c:144:24: error: invalid use of undefined type 'struct cxl_memdev'
144 | cdev_device_del(&cxlmd->cdev, dev);
| ^~
drivers/cxl/core/memdev.c: At top level:
>> drivers/cxl/core/memdev.c:148:51: warning: 'struct cxl_mem' declared inside parameter list will not be visible outside of this definition or declaration
148 | static struct cxl_memdev *cxl_memdev_alloc(struct cxl_mem *cxlm,
| ^~~~~~~
drivers/cxl/core/memdev.c: In function 'cxl_memdev_alloc':
drivers/cxl/core/memdev.c:151:29: error: invalid use of undefined type 'struct cxl_mem'
151 | struct pci_dev *pdev = cxlm->pdev;
| ^~
>> drivers/cxl/core/memdev.c:157:24: error: invalid application of 'sizeof' to incomplete type 'struct cxl_memdev'
157 | cxlmd = kzalloc(sizeof(*cxlmd), GFP_KERNEL);
| ^
drivers/cxl/core/memdev.c:164:7: error: invalid use of undefined type 'struct cxl_memdev'
164 | cxlmd->id = rc;
| ^~
drivers/cxl/core/memdev.c:166:14: error: invalid use of undefined type 'struct cxl_memdev'
166 | dev = &cxlmd->dev;
| ^~
>> drivers/cxl/core/memdev.c:169:14: error: 'cxl_bus_type' undeclared (first use in this function); did you mean 'pci_bus_type'?
169 | dev->bus = &cxl_bus_type;
| ^~~~~~~~~~~~
| pci_bus_type
drivers/cxl/core/memdev.c:169:14: note: each undeclared identifier is reported only once for each function it appears in
In file included from include/linux/fs.h:7,
from include/linux/huge_mm.h:8,
from include/linux/mm.h:728,
from include/linux/scatterlist.h:8,
from include/linux/dmapool.h:14,
from include/linux/pci.h:1466,
from drivers/cxl/core/memdev.c:7:
drivers/cxl/core/memdev.c:170:40: error: invalid use of undefined type 'struct cxl_memdev'
170 | dev->devt = MKDEV(cxl_mem_major, cxlmd->id);
| ^~
include/linux/kdev_t.h:12:46: note: in definition of macro 'MKDEV'
12 | #define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
| ^~
drivers/cxl/core/memdev.c:174:15: error: invalid use of undefined type 'struct cxl_memdev'
174 | cdev = &cxlmd->cdev;
| ^~
>> drivers/cxl/core/memdev.c:175:2: error: implicit declaration of function 'cdev_init'; did you mean 'cred_init'? [-Werror=implicit-function-declaration]
175 | cdev_init(cdev, fops);
| ^~~~~~~~~
| cred_init
drivers/cxl/core/memdev.c: At top level:
>> drivers/cxl/core/memdev.c:185:20: warning: 'struct cdevm_file_operations' declared inside parameter list will not be visible outside of this definition or declaration
185 | const struct cdevm_file_operations *cdevm_fops)
| ^~~~~~~~~~~~~~~~~~~~~
drivers/cxl/core/memdev.c:184:49: warning: 'struct cxl_mem' declared inside parameter list will not be visible outside of this definition or declaration
184 | devm_cxl_add_memdev(struct device *host, struct cxl_mem *cxlm,
| ^~~~~~~
>> drivers/cxl/core/memdev.c:184:1: warning: no previous prototype for 'devm_cxl_add_memdev' [-Wmissing-prototypes]
184 | devm_cxl_add_memdev(struct device *host, struct cxl_mem *cxlm,
| ^~~~~~~~~~~~~~~~~~~
drivers/cxl/core/memdev.c: In function 'devm_cxl_add_memdev':
drivers/cxl/core/memdev.c:192:44: error: invalid use of undefined type 'const struct cdevm_file_operations'
192 | cxlmd = cxl_memdev_alloc(cxlm, &cdevm_fops->fops);
| ^~
>> drivers/cxl/core/memdev.c:192:27: error: passing argument 1 of 'cxl_memdev_alloc' from incompatible pointer type [-Werror=incompatible-pointer-types]
192 | cxlmd = cxl_memdev_alloc(cxlm, &cdevm_fops->fops);
| ^~~~
| |
| struct cxl_mem *
drivers/cxl/core/memdev.c:148:60: note: expected 'struct cxl_mem *' but argument is of type 'struct cxl_mem *'
148 | static struct cxl_memdev *cxl_memdev_alloc(struct cxl_mem *cxlm,
| ~~~~~~~~~~~~~~~~^~~~
drivers/cxl/core/memdev.c:196:14: error: invalid use of undefined type 'struct cxl_memdev'
196 | dev = &cxlmd->dev;
| ^~
drivers/cxl/core/memdev.c:197:39: error: invalid use of undefined type 'struct cxl_memdev'
197 | rc = dev_set_name(dev, "mem%d", cxlmd->id);
| ^~
drivers/cxl/core/memdev.c:205:7: error: invalid use of undefined type 'struct cxl_memdev'
205 | cxlmd->cxlm = cxlm;
| ^~
drivers/cxl/core/memdev.c:207:15: error: invalid use of undefined type 'struct cxl_memdev'
207 | cdev = &cxlmd->cdev;
| ^~
>> drivers/cxl/core/memdev.c:208:7: error: implicit declaration of function 'cdev_device_add'; did you mean 'pci_device_add'? [-Werror=implicit-function-declaration]
208 | rc = cdev_device_add(cdev, dev);
| ^~~~~~~~~~~~~~~
| pci_device_add
drivers/cxl/core/memdev.c:222:12: error: invalid use of undefined type 'const struct cdevm_file_operations'
222 | cdevm_fops->shutdown(dev);
| ^~
drivers/cxl/core/memdev.c: At top level:
>> drivers/cxl/core/memdev.c:228:12: warning: no previous prototype for 'cxl_memdev_init' [-Wmissing-prototypes]
228 | __init int cxl_memdev_init(void)
| ^~~~~~~~~~~~~~~
drivers/cxl/core/memdev.c:242:6: warning: no previous prototype for 'cxl_memdev_exit' [-Wmissing-prototypes]
242 | void cxl_memdev_exit(void)
| ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/to_cxl_memdev +21 drivers/cxl/core/memdev.c
3
> 4 #include <linux/device.h>
5 #include <linux/slab.h>
6 #include <linux/idr.h>
7 #include <linux/pci.h>
8 #include <mem.h>
9
10 /*
11 * An entire PCI topology full of devices should be enough for any
12 * config
13 */
14 #define CXL_MEM_MAX_DEVS 65536
15
16 static int cxl_mem_major;
17 static DEFINE_IDA(cxl_memdev_ida);
18
19 static void cxl_memdev_release(struct device *dev)
20 {
> 21 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
22
> 23 ida_free(&cxl_memdev_ida, cxlmd->id);
24 kfree(cxlmd);
25 }
26
27 static char *cxl_memdev_devnode(struct device *dev, umode_t *mode, kuid_t *uid,
28 kgid_t *gid)
29 {
30 return kasprintf(GFP_KERNEL, "cxl/%s", dev_name(dev));
31 }
32
33 static ssize_t firmware_version_show(struct device *dev,
34 struct device_attribute *attr, char *buf)
35 {
> 36 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
37 struct cxl_mem *cxlm = cxlmd->cxlm;
38
> 39 return sysfs_emit(buf, "%.16s\n", cxlm->firmware_version);
40 }
41 static DEVICE_ATTR_RO(firmware_version);
42
43 static ssize_t payload_max_show(struct device *dev,
44 struct device_attribute *attr, char *buf)
45 {
46 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
47 struct cxl_mem *cxlm = cxlmd->cxlm;
48
49 return sysfs_emit(buf, "%zu\n", cxlm->payload_size);
50 }
51 static DEVICE_ATTR_RO(payload_max);
52
53 static ssize_t label_storage_size_show(struct device *dev,
54 struct device_attribute *attr, char *buf)
55 {
56 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
57 struct cxl_mem *cxlm = cxlmd->cxlm;
58
59 return sysfs_emit(buf, "%zu\n", cxlm->lsa_size);
60 }
61 static DEVICE_ATTR_RO(label_storage_size);
62
63 static ssize_t ram_size_show(struct device *dev, struct device_attribute *attr,
64 char *buf)
65 {
66 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
67 struct cxl_mem *cxlm = cxlmd->cxlm;
68 unsigned long long len = range_len(&cxlm->ram_range);
69
70 return sysfs_emit(buf, "%#llx\n", len);
71 }
72
73 static struct device_attribute dev_attr_ram_size =
74 __ATTR(size, 0444, ram_size_show, NULL);
75
76 static ssize_t pmem_size_show(struct device *dev, struct device_attribute *attr,
77 char *buf)
78 {
79 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
80 struct cxl_mem *cxlm = cxlmd->cxlm;
81 unsigned long long len = range_len(&cxlm->pmem_range);
82
83 return sysfs_emit(buf, "%#llx\n", len);
84 }
85
86 static struct device_attribute dev_attr_pmem_size =
87 __ATTR(size, 0444, pmem_size_show, NULL);
88
89 static struct attribute *cxl_memdev_attributes[] = {
90 &dev_attr_firmware_version.attr,
91 &dev_attr_payload_max.attr,
92 &dev_attr_label_storage_size.attr,
93 NULL,
94 };
95
96 static struct attribute *cxl_memdev_pmem_attributes[] = {
97 &dev_attr_pmem_size.attr,
98 NULL,
99 };
100
101 static struct attribute *cxl_memdev_ram_attributes[] = {
102 &dev_attr_ram_size.attr,
103 NULL,
104 };
105
106 static struct attribute_group cxl_memdev_attribute_group = {
107 .attrs = cxl_memdev_attributes,
108 };
109
110 static struct attribute_group cxl_memdev_ram_attribute_group = {
111 .name = "ram",
112 .attrs = cxl_memdev_ram_attributes,
113 };
114
115 static struct attribute_group cxl_memdev_pmem_attribute_group = {
116 .name = "pmem",
117 .attrs = cxl_memdev_pmem_attributes,
118 };
119
120 static const struct attribute_group *cxl_memdev_attribute_groups[] = {
121 &cxl_memdev_attribute_group,
122 &cxl_memdev_ram_attribute_group,
123 &cxl_memdev_pmem_attribute_group,
124 NULL,
125 };
126
127 static const struct device_type cxl_memdev_type = {
128 .name = "cxl_memdev",
129 .release = cxl_memdev_release,
130 .devnode = cxl_memdev_devnode,
131 .groups = cxl_memdev_attribute_groups,
132 };
133
134 static void cxl_memdev_unregister(void *_cxlmd)
135 {
136 struct cxl_memdev *cxlmd = _cxlmd;
137 struct device *dev = &cxlmd->dev;
138 struct cdev *cdev = &cxlmd->cdev;
139 const struct cdevm_file_operations *cdevm_fops;
140
> 141 cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
> 142 cdevm_fops->shutdown(dev);
143
> 144 cdev_device_del(&cxlmd->cdev, dev);
145 put_device(dev);
146 }
147
> 148 static struct cxl_memdev *cxl_memdev_alloc(struct cxl_mem *cxlm,
149 const struct file_operations *fops)
150 {
151 struct pci_dev *pdev = cxlm->pdev;
152 struct cxl_memdev *cxlmd;
153 struct device *dev;
154 struct cdev *cdev;
155 int rc;
156
> 157 cxlmd = kzalloc(sizeof(*cxlmd), GFP_KERNEL);
158 if (!cxlmd)
159 return ERR_PTR(-ENOMEM);
160
161 rc = ida_alloc_range(&cxl_memdev_ida, 0, CXL_MEM_MAX_DEVS, GFP_KERNEL);
162 if (rc < 0)
163 goto err;
164 cxlmd->id = rc;
165
166 dev = &cxlmd->dev;
167 device_initialize(dev);
168 dev->parent = &pdev->dev;
> 169 dev->bus = &cxl_bus_type;
> 170 dev->devt = MKDEV(cxl_mem_major, cxlmd->id);
171 dev->type = &cxl_memdev_type;
172 device_set_pm_not_required(dev);
173
> 174 cdev = &cxlmd->cdev;
> 175 cdev_init(cdev, fops);
176 return cxlmd;
177
178 err:
179 kfree(cxlmd);
180 return ERR_PTR(rc);
181 }
182
183 struct cxl_memdev *
> 184 devm_cxl_add_memdev(struct device *host, struct cxl_mem *cxlm,
> 185 const struct cdevm_file_operations *cdevm_fops)
186 {
187 struct cxl_memdev *cxlmd;
188 struct device *dev;
189 struct cdev *cdev;
190 int rc;
191
> 192 cxlmd = cxl_memdev_alloc(cxlm, &cdevm_fops->fops);
193 if (IS_ERR(cxlmd))
194 return cxlmd;
195
196 dev = &cxlmd->dev;
> 197 rc = dev_set_name(dev, "mem%d", cxlmd->id);
198 if (rc)
199 goto err;
200
201 /*
202 * Activate ioctl operations, no cxl_memdev_rwsem manipulation
203 * needed as this is ordered with cdev_add() publishing the device.
204 */
205 cxlmd->cxlm = cxlm;
206
207 cdev = &cxlmd->cdev;
> 208 rc = cdev_device_add(cdev, dev);
209 if (rc)
210 goto err;
211
212 rc = devm_add_action_or_reset(host, cxl_memdev_unregister, cxlmd);
213 if (rc)
214 return ERR_PTR(rc);
215 return cxlmd;
216
217 err:
218 /*
219 * The cdev was briefly live, shutdown any ioctl operations that
220 * saw that state.
221 */
222 cdevm_fops->shutdown(dev);
223 put_device(dev);
224 return ERR_PTR(rc);
225 }
226 EXPORT_SYMBOL_GPL(devm_cxl_add_memdev);
227
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 62334 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: Ben Widawsky <ben.widawsky@intel.com>
Cc: kbuild-all@lists.01.org,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Ben Widawsky <ben.widawsky@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
linux-kernel@vger.kernel.org
Subject: [cxl-cxl:pending 6/6] drivers/cxl/core/memdev.c:21:29: error: implicit declaration of function 'to_cxl_memdev'
Date: Sun, 1 Aug 2021 03:59:58 +0800 [thread overview]
Message-ID: <202108010356.p1fp7X3c-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 25099 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git pending
head: 13a47ea9e8feb1362eaf4601b5b40f7cea9174ff
commit: 13a47ea9e8feb1362eaf4601b5b40f7cea9174ff [6/6] cxl/core: Move memdev management to core
config: um-allmodconfig (attached as .config)
compiler: gcc-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git/commit/?id=13a47ea9e8feb1362eaf4601b5b40f7cea9174ff
git remote add cxl-cxl https://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl.git
git fetch --no-tags cxl-cxl pending
git checkout 13a47ea9e8feb1362eaf4601b5b40f7cea9174ff
# save the attached .config to linux build tree
make W=1 ARCH=um
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All error/warnings (new ones prefixed by >>):
drivers/cxl/core/memdev.c: In function 'cxl_memdev_release':
>> drivers/cxl/core/memdev.c:21:29: error: implicit declaration of function 'to_cxl_memdev' [-Werror=implicit-function-declaration]
21 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
>> drivers/cxl/core/memdev.c:21:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
>> drivers/cxl/core/memdev.c:23:33: error: invalid use of undefined type 'struct cxl_memdev'
23 | ida_free(&cxl_memdev_ida, cxlmd->id);
| ^~
drivers/cxl/core/memdev.c: In function 'firmware_version_show':
drivers/cxl/core/memdev.c:36:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
36 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
drivers/cxl/core/memdev.c:37:30: error: invalid use of undefined type 'struct cxl_memdev'
37 | struct cxl_mem *cxlm = cxlmd->cxlm;
| ^~
>> drivers/cxl/core/memdev.c:39:40: error: invalid use of undefined type 'struct cxl_mem'
39 | return sysfs_emit(buf, "%.16s\n", cxlm->firmware_version);
| ^~
drivers/cxl/core/memdev.c: In function 'payload_max_show':
drivers/cxl/core/memdev.c:46:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
46 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
drivers/cxl/core/memdev.c:47:30: error: invalid use of undefined type 'struct cxl_memdev'
47 | struct cxl_mem *cxlm = cxlmd->cxlm;
| ^~
drivers/cxl/core/memdev.c:49:38: error: invalid use of undefined type 'struct cxl_mem'
49 | return sysfs_emit(buf, "%zu\n", cxlm->payload_size);
| ^~
drivers/cxl/core/memdev.c: In function 'label_storage_size_show':
drivers/cxl/core/memdev.c:56:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
56 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
drivers/cxl/core/memdev.c:57:30: error: invalid use of undefined type 'struct cxl_memdev'
57 | struct cxl_mem *cxlm = cxlmd->cxlm;
| ^~
drivers/cxl/core/memdev.c:59:38: error: invalid use of undefined type 'struct cxl_mem'
59 | return sysfs_emit(buf, "%zu\n", cxlm->lsa_size);
| ^~
drivers/cxl/core/memdev.c: In function 'ram_size_show':
drivers/cxl/core/memdev.c:66:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
66 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
drivers/cxl/core/memdev.c:67:30: error: invalid use of undefined type 'struct cxl_memdev'
67 | struct cxl_mem *cxlm = cxlmd->cxlm;
| ^~
drivers/cxl/core/memdev.c:68:42: error: invalid use of undefined type 'struct cxl_mem'
68 | unsigned long long len = range_len(&cxlm->ram_range);
| ^~
drivers/cxl/core/memdev.c: In function 'pmem_size_show':
drivers/cxl/core/memdev.c:79:29: warning: initialization of 'struct cxl_memdev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
79 | struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
| ^~~~~~~~~~~~~
drivers/cxl/core/memdev.c:80:30: error: invalid use of undefined type 'struct cxl_memdev'
80 | struct cxl_mem *cxlm = cxlmd->cxlm;
| ^~
drivers/cxl/core/memdev.c:81:42: error: invalid use of undefined type 'struct cxl_mem'
81 | unsigned long long len = range_len(&cxlm->pmem_range);
| ^~
drivers/cxl/core/memdev.c: In function 'cxl_memdev_unregister':
drivers/cxl/core/memdev.c:137:29: error: invalid use of undefined type 'struct cxl_memdev'
137 | struct device *dev = &cxlmd->dev;
| ^~
drivers/cxl/core/memdev.c:138:28: error: invalid use of undefined type 'struct cxl_memdev'
138 | struct cdev *cdev = &cxlmd->cdev;
| ^~
In file included from include/linux/list.h:9,
from include/linux/rculist.h:10,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/ratelimit.h:6,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from drivers/cxl/core/memdev.c:4:
>> drivers/cxl/core/memdev.c:141:32: error: invalid use of undefined type 'struct cdev'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~
include/linux/kernel.h:494:26: note: in definition of macro 'container_of'
494 | void *__mptr = (void *)(ptr); \
| ^~~
In file included from <command-line>:
>> drivers/cxl/core/memdev.c:141:32: error: invalid use of undefined type 'struct cdev'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~
include/linux/compiler_types.h:308:9: note: in definition of macro '__compiletime_assert'
308 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:328:2: note: in expansion of macro '_compiletime_assert'
328 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/kernel.h:495:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~~~~~~
include/linux/kernel.h:495:20: note: in expansion of macro '__same_type'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~
drivers/cxl/core/memdev.c:141:15: note: in expansion of macro 'container_of'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~~~~~~~~~~~
>> include/linux/kernel.h:495:51: error: invalid use of undefined type 'const struct cdevm_file_operations'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~
include/linux/compiler_types.h:308:9: note: in definition of macro '__compiletime_assert'
308 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:328:2: note: in expansion of macro '_compiletime_assert'
328 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/kernel.h:495:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~~~~~~
include/linux/kernel.h:495:20: note: in expansion of macro '__same_type'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~
drivers/cxl/core/memdev.c:141:15: note: in expansion of macro 'container_of'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~~~~~~~~~~~
>> drivers/cxl/core/memdev.c:141:32: error: invalid use of undefined type 'struct cdev'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~
include/linux/compiler_types.h:308:9: note: in definition of macro '__compiletime_assert'
308 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:328:2: note: in expansion of macro '_compiletime_assert'
328 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/kernel.h:495:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
495 | BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
| ^~~~~~~~~~~~~~~~
include/linux/kernel.h:496:6: note: in expansion of macro '__same_type'
496 | !__same_type(*(ptr), void), \
| ^~~~~~~~~~~
drivers/cxl/core/memdev.c:141:15: note: in expansion of macro 'container_of'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~~~~~~~~~~~
>> include/linux/compiler_types.h:140:35: error: invalid use of undefined type 'const struct cdevm_file_operations'
140 | #define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
| ^~~~~~~~~~~~~~~~~~
include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
17 | #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
| ^~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:498:21: note: in expansion of macro 'offsetof'
498 | ((type *)(__mptr - offsetof(type, member))); })
| ^~~~~~~~
drivers/cxl/core/memdev.c:141:15: note: in expansion of macro 'container_of'
141 | cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
| ^~~~~~~~~~~~
>> drivers/cxl/core/memdev.c:142:12: error: invalid use of undefined type 'const struct cdevm_file_operations'
142 | cdevm_fops->shutdown(dev);
| ^~
>> drivers/cxl/core/memdev.c:144:2: error: implicit declaration of function 'cdev_device_del'; did you mean 'device_del'? [-Werror=implicit-function-declaration]
144 | cdev_device_del(&cxlmd->cdev, dev);
| ^~~~~~~~~~~~~~~
| device_del
drivers/cxl/core/memdev.c:144:24: error: invalid use of undefined type 'struct cxl_memdev'
144 | cdev_device_del(&cxlmd->cdev, dev);
| ^~
drivers/cxl/core/memdev.c: At top level:
>> drivers/cxl/core/memdev.c:148:51: warning: 'struct cxl_mem' declared inside parameter list will not be visible outside of this definition or declaration
148 | static struct cxl_memdev *cxl_memdev_alloc(struct cxl_mem *cxlm,
| ^~~~~~~
drivers/cxl/core/memdev.c: In function 'cxl_memdev_alloc':
drivers/cxl/core/memdev.c:151:29: error: invalid use of undefined type 'struct cxl_mem'
151 | struct pci_dev *pdev = cxlm->pdev;
| ^~
>> drivers/cxl/core/memdev.c:157:24: error: invalid application of 'sizeof' to incomplete type 'struct cxl_memdev'
157 | cxlmd = kzalloc(sizeof(*cxlmd), GFP_KERNEL);
| ^
drivers/cxl/core/memdev.c:164:7: error: invalid use of undefined type 'struct cxl_memdev'
164 | cxlmd->id = rc;
| ^~
drivers/cxl/core/memdev.c:166:14: error: invalid use of undefined type 'struct cxl_memdev'
166 | dev = &cxlmd->dev;
| ^~
>> drivers/cxl/core/memdev.c:169:14: error: 'cxl_bus_type' undeclared (first use in this function); did you mean 'pci_bus_type'?
169 | dev->bus = &cxl_bus_type;
| ^~~~~~~~~~~~
| pci_bus_type
drivers/cxl/core/memdev.c:169:14: note: each undeclared identifier is reported only once for each function it appears in
In file included from include/linux/fs.h:7,
from include/linux/huge_mm.h:8,
from include/linux/mm.h:728,
from include/linux/scatterlist.h:8,
from include/linux/dmapool.h:14,
from include/linux/pci.h:1466,
from drivers/cxl/core/memdev.c:7:
drivers/cxl/core/memdev.c:170:40: error: invalid use of undefined type 'struct cxl_memdev'
170 | dev->devt = MKDEV(cxl_mem_major, cxlmd->id);
| ^~
include/linux/kdev_t.h:12:46: note: in definition of macro 'MKDEV'
12 | #define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
| ^~
drivers/cxl/core/memdev.c:174:15: error: invalid use of undefined type 'struct cxl_memdev'
174 | cdev = &cxlmd->cdev;
| ^~
>> drivers/cxl/core/memdev.c:175:2: error: implicit declaration of function 'cdev_init'; did you mean 'cred_init'? [-Werror=implicit-function-declaration]
175 | cdev_init(cdev, fops);
| ^~~~~~~~~
| cred_init
drivers/cxl/core/memdev.c: At top level:
>> drivers/cxl/core/memdev.c:185:20: warning: 'struct cdevm_file_operations' declared inside parameter list will not be visible outside of this definition or declaration
185 | const struct cdevm_file_operations *cdevm_fops)
| ^~~~~~~~~~~~~~~~~~~~~
drivers/cxl/core/memdev.c:184:49: warning: 'struct cxl_mem' declared inside parameter list will not be visible outside of this definition or declaration
184 | devm_cxl_add_memdev(struct device *host, struct cxl_mem *cxlm,
| ^~~~~~~
>> drivers/cxl/core/memdev.c:184:1: warning: no previous prototype for 'devm_cxl_add_memdev' [-Wmissing-prototypes]
184 | devm_cxl_add_memdev(struct device *host, struct cxl_mem *cxlm,
| ^~~~~~~~~~~~~~~~~~~
drivers/cxl/core/memdev.c: In function 'devm_cxl_add_memdev':
drivers/cxl/core/memdev.c:192:44: error: invalid use of undefined type 'const struct cdevm_file_operations'
192 | cxlmd = cxl_memdev_alloc(cxlm, &cdevm_fops->fops);
| ^~
>> drivers/cxl/core/memdev.c:192:27: error: passing argument 1 of 'cxl_memdev_alloc' from incompatible pointer type [-Werror=incompatible-pointer-types]
192 | cxlmd = cxl_memdev_alloc(cxlm, &cdevm_fops->fops);
| ^~~~
| |
| struct cxl_mem *
drivers/cxl/core/memdev.c:148:60: note: expected 'struct cxl_mem *' but argument is of type 'struct cxl_mem *'
148 | static struct cxl_memdev *cxl_memdev_alloc(struct cxl_mem *cxlm,
| ~~~~~~~~~~~~~~~~^~~~
drivers/cxl/core/memdev.c:196:14: error: invalid use of undefined type 'struct cxl_memdev'
196 | dev = &cxlmd->dev;
| ^~
drivers/cxl/core/memdev.c:197:39: error: invalid use of undefined type 'struct cxl_memdev'
197 | rc = dev_set_name(dev, "mem%d", cxlmd->id);
| ^~
drivers/cxl/core/memdev.c:205:7: error: invalid use of undefined type 'struct cxl_memdev'
205 | cxlmd->cxlm = cxlm;
| ^~
drivers/cxl/core/memdev.c:207:15: error: invalid use of undefined type 'struct cxl_memdev'
207 | cdev = &cxlmd->cdev;
| ^~
>> drivers/cxl/core/memdev.c:208:7: error: implicit declaration of function 'cdev_device_add'; did you mean 'pci_device_add'? [-Werror=implicit-function-declaration]
208 | rc = cdev_device_add(cdev, dev);
| ^~~~~~~~~~~~~~~
| pci_device_add
drivers/cxl/core/memdev.c:222:12: error: invalid use of undefined type 'const struct cdevm_file_operations'
222 | cdevm_fops->shutdown(dev);
| ^~
drivers/cxl/core/memdev.c: At top level:
>> drivers/cxl/core/memdev.c:228:12: warning: no previous prototype for 'cxl_memdev_init' [-Wmissing-prototypes]
228 | __init int cxl_memdev_init(void)
| ^~~~~~~~~~~~~~~
drivers/cxl/core/memdev.c:242:6: warning: no previous prototype for 'cxl_memdev_exit' [-Wmissing-prototypes]
242 | void cxl_memdev_exit(void)
| ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/to_cxl_memdev +21 drivers/cxl/core/memdev.c
3
> 4 #include <linux/device.h>
5 #include <linux/slab.h>
6 #include <linux/idr.h>
7 #include <linux/pci.h>
8 #include <mem.h>
9
10 /*
11 * An entire PCI topology full of devices should be enough for any
12 * config
13 */
14 #define CXL_MEM_MAX_DEVS 65536
15
16 static int cxl_mem_major;
17 static DEFINE_IDA(cxl_memdev_ida);
18
19 static void cxl_memdev_release(struct device *dev)
20 {
> 21 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
22
> 23 ida_free(&cxl_memdev_ida, cxlmd->id);
24 kfree(cxlmd);
25 }
26
27 static char *cxl_memdev_devnode(struct device *dev, umode_t *mode, kuid_t *uid,
28 kgid_t *gid)
29 {
30 return kasprintf(GFP_KERNEL, "cxl/%s", dev_name(dev));
31 }
32
33 static ssize_t firmware_version_show(struct device *dev,
34 struct device_attribute *attr, char *buf)
35 {
> 36 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
37 struct cxl_mem *cxlm = cxlmd->cxlm;
38
> 39 return sysfs_emit(buf, "%.16s\n", cxlm->firmware_version);
40 }
41 static DEVICE_ATTR_RO(firmware_version);
42
43 static ssize_t payload_max_show(struct device *dev,
44 struct device_attribute *attr, char *buf)
45 {
46 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
47 struct cxl_mem *cxlm = cxlmd->cxlm;
48
49 return sysfs_emit(buf, "%zu\n", cxlm->payload_size);
50 }
51 static DEVICE_ATTR_RO(payload_max);
52
53 static ssize_t label_storage_size_show(struct device *dev,
54 struct device_attribute *attr, char *buf)
55 {
56 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
57 struct cxl_mem *cxlm = cxlmd->cxlm;
58
59 return sysfs_emit(buf, "%zu\n", cxlm->lsa_size);
60 }
61 static DEVICE_ATTR_RO(label_storage_size);
62
63 static ssize_t ram_size_show(struct device *dev, struct device_attribute *attr,
64 char *buf)
65 {
66 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
67 struct cxl_mem *cxlm = cxlmd->cxlm;
68 unsigned long long len = range_len(&cxlm->ram_range);
69
70 return sysfs_emit(buf, "%#llx\n", len);
71 }
72
73 static struct device_attribute dev_attr_ram_size =
74 __ATTR(size, 0444, ram_size_show, NULL);
75
76 static ssize_t pmem_size_show(struct device *dev, struct device_attribute *attr,
77 char *buf)
78 {
79 struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
80 struct cxl_mem *cxlm = cxlmd->cxlm;
81 unsigned long long len = range_len(&cxlm->pmem_range);
82
83 return sysfs_emit(buf, "%#llx\n", len);
84 }
85
86 static struct device_attribute dev_attr_pmem_size =
87 __ATTR(size, 0444, pmem_size_show, NULL);
88
89 static struct attribute *cxl_memdev_attributes[] = {
90 &dev_attr_firmware_version.attr,
91 &dev_attr_payload_max.attr,
92 &dev_attr_label_storage_size.attr,
93 NULL,
94 };
95
96 static struct attribute *cxl_memdev_pmem_attributes[] = {
97 &dev_attr_pmem_size.attr,
98 NULL,
99 };
100
101 static struct attribute *cxl_memdev_ram_attributes[] = {
102 &dev_attr_ram_size.attr,
103 NULL,
104 };
105
106 static struct attribute_group cxl_memdev_attribute_group = {
107 .attrs = cxl_memdev_attributes,
108 };
109
110 static struct attribute_group cxl_memdev_ram_attribute_group = {
111 .name = "ram",
112 .attrs = cxl_memdev_ram_attributes,
113 };
114
115 static struct attribute_group cxl_memdev_pmem_attribute_group = {
116 .name = "pmem",
117 .attrs = cxl_memdev_pmem_attributes,
118 };
119
120 static const struct attribute_group *cxl_memdev_attribute_groups[] = {
121 &cxl_memdev_attribute_group,
122 &cxl_memdev_ram_attribute_group,
123 &cxl_memdev_pmem_attribute_group,
124 NULL,
125 };
126
127 static const struct device_type cxl_memdev_type = {
128 .name = "cxl_memdev",
129 .release = cxl_memdev_release,
130 .devnode = cxl_memdev_devnode,
131 .groups = cxl_memdev_attribute_groups,
132 };
133
134 static void cxl_memdev_unregister(void *_cxlmd)
135 {
136 struct cxl_memdev *cxlmd = _cxlmd;
137 struct device *dev = &cxlmd->dev;
138 struct cdev *cdev = &cxlmd->cdev;
139 const struct cdevm_file_operations *cdevm_fops;
140
> 141 cdevm_fops = container_of(cdev->ops, typeof(*cdevm_fops), fops);
> 142 cdevm_fops->shutdown(dev);
143
> 144 cdev_device_del(&cxlmd->cdev, dev);
145 put_device(dev);
146 }
147
> 148 static struct cxl_memdev *cxl_memdev_alloc(struct cxl_mem *cxlm,
149 const struct file_operations *fops)
150 {
151 struct pci_dev *pdev = cxlm->pdev;
152 struct cxl_memdev *cxlmd;
153 struct device *dev;
154 struct cdev *cdev;
155 int rc;
156
> 157 cxlmd = kzalloc(sizeof(*cxlmd), GFP_KERNEL);
158 if (!cxlmd)
159 return ERR_PTR(-ENOMEM);
160
161 rc = ida_alloc_range(&cxl_memdev_ida, 0, CXL_MEM_MAX_DEVS, GFP_KERNEL);
162 if (rc < 0)
163 goto err;
164 cxlmd->id = rc;
165
166 dev = &cxlmd->dev;
167 device_initialize(dev);
168 dev->parent = &pdev->dev;
> 169 dev->bus = &cxl_bus_type;
> 170 dev->devt = MKDEV(cxl_mem_major, cxlmd->id);
171 dev->type = &cxl_memdev_type;
172 device_set_pm_not_required(dev);
173
> 174 cdev = &cxlmd->cdev;
> 175 cdev_init(cdev, fops);
176 return cxlmd;
177
178 err:
179 kfree(cxlmd);
180 return ERR_PTR(rc);
181 }
182
183 struct cxl_memdev *
> 184 devm_cxl_add_memdev(struct device *host, struct cxl_mem *cxlm,
> 185 const struct cdevm_file_operations *cdevm_fops)
186 {
187 struct cxl_memdev *cxlmd;
188 struct device *dev;
189 struct cdev *cdev;
190 int rc;
191
> 192 cxlmd = cxl_memdev_alloc(cxlm, &cdevm_fops->fops);
193 if (IS_ERR(cxlmd))
194 return cxlmd;
195
196 dev = &cxlmd->dev;
> 197 rc = dev_set_name(dev, "mem%d", cxlmd->id);
198 if (rc)
199 goto err;
200
201 /*
202 * Activate ioctl operations, no cxl_memdev_rwsem manipulation
203 * needed as this is ordered with cdev_add() publishing the device.
204 */
205 cxlmd->cxlm = cxlm;
206
207 cdev = &cxlmd->cdev;
> 208 rc = cdev_device_add(cdev, dev);
209 if (rc)
210 goto err;
211
212 rc = devm_add_action_or_reset(host, cxl_memdev_unregister, cxlmd);
213 if (rc)
214 return ERR_PTR(rc);
215 return cxlmd;
216
217 err:
218 /*
219 * The cdev was briefly live, shutdown any ioctl operations that
220 * saw that state.
221 */
222 cdevm_fops->shutdown(dev);
223 put_device(dev);
224 return ERR_PTR(rc);
225 }
226 EXPORT_SYMBOL_GPL(devm_cxl_add_memdev);
227
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 62334 bytes --]
next reply other threads:[~2021-07-31 19:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-31 19:59 kernel test robot [this message]
2021-07-31 19:59 ` [cxl-cxl:pending 6/6] drivers/cxl/core/memdev.c:21:29: error: implicit declaration of function 'to_cxl_memdev' kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202108010356.p1fp7X3c-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild-all@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.