* [PATCH] NVMe: Set block queue max sectors
@ 2012-07-25 22:07 Keith Busch
2012-07-26 16:22 ` Matthew Wilcox
0 siblings, 1 reply; 4+ messages in thread
From: Keith Busch @ 2012-07-25 22:07 UTC (permalink / raw)
Set the max hw sectors in a namespace's request queue if the nvme device has a
max data transfer size.
Signed-off-by: Keith Busch <keith.busch at intel.com>
---
drivers/block/nvme.c | 6 ++++++
include/linux/nvme.h | 1 +
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index 38b9c73..3247037 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -78,6 +78,7 @@ struct nvme_dev {
char serial[20];
char model[40];
char firmware_rev[8];
+ u32 max_hw_sectors;
};
/*
@@ -1345,6 +1346,8 @@ static struct nvme_ns *nvme_alloc_ns(struct nvme_dev *dev, int nsid,
lbaf = id->flbas & 0xf;
ns->lba_shift = id->lbaf[lbaf].ds;
blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift);
+ if (dev->max_hw_sectors)
+ blk_queue_max_hw_sectors(ns->queue, dev->max_hw_sectors);
disk->major = nvme_major;
disk->minors = NVME_MINORS;
@@ -1486,6 +1489,9 @@ static int __devinit nvme_dev_add(struct nvme_dev *dev)
memcpy(dev->serial, ctrl->sn, sizeof(ctrl->sn));
memcpy(dev->model, ctrl->mn, sizeof(ctrl->mn));
memcpy(dev->firmware_rev, ctrl->fr, sizeof(ctrl->fr));
+ if (ctrl->mdts)
+ dev->max_hw_sectors = ((1 << ctrl->mdts) * (1 << (12 +
+ NVME_CAP_MPSMIN(readq(&dev->bar->cap))))) >> 9;
id_ns = mem;
for (i = 1; i <= nn; i++) {
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 9490a00..8c71d20 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -37,6 +37,7 @@ struct nvme_bar {
#define NVME_CAP_TIMEOUT(cap) (((cap) >> 24) & 0xff)
#define NVME_CAP_STRIDE(cap) (((cap) >> 32) & 0xf)
+#define NVME_CAP_MPSMIN(cap) (((cap) >> 48) & 0xf)
enum {
NVME_CC_ENABLE = 1 << 0,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] NVMe: Set block queue max sectors
2012-07-25 22:07 [PATCH] NVMe: Set block queue max sectors Keith Busch
@ 2012-07-26 16:22 ` Matthew Wilcox
0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2012-07-26 16:22 UTC (permalink / raw)
On Wed, Jul 25, 2012@04:07:10PM -0600, Keith Busch wrote:
> Set the max hw sectors in a namespace's request queue if the nvme device has a
> max data transfer size.
Could I trouble you to reflow your comments in the future? When one
types 'git log', it inserts four spaces before the message, so this
would look like:
Set the max hw sectors in a namespace's request queue if the nvme device has a
max data transfer size.
I find that typing !{fmt in vi does the right thing (it defaults to 75
columns), but I don't know which editor you use.
> memcpy(dev->firmware_rev, ctrl->fr, sizeof(ctrl->fr));
> + if (ctrl->mdts)
> + dev->max_hw_sectors = ((1 << ctrl->mdts) * (1 << (12 +
> + NVME_CAP_MPSMIN(readq(&dev->bar->cap))))) >> 9;
>
There's something about seeing five close-parens in a row that makes
me uncomfortable. Maybe I was molested by a lisp compiler as a child
or something, but it tends to indicate an overly complex expression.
Let's see, what might look better ...
if (ctrl->mdts) {
int mpsmin = 1 << (NVME_CAP_MPSMIN(readq(&dev->bar->cap)) + 12);
dev->max_hw_sectors = ((1 << ctrl->mdts) * mpsmin) >> 9;
}
Alternatively, we could redistribute some of the arithmetic ...
if (ctrl->mdts)
dev->max_hw_sectors = 1 << (12 - 9 + ctrl->mdts +
NVME_CAP_MPSMIN(readq(&dev->bar->cap)));
but that's a little obscure. Perhaps a little less obscure:
if (ctrl->mdts) {
int shift = NVME_CAP_MPSMIN(readq(&dev->bar->cap)) + 12;
dev->max_hw_sectors = 1 << (ctrl->mdts + shift - 9);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] NVMe: Set block queue max sectors
2012-07-26 17:29 Keith Busch
@ 2012-07-26 17:43 ` Matthew Wilcox
0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2012-07-26 17:43 UTC (permalink / raw)
On Thu, Jul 26, 2012@11:29:57AM -0600, Keith Busch wrote:
> Set the max hw sectors in a namespace's request queue if the nvme device
> has a max data transfer size.
Thanks, committed. There was trailing whitespace that I fixed up.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] NVMe: Set block queue max sectors
@ 2012-07-26 17:29 Keith Busch
2012-07-26 17:43 ` Matthew Wilcox
0 siblings, 1 reply; 4+ messages in thread
From: Keith Busch @ 2012-07-26 17:29 UTC (permalink / raw)
Set the max hw sectors in a namespace's request queue if the nvme device
has a max data transfer size.
Signed-off-by: Keith Busch <keith.busch at intel.com>
---
drivers/block/nvme.c | 7 +++++++
include/linux/nvme.h | 1 +
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index 7bcd882..933b321 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -78,6 +78,7 @@ struct nvme_dev {
char serial[20];
char model[40];
char firmware_rev[8];
+ u32 max_hw_sectors;
};
/*
@@ -1344,6 +1345,8 @@ static struct nvme_ns *nvme_alloc_ns(struct nvme_dev *dev, int nsid,
lbaf = id->flbas & 0xf;
ns->lba_shift = id->lbaf[lbaf].ds;
blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift);
+ if (dev->max_hw_sectors)
+ blk_queue_max_hw_sectors(ns->queue, dev->max_hw_sectors);
disk->major = nvme_major;
disk->minors = NVME_MINORS;
@@ -1485,6 +1488,10 @@ static int __devinit nvme_dev_add(struct nvme_dev *dev)
memcpy(dev->serial, ctrl->sn, sizeof(ctrl->sn));
memcpy(dev->model, ctrl->mn, sizeof(ctrl->mn));
memcpy(dev->firmware_rev, ctrl->fr, sizeof(ctrl->fr));
+ if (ctrl->mdts) {
+ int shift = NVME_CAP_MPSMIN(readq(&dev->bar->cap)) + 12;
+ dev->max_hw_sectors = 1 << (ctrl->mdts + shift - 9);
+ }
id_ns = mem;
for (i = 1; i <= nn; i++) {
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 9490a00..8c71d20 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -37,6 +37,7 @@ struct nvme_bar {
#define NVME_CAP_TIMEOUT(cap) (((cap) >> 24) & 0xff)
#define NVME_CAP_STRIDE(cap) (((cap) >> 32) & 0xf)
+#define NVME_CAP_MPSMIN(cap) (((cap) >> 48) & 0xf)
enum {
NVME_CC_ENABLE = 1 << 0,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-26 17:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-25 22:07 [PATCH] NVMe: Set block queue max sectors Keith Busch
2012-07-26 16:22 ` Matthew Wilcox
2012-07-26 17:29 Keith Busch
2012-07-26 17:43 ` Matthew Wilcox
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.