From: Guenter Roeck <linux@roeck-us.net>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Sagi Grimberg <sagi@grimberg.me>,
Linux PM <linux-pm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-nvme@lists.infradead.org, Jens Axboe <axboe@fb.com>,
Keith Busch <kbusch@kernel.org>, Christoph Hellwig <hch@lst.de>,
Chris Healy <cphealy@gmail.com>
Subject: Re: [PATCH v4] nvme: Add hardware monitoring support
Date: Tue, 5 Nov 2019 10:10:23 -0800 [thread overview]
Message-ID: <20191105181023.GA22468@roeck-us.net> (raw)
In-Reply-To: <CAC5umyiJT300+MunDi4wwwAgSxiqx7_rersbNRvybcNoo3kGDg@mail.gmail.com>
On Wed, Nov 06, 2019 at 12:44:56AM +0900, Akinobu Mita wrote:
> 2019年11月6日(水) 0:38 Akinobu Mita <akinobu.mita@gmail.com>:
> >
> > 2019年11月2日(土) 23:55 Guenter Roeck <linux@roeck-us.net>:
> > > diff --git a/drivers/nvme/host/nvme-hwmon.c b/drivers/nvme/host/nvme-hwmon.c
> > > new file mode 100644
> > > index 000000000000..28b4b7f43bb0
> > > --- /dev/null
> > > +++ b/drivers/nvme/host/nvme-hwmon.c
> > > @@ -0,0 +1,181 @@
> > > +// SPDX-License-Identifier: GPL-2.0
> > > +/*
> > > + * NVM Express hardware monitoring support
> > > + * Copyright (c) 2019, Guenter Roeck
> > > + */
> > > +
> > > +#include <linux/hwmon.h>
> > > +#include <asm/unaligned.h>
> > > +
> > > +#include "nvme.h"
> > > +
> > > +struct nvme_hwmon_data {
> > > + struct nvme_ctrl *ctrl;
> > > + struct nvme_smart_log log;
> > > + struct mutex read_lock;
> > > +};
> > > +
> > > +static int nvme_hwmon_get_smart_log(struct nvme_hwmon_data *data)
> > > +{
> > > + int ret;
> > > +
> > > + ret = nvme_get_log(data->ctrl, NVME_NSID_ALL, NVME_LOG_SMART, 0,
> > > + &data->log, sizeof(data->log), 0);
> > > +
> > > + return ret <= 0 ? ret : -EIO;
> > > +}
> > > +
> > > +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 temp;
> > > + int err;
> > > +
> > > + /*
> > > + * First handle attributes which don't require us to read
> > > + * the smart log.
> > > + */
> > > + switch (attr) {
> > > + case hwmon_temp_max:
> > > + *val = (data->ctrl->wctemp - 273) * 1000;
> > > + return 0;
> > > + case hwmon_temp_crit:
> > > + *val = (data->ctrl->cctemp - 273) * 1000;
> >
> > This attribute should be 'hwmon_temp_max_alarm' rather than
> > 'hwmon_temp_crit_alarm'?
>
Yes, you are correct. Actually, re-reading the specification,
the bit may also be set for under-temperature alarms, so I'll
use the more generic hwmon_temp_alarm.
Thanks,
Guenter
> Oops, I misquoted the code.
>
> This comment should be addressed to the code below:
>
> + case hwmon_temp_crit_alarm:
> + *val = !!(log->critical_warning & NVME_SMART_CRIT_TEMPERATURE);
> + break;
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
prev parent reply other threads:[~2019-11-05 18:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-02 14:55 [PATCH v4] nvme: Add hardware monitoring support Guenter Roeck
2019-11-04 15:34 ` Christoph Hellwig
2019-11-05 15:38 ` Akinobu Mita
2019-11-05 15:44 ` Akinobu Mita
2019-11-05 18:10 ` Guenter Roeck [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=20191105181023.GA22468@roeck-us.net \
--to=linux@roeck-us.net \
--cc=akinobu.mita@gmail.com \
--cc=axboe@fb.com \
--cc=cphealy@gmail.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--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