Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp243220pxb; Wed, 25 Aug 2021 02:06:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyH9OSmuCBOvqBw/ehaxkRfzXWlvDwHs6NmUCHH1G1APV8p2dx7FhJYSY9xVozMXlxg1v3 X-Received: by 2002:a05:6602:1246:: with SMTP id o6mr9882267iou.173.1629882360477; Wed, 25 Aug 2021 02:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629882360; cv=none; d=google.com; s=arc-20160816; b=AqWIXAFDoKDs8n+kGXEAGXYPaHGJgVtjNSSSEb+iDP4tvkaw/I5ok5D6w60ZuKUhrx J1NibrYxCRC1toR5ax2uNeM985tERJOfJffe0OvPaPrHjvIUGzYFvSjJoY2LMdo8GQyx XuNaXfb3qZ8Q6eBvaPNMa3ng7SZRTOQPu63ZOWvrn78ipVBLkJvF1rsz5L5FsSiKWA02 0mwtSqXh+V54lbSC7Tw6FmSDQyin2COifOWEkfJFL+Doj3mOuuurnL9v7/PchUy6sM9Q SViAhBrJWHZX5hqWntCwuhAm2NcwFxGqL3d0hsfJtj1SoUzzX23nDa8L6iqYGqirILtL ifnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ANSeXgSMbXaVqDqlNKbhIQwwHO35PgsfiDdAJesICD4=; b=CrAnh6BHAP88cie8y91BVum0A7z3wdSTBKRJ3TsdwKzxzxikfSiAqmX/g399vivtC0 h1NmIp9wY/Uq/qicfoPioG1WZlMUx67X/VD8HXvw0ll3vV7jCGxqwWJgJ0hm9lVL982O 0W/WKWSpQMXnKy7I8ZcG5NjZI9qDkbzAaZIBvUQB+98JleehxH1cJIiLHDEN9PVXPm8W MW36pjL4WBkM1UlHh5DnE38VbMUd+70VqI40TAKPLnNpfIJPoWjIHQ0g9znJuOKlgsho 8VHbflx3DsbxQpKyqocnINdgekhu1Wa3TuSlpuBcfEQSSLi+jFS4CtTqDn0xZE2AgITa B78w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si19375616ioq.78.2021.08.25.02.05.49; Wed, 25 Aug 2021 02:06:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239461AbhHYJFN (ORCPT + 99 others); Wed, 25 Aug 2021 05:05:13 -0400 Received: from verein.lst.de ([213.95.11.211]:55365 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232302AbhHYJFM (ORCPT ); Wed, 25 Aug 2021 05:05:12 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 0FB9D67357; Wed, 25 Aug 2021 11:04:25 +0200 (CEST) Date: Wed, 25 Aug 2021 11:04:24 +0200 From: "hch@lst.de" To: Sagi Grimberg Cc: sasaki tatsuya , "kbusch@kernel.org" , "axboe@fb.com" , "hch@lst.de" , "linux-nvme@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] nvme: update keep alive interval when kato is modified Message-ID: <20210825090424.GA468@lst.de> References: <526a1a756d6c4643b15b1b305cc32817@kioxia.com> <05033836-83b9-c060-0348-774a02b60d01@grimberg.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <05033836-83b9-c060-0348-774a02b60d01@grimberg.me> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 24, 2021 at 01:41:44PM -0700, Sagi Grimberg wrote: >> +{ >> + /* >> + * Keep alive commands interval on the host should be updated >> + * when KATO is modified by Set Features commands. >> + */ >> + if (cmd->opcode == nvme_admin_set_features && >> + (cmd->cdw10 & 0xFF) == NVME_FEAT_KATO) { >> + /* ms -> s */ > > no need for this comment. > >> + unsigned int new_kato = DIV_ROUND_UP(cmd->cdw11, 1000); >> + >> + nvme_update_keep_alive(ctrl, new_kato); > > I think you can now inline nvme_update_keep_alive here, no need to keep > it in a function. Actually, іf thinking ahead I think one helper per fixup would be really useful to keep the code organized. But the DIV_ROUND_UP should move into nvme_update_keep_alive to keep it self-contained. We can then restructure the caller a bit to make it easier to expand: switch (cmd->opcode) { case nvme_admin_set_features: switch (cmd->cdw10 & 0xff) { case NVME_FEAT_KATO: nvme_update_keep_alive(ctrl, cmd); break; } }