nvme: return errors for hwmon init
Subsystems (2)
Keith Busch
maintainerPATCH 1/1 nvme: return errors for hwmon init
Initializing the nvme hwmon retrieves a log from the controller. If the controller is broken, we need to return the appropriate error so that subsequent initialization doesn't attempt to continue.
--- drivers/nvme/host/core.c | 7 +++++-- drivers/nvme/host/hwmon.c | 14 ++++++-------- drivers/nvme/host/nvme.h | 7 +++++-- 3 files changed, 16 insertions(+), 12 deletions(-)
drivers/nvme/host/core.c +5 -2
@@ -3239,8 +3239,11 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)if (ret <0 )return ret; -if (!ctrl->identified) -nvme_hwmon_init (ctrl); +if (!ctrl->identified) { + ret =nvme_hwmon_init (ctrl); +if (ret <0 ) +return ret; + } ctrl->identified = true;
drivers/nvme/host/hwmon.c +6 -8
@@ -59,12 +59,8 @@ static int nvme_set_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under,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 , +return nvme_get_log (data->ctrl,NVME_NSID_ALL ,NVME_LOG_SMART ,0 ,NVME_CSI_NVM , &data->log,sizeof (data->log),0 ); - -return ret <=0 ? ret : -EIO ; } static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
@@ -225,7 +221,7 @@ static const struct hwmon_chip_info nvme_hwmon_chip_info = { .info = nvme_hwmon_info, }; -void nvme_hwmon_init (struct nvme_ctrl *ctrl) +int nvme_hwmon_init (struct nvme_ctrl *ctrl) {struct device *dev = ctrl->dev;struct nvme_hwmon_data *data;
@@ -234,7 +230,7 @@ void nvme_hwmon_init(struct nvme_ctrl *ctrl) data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL );if (!data) -return ; +return 0 ; data->ctrl = ctrl;mutex_init (&data->read_lock);
@@ -244,7 +240,7 @@ void nvme_hwmon_init(struct nvme_ctrl *ctrl)dev_warn (ctrl->device,"Failed to read smart log (error %d)\n" , err);devm_kfree (dev, data); -return ; +return err; } hwmon = devm_hwmon_device_register_with_info(dev, "nvme", data,
@@ -254,4 +250,6 @@ void nvme_hwmon_init(struct nvme_ctrl *ctrl)dev_warn (dev,"Failed to instantiate hwmon device\n" );devm_kfree (dev, data); } + +return 0 ; }
drivers/nvme/host/nvme.h +5 -2
@@ -827,9 +827,12 @@ static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev) }#ifdef CONFIG_NVME_HWMON -void nvme_hwmon_init (struct nvme_ctrl *ctrl); +int nvme_hwmon_init (struct nvme_ctrl *ctrl);#else -static inline void nvme_hwmon_init (struct nvme_ctrl *ctrl) { } +static inline int nvme_hwmon_init (struct nvme_ctrl *ctrl) +{ +return 0 ; +}#endif u32 nvme_command_effects(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
Signature · 7 lines
2.24.1 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Christoph Hellwig
maintainerQuoted 6 lines · Keith Busch
Initializing the nvme hwmon retrieves a log from the controller. If the controller is broken, we need to return the appropriate error so that subsequent initialization doesn't attempt to continue.
Reported-by Tong Zhang <[email protected]>Signed-off-by Keith Busch <[email protected]>
Looks good to me. I'm about to send a PR to Jens later today, but I plan to pick this up for 5.9 after that.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Thanks Keith and Christoph,
I can confirm this patch made the double free irq issue gone.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme