block/blk-mq.c:324:26: sparse: sparse: incorrect type in assignment (different base types)

From: kernel test robot
Date: Fri Nov 12 2021 - 16:27:37 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5833291ab6de9c3e2374336b51c814e515e8f3a5
commit: 128459062bc994355027e190477c432ec5b5638a block: cache rq_flags inside blk_mq_rq_ctx_init()
date: 4 weeks ago
config: x86_64-rhel-8.3-kselftests (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=128459062bc994355027e190477c432ec5b5638a
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 128459062bc994355027e190477c432ec5b5638a
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)
>> block/blk-mq.c:324:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int rq_flags @@ got restricted req_flags_t [usertype] @@
block/blk-mq.c:324:26: sparse: expected unsigned int rq_flags
block/blk-mq.c:324:26: sparse: got restricted req_flags_t [usertype]
>> block/blk-mq.c:333:26: sparse: sparse: invalid assignment: |=
>> block/blk-mq.c:333:26: sparse: left side has type unsigned int
>> block/blk-mq.c:333:26: sparse: right side has type restricted req_flags_t
block/blk-mq.c:335:26: sparse: sparse: invalid assignment: |=
block/blk-mq.c:335:26: sparse: left side has type unsigned int
block/blk-mq.c:335:26: sparse: right side has type restricted req_flags_t
>> block/blk-mq.c:336:22: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted req_flags_t [usertype] rq_flags @@ got unsigned int rq_flags @@
block/blk-mq.c:336:22: sparse: expected restricted req_flags_t [usertype] rq_flags
block/blk-mq.c:336:22: sparse: got unsigned int rq_flags

vim +324 block/blk-mq.c

311
312 static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
313 unsigned int tag, u64 alloc_time_ns)
314 {
315 struct blk_mq_ctx *ctx = data->ctx;
316 struct blk_mq_hw_ctx *hctx = data->hctx;
317 struct request_queue *q = data->q;
318 struct elevator_queue *e = q->elevator;
319 struct blk_mq_tags *tags = blk_mq_tags_from_data(data);
320 struct request *rq = tags->static_rqs[tag];
321 unsigned int rq_flags = 0;
322
323 if (e) {
> 324 rq_flags = RQF_ELV;
325 rq->tag = BLK_MQ_NO_TAG;
326 rq->internal_tag = tag;
327 } else {
328 rq->tag = tag;
329 rq->internal_tag = BLK_MQ_NO_TAG;
330 }
331
332 if (data->flags & BLK_MQ_REQ_PM)
> 333 rq_flags |= RQF_PM;
334 if (blk_queue_io_stat(q))
335 rq_flags |= RQF_IO_STAT;
> 336 rq->rq_flags = rq_flags;
337
338 if (blk_mq_need_time_stamp(rq))
339 rq->start_time_ns = ktime_get_ns();
340 else
341 rq->start_time_ns = 0;
342 /* csd/requeue_work/fifo_time is initialized before use */
343 rq->q = q;
344 rq->mq_ctx = ctx;
345 rq->mq_hctx = hctx;
346 rq->cmd_flags = data->cmd_flags;
347 rq->rq_disk = NULL;
348 rq->part = NULL;
349 #ifdef CONFIG_BLK_RQ_ALLOC_TIME
350 rq->alloc_time_ns = alloc_time_ns;
351 #endif
352 rq->io_start_time_ns = 0;
353 rq->stats_sectors = 0;
354 rq->nr_phys_segments = 0;
355 #if defined(CONFIG_BLK_DEV_INTEGRITY)
356 rq->nr_integrity_segments = 0;
357 #endif
358 rq->timeout = 0;
359 rq->end_io = NULL;
360 rq->end_io_data = NULL;
361
362 data->ctx->rq_dispatched[op_is_sync(data->cmd_flags)]++;
363 blk_crypto_rq_set_defaults(rq);
364 INIT_LIST_HEAD(&rq->queuelist);
365 /* tag was already set */
366 WRITE_ONCE(rq->deadline, 0);
367 refcount_set(&rq->ref, 1);
368
369 if (rq->rq_flags & RQF_ELV) {
370 struct elevator_queue *e = data->q->elevator;
371
372 rq->elv.icq = NULL;
373 INIT_HLIST_NODE(&rq->hash);
374 RB_CLEAR_NODE(&rq->rb_node);
375
376 if (!op_is_flush(data->cmd_flags) &&
377 e->type->ops.prepare_request) {
378 if (e->type->icq_cache)
379 blk_mq_sched_assign_ioc(rq);
380
381 e->type->ops.prepare_request(rq);
382 rq->rq_flags |= RQF_ELVPRIV;
383 }
384 }
385
386 data->hctx->queued++;
387 return rq;
388 }
389

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip