LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
Cc: "Busch, Keith" <keith.busch@intel.com>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
	linux-pm <linux-pm@vger.kernel.org>,
	Mario Limonciello <Mario.Limonciello@dell.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Kai Heng Feng <kai.heng.feng@canonical.com>,
	Rafael Wysocki <rafael@kernel.org>
Subject: Re: [PATCH] nvme/pci: Use host managed power state for suspend
Date: Mon, 13 May 2019 07:47:08 -0600	[thread overview]
Message-ID: <20190513134708.GB15318@localhost.localdomain> (raw)
In-Reply-To: <SN6PR04MB452735778FD952AA838E78C9860E0@SN6PR04MB4527.namprd04.prod.outlook.com>

On Sat, May 11, 2019 at 11:06:35PM -0700, Chaitanya Kulkarni wrote:
> On 5/10/19 2:35 PM, Keith Busch wrote:
> >   
> > +int nvme_set_power(struct nvme_ctrl *ctrl, unsigned ps)

> dev->ctrl.npss is u8 can we use same data type here ?
> If this is due to last_ps we use as a result and then call set_power may 
> be we can change the type of last_ps ?
> OR
> can we please use unsigned int to avoid possible warnings ?

Right, the feature uses a 32-bit value even though only the first byte
is defined at the moment. It's just for foward compatibility. Will make
this a u32.

> > +int nvme_get_power(struct nvme_ctrl *ctrl, u32 *result)
> > +{
> > +	struct nvme_command c;
> May be use struct nvme_command c {} so we can get rid of the memset() call.

Good point.

> > +	union nvme_result res;
> > +	int ret;
> > +
> > +	if (!result)
> > +		return -EINVAL;
> > +
> > +	memset(&c, 0, sizeof(c));
> > +	c.features.opcode = nvme_admin_get_features;
> > +	c.features.fid = cpu_to_le32(NVME_FEAT_POWER_MGMT);
> > +
> > +	ret = __nvme_submit_sync_cmd(ctrl->admin_q, &c, &res,
> > +			NULL, 0, 0, NVME_QID_ANY, 0, 0, false);
> > +	if (ret >= 0)
> > +		*result = le32_to_cpu(res.u32);
>
> May be add a check for result here in above if before deref pointer :-
> 	if (ret >= 0 && result)

I have it checked at the top of the function since it doesn't make much
sense to call this without a way to return the result.

      parent reply	other threads:[~2019-05-13 13:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10 21:29 Keith Busch
2019-05-11  0:52 ` Mario.Limonciello
2019-05-13 14:24   ` Mario.Limonciello
2019-05-13 14:37     ` Christoph Hellwig
2019-05-13 14:43       ` Mario.Limonciello
2019-05-13 14:54         ` Christoph Hellwig
2019-05-13 14:55         ` Keith Busch
2019-05-13 15:05           ` Mario.Limonciello
2019-05-13 15:04             ` Keith Busch
2019-05-14  8:04               ` Rafael J. Wysocki
2019-05-14 22:16                 ` Keith Busch
2019-05-15  9:00                   ` Rafael J. Wysocki
2019-05-13 14:37     ` Keith Busch
2019-05-13 14:54       ` Mario.Limonciello
2019-05-13 14:57         ` Christoph Hellwig
2019-05-13 15:16           ` Keith Busch
2019-05-13 17:16             ` Kai-Heng Feng
2019-05-13 18:16               ` Keith Busch
2019-05-13 18:01           ` Mario.Limonciello
2019-05-14  6:11             ` Christoph Hellwig
2019-05-11  1:33 ` Edmund Nadolski
2019-05-11  7:22 ` Christoph Hellwig
2019-05-12 14:34   ` Sagi Grimberg
2019-05-13 13:36   ` Keith Busch
2019-05-12  6:06 ` Chaitanya Kulkarni
2019-05-12 14:30   ` Minwoo Im
2019-05-12 15:20     ` Chaitanya Kulkarni
2019-05-13 13:47   ` Keith Busch [this message]

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=20190513134708.GB15318@localhost.localdomain \
    --to=kbusch@kernel.org \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --cc=Mario.Limonciello@dell.com \
    --cc=hch@lst.de \
    --cc=kai.heng.feng@canonical.com \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=sagi@grimberg.me \
    --subject='Re: [PATCH] nvme/pci: Use host managed power state for suspend' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).