[PATCH] nvme: Remove redundant validation in nvme_start_ctrl()

Chaitanya Kulkarni Chaitanya.Kulkarni at wdc.com
Mon Jul 13 19:58:18 EDT 2020


On 7/12/20 23:31, Baolin Wang wrote:
> We've already validated the 'kato' in nvme_start_keep_alive(), thus no
> need to validate it again in nvme_start_ctrl(). Remove it.
> 
> Signed-off-by: Baolin Wang <baolin.wang at linux.alibaba.com>
> ---
>   drivers/nvme/host/core.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 3d00ea4..a95e26e 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -4313,8 +4313,7 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl)
>   
>   void nvme_start_ctrl(struct nvme_ctrl *ctrl)
>   {
> -	if (ctrl->kato)
> -		nvme_start_keep_alive(ctrl);
> +	nvme_start_keep_alive(ctrl);
>   
>   	nvme_enable_aen(ctrl);
>   
> 

Since start keep alive is so small to make a function call how about we 
in-line the call ? untested patch :-

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 09abf2ca33f5..c7289c23658a 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4311,8 +4311,9 @@ EXPORT_SYMBOL_GPL(nvme_stop_ctrl);

  void nvme_start_ctrl(struct nvme_ctrl *ctrl)
  {
+       /* if ctrl keep alive time out is set start keep alive */
         if (ctrl->kato)
-               nvme_start_keep_alive(ctrl);
+               queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * 
HZ);

         nvme_enable_aen(ctrl);

root at iouring nvme (xarray) # git diff
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 09abf2ca33f5..08e1a6826b08 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1031,14 +1031,6 @@ static void nvme_keep_alive_work(struct 
work_struct *work)
         }
  }

-static void nvme_start_keep_alive(struct nvme_ctrl *ctrl)
-{
-       if (unlikely(ctrl->kato == 0))
-               return;
-
-       queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * HZ);
-}
-
  void nvme_stop_keep_alive(struct nvme_ctrl *ctrl)
  {
         if (unlikely(ctrl->kato == 0))
@@ -4311,8 +4303,9 @@ EXPORT_SYMBOL_GPL(nvme_stop_ctrl);

  void nvme_start_ctrl(struct nvme_ctrl *ctrl)
  {
+       /* if ctrl keep alive time out is set start keep alive */
         if (ctrl->kato)
-               nvme_start_keep_alive(ctrl);
+               queue_delayed_work(nvme_wq, &ctrl->ka_work, ctrl->kato * 
HZ);

         nvme_enable_aen(ctrl);





More information about the Linux-nvme mailing list