* [PATCH 1/4] nvme: add a helper to check ctrl sgl support
2021-06-10 1:28 [PATCH 0/4] nvme: add ctrl sgl supported helper Chaitanya Kulkarni
@ 2021-06-10 1:28 ` Chaitanya Kulkarni
2021-06-10 1:28 ` [PATCH 2/4] nvme-fc: use ctrl sgl check helper Chaitanya Kulkarni
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-10 1:28 UTC (permalink / raw)
To: linux-nvme; +Cc: hch, Chaitanya Kulkarni
For various transports such as fc/tcp/pci it is common to check if
NVMe SGLs are supported or not by the controller.
In this preparation patch we add a helper to avoid the open coding of
such checks in the various transport.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
drivers/nvme/host/nvme.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 1f397ecba16c..1aab74128d40 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -869,6 +869,14 @@ static inline void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
}
#endif
+static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl)
+{
+ if (!(ctrl->sgls & ((1 << 0) | (1 << 1))))
+ return true;
+
+ return false;
+}
+
u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
u8 opcode);
void nvme_execute_passthru_rq(struct request *rq);
--
2.22.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/4] nvme-fc: use ctrl sgl check helper
2021-06-10 1:28 [PATCH 0/4] nvme: add ctrl sgl supported helper Chaitanya Kulkarni
2021-06-10 1:28 ` [PATCH 1/4] nvme: add a helper to check ctrl sgl support Chaitanya Kulkarni
@ 2021-06-10 1:28 ` Chaitanya Kulkarni
2021-06-10 1:28 ` [PATCH 3/4] nvm-pci: " Chaitanya Kulkarni
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-10 1:28 UTC (permalink / raw)
To: linux-nvme; +Cc: hch, Chaitanya Kulkarni, James Smart
Use the helper to check NVMe controller's SGL support.
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
drivers/nvme/host/fc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index f183f9fa03d0..7600863f7752 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -3112,7 +3112,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
}
/* FC-NVME supports normal SGL Data Block Descriptors */
- if (!(ctrl->ctrl.sgls & ((1 << 0) | (1 << 1)))) {
+ if (!nvme_ctrl_sgl_supported(&ctrl->ctrl)) {
dev_err(ctrl->ctrl.device,
"Mandatory sgls are not supported!\n");
ret = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
--
2.22.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/4] nvm-pci: use ctrl sgl check helper
2021-06-10 1:28 [PATCH 0/4] nvme: add ctrl sgl supported helper Chaitanya Kulkarni
2021-06-10 1:28 ` [PATCH 1/4] nvme: add a helper to check ctrl sgl support Chaitanya Kulkarni
2021-06-10 1:28 ` [PATCH 2/4] nvme-fc: use ctrl sgl check helper Chaitanya Kulkarni
@ 2021-06-10 1:28 ` Chaitanya Kulkarni
2021-06-10 1:28 ` [PATCH 4/4] nvme-tcp: " Chaitanya Kulkarni
2021-06-15 16:18 ` [PATCH 0/4] nvme: add ctrl sgl supported helper Christoph Hellwig
4 siblings, 0 replies; 8+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-10 1:28 UTC (permalink / raw)
To: linux-nvme; +Cc: hch, Chaitanya Kulkarni
Use the helper to check NVMe controller's SGL support.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
drivers/nvme/host/pci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index c5356028199d..5df1adc5a1db 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -536,7 +536,7 @@ static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req)
avg_seg_size = DIV_ROUND_UP(blk_rq_payload_bytes(req), nseg);
- if (!(dev->ctrl.sgls & ((1 << 0) | (1 << 1))))
+ if (!nvme_ctrl_sgl_supported(&dev->ctrl))
return false;
if (!iod->nvmeq->qid)
return false;
@@ -853,7 +853,7 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,
&cmnd->rw, &bv);
if (iod->nvmeq->qid && sgl_threshold &&
- dev->ctrl.sgls & ((1 << 0) | (1 << 1)))
+ nvme_ctrl_sgl_supported(&dev->ctrl))
return nvme_setup_sgl_simple(dev, req,
&cmnd->rw, &bv);
}
--
2.22.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/4] nvme-tcp: use ctrl sgl check helper
2021-06-10 1:28 [PATCH 0/4] nvme: add ctrl sgl supported helper Chaitanya Kulkarni
` (2 preceding siblings ...)
2021-06-10 1:28 ` [PATCH 3/4] nvm-pci: " Chaitanya Kulkarni
@ 2021-06-10 1:28 ` Chaitanya Kulkarni
2021-06-17 1:36 ` Prabhakar Kushwaha
2021-06-15 16:18 ` [PATCH 0/4] nvme: add ctrl sgl supported helper Christoph Hellwig
4 siblings, 1 reply; 8+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-10 1:28 UTC (permalink / raw)
To: linux-nvme; +Cc: hch, Chaitanya Kulkarni, Sagi Grimberg
Use the helper to check NVMe controller's SGL support.
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
drivers/nvme/host/tcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 6a65b0516180..c7bd37103cf4 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1993,7 +1993,7 @@ static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new)
goto destroy_admin;
}
- if (!(ctrl->sgls & ((1 << 0) | (1 << 1)))) {
+ if (!nvme_ctrl_sgl_supported(ctrl)) {
ret = -EOPNOTSUPP;
dev_err(ctrl->device, "Mandatory sgls are not supported!\n");
goto destroy_admin;
--
2.22.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 4/4] nvme-tcp: use ctrl sgl check helper
2021-06-10 1:28 ` [PATCH 4/4] nvme-tcp: " Chaitanya Kulkarni
@ 2021-06-17 1:36 ` Prabhakar Kushwaha
2021-06-17 4:59 ` Chaitanya Kulkarni
0 siblings, 1 reply; 8+ messages in thread
From: Prabhakar Kushwaha @ 2021-06-17 1:36 UTC (permalink / raw)
To: Chaitanya Kulkarni
Cc: linux-nvme, hch, Sagi Grimberg, Prabhakar Kushwaha, Shai Malin,
Omkar Kulkarni, malin1024
Hi Chaitanya,
On Thu, Jun 10, 2021 at 7:04 AM Chaitanya Kulkarni
<chaitanya.kulkarni@wdc.com> wrote:
>
> Use the helper to check NVMe controller's SGL support.
>
> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
> drivers/nvme/host/tcp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 6a65b0516180..c7bd37103cf4 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -1993,7 +1993,7 @@ static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new)
> goto destroy_admin;
> }
>
> - if (!(ctrl->sgls & ((1 << 0) | (1 << 1)))) {
> + if (!nvme_ctrl_sgl_supported(ctrl)) {
> ret = -EOPNOTSUPP;
> dev_err(ctrl->device, "Mandatory sgls are not supported!\n");
> goto destroy_admin;
> --
> 2.22.1
>
>
base patch defines nvme_ctrl_sgl_supported as below
+static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl)
+{
+ if (!(ctrl->sgls & ((1 << 0) | (1 << 1))))
+ return true;
+
+ return false;
+}
The "!" is already part of nvme_ctrl_sgl_supported(). There is no
point in keeping "!" at other places.
So, either remove "!" from other places or from nvme_ctrl_sgl_supported().
I request you to check the logic again.
In case you are planning to fix, the best place would be
nvme_ctrl_sgl_supported() to have minimal changes.
-pk
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/4] nvme-tcp: use ctrl sgl check helper
2021-06-17 1:36 ` Prabhakar Kushwaha
@ 2021-06-17 4:59 ` Chaitanya Kulkarni
0 siblings, 0 replies; 8+ messages in thread
From: Chaitanya Kulkarni @ 2021-06-17 4:59 UTC (permalink / raw)
To: Prabhakar Kushwaha
Cc: linux-nvme, hch, Sagi Grimberg, Prabhakar Kushwaha, Shai Malin,
Omkar Kulkarni, malin1024
> On Jun 16, 2021, at 6:37 PM, Prabhakar Kushwaha <prabhakar.pkin@gmail.com> wrote:
>
> Hi Chaitanya,
>
>> On Thu, Jun 10, 2021 at 7:04 AM Chaitanya Kulkarni
>> <chaitanya.kulkarni@wdc.com> wrote:
>>
>> Use the helper to check NVMe controller's SGL support.
>>
>> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
>> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
>> ---
>> drivers/nvme/host/tcp.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
>> index 6a65b0516180..c7bd37103cf4 100644
>> --- a/drivers/nvme/host/tcp.c
>> +++ b/drivers/nvme/host/tcp.c
>> @@ -1993,7 +1993,7 @@ static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new)
>> goto destroy_admin;
>> }
>>
>> - if (!(ctrl->sgls & ((1 << 0) | (1 << 1)))) {
>> + if (!nvme_ctrl_sgl_supported(ctrl)) {
>> ret = -EOPNOTSUPP;
>> dev_err(ctrl->device, "Mandatory sgls are not supported!\n");
>> goto destroy_admin;
>> --
>> 2.22.1
>>
>>
>
> base patch defines nvme_ctrl_sgl_supported as below
> +static inline bool nvme_ctrl_sgl_supported(struct nvme_ctrl *ctrl)
> +{
> + if (!(ctrl->sgls & ((1 << 0) | (1 << 1))))
> + return true;
> +
> + return false;
> +}
>
> The "!" is already part of nvme_ctrl_sgl_supported(). There is no
> point in keeping "!" at other places.
> So, either remove "!" from other places or from nvme_ctrl_sgl_supported().
>
> I request you to check the logic again.
> In case you are planning to fix, the best place would be
> nvme_ctrl_sgl_supported() to have minimal changes.
>
> -pk
Thanks for pointing this out. I'll send out the fix shortly.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] nvme: add ctrl sgl supported helper
2021-06-10 1:28 [PATCH 0/4] nvme: add ctrl sgl supported helper Chaitanya Kulkarni
` (3 preceding siblings ...)
2021-06-10 1:28 ` [PATCH 4/4] nvme-tcp: " Chaitanya Kulkarni
@ 2021-06-15 16:18 ` Christoph Hellwig
4 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2021-06-15 16:18 UTC (permalink / raw)
To: Chaitanya Kulkarni; +Cc: linux-nvme, hch
Thanks,
applied to nvme-5.14.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 8+ messages in thread