Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5220760yba; Mon, 13 May 2019 07:21:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzY7Rz2aer/7eCanUh8IgDm1isM/M20FeRY2F+7jt/yGbV4pUb/YnNVmR0HtxMwqMzuoKHU X-Received: by 2002:a63:e602:: with SMTP id g2mr31751571pgh.172.1557757312674; Mon, 13 May 2019 07:21:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557757312; cv=none; d=google.com; s=arc-20160816; b=el3Uor2k5OQ9kBmRbH/Oc2zPXUjAzEvVuZyAwzFUJD8CwZ8/eTFdkG/vyy0MTPoy/P 2H9MSAKSSZ90Qrq1WJ33GxwnU47jtIMIHV3176UzDE/TLVhJwCCRfT4JSSUybBT3T4JV 2krXU+vMzhLXXwXIcQSZUXRNEzO0He87/iJTvKlQ5jfmT5t8Kn6d6H1gShQxXEBzMHnq 5Rh0F+sixY9SPXdvmJGA+pYuRGNDWsfPccQk38Ph4FaqMk54eUFuy6DgznEPiG9yonMV jcm3SPWwXHBZa2KEu/H7pvCX6fbW9T6wUnC/tmJ4F8/Cok79madX4mjRXNXZ1yv9PW5n VwhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=GoyjthmeFSueMDDELJFbBq4UpTXC9LQ957cnOCRiCKs=; b=k5ejWtwBtITyHWmEgyzxM1+Dsibnhmh2e8Rj8R7PKfY/lqxvSaMxy4Ccr0zueZ12al ZrPO1itMXyUK8xMtb6/8mZpxWt6S+xu160B1v1EJrRIz7Ed62s3IoHTen3Tvs8CAa/a8 njLqQgi/TjJTJfIjaho8bXMwfVUK2WanOlexRWVaopzSG/fj7h8q40cpcucpjcoGD4Xb UE3ImqxqKAbQCsu/l2TY3X9Q3a9nuWyEhKRyGoA8h5wt8mOQ6W4owzdRHv3ee8o4i+lK m5VpoFpbSeHCs/U+EJ+Wq6JvRI8D+tzi4JVdnEUGNtPVwJNeOyuTr1ClYx2LjWmMvz36 x7tw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w8si15534564plz.301.2019.05.13.07.21.36; Mon, 13 May 2019 07:21:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729869AbfEMNwb (ORCPT + 99 others); Mon, 13 May 2019 09:52:31 -0400 Received: from mga09.intel.com ([134.134.136.24]:40693 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729452AbfEMNwb (ORCPT ); Mon, 13 May 2019 09:52:31 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 May 2019 06:52:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,465,1549958400"; d="scan'208";a="171196692" Received: from unknown (HELO localhost.localdomain) ([10.232.112.69]) by fmsmga002.fm.intel.com with ESMTP; 13 May 2019 06:52:29 -0700 Date: Mon, 13 May 2019 07:47:08 -0600 From: Keith Busch To: Chaitanya Kulkarni Cc: "Busch, Keith" , Christoph Hellwig , Sagi Grimberg , "linux-nvme@lists.infradead.org" , linux-pm , Mario Limonciello , lkml , Kai Heng Feng , Rafael Wysocki Subject: Re: [PATCH] nvme/pci: Use host managed power state for suspend Message-ID: <20190513134708.GB15318@localhost.localdomain> References: <20190510212937.11661-1-keith.busch@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.