lkml.org 
[lkml]   [2018]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1 4/4] mhi_bus: dev: uci: add user space interface driver
Hi Sujeev,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.17-rc2 next-20180426]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Sujeev-Dias/mhi_bus-core-Add-support-for-MHI-host-interface/20180428-065959
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All warnings (new ones prefixed by >>):

In file included from drivers/bus/mhi/devices/mhi_uci.c:26:0:
include/linux/mhi.h:658:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
static inlint int mhi_force_rddm_mode(struct mhi_controller *mhi_cntrl)
^~~
In file included from include/linux/printk.h:7:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/cdev.h:5,
from drivers/bus/mhi/devices/mhi_uci.c:13:
drivers/bus/mhi/devices/mhi_uci.c: In function 'mhi_queue_inbound':
>> include/linux/kern_levels.h:5:18: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t {aka unsigned int}' [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
>> drivers/bus/mhi/devices/mhi_uci.c:73:4: note: in expansion of macro 'pr_err'
pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__); \
^~~~~~
>> drivers/bus/mhi/devices/mhi_uci.c:114:3: note: in expansion of macro 'MSG_VERB'
MSG_VERB("Allocated buf %d of %d size %ld\n", i, nr_trbs, mtu);
^~~~~~~~
drivers/bus/mhi/devices/mhi_uci.c:114:43: note: format string is defined here
MSG_VERB("Allocated buf %d of %d size %ld\n", i, nr_trbs, mtu);
~~^
%d
In file included from include/linux/printk.h:7:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/cdev.h:5,
from drivers/bus/mhi/devices/mhi_uci.c:13:
drivers/bus/mhi/devices/mhi_uci.c: In function 'mhi_uci_write':
include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t {aka unsigned int}' [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
>> drivers/bus/mhi/devices/mhi_uci.c:73:4: note: in expansion of macro 'pr_err'
pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__); \
^~~~~~
drivers/bus/mhi/devices/mhi_uci.c:243:2: note: in expansion of macro 'MSG_VERB'
MSG_VERB("Enter: to xfer:%lu bytes\n", count);
^~~~~~~~
drivers/bus/mhi/devices/mhi_uci.c:243:29: note: format string is defined here
MSG_VERB("Enter: to xfer:%lu bytes\n", count);
~~^
%u
In file included from include/linux/printk.h:7:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/cdev.h:5,
from drivers/bus/mhi/devices/mhi_uci.c:13:
include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t {aka unsigned int}' [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
drivers/bus/mhi/devices/mhi_uci.c:89:4: note: in expansion of macro 'pr_err'
pr_err("[E][%s] " fmt, __func__, ##__VA_ARGS__); \
^~~~~~
>> drivers/bus/mhi/devices/mhi_uci.c:266:4: note: in expansion of macro 'MSG_ERR'
MSG_ERR("Failed to allocate memory %lu\n", xfer_size);
^~~~~~~
drivers/bus/mhi/devices/mhi_uci.c:266:41: note: format string is defined here
MSG_ERR("Failed to allocate memory %lu\n", xfer_size);
~~^
%u
In file included from include/linux/printk.h:7:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/cdev.h:5,
from drivers/bus/mhi/devices/mhi_uci.c:13:
include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t {aka unsigned int}' [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
>> drivers/bus/mhi/devices/mhi_uci.c:73:4: note: in expansion of macro 'pr_err'
pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__); \
^~~~~~
drivers/bus/mhi/devices/mhi_uci.c:295:2: note: in expansion of macro 'MSG_VERB'
MSG_VERB("Exit: Number of bytes xferred:%lu\n", bytes_xfered);
^~~~~~~~
drivers/bus/mhi/devices/mhi_uci.c:295:44: note: format string is defined here
MSG_VERB("Exit: Number of bytes xferred:%lu\n", bytes_xfered);
~~^
%u
In file included from include/linux/printk.h:7:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/cdev.h:5,
from drivers/bus/mhi/devices/mhi_uci.c:13:
drivers/bus/mhi/devices/mhi_uci.c: In function 'mhi_uci_read':
include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t {aka unsigned int}' [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
>> drivers/bus/mhi/devices/mhi_uci.c:73:4: note: in expansion of macro 'pr_err'
pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__); \
^~~~~~
drivers/bus/mhi/devices/mhi_uci.c:321:2: note: in expansion of macro 'MSG_VERB'
MSG_VERB("Client provided buf len:%lu\n", count);
^~~~~~~~
drivers/bus/mhi/devices/mhi_uci.c:321:38: note: format string is defined here
MSG_VERB("Client provided buf len:%lu\n", count);
~~^
%u
In file included from include/linux/printk.h:7:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/cdev.h:5,
from drivers/bus/mhi/devices/mhi_uci.c:13:
include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t {aka unsigned int}' [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
>> drivers/bus/mhi/devices/mhi_uci.c:73:4: note: in expansion of macro 'pr_err'
pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__); \
^~~~~~
drivers/bus/mhi/devices/mhi_uci.c:376:2: note: in expansion of macro 'MSG_VERB'
MSG_VERB("Copied %lu of %lu bytes\n", to_copy, uci_chan->rx_size);
^~~~~~~~
drivers/bus/mhi/devices/mhi_uci.c:376:21: note: format string is defined here
MSG_VERB("Copied %lu of %lu bytes\n", to_copy, uci_chan->rx_size);
~~^
%u
In file included from include/linux/printk.h:7:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/cdev.h:5,
from drivers/bus/mhi/devices/mhi_uci.c:13:
include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
>> drivers/bus/mhi/devices/mhi_uci.c:73:4: note: in expansion of macro 'pr_err'
pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__); \
^~~~~~
drivers/bus/mhi/devices/mhi_uci.c:376:2: note: in expansion of macro 'MSG_VERB'
MSG_VERB("Copied %lu of %lu bytes\n", to_copy, uci_chan->rx_size);
^~~~~~~~
drivers/bus/mhi/devices/mhi_uci.c:376:28: note: format string is defined here
MSG_VERB("Copied %lu of %lu bytes\n", to_copy, uci_chan->rx_size);
~~^
%u
In file included from include/linux/printk.h:7:0,
from include/linux/kernel.h:14,
from include/linux/list.h:9,
from include/linux/kobject.h:19,
from include/linux/cdev.h:5,
from drivers/bus/mhi/devices/mhi_uci.c:13:
include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t {aka unsigned int}' [-Wformat=]
#define KERN_SOH "\001" /* ASCII Start Of Header */
^
include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
#define KERN_ERR KERN_SOH "3" /* error conditions */
^~~~~~~~
include/linux/printk.h:304:9: note: in expansion of macro 'KERN_ERR'
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~
>> drivers/bus/mhi/devices/mhi_uci.c:73:4: note: in expansion of macro 'pr_err'
pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__); \
^~~~~~
drivers/bus/mhi/devices/mhi_uci.c:400:2: note: in expansion of macro 'MSG_VERB'
MSG_VERB("Returning %lu bytes\n", to_copy);
^~~~~~~~
drivers/bus/mhi/devices/mhi_uci.c:400:24: note: format string is defined here
MSG_VERB("Returning %lu bytes\n", to_copy);
~~^
%u

vim +/pr_err +73 drivers/bus/mhi/devices/mhi_uci.c

70
71 #define MSG_VERB(fmt, ...) do { \
72 if (msg_lvl <= MHI_MSG_LVL_VERBOSE) \
> 73 pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__); \
74 } while (0)
75
76 #else
77
78 #define MSG_VERB(fmt, ...)
79
80 #endif
81
82 #define MSG_LOG(fmt, ...) do { \
83 if (msg_lvl <= MHI_MSG_LVL_INFO) \
84 pr_err("[I][%s] " fmt, __func__, ##__VA_ARGS__); \
85 } while (0)
86
87 #define MSG_ERR(fmt, ...) do { \
88 if (msg_lvl <= MHI_MSG_LVL_ERROR) \
> 89 pr_err("[E][%s] " fmt, __func__, ##__VA_ARGS__); \
90 } while (0)
91
92 #define MAX_UCI_DEVICES (64)
93
94 static DECLARE_BITMAP(uci_minors, MAX_UCI_DEVICES);
95 static struct mhi_uci_drv mhi_uci_drv;
96
97 static int mhi_queue_inbound(struct uci_dev *uci_dev)
98 {
99 struct mhi_device *mhi_dev = uci_dev->mhi_dev;
100 int nr_trbs = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE);
101 size_t mtu = uci_dev->mtu;
102 void *buf;
103 struct uci_buf *uci_buf;
104 int ret = -EIO, i;
105
106 for (i = 0; i < nr_trbs; i++) {
107 buf = kmalloc(mtu + sizeof(*uci_buf), GFP_KERNEL);
108 if (!buf)
109 return -ENOMEM;
110
111 uci_buf = buf + mtu;
112 uci_buf->data = buf;
113
> 114 MSG_VERB("Allocated buf %d of %d size %ld\n", i, nr_trbs, mtu);
115
116 ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, buf, mtu,
117 MHI_EOT);
118 if (ret) {
119 kfree(buf);
120 MSG_ERR("Failed to queue buffer %d\n", i);
121 return ret;
122 }
123 }
124
125 return ret;
126 }
127
128 static long mhi_uci_ioctl(struct file *file,
129 unsigned int cmd,
130 unsigned long arg)
131 {
132 struct uci_dev *uci_dev = file->private_data;
133 struct mhi_device *mhi_dev = uci_dev->mhi_dev;
134 long ret = -ERESTARTSYS;
135
136 mutex_lock(&uci_dev->mutex);
137 if (uci_dev->enabled)
138 ret = mhi_ioctl(mhi_dev, cmd, arg);
139 mutex_unlock(&uci_dev->mutex);
140
141 return ret;
142 }
143
144 static int mhi_uci_release(struct inode *inode, struct file *file)
145 {
146 struct uci_dev *uci_dev = file->private_data;
147
148 mutex_lock(&uci_dev->mutex);
149 uci_dev->ref_count--;
150 if (!uci_dev->ref_count) {
151 struct uci_buf *itr, *tmp;
152 struct uci_chan *uci_chan;
153
154 MSG_LOG("Last client left, closing node\n");
155
156 if (uci_dev->enabled)
157 mhi_unprepare_from_transfer(uci_dev->mhi_dev);
158
159 /* clean inbound channel */
160 uci_chan = &uci_dev->dl_chan;
161 list_for_each_entry_safe(itr, tmp, &uci_chan->pending, node) {
162 list_del(&itr->node);
163 kfree(itr->data);
164 }
165 if (uci_chan->cur_buf)
166 kfree(uci_chan->cur_buf->data);
167
168 uci_chan->cur_buf = NULL;
169
170 if (!uci_dev->enabled) {
171 MSG_LOG("Node is deleted, freeing dev node\n");
172 mutex_unlock(&uci_dev->mutex);
173 mutex_destroy(&uci_dev->mutex);
174 clear_bit(MINOR(uci_dev->devt), uci_minors);
175 kfree(uci_dev);
176 return 0;
177 }
178 }
179
180 mutex_unlock(&uci_dev->mutex);
181
182 MSG_LOG("exit: ref_count:%d\n", uci_dev->ref_count);
183
184 return 0;
185 }
186
187 static unsigned int mhi_uci_poll(struct file *file, poll_table *wait)
188 {
189 struct uci_dev *uci_dev = file->private_data;
190 struct mhi_device *mhi_dev = uci_dev->mhi_dev;
191 struct uci_chan *uci_chan;
192 unsigned int mask = 0;
193
194 poll_wait(file, &uci_dev->dl_chan.wq, wait);
195 poll_wait(file, &uci_dev->ul_chan.wq, wait);
196
197 uci_chan = &uci_dev->dl_chan;
198 spin_lock_bh(&uci_chan->lock);
199 if (!uci_dev->enabled) {
200 mask = POLLERR;
201 } else if (!list_empty(&uci_chan->pending) || uci_chan->cur_buf) {
202 MSG_VERB("Client can read from node\n");
203 mask |= POLLIN | POLLRDNORM;
204 }
205 spin_unlock_bh(&uci_chan->lock);
206
207 uci_chan = &uci_dev->ul_chan;
208 spin_lock_bh(&uci_chan->lock);
209 if (!uci_dev->enabled) {
210 mask |= POLLERR;
211 } else if (mhi_get_no_free_descriptors(mhi_dev, DMA_TO_DEVICE) > 0) {
212 MSG_VERB("Client can write to node\n");
213 mask |= POLLOUT | POLLWRNORM;
214 }
215 spin_unlock_bh(&uci_chan->lock);
216
217 MSG_LOG("Client attempted to poll, returning mask 0x%x\n", mask);
218
219 return mask;
220 }
221
222 static ssize_t mhi_uci_write(struct file *file,
223 const char __user *buf,
224 size_t count,
225 loff_t *offp)
226 {
227 struct uci_dev *uci_dev = file->private_data;
228 struct mhi_device *mhi_dev = uci_dev->mhi_dev;
229 struct uci_chan *uci_chan = &uci_dev->ul_chan;
230 size_t bytes_xfered = 0;
231 int ret;
232
233 if (!buf || !count)
234 return -EINVAL;
235
236 /* confirm channel is active */
237 spin_lock_bh(&uci_chan->lock);
238 if (!uci_dev->enabled) {
239 spin_unlock_bh(&uci_chan->lock);
240 return -ERESTARTSYS;
241 }
242
243 MSG_VERB("Enter: to xfer:%lu bytes\n", count);
244
245 while (count) {
246 size_t xfer_size;
247 void *kbuf;
248 enum MHI_FLAGS flags;
249
250 spin_unlock_bh(&uci_chan->lock);
251
252 /* wait for free descriptors */
253 ret = wait_event_interruptible(uci_chan->wq,
254 (!uci_dev->enabled) ||
255 mhi_get_no_free_descriptors
256 (mhi_dev, DMA_TO_DEVICE) > 0);
257
258 if (ret == -ERESTARTSYS) {
259 MSG_LOG("Exit signal caught for node\n");
260 return -ERESTARTSYS;
261 }
262
263 xfer_size = min_t(size_t, count, uci_dev->mtu);
264 kbuf = kmalloc(xfer_size, GFP_KERNEL);
265 if (!kbuf) {
> 266 MSG_ERR("Failed to allocate memory %lu\n", xfer_size);
267 return -ENOMEM;
268 }
269
270 ret = copy_from_user(kbuf, buf, xfer_size);
271 if (unlikely(ret)) {
272 kfree(kbuf);
273 return ret;
274 }
275
276 spin_lock_bh(&uci_chan->lock);
277 flags = (count - xfer_size) ? MHI_EOB : MHI_EOT;
278 if (uci_dev->enabled)
279 ret = mhi_queue_transfer(mhi_dev, DMA_TO_DEVICE, kbuf,
280 xfer_size, flags);
281 else
282 ret = -ERESTARTSYS;
283
284 if (ret) {
285 kfree(kbuf);
286 goto sys_interrupt;
287 }
288
289 bytes_xfered += xfer_size;
290 count -= xfer_size;
291 buf += xfer_size;
292 }
293
294 spin_unlock_bh(&uci_chan->lock);
295 MSG_VERB("Exit: Number of bytes xferred:%lu\n", bytes_xfered);
296
297 return bytes_xfered;
298
299 sys_interrupt:
300 spin_unlock_bh(&uci_chan->lock);
301
302 return ret;
303 }
304

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[unhandled content-type:application/gzip]
\
 
 \ /
  Last update: 2018-04-28 03:06    [W:0.349 / U:0.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site