From: Christoph Hellwig <hch@lst.de>
To: Keith Busch <kbusch@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>,
sagi@grimberg.me, fancer.lancer@gmail.com, linux@roeck-us.net,
linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme-hwmon: don't return errors from nvme_hwmon_init
Date: Tue, 18 Oct 2022 17:23:09 +0200 [thread overview]
Message-ID: <20221018152309.GB22639@lst.de> (raw)
In-Reply-To: <Y07C/FdD3mpKgBjN@kbusch-mbp.dhcp.thefacebook.com>
On Tue, Oct 18, 2022 at 09:15:08AM -0600, Keith Busch wrote:
> We still need to check for < 0 since nvme_hwmon_init() sends an admin
> command. If the admin command times out, the controller is reset and
> -EINTR is returned, indicating we have to abort initialization. All
> other errors should be ignored, though, since the controller remains
> usable.
So I guess we should just ignore everything but EINTR, e.g.:
diff --git a/drivers/nvme/host/hwmon.c b/drivers/nvme/host/hwmon.c
index 0a586d7129201..aed245678315f 100644
--- a/drivers/nvme/host/hwmon.c
+++ b/drivers/nvme/host/hwmon.c
@@ -230,7 +230,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
- return 0;
+ goto err;
data->ctrl = ctrl;
mutex_init(&data->read_lock);
@@ -238,8 +238,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
err = nvme_hwmon_get_smart_log(data);
if (err) {
dev_warn(dev, "Failed to read smart log (error %d)\n", err);
- kfree(data);
- return err;
+ goto err_free_data;
}
hwmon = hwmon_device_register_with_info(dev, "nvme",
@@ -247,11 +246,22 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
NULL);
if (IS_ERR(hwmon)) {
dev_warn(dev, "Failed to instantiate hwmon device\n");
- kfree(data);
- return PTR_ERR(hwmon);
+ err = PTR_ERR(hwmon);
+ goto err_free_data;
}
ctrl->hwmon_device = hwmon;
return 0;
+
+err_free_data:
+ kfree(data);
+err:
+ /*
+ * Do not return errors unless we are in a controller reset.
+ * The controller works perfectly fine without the hwmon registration.
+ */
+ if (err == -EINTR)
+ return -EINTR;
+ return 0;
}
void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
--
2.30.2
next prev parent reply other threads:[~2022-10-18 15:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 14:58 [PATCH] nvme-hwmon: don't return errors from nvme_hwmon_init Christoph Hellwig
2022-10-18 15:14 ` Serge Semin
2022-10-18 15:16 ` Christoph Hellwig
2022-10-18 15:21 ` Serge Semin
2022-10-18 15:23 ` Christoph Hellwig
2022-10-18 15:25 ` Serge Semin
2022-10-18 15:15 ` Keith Busch
2022-10-18 15:23 ` Christoph Hellwig [this message]
2022-10-18 15:26 ` Keith Busch
2022-10-18 15:31 ` Christoph Hellwig
2022-10-18 15:31 ` Serge Semin
2022-10-18 15:38 ` Christoph Hellwig
2022-10-18 15:44 ` Serge Semin
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=20221018152309.GB22639@lst.de \
--to=hch@lst.de \
--cc=fancer.lancer@gmail.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.