Commit 70ee4a4c authored by Jens Axboe's avatar Jens Axboe

Merge tag 'nvme-6.1-2022-10-22' of git://git.infradead.org/nvme into block-6.1

Pull NVMe fixes from Christoph:

"nvme fixes for Linux 6.1

 - fix nvme-hwmon for DMA non-cohehrent architectures (Serge Semin)
 - add a nvme-hwmong maintainer (Christoph Hellwig)
 - fix error pointer dereference in error handling (Dan Carpenter)
 - fix invalid memory reference in nvmet_subsys_attr_qid_max_show
   (Daniel Wagner)
 - don't limit the DMA segment size in nvme-apple (Russell King)
 - fix workqueue MEM_RECLAIM flushing dependency (Sagi Grimberg)
 - disable write zeroes on various Kingston SSDs (Xander Li)"

* tag 'nvme-6.1-2022-10-22' of git://git.infradead.org/nvme:
  nvmet: fix invalid memory reference in nvmet_subsys_attr_qid_max_show
  nvmet: fix workqueue MEM_RECLAIM flushing dependency
  nvme-hwmon: kmalloc the NVME SMART log buffer
  nvme-hwmon: consistently ignore errors from nvme_hwmon_init
  nvme: add Guenther as nvme-hwmon maintainer
  nvme-apple: don't limit DMA segement size
  nvme-pci: disable write zeroes on various Kingston SSD
  nvme: fix error pointer dereference in error handling
parents 72495b5a 94f5a068
...@@ -14640,6 +14640,12 @@ F: drivers/nvme/target/auth.c ...@@ -14640,6 +14640,12 @@ F: drivers/nvme/target/auth.c
F: drivers/nvme/target/fabrics-cmd-auth.c F: drivers/nvme/target/fabrics-cmd-auth.c
F: include/linux/nvme-auth.h F: include/linux/nvme-auth.h
NVM EXPRESS HARDWARE MONITORING SUPPORT
M: Guenter Roeck <linux@roeck-us.net>
L: linux-nvme@lists.infradead.org
S: Supported
F: drivers/nvme/host/hwmon.c
NVM EXPRESS FC TRANSPORT DRIVERS NVM EXPRESS FC TRANSPORT DRIVERS
M: James Smart <james.smart@broadcom.com> M: James Smart <james.smart@broadcom.com>
L: linux-nvme@lists.infradead.org L: linux-nvme@lists.infradead.org
......
...@@ -1039,6 +1039,8 @@ static void apple_nvme_reset_work(struct work_struct *work) ...@@ -1039,6 +1039,8 @@ static void apple_nvme_reset_work(struct work_struct *work)
dma_max_mapping_size(anv->dev) >> 9); dma_max_mapping_size(anv->dev) >> 9);
anv->ctrl.max_segments = NVME_MAX_SEGS; anv->ctrl.max_segments = NVME_MAX_SEGS;
dma_set_max_seg_size(anv->dev, 0xffffffff);
/* /*
* Enable NVMMU and linear submission queues. * Enable NVMMU and linear submission queues.
* While we could keep those disabled and pretend this is slightly * While we could keep those disabled and pretend this is slightly
......
...@@ -3262,8 +3262,12 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl) ...@@ -3262,8 +3262,12 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl)
return ret; return ret;
if (!ctrl->identified && !nvme_discovery_ctrl(ctrl)) { if (!ctrl->identified && !nvme_discovery_ctrl(ctrl)) {
/*
* Do not return errors unless we are in a controller reset,
* the controller works perfectly fine without hwmon.
*/
ret = nvme_hwmon_init(ctrl); ret = nvme_hwmon_init(ctrl);
if (ret < 0) if (ret == -EINTR)
return ret; return ret;
} }
...@@ -4846,7 +4850,7 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set, ...@@ -4846,7 +4850,7 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
return 0; return 0;
out_cleanup_admin_q: out_cleanup_admin_q:
blk_mq_destroy_queue(ctrl->fabrics_q); blk_mq_destroy_queue(ctrl->admin_q);
out_free_tagset: out_free_tagset:
blk_mq_free_tag_set(ctrl->admin_tagset); blk_mq_free_tag_set(ctrl->admin_tagset);
return ret; return ret;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
struct nvme_hwmon_data { struct nvme_hwmon_data {
struct nvme_ctrl *ctrl; struct nvme_ctrl *ctrl;
struct nvme_smart_log log; struct nvme_smart_log *log;
struct mutex read_lock; struct mutex read_lock;
}; };
...@@ -60,14 +60,14 @@ static int nvme_set_temp_thresh(struct nvme_ctrl *ctrl, int sensor, bool under, ...@@ -60,14 +60,14 @@ 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) 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, return nvme_get_log(data->ctrl, NVME_NSID_ALL, NVME_LOG_SMART, 0,
NVME_CSI_NVM, &data->log, sizeof(data->log), 0); NVME_CSI_NVM, data->log, sizeof(*data->log), 0);
} }
static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type, static int nvme_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val) u32 attr, int channel, long *val)
{ {
struct nvme_hwmon_data *data = dev_get_drvdata(dev); struct nvme_hwmon_data *data = dev_get_drvdata(dev);
struct nvme_smart_log *log = &data->log; struct nvme_smart_log *log = data->log;
int temp; int temp;
int err; int err;
...@@ -163,7 +163,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data, ...@@ -163,7 +163,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data,
case hwmon_temp_max: case hwmon_temp_max:
case hwmon_temp_min: case hwmon_temp_min:
if ((!channel && data->ctrl->wctemp) || if ((!channel && data->ctrl->wctemp) ||
(channel && data->log.temp_sensor[channel - 1])) { (channel && data->log->temp_sensor[channel - 1])) {
if (data->ctrl->quirks & if (data->ctrl->quirks &
NVME_QUIRK_NO_TEMP_THRESH_CHANGE) NVME_QUIRK_NO_TEMP_THRESH_CHANGE)
return 0444; return 0444;
...@@ -176,7 +176,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data, ...@@ -176,7 +176,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data,
break; break;
case hwmon_temp_input: case hwmon_temp_input:
case hwmon_temp_label: case hwmon_temp_label:
if (!channel || data->log.temp_sensor[channel - 1]) if (!channel || data->log->temp_sensor[channel - 1])
return 0444; return 0444;
break; break;
default: default:
...@@ -230,7 +230,13 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) ...@@ -230,7 +230,13 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
data = kzalloc(sizeof(*data), GFP_KERNEL); data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) if (!data)
return 0; return -ENOMEM;
data->log = kzalloc(sizeof(*data->log), GFP_KERNEL);
if (!data->log) {
err = -ENOMEM;
goto err_free_data;
}
data->ctrl = ctrl; data->ctrl = ctrl;
mutex_init(&data->read_lock); mutex_init(&data->read_lock);
...@@ -238,8 +244,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) ...@@ -238,8 +244,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
err = nvme_hwmon_get_smart_log(data); err = nvme_hwmon_get_smart_log(data);
if (err) { if (err) {
dev_warn(dev, "Failed to read smart log (error %d)\n", err); dev_warn(dev, "Failed to read smart log (error %d)\n", err);
kfree(data); goto err_free_log;
return err;
} }
hwmon = hwmon_device_register_with_info(dev, "nvme", hwmon = hwmon_device_register_with_info(dev, "nvme",
...@@ -247,11 +252,17 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) ...@@ -247,11 +252,17 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
NULL); NULL);
if (IS_ERR(hwmon)) { if (IS_ERR(hwmon)) {
dev_warn(dev, "Failed to instantiate hwmon device\n"); dev_warn(dev, "Failed to instantiate hwmon device\n");
kfree(data); err = PTR_ERR(hwmon);
return PTR_ERR(hwmon); goto err_free_log;
} }
ctrl->hwmon_device = hwmon; ctrl->hwmon_device = hwmon;
return 0; return 0;
err_free_log:
kfree(data->log);
err_free_data:
kfree(data);
return err;
} }
void nvme_hwmon_exit(struct nvme_ctrl *ctrl) void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
...@@ -262,6 +273,7 @@ void nvme_hwmon_exit(struct nvme_ctrl *ctrl) ...@@ -262,6 +273,7 @@ void nvme_hwmon_exit(struct nvme_ctrl *ctrl)
hwmon_device_unregister(ctrl->hwmon_device); hwmon_device_unregister(ctrl->hwmon_device);
ctrl->hwmon_device = NULL; ctrl->hwmon_device = NULL;
kfree(data->log);
kfree(data); kfree(data);
} }
} }
...@@ -3511,6 +3511,16 @@ static const struct pci_device_id nvme_id_table[] = { ...@@ -3511,6 +3511,16 @@ static const struct pci_device_id nvme_id_table[] = {
.driver_data = NVME_QUIRK_NO_DEEPEST_PS, }, .driver_data = NVME_QUIRK_NO_DEEPEST_PS, },
{ PCI_DEVICE(0x2646, 0x2263), /* KINGSTON A2000 NVMe SSD */ { PCI_DEVICE(0x2646, 0x2263), /* KINGSTON A2000 NVMe SSD */
.driver_data = NVME_QUIRK_NO_DEEPEST_PS, }, .driver_data = NVME_QUIRK_NO_DEEPEST_PS, },
{ PCI_DEVICE(0x2646, 0x5018), /* KINGSTON OM8SFP4xxxxP OS21012 NVMe SSD */
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
{ PCI_DEVICE(0x2646, 0x5016), /* KINGSTON OM3PGP4xxxxP OS21011 NVMe SSD */
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
{ PCI_DEVICE(0x2646, 0x501A), /* KINGSTON OM8PGP4xxxxP OS21005 NVMe SSD */
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
{ PCI_DEVICE(0x2646, 0x501B), /* KINGSTON OM8PGP4xxxxQ OS21005 NVMe SSD */
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
{ PCI_DEVICE(0x2646, 0x501E), /* KINGSTON OM3PGP4xxxxQ OS21011 NVMe SSD */
.driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
{ PCI_DEVICE(0x1e4B, 0x1001), /* MAXIO MAP1001 */ { PCI_DEVICE(0x1e4B, 0x1001), /* MAXIO MAP1001 */
.driver_data = NVME_QUIRK_BOGUS_NID, }, .driver_data = NVME_QUIRK_BOGUS_NID, },
{ PCI_DEVICE(0x1e4B, 0x1002), /* MAXIO MAP1002 */ { PCI_DEVICE(0x1e4B, 0x1002), /* MAXIO MAP1002 */
......
...@@ -1290,12 +1290,8 @@ static ssize_t nvmet_subsys_attr_qid_max_show(struct config_item *item, ...@@ -1290,12 +1290,8 @@ static ssize_t nvmet_subsys_attr_qid_max_show(struct config_item *item,
static ssize_t nvmet_subsys_attr_qid_max_store(struct config_item *item, static ssize_t nvmet_subsys_attr_qid_max_store(struct config_item *item,
const char *page, size_t cnt) const char *page, size_t cnt)
{ {
struct nvmet_port *port = to_nvmet_port(item);
u16 qid_max; u16 qid_max;
if (nvmet_is_port_enabled(port, __func__))
return -EACCES;
if (sscanf(page, "%hu\n", &qid_max) != 1) if (sscanf(page, "%hu\n", &qid_max) != 1)
return -EINVAL; return -EINVAL;
......
...@@ -1176,7 +1176,7 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl) ...@@ -1176,7 +1176,7 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl)
* reset the keep alive timer when the controller is enabled. * reset the keep alive timer when the controller is enabled.
*/ */
if (ctrl->kato) if (ctrl->kato)
mod_delayed_work(system_wq, &ctrl->ka_work, ctrl->kato * HZ); mod_delayed_work(nvmet_wq, &ctrl->ka_work, ctrl->kato * HZ);
} }
static void nvmet_clear_ctrl(struct nvmet_ctrl *ctrl) static void nvmet_clear_ctrl(struct nvmet_ctrl *ctrl)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment