Linux Power Management development
 help / color / mirror / Atom feed
From: Keith Busch <keith.busch@intel.com>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: linux-nvme@lists.infradead.org, linux-pm@vger.kernel.org,
	Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Jens Axboe <axboe@fb.com>, Christoph Hellwig <hch@lst.de>,
	Sagi Grimberg <sagi@grimberg.me>
Subject: Re: [PATCH 1/2] nvme: add thermal zone infrastructure
Date: Wed, 15 May 2019 13:15:19 -0600	[thread overview]
Message-ID: <20190515191518.GA21916@localhost.localdomain> (raw)
In-Reply-To: <1557933437-4693-2-git-send-email-akinobu.mita@gmail.com>

On Thu, May 16, 2019 at 12:17:16AM +0900, Akinobu Mita wrote:
> +int nvme_thermal_zones_register(struct nvme_ctrl *ctrl)
> +{
> +	struct nvme_smart_log *log;
> +	int ret;
> +	int i;
> +
> +	log = kzalloc(sizeof(*log), GFP_KERNEL);
> +	if (!log)
> +		return -ENOMEM;
> +
> +	ret = nvme_get_log(ctrl, NVME_NSID_ALL, NVME_LOG_SMART, 0,
> +			   log, sizeof(*log), 0);
> +	if (ret) {
> +		ret = ret > 0 ? -EINVAL : ret;
> +		goto free_log;
> +	}
> +
> +	for (i = 0; i < ARRAY_SIZE(ctrl->tzdev); i++) {
> +		struct thermal_zone_device *tzdev;
> +
> +		if (i && !le16_to_cpu(log->temp_sensor[i - 1]))
> +			continue;
> +		if (ctrl->tzdev[i])
> +			continue;
> +
> +		tzdev = nvme_thermal_zone_register(ctrl, i);
> +		if (!IS_ERR(tzdev))
> +			ctrl->tzdev[i] = tzdev;
> +	}
> +
> +free_log:
> +	kfree(log);
> +
> +	return ret;
> +}

Since this routine is intended for use in the device initialization path,
the error returns are extra important. We have used < 0 to indicate we
need to abandon initialization because we won't be able communicate with
the device if we proceed. Since thermal reporting is not mandatory to
manage our controllers, out-of-memory or a device that doesn't support
SMART should just return 0. We should only halt init if the controller
is unresponsive here.

In general, I'm okay with this feature.

  reply	other threads:[~2019-05-15 19:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15 15:17 [PATCH 0/2] nvme: add thermal zone devices Akinobu Mita
2019-05-15 15:17 ` [PATCH 1/2] nvme: add thermal zone infrastructure Akinobu Mita
2019-05-15 19:15   ` Keith Busch [this message]
2019-05-16 15:22     ` Akinobu Mita
2019-05-16 15:26       ` Keith Busch
2019-05-16 14:23   ` Minwoo Im
2019-05-16 14:32   ` Minwoo Im
2019-05-16 16:17     ` Akinobu Mita
2019-05-16 16:48       ` Minwoo Im
2019-05-16 14:35   ` Akinobu Mita
2019-05-16 21:22   ` Heitke, Kenneth
2019-05-17 15:01     ` Akinobu Mita
2019-05-17 15:09       ` Keith Busch
2019-05-17 15:36         ` Akinobu Mita
2019-05-16 21:25   ` Heitke, Kenneth
2019-05-17 15:03     ` Akinobu Mita
2019-05-16 23:44   ` Chaitanya Kulkarni
2019-05-17 15:35     ` Akinobu Mita
2019-05-15 15:17 ` [PATCH 2/2] nvme-pci: support thermal zone Akinobu Mita
2019-05-15 17:03   ` Keith Busch
2019-05-16 14:30     ` Akinobu Mita

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=20190515191518.GA21916@localhost.localdomain \
    --to=keith.busch@intel.com \
    --cc=akinobu.mita@gmail.com \
    --cc=axboe@fb.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=edubezval@gmail.com \
    --cc=hch@lst.de \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=sagi@grimberg.me \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox