From: willy@linux.intel.com (Matthew Wilcox)
Subject: [PATCH] nvme: add a constant for the identify payload size
Date: Wed, 9 Mar 2016 14:07:31 -0500 [thread overview]
Message-ID: <20160309190731.GD2464@linux.intel.com> (raw)
In-Reply-To: <1457542477-25191-1-git-send-email-hch@lst.de>
On Wed, Mar 09, 2016@05:54:37PM +0100, Christoph Hellwig wrote:
> The NVMe spec specifies a hardcoded payload length of 4k for all
> types of Identify commands. Use a constant instead of hardcoded
> values that can be confused for the page size.
I think the problem here is that we don't have a struct for nvme_ns_list.
Something like this:
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e2d11d6..a4a7210 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -296,14 +296,16 @@ int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
return error;
}
-static int nvme_identify_ns_list(struct nvme_ctrl *dev, unsigned nsid, __le32 *ns_list)
+static int nvme_identify_ns_list(struct nvme_ctrl *dev, unsigned nsid,
+ struct nvme_id_ns_list *ns_list)
{
struct nvme_command c = { };
c.identify.opcode = nvme_admin_identify;
c.identify.cns = cpu_to_le32(2);
c.identify.nsid = cpu_to_le32(nsid);
- return nvme_submit_sync_cmd(dev->admin_q, &c, ns_list, 0x1000);
+ return nvme_submit_sync_cmd(dev->admin_q, &c, ns_list,
+ sizeof(*ns_list));
}
int nvme_identify_ns(struct nvme_ctrl *dev, unsigned nsid,
@@ -1296,11 +1298,11 @@ static void nvme_validate_ns(struct nvme_ctrl *ctrl, unsigned nsid)
static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn)
{
struct nvme_ns *ns;
- __le32 *ns_list;
+ struct nvme_id_ns_list *ns_list;
unsigned i, j, nsid, prev = 0, num_lists = DIV_ROUND_UP(nn, 1024);
int ret = 0;
- ns_list = kzalloc(0x1000, GFP_KERNEL);
+ ns_list = kzalloc(sizeof(*ns_list), GFP_KERNEL);
if (!ns_list)
return -ENOMEM;
@@ -1310,7 +1312,7 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn)
goto out;
for (j = 0; j < min(nn, 1024U); j++) {
- nsid = le32_to_cpu(ns_list[j]);
+ nsid = le32_to_cpu(ns_list->nsid[j]);
if (!nsid)
goto out;
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index aff71ef..ec2198c 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -175,6 +175,7 @@ static inline void _nvme_check_size(void)
BUILD_BUG_ON(sizeof(struct nvme_command) != 64);
BUILD_BUG_ON(sizeof(struct nvme_id_ctrl) != 4096);
BUILD_BUG_ON(sizeof(struct nvme_id_ns) != 4096);
+ BUILD_BUG_ON(sizeof(struct nvme_id_ns_list) != 4096);
BUILD_BUG_ON(sizeof(struct nvme_lba_range_type) != 64);
BUILD_BUG_ON(sizeof(struct nvme_smart_log) != 512);
}
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index a55986f..e9122cf 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -183,6 +183,10 @@ struct nvme_id_ns {
__u8 vs[3712];
};
+struct nvme_id_ns_list {
+ __le32 nsid[1024];
+};
+
enum {
NVME_NS_FEAT_THIN = 1 << 0,
NVME_NS_FLBAS_LBA_MASK = 0xf,
next prev parent reply other threads:[~2016-03-09 19:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-09 16:54 [PATCH] nvme: add a constant for the identify payload size Christoph Hellwig
2016-03-09 16:57 ` Sagi Grimberg
2016-03-09 19:07 ` Matthew Wilcox [this message]
2016-03-10 8:06 ` Christoph Hellwig
2016-03-10 14:30 ` Matthew Wilcox
2016-03-10 8:27 ` Johannes Thumshirn
2016-03-10 8:26 ` Johannes Thumshirn
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=20160309190731.GD2464@linux.intel.com \
--to=willy@linux.intel.com \
/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.