From: Christoph Hellwig <hch@lst.de>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@fb.com>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
Akinobu Mita <akinobu.mita@gmail.com>,
linux-pm@vger.kernel.org, Chris Healy <cphealy@gmail.com>
Subject: Re: [PATCH v2] nvme: Add hardware monitoring support
Date: Wed, 30 Oct 2019 15:12:56 +0100 [thread overview]
Message-ID: <20191030141256.GB14252@lst.de> (raw)
In-Reply-To: <20191029223214.18889-1-linux@roeck-us.net>
On Tue, Oct 29, 2019 at 03:32:14PM -0700, Guenter Roeck wrote:
> This patch adds support to read NVME temperatures from the kernel using the
> hwmon API and adds temperature zones for NVME drives. The thermal subsystem
> can use this information to set thermal policies, and userspace can access
> it using libsensors and/or the "sensors" command.
Except in all upper case or all lower case identifier the speling should
always be "NVMe". Thi also happens a few more places like in the Kconfig
text.
> +static int nvme_hwmon_get_smart_log(struct nvme_hwmon_data *data)
> +{
> + return nvme_get_log(data->ctrl, NVME_NSID_ALL, NVME_LOG_SMART, 0,
> + &data->log, sizeof(data->log), 0);
> +}
> +
> +static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
> + u32 attr, int channel, long *val)
> +{
> + struct nvme_hwmon_data *data = dev_get_drvdata(dev);
> + struct nvme_smart_log *log = &data->log;
> + int err;
> + int temp;
> +
> + err = nvme_hwmon_get_smart_log(data);
> + if (err)
> + return err < 0 ? err : -EPROTO;
I think the handling of positive errnos fits better into
nvme_hwmon_get_smart_log. Also EIO sounds like a better error for
generic NVMe level errors.
> +
> + switch (attr) {
> + case hwmon_temp_max:
> + *val = (data->ctrl->wctemp - 273) * 1000;
> + break;
> + case hwmon_temp_crit:
> + *val = (data->ctrl->cctemp - 273) * 1000;
> + break;
> + case hwmon_temp_input:
> + if (!channel)
> + temp = le16_to_cpup((__le16 *)log->temperature);
This needs to use get_unaligned_le16, otherwise you'll run into problems
on architectures that don't support unaligned loads.
> +static const struct hwmon_ops nvme_hwmon_ops = {
> + .is_visible = nvme_hwmon_is_visible,
> + .read = nvme_hwmon_read,
> + .read_string = nvme_hwmon_read_string,
> +};
> +
> +static const struct hwmon_chip_info nvme_hwmon_chip_info = {
> + .ops = &nvme_hwmon_ops,
> + .info = nvme_hwmon_info,
> +};
Please use tabs to align all the = in an ops structure.
> +#if IS_ENABLED(CONFIG_NVME_HWMON)
No real need to use IS_ENABLED here, a plain ifdef should do it.
next prev parent reply other threads:[~2019-10-30 14:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-29 22:32 [PATCH v2] nvme: Add hardware monitoring support Guenter Roeck
2019-10-30 0:53 ` Keith Busch
2019-11-06 21:29 ` Pavel Machek
2019-11-06 22:30 ` Guenter Roeck
2019-11-06 23:58 ` Chris Healy
2019-10-30 11:16 ` Akinobu Mita
2019-10-30 14:05 ` Christoph Hellwig
2019-10-31 2:54 ` Guenter Roeck
2019-10-31 13:46 ` Christoph Hellwig
2019-10-31 13:46 ` Akinobu Mita
2019-10-31 2:20 ` Guenter Roeck
2019-10-31 13:44 ` Akinobu Mita
2019-10-31 13:45 ` Christoph Hellwig
2019-10-31 17:54 ` Guenter Roeck
2019-10-30 14:12 ` Christoph Hellwig [this message]
2019-10-30 23:40 ` Chris Healy
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=20191030141256.GB14252@lst.de \
--to=hch@lst.de \
--cc=akinobu.mita@gmail.com \
--cc=axboe@fb.com \
--cc=cphealy@gmail.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@roeck-us.net \
--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;
as well as URLs for NNTP newsgroup(s).