linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Akinobu Mita <akinobu.mita@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
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 v3] nvme: Add hardware monitoring support
Date: Sat, 2 Nov 2019 01:19:03 +0900	[thread overview]
Message-ID: <CAC5umyhiOiAiYWs2Y=L5133CCQNnAgi8oq6AbGzgkznZKz5f-w@mail.gmail.com> (raw)
In-Reply-To: <20191101035646.25644-1-linux@roeck-us.net>

2019年11月1日(金) 12:56 Guenter Roeck <linux@roeck-us.net>:
> +void nvme_hwmon_init(struct nvme_ctrl *ctrl)
> +{
> +       struct device *dev = ctrl->device;

Should we use 'ctrl->dev' instead of 'ctrl->device'?

The 'ctrl->device' is a pointer to char device and the '->of_node' member
is NULL.

So if devm_hwmon_device_register_with_info() (i.e. __hwmon_device_register)
is called with 'ctrl->device', it doesn't attempt to register a sensor to a
DT thermal zone (i.e. hwmon_thermal_add_sensor() is not called at all).

This change was required, when I tried this nvme hwmon patch with the
following DT thermal setup.

https://lore.kernel.org/linux-devicetree/1561990354-4084-3-git-send-email-akinobu.mita@gmail.com/

> +       struct nvme_hwmon_data *data;
> +       struct device *hwmon;
> +       int err;
> +
> +       data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +       if (!data)
> +               return;
> +
> +       data->ctrl = ctrl;
> +       mutex_init(&data->read_lock);
> +
> +       err = nvme_hwmon_get_smart_log(data);
> +       if (err) {
> +               dev_warn(dev, "Failed to read smart log (error %d)\n", err);
> +               devm_kfree(dev, data);
> +               return;
> +       }
> +
> +       hwmon = devm_hwmon_device_register_with_info(dev, dev_name(dev), data,
> +                                                    &nvme_hwmon_chip_info,
> +                                                    NULL);

If the above change is applied, the second 'name' argument is changed
from 'nvme0' to '0000:01:00.0' as a side effect.  So we may want to
change the second argument, too.

> +       if (IS_ERR(hwmon)) {
> +               dev_warn(dev, "Failed to instantiate hwmon device\n");
> +               devm_kfree(dev, data);
> +       }
> +}

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  reply	other threads:[~2019-11-01 16:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01  3:56 [PATCH v3] nvme: Add hardware monitoring support Guenter Roeck
2019-11-01 16:19 ` Akinobu Mita [this message]
2019-11-01 19:14   ` Guenter Roeck

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='CAC5umyhiOiAiYWs2Y=L5133CCQNnAgi8oq6AbGzgkznZKz5f-w@mail.gmail.com' \
    --to=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=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).