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

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
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -14640,6 +14640,12 @@ F: drivers/nvme/target/auth.c
F:	drivers/nvme/target/fabrics-cmd-auth.c
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
M:	James Smart <james.smart@broadcom.com>
L:	linux-nvme@lists.infradead.org
+2 −0
Original line number Diff line number Diff line
@@ -1039,6 +1039,8 @@ static void apple_nvme_reset_work(struct work_struct *work)
					 dma_max_mapping_size(anv->dev) >> 9);
	anv->ctrl.max_segments = NVME_MAX_SEGS;

	dma_set_max_seg_size(anv->dev, 0xffffffff);

	/*
	 * Enable NVMMU and linear submission queues.
	 * While we could keep those disabled and pretend this is slightly
+6 −2
Original line number Diff line number Diff line
@@ -3262,8 +3262,12 @@ int nvme_init_ctrl_finish(struct nvme_ctrl *ctrl)
		return ret;

	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);
		if (ret < 0)
		if (ret == -EINTR)
			return ret;
	}

@@ -4846,7 +4850,7 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
	return 0;

out_cleanup_admin_q:
	blk_mq_destroy_queue(ctrl->fabrics_q);
	blk_mq_destroy_queue(ctrl->admin_q);
out_free_tagset:
	blk_mq_free_tag_set(ctrl->admin_tagset);
	return ret;
+22 −10
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@

struct nvme_hwmon_data {
	struct nvme_ctrl *ctrl;
	struct nvme_smart_log log;
	struct nvme_smart_log *log;
	struct mutex read_lock;
};

@@ -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)
{
	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,
			   u32 attr, int channel, long *val)
{
	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 err;

@@ -163,7 +163,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data,
	case hwmon_temp_max:
	case hwmon_temp_min:
		if ((!channel && data->ctrl->wctemp) ||
		    (channel && data->log.temp_sensor[channel - 1])) {
		    (channel && data->log->temp_sensor[channel - 1])) {
			if (data->ctrl->quirks &
			    NVME_QUIRK_NO_TEMP_THRESH_CHANGE)
				return 0444;
@@ -176,7 +176,7 @@ static umode_t nvme_hwmon_is_visible(const void *_data,
		break;
	case hwmon_temp_input:
	case hwmon_temp_label:
		if (!channel || data->log.temp_sensor[channel - 1])
		if (!channel || data->log->temp_sensor[channel - 1])
			return 0444;
		break;
	default:
@@ -230,7 +230,13 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)

	data = kzalloc(sizeof(*data), GFP_KERNEL);
	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;
	mutex_init(&data->read_lock);
@@ -238,8 +244,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_log;
	}

	hwmon = hwmon_device_register_with_info(dev, "nvme",
@@ -247,11 +252,17 @@ 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_log;
	}
	ctrl->hwmon_device = hwmon;
	return 0;

err_free_log:
	kfree(data->log);
err_free_data:
	kfree(data);
	return err;
}

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);
		ctrl->hwmon_device = NULL;
		kfree(data->log);
		kfree(data);
	}
}
+10 −0
Original line number Diff line number Diff line
@@ -3511,6 +3511,16 @@ static const struct pci_device_id nvme_id_table[] = {
		.driver_data = NVME_QUIRK_NO_DEEPEST_PS, },
	{ PCI_DEVICE(0x2646, 0x2263),   /* KINGSTON A2000 NVMe SSD  */
		.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 */
		.driver_data = NVME_QUIRK_BOGUS_NID, },
	{ PCI_DEVICE(0x1e4B, 0x1002),   /* MAXIO MAP1002 */
Loading