From: Guixin Liu <kanie@linux.alibaba.com>
To: kernel test robot <lkp@intel.com>, Keith Busch <kbusch@kernel.org>
Cc: oe-kbuild-all@lists.linux.dev, linux-nvme@lists.infradead.org,
Keith Busch <kbusch@kernel.org>,
Dmitry Bogdanov <d.bogdanov@yadro.com>,
Christoph Hellwig <hch@lst.de>,
Chaitanya Kulkarni <kch@nvidia.com>
Subject: Re: [linux-nvme:nvme-6.13 7/7] drivers/nvme/target/pr.c:857:34: sparse: sparse: incorrect type in assignment (different base types)
Date: Fri, 8 Nov 2024 11:29:35 +0800 [thread overview]
Message-ID: <c44c4ea6-ef4d-4152-ba21-9a76011dd75e@linux.alibaba.com> (raw)
In-Reply-To: <202411081109.soCWJfGT-lkp@intel.com>
在 2024/11/8 11:18, kernel test robot 写道:
> tree: git://git.infradead.org/nvme.git nvme-6.13
> head: 4c0ce9416cd06e9ef0e049f7a9226707c3786b1a
> commit: 4c0ce9416cd06e9ef0e049f7a9226707c3786b1a [7/7] nvmet: support reservation feature
> config: x86_64-randconfig-121-20241108 (https://download.01.org/0day-ci/archive/20241108/202411081109.soCWJfGT-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241108/202411081109.soCWJfGT-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202411081109.soCWJfGT-lkp@intel.com/
>
> sparse warnings: (new ones prefixed by >>)
>>> drivers/nvme/target/pr.c:857:34: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le16 [usertype] cntlid @@ got int @@
> drivers/nvme/target/pr.c:857:34: sparse: expected restricted __le16 [usertype] cntlid
> drivers/nvme/target/pr.c:857:34: sparse: got int
>
> vim +857 drivers/nvme/target/pr.c
>
> 802
> 803 static void nvmet_execute_pr_report(struct nvmet_req *req)
> 804 {
> 805 u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
> 806 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
> 807 u32 num_bytes = 4 * (cdw10 + 1); /* cdw10 is number of dwords */
> 808 u8 eds = cdw11 & 1; /* Extended data structure, bit 00 */
> 809 struct nvme_registered_ctrl_ext *ctrl_eds;
> 810 struct nvme_reservation_status_ext *data;
> 811 struct nvmet_pr *pr = &req->ns->pr;
> 812 struct nvmet_pr_registrant *holder;
> 813 struct nvmet_pr_registrant *reg;
> 814 u16 num_ctrls = 0;
> 815 u16 status;
> 816 u8 rtype;
> 817
> 818 /* nvmet hostid(uuid_t) is 128 bit. */
> 819 if (!eds) {
> 820 req->error_loc = offsetof(struct nvme_common_command, cdw11);
> 821 status = NVME_SC_HOST_ID_INCONSIST | NVME_STATUS_DNR;
> 822 goto out;
> 823 }
> 824
> 825 if (num_bytes < sizeof(struct nvme_reservation_status_ext)) {
> 826 req->error_loc = offsetof(struct nvme_common_command, cdw10);
> 827 status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
> 828 goto out;
> 829 }
> 830
> 831 data = kmalloc(num_bytes, GFP_KERNEL);
> 832 if (!data) {
> 833 status = NVME_SC_INTERNAL;
> 834 goto out;
> 835 }
> 836 memset(data, 0, num_bytes);
> 837 data->gen = cpu_to_le32(atomic_read(&pr->generation));
> 838 data->ptpls = 0;
> 839 ctrl_eds = data->regctl_eds;
> 840
> 841 rcu_read_lock();
> 842 holder = rcu_dereference(pr->holder);
> 843 rtype = holder ? holder->rtype : 0;
> 844 data->rtype = rtype;
> 845
> 846 list_for_each_entry_rcu(reg, &pr->registrant_list, entry) {
> 847 num_ctrls++;
> 848 /*
> 849 * continue to get the number of all registrans.
> 850 */
> 851 if ((void *)(ctrl_eds + sizeof(*ctrl_eds)) >
> 852 (void *)(data + num_bytes))
> 853 continue;
> 854 /*
> 855 * Dynamic controller, set cntlid to 0xffff.
> 856 */
> > 857 ctrl_eds->cntlid = NVME_CNTLID_DYNAMIC;
Hi Keith,
I miss here should use cpu_to_le16, should I send a v20 to fix this?
Best Regards,
Guixin Liu
> 858 if (rtype == NVME_PR_WRITE_EXCLUSIVE_ALL_REGS ||
> 859 rtype == NVME_PR_EXCLUSIVE_ACCESS_ALL_REGS)
> 860 ctrl_eds->rcsts = 1;
> 861 if (reg == holder)
> 862 ctrl_eds->rcsts = 1;
> 863 uuid_copy((uuid_t *)&ctrl_eds->hostid, ®->hostid);
> 864 ctrl_eds->rkey = cpu_to_le64(reg->rkey);
> 865 ctrl_eds++;
> 866 }
> 867 rcu_read_unlock();
> 868
> 869 put_unaligned_le16(num_ctrls, data->regctl);
> 870 status = nvmet_copy_to_sgl(req, 0, data, num_bytes);
> 871 kfree(data);
> 872 out:
> 873 nvmet_req_complete(req, status);
> 874 }
> 875
>
next prev parent reply other threads:[~2024-11-08 3:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 3:18 [linux-nvme:nvme-6.13 7/7] drivers/nvme/target/pr.c:857:34: sparse: sparse: incorrect type in assignment (different base types) kernel test robot
2024-11-08 3:29 ` Guixin Liu [this message]
2024-11-08 7:10 ` Christoph Hellwig
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=c44c4ea6-ef4d-4152-ba21-9a76011dd75e@linux.alibaba.com \
--to=kanie@linux.alibaba.com \
--cc=d.bogdanov@yadro.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-nvme@lists.infradead.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox