[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202212220751.6Ote1SjP-lkp@intel.com>
Date: Thu, 22 Dec 2022 07:55:26 +0800
From: kernel test robot <lkp@...el.com>
To: Dmitry Fomichev <dmitry.fomichev@....com>
Cc: oe-kbuild-all@...ts.linux.dev, kvm@...r.kernel.org,
virtualization@...ts.linux-foundation.org, netdev@...r.kernel.org,
"Michael S. Tsirkin" <mst@...hat.com>,
Stefan Hajnoczi <stefanha@...il.com>
Subject: [mst-vhost:vhost 4/58] drivers/block/virtio_blk.c:598:25: sparse:
sparse: cast from restricted __virtio64
tree: https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost
head: 47897ed42d6e6dade252fd6edb6f79694485cc5e
commit: 5a56d174a4a7e2dbd2d86afc92240a973f7bb0e5 [4/58] virtio-blk: add support for zoned block devices
config: alpha-randconfig-s053-20221219
compiler: alpha-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git/commit/?id=5a56d174a4a7e2dbd2d86afc92240a973f7bb0e5
git remote add mst-vhost https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git
git fetch --no-tags mst-vhost vhost
git checkout 5a56d174a4a7e2dbd2d86afc92240a973f7bb0e5
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=alpha olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=alpha SHELL=/bin/bash drivers/block/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
sparse warnings: (new ones prefixed by >>)
drivers/block/virtio_blk.c:598:25: sparse: sparse: cast to restricted __le64
>> drivers/block/virtio_blk.c:598:25: sparse: sparse: cast from restricted __virtio64
drivers/block/virtio_blk.c:599:22: sparse: sparse: cast to restricted __le64
drivers/block/virtio_blk.c:599:22: sparse: sparse: cast from restricted __virtio64
drivers/block/virtio_blk.c:603:27: sparse: sparse: cast to restricted __le64
drivers/block/virtio_blk.c:603:27: sparse: sparse: cast from restricted __virtio64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast to restricted __le64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast from restricted __virtio64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast to restricted __le64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast from restricted __virtio64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast to restricted __le64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast from restricted __virtio64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast to restricted __le64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast from restricted __virtio64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast to restricted __le64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast from restricted __virtio64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast to restricted __le64
drivers/block/virtio_blk.c:637:22: sparse: sparse: cast from restricted __virtio64
drivers/block/virtio_blk.c:646:34: sparse: sparse: cast to restricted __le64
drivers/block/virtio_blk.c:646:34: sparse: sparse: cast from restricted __virtio64
>> drivers/block/virtio_blk.c:708:45: sparse: sparse: cast to restricted __le32
drivers/block/virtio_blk.c:710:9: sparse: sparse: cast to restricted __le32
drivers/block/virtio_blk.c:714:47: sparse: sparse: cast to restricted __le32
drivers/block/virtio_blk.c:715:9: sparse: sparse: cast to restricted __le32
drivers/block/virtio_blk.c:723:42: sparse: sparse: cast to restricted __le32
drivers/block/virtio_blk.c:724:29: sparse: sparse: cast to restricted __le32
drivers/block/virtio_blk.c:726:9: sparse: sparse: cast to restricted __le32
drivers/block/virtio_blk.c:733:30: sparse: sparse: cast to restricted __le32
drivers/block/virtio_blk.c:756:54: sparse: sparse: cast to restricted __le32
drivers/block/virtio_blk.c:757:17: sparse: sparse: cast to restricted __le32
drivers/block/virtio_blk.c:326:36: sparse: sparse: incorrect type in initializer (different base types) @@ expected int status @@ got restricted blk_status_t @@
drivers/block/virtio_blk.c:326:36: sparse: expected int status
drivers/block/virtio_blk.c:326:36: sparse: got restricted blk_status_t
drivers/block/virtio_blk.c:332:33: sparse: sparse: cast to restricted __le64
drivers/block/virtio_blk.c:334:33: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected restricted blk_status_t [usertype] error @@ got int status @@
drivers/block/virtio_blk.c:334:33: sparse: expected restricted blk_status_t [usertype] error
drivers/block/virtio_blk.c:334:33: sparse: got int status
vim +598 drivers/block/virtio_blk.c
579
580 static int virtblk_parse_zone(struct virtio_blk *vblk,
581 struct virtio_blk_zone_descriptor *entry,
582 unsigned int idx, unsigned int zone_sectors,
583 report_zones_cb cb, void *data)
584 {
585 struct blk_zone zone = { };
586
587 if (entry->z_type != VIRTIO_BLK_ZT_SWR &&
588 entry->z_type != VIRTIO_BLK_ZT_SWP &&
589 entry->z_type != VIRTIO_BLK_ZT_CONV) {
590 dev_err(&vblk->vdev->dev, "invalid zone type %#x\n",
591 entry->z_type);
592 return -EINVAL;
593 }
594
595 zone.type = entry->z_type;
596 zone.cond = entry->z_state;
597 zone.len = zone_sectors;
> 598 zone.capacity = le64_to_cpu(entry->z_cap);
599 zone.start = le64_to_cpu(entry->z_start);
600 if (zone.cond == BLK_ZONE_COND_FULL)
601 zone.wp = zone.start + zone.len;
602 else
603 zone.wp = le64_to_cpu(entry->z_wp);
604
605 return cb(&zone, idx, data);
606 }
607
608 static int virtblk_report_zones(struct gendisk *disk, sector_t sector,
609 unsigned int nr_zones, report_zones_cb cb,
610 void *data)
611 {
612 struct virtio_blk *vblk = disk->private_data;
613 struct virtio_blk_zone_report *report;
614 unsigned int zone_sectors = vblk->zone_sectors;
615 unsigned int nz, i;
616 int ret, zone_idx = 0;
617 size_t buflen;
618
619 if (WARN_ON_ONCE(!vblk->zone_sectors))
620 return -EOPNOTSUPP;
621
622 report = virtblk_alloc_report_buffer(vblk, nr_zones,
623 zone_sectors, &buflen);
624 if (!report)
625 return -ENOMEM;
626
627 while (zone_idx < nr_zones && sector < get_capacity(vblk->disk)) {
628 memset(report, 0, buflen);
629
630 ret = virtblk_submit_zone_report(vblk, (char *)report,
631 buflen, sector);
632 if (ret) {
633 if (ret > 0)
634 ret = -EIO;
635 goto out_free;
636 }
637 nz = min((unsigned int)le64_to_cpu(report->nr_zones), nr_zones);
638 if (!nz)
639 break;
640
641 for (i = 0; i < nz && zone_idx < nr_zones; i++) {
642 ret = virtblk_parse_zone(vblk, &report->zones[i],
643 zone_idx, zone_sectors, cb, data);
644 if (ret)
645 goto out_free;
646 sector = le64_to_cpu(report->zones[i].z_start) + zone_sectors;
647 zone_idx++;
648 }
649 }
650
651 if (zone_idx > 0)
652 ret = zone_idx;
653 else
654 ret = -EINVAL;
655 out_free:
656 kvfree(report);
657 return ret;
658 }
659
660 static void virtblk_revalidate_zones(struct virtio_blk *vblk)
661 {
662 u8 model;
663
664 if (!vblk->zone_sectors)
665 return;
666
667 virtio_cread(vblk->vdev, struct virtio_blk_config,
668 zoned.model, &model);
669 if (!blk_revalidate_disk_zones(vblk->disk, NULL))
670 set_capacity_and_notify(vblk->disk, 0);
671 }
672
673 static int virtblk_probe_zoned_device(struct virtio_device *vdev,
674 struct virtio_blk *vblk,
675 struct request_queue *q)
676 {
677 u32 v;
678 u8 model;
679 int ret;
680
681 virtio_cread(vdev, struct virtio_blk_config,
682 zoned.model, &model);
683
684 switch (model) {
685 case VIRTIO_BLK_Z_NONE:
686 return 0;
687 case VIRTIO_BLK_Z_HM:
688 break;
689 case VIRTIO_BLK_Z_HA:
690 /*
691 * Present the host-aware device as a regular drive.
692 * TODO It is possible to add an option to make it appear
693 * in the system as a zoned drive.
694 */
695 return 0;
696 default:
697 dev_err(&vdev->dev, "unsupported zone model %d\n", model);
698 return -EINVAL;
699 }
700
701 dev_dbg(&vdev->dev, "probing host-managed zoned device\n");
702
703 disk_set_zoned(vblk->disk, BLK_ZONED_HM);
704 blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
705
706 virtio_cread(vdev, struct virtio_blk_config,
707 zoned.max_open_zones, &v);
> 708 disk_set_max_open_zones(vblk->disk, le32_to_cpu(v));
709
710 dev_dbg(&vdev->dev, "max open zones = %u\n", le32_to_cpu(v));
711
712 virtio_cread(vdev, struct virtio_blk_config,
713 zoned.max_active_zones, &v);
714 disk_set_max_active_zones(vblk->disk, le32_to_cpu(v));
715 dev_dbg(&vdev->dev, "max active zones = %u\n", le32_to_cpu(v));
716
717 virtio_cread(vdev, struct virtio_blk_config,
718 zoned.write_granularity, &v);
719 if (!v) {
720 dev_warn(&vdev->dev, "zero write granularity reported\n");
721 return -ENODEV;
722 }
723 blk_queue_physical_block_size(q, le32_to_cpu(v));
724 blk_queue_io_min(q, le32_to_cpu(v));
725
726 dev_dbg(&vdev->dev, "write granularity = %u\n", le32_to_cpu(v));
727
728 /*
729 * virtio ZBD specification doesn't require zones to be a power of
730 * two sectors in size, but the code in this driver expects that.
731 */
732 virtio_cread(vdev, struct virtio_blk_config, zoned.zone_sectors, &v);
733 vblk->zone_sectors = le32_to_cpu(v);
734 if (vblk->zone_sectors == 0 || !is_power_of_2(vblk->zone_sectors)) {
735 dev_err(&vdev->dev,
736 "zoned device with non power of two zone size %u\n",
737 vblk->zone_sectors);
738 return -ENODEV;
739 }
740 dev_dbg(&vdev->dev, "zone sectors = %u\n", vblk->zone_sectors);
741
742 if (virtio_has_feature(vdev, VIRTIO_BLK_F_DISCARD)) {
743 dev_warn(&vblk->vdev->dev,
744 "ignoring negotiated F_DISCARD for zoned device\n");
745 blk_queue_max_discard_sectors(q, 0);
746 }
747
748 ret = blk_revalidate_disk_zones(vblk->disk, NULL);
749 if (!ret) {
750 virtio_cread(vdev, struct virtio_blk_config,
751 zoned.max_append_sectors, &v);
752 if (!v) {
753 dev_warn(&vdev->dev, "zero max_append_sectors reported\n");
754 return -ENODEV;
755 }
756 blk_queue_max_zone_append_sectors(q, le32_to_cpu(v));
757 dev_dbg(&vdev->dev, "max append sectors = %u\n", le32_to_cpu(v));
758 }
759
760 return ret;
761 }
762
--
0-DAY CI Kernel Test Service
https://01.org/lkp
View attachment "config" of type "text/plain" (167433 bytes)
Powered by blists - more mailing lists