linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers
@ 2018-12-14 13:21 Ivan Mironov
  2018-12-14 13:21 ` [PATCH 1/6] scsi: hpsa: Add function to check if device is a disk or a zoned device Ivan Mironov
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Ivan Mironov @ 2018-12-14 13:21 UTC (permalink / raw)
  To: linux-scsi, mironov.ivan
  Cc: linux-kernel, Don Brace, James E.J. Bottomley,
	Martin K. Petersen, esc.storagedev

This series of patches adds support of the HBA mode on HP Smart Array
P410i RAID controllers.

This is not guaranteed to be correct as I do not have any access to
documentation on these controllers. However, this works fine for me
on hardware that I have. Also, these changes successfully passes blktests[1]
and xfstests[2].

To make sure that this new functionality does not break anything, it is
disabled by default and may be enabled only manually using new module
parameter.

[1] https://github.com/osandov/blktests
[2] https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git

Ivan Mironov (6):
  scsi: hpsa: Add function to check if device is a disk or a zoned
    device
  scsi: hpsa: Support HBA mode on HP Smart Array P410i controllers
  scsi: hpsa: Add/mask existing devices on rescan if visibility changes
  scsi: hpsa: Ignore HBA flag from NVRAM if logical devices exist
  scsi: hpsa: Name more fields in "struct bmic_identify_controller"
  scsi: hpsa: Do not use HBA flag from NVRAM if HBA is not supported

 drivers/scsi/hpsa.c     | 145 ++++++++++++++++++++++++++++++++++++----
 drivers/scsi/hpsa.h     |   3 +
 drivers/scsi/hpsa_cmd.h | 113 ++++++++++++++++++++++++++++++-
 3 files changed, 244 insertions(+), 17 deletions(-)

-- 
2.19.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/6] scsi: hpsa: Add function to check if device is a disk or a zoned device
  2018-12-14 13:21 [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Ivan Mironov
@ 2018-12-14 13:21 ` Ivan Mironov
  2018-12-14 13:26   ` Johannes Thumshirn
  2018-12-14 13:21 ` [PATCH 2/6] scsi: hpsa: Support HBA mode on HP Smart Array P410i controllers Ivan Mironov
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Ivan Mironov @ 2018-12-14 13:21 UTC (permalink / raw)
  To: linux-scsi, mironov.ivan
  Cc: linux-kernel, Don Brace, James E.J. Bottomley,
	Martin K. Petersen, esc.storagedev

This check is used multiple times within the driver. New function makes
conditional statements a bit shorter and more readable.

Signed-off-by: Ivan Mironov <mironov.ivan@gmail.com>
---
 drivers/scsi/hpsa.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index c9cccf35e9d7..fc06b790f16b 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -768,6 +768,11 @@ static ssize_t sas_address_show(struct device *dev,
 	return snprintf(buf, PAGE_SIZE, "0x%016llx\n", sas_address);
 }
 
+static inline bool is_disk_or_zbc(const struct hpsa_scsi_dev_t *hdev)
+{
+	return hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC;
+}
+
 static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev,
 	     struct device_attribute *attr, char *buf)
 {
@@ -788,7 +793,7 @@ static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev,
 	offload_enabled = hdev->offload_enabled;
 	spin_unlock_irqrestore(&h->lock, flags);
 
-	if (hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC)
+	if (is_disk_or_zbc(hdev))
 		return snprintf(buf, 20, "%d\n", offload_enabled);
 	else
 		return snprintf(buf, 40, "%s\n",
@@ -855,8 +860,7 @@ static ssize_t path_info_show(struct device *dev,
 				PAGE_SIZE - output_len,
 				"PORT: %.2s ",
 				phys_connector);
-		if ((hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) &&
-			hdev->expose_device) {
+		if (is_disk_or_zbc(hdev) && hdev->expose_device) {
 			if (box == 0 || box == 0xFF) {
 				output_len += scnprintf(buf + output_len,
 					PAGE_SIZE - output_len,
@@ -1715,8 +1719,7 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h,
 		for (j = 0; j < ndevices; j++) {
 			if (dev[j] == NULL)
 				continue;
-			if (dev[j]->devtype != TYPE_DISK &&
-			    dev[j]->devtype != TYPE_ZBC)
+			if (!is_disk_or_zbc(dev[j]))
 				continue;
 			if (is_logical_device(dev[j]))
 				continue;
@@ -1770,8 +1773,7 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
 	for (i = 0; i < ndevices; i++) {
 		if (dev[i] == NULL)
 			continue;
-		if (dev[i]->devtype != TYPE_DISK &&
-		    dev[i]->devtype != TYPE_ZBC)
+		if (!is_disk_or_zbc(dev[i]))
 			continue;
 		if (!is_logical_device(dev[i]))
 			continue;
@@ -3965,9 +3967,8 @@ static int hpsa_update_device_info(struct ctlr_info *h,
 			scsi_device_type(this_device->devtype),
 			this_device->model);
 
-	if ((this_device->devtype == TYPE_DISK ||
-		this_device->devtype == TYPE_ZBC) &&
-		is_logical_dev_addr_mode(scsi3addr)) {
+	if (is_disk_or_zbc(this_device) &&
+			is_logical_dev_addr_mode(scsi3addr)) {
 		unsigned char volume_offline;
 
 		hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level);
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/6] scsi: hpsa: Support HBA mode on HP Smart Array P410i controllers
  2018-12-14 13:21 [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Ivan Mironov
  2018-12-14 13:21 ` [PATCH 1/6] scsi: hpsa: Add function to check if device is a disk or a zoned device Ivan Mironov
@ 2018-12-14 13:21 ` Ivan Mironov
  2018-12-14 13:21 ` [PATCH 3/6] scsi: hpsa: Add/mask existing devices on rescan if visibility changes Ivan Mironov
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Ivan Mironov @ 2018-12-14 13:21 UTC (permalink / raw)
  To: linux-scsi, mironov.ivan
  Cc: linux-kernel, Don Brace, James E.J. Bottomley,
	Martin K. Petersen, esc.storagedev

This patch is based on code from the 316b221, most of which was removed by
the b9092b7.

Originally, HBA mode on these controllers was supported only on
Itanium-based HP Integrity servers running HP-UX. Tool for switching
between RAID and HBA modes existed only in form of EFI binary for
ia64 architecture: saupdate.efi[1]. However, I guessed how to overwrite the
corresponding flags field in controller's NVRAM, and was able to
reimplement RAID/HBA mode switching tool for Linux[2].

This change was successfully tested using blktests[3] and xfstests[4] on
my hardware, with embedded P410i controller (PCI ID: 103c:3245, board
ID: 0x3245103c) with firmware version 6.64.

This may work with some other controllers, but it is not tested
(because I do not have the hardware) and it may be very dangerous. That is
why this functionality is disabled by default and may be enabled only
manually using the new module parameter.

[1] https://support.hpe.com/hpsc/swd/public/detail?swItemId=MTX_0b76aec489764aea9802a6d27b
[2] https://github.com/im-0/hpsahba
[3] https://github.com/osandov/blktests
[4] https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git

Signed-off-by: Ivan Mironov <mironov.ivan@gmail.com>
---
 drivers/scsi/hpsa.c | 98 +++++++++++++++++++++++++++++++++++++++++++--
 drivers/scsi/hpsa.h |  3 ++
 2 files changed, 97 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index fc06b790f16b..ee3d7c722a63 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -88,6 +88,11 @@ module_param(hpsa_simple_mode, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(hpsa_simple_mode,
 	"Use 'simple mode' rather than 'performant mode'");
 
+static bool hpsa_use_nvram_hba_flag;
+module_param(hpsa_use_nvram_hba_flag, bool, 0444);
+MODULE_PARM_DESC(hpsa_use_nvram_hba_flag,
+	"Use flag from NVRAM to enable HBA mode");
+
 /* define the PCI info for the cards we can control */
 static const struct pci_device_id hpsa_pci_device_id[] = {
 	{PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3241},
@@ -3039,6 +3044,37 @@ static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr,
 	return rc;
 }
 
+static int hpsa_bmic_ctrl_mode_sense(struct ctlr_info *h,
+	struct bmic_controller_parameters *buf)
+{
+	int rc = IO_OK;
+	struct CommandList *c;
+	struct ErrorInfo *ei;
+
+	c = cmd_alloc(h);
+
+	if (fill_cmd(c, BMIC_SENSE_CONTROLLER_PARAMETERS, h, buf, sizeof(*buf),
+			0, RAID_CTLR_LUNID, TYPE_CMD)) {
+		rc = -1;
+		goto out;
+	}
+
+	rc = hpsa_scsi_do_simple_cmd_with_retry(h, c, PCI_DMA_FROMDEVICE,
+		NO_TIMEOUT);
+	if (rc)
+		goto out;
+
+	ei = c->err_info;
+	if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) {
+		hpsa_scsi_interpret_error(h, c);
+		rc = -1;
+	}
+
+out:
+	cmd_free(h, c);
+	return rc;
+}
+
 static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr,
 	u8 reset_type, int reply_queue)
 {
@@ -4296,6 +4332,50 @@ static bool hpsa_skip_device(struct ctlr_info *h, u8 *lunaddrbytes,
 	return false;
 }
 
+static int hpsa_nvram_hba_flag_enabled(struct ctlr_info *h, bool *flag_enabled)
+{
+	int rc;
+	struct bmic_controller_parameters *ctlr_params;
+
+	ctlr_params = kzalloc(sizeof(*ctlr_params), GFP_KERNEL);
+	if (!ctlr_params) {
+		rc = -ENOMEM;
+		goto out;
+	}
+
+	rc = hpsa_bmic_ctrl_mode_sense(h, ctlr_params);
+	if (rc)
+		goto out;
+
+	*flag_enabled = ctlr_params->nvram_flags & HPSA_NVRAM_FLAG_HBA;
+
+out:
+	kfree(ctlr_params);
+	return rc;
+}
+
+static int hpsa_update_nvram_hba_mode(struct ctlr_info *h)
+{
+	int rc;
+	bool flag_enabled;
+
+	if (!hpsa_use_nvram_hba_flag)
+		return 0;
+
+	rc = hpsa_nvram_hba_flag_enabled(h, &flag_enabled);
+	if (rc == -ENOMEM)
+		dev_warn(&h->pdev->dev, "Out of memory.\n");
+	if (rc)
+		return rc;
+
+	dev_info(&h->pdev->dev, "NVRAM HBA flag: %s\n",
+		flag_enabled ? "enabled" : "disabled");
+
+	h->nvram_hba_mode_enabled = flag_enabled;
+
+	return 0;
+}
+
 static void hpsa_update_scsi_devices(struct ctlr_info *h)
 {
 	/* the idea here is we could get notified
@@ -4352,6 +4432,11 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
 			__func__);
 	}
 
+	if (hpsa_update_nvram_hba_mode(h)) {
+		h->drv_req_rescan = 1;
+		goto out;
+	}
+
 	/* We might see up to the maximum number of logical and physical disks
 	 * plus external target devices, and a device for the local RAID
 	 * controller.
@@ -4437,11 +4522,16 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
 		 * Expose all devices except for physical devices that
 		 * are masked.
 		 */
-		if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device)
-			this_device->expose_device = 0;
-		else
+		if (MASKED_DEVICE(lunaddrbytes) &&
+				this_device->physical_device) {
+			if (is_disk_or_zbc(this_device) &&
+					h->nvram_hba_mode_enabled)
+				this_device->expose_device = 1;
+			else
+				this_device->expose_device = 0;
+		} else {
 			this_device->expose_device = 1;
-
+		}
 
 		/*
 		 * Get the SAS address for physical devices that are exposed.
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
index 59e023696fff..5b508f270520 100644
--- a/drivers/scsi/hpsa.h
+++ b/drivers/scsi/hpsa.h
@@ -158,6 +158,8 @@ struct bmic_controller_parameters {
 };
 #pragma pack()
 
+#define HPSA_NVRAM_FLAG_HBA (1 << 3)
+
 struct ctlr_info {
 	unsigned int *reply_map;
 	int	ctlr;
@@ -182,6 +184,7 @@ struct ctlr_info {
 	unsigned int msix_vectors;
 	int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
 	struct access_method access;
+	bool nvram_hba_mode_enabled;
 
 	/* queue and queue Info */
 	unsigned int Qdepth;
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/6] scsi: hpsa: Add/mask existing devices on rescan if visibility changes
  2018-12-14 13:21 [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Ivan Mironov
  2018-12-14 13:21 ` [PATCH 1/6] scsi: hpsa: Add function to check if device is a disk or a zoned device Ivan Mironov
  2018-12-14 13:21 ` [PATCH 2/6] scsi: hpsa: Support HBA mode on HP Smart Array P410i controllers Ivan Mironov
@ 2018-12-14 13:21 ` Ivan Mironov
  2018-12-14 13:21 ` [PATCH 4/6] scsi: hpsa: Ignore HBA flag from NVRAM if logical devices exist Ivan Mironov
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Ivan Mironov @ 2018-12-14 13:21 UTC (permalink / raw)
  To: linux-scsi, mironov.ivan
  Cc: linux-kernel, Don Brace, James E.J. Bottomley,
	Martin K. Petersen, esc.storagedev

Controller may be switched between RAID and HBA modes even without a
reboot.

When changing to HBA mode, it does some internal reset magic and
automatically removes any configured RAID arrays. Without this patch,
driver successfully detects disappearance of logical arrays, but does
not expose any physical disks.

Signed-off-by: Ivan Mironov <mironov.ivan@gmail.com>
---
 drivers/scsi/hpsa.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index ee3d7c722a63..60f1f7949d8d 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1541,6 +1541,14 @@ static inline int device_updated(struct hpsa_scsi_dev_t *dev1,
 	return 0;
 }
 
+static inline bool device_expose_changed(struct hpsa_scsi_dev_t *dev1,
+	struct hpsa_scsi_dev_t *dev2)
+{
+	if (dev1->expose_device != dev2->expose_device)
+		return true;
+	return false;
+}
+
 /* Find needle in haystack.  If exact match found, return DEVICE_SAME,
  * and return needle location in *index.  If scsi3addr matches, but not
  * vendor, model, serial num, etc. return DEVICE_CHANGED, and return needle
@@ -1569,6 +1577,8 @@ static int hpsa_scsi_find_entry(struct hpsa_scsi_dev_t *needle,
 			if (device_is_the_same(needle, haystack[i])) {
 				if (device_updated(needle, haystack[i]))
 					return DEVICE_UPDATED;
+				if (device_expose_changed(needle, haystack[i]))
+					return DEVICE_CHANGED;
 				return DEVICE_SAME;
 			} else {
 				/* Keep offline devices offline */
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/6] scsi: hpsa: Ignore HBA flag from NVRAM if logical devices exist
  2018-12-14 13:21 [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Ivan Mironov
                   ` (2 preceding siblings ...)
  2018-12-14 13:21 ` [PATCH 3/6] scsi: hpsa: Add/mask existing devices on rescan if visibility changes Ivan Mironov
@ 2018-12-14 13:21 ` Ivan Mironov
  2018-12-14 13:21 ` [PATCH 5/6] scsi: hpsa: Name more fields in "struct bmic_identify_controller" Ivan Mironov
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Ivan Mironov @ 2018-12-14 13:21 UTC (permalink / raw)
  To: linux-scsi, mironov.ivan
  Cc: linux-kernel, Don Brace, James E.J. Bottomley,
	Martin K. Petersen, esc.storagedev

Simultaneous use of physical devices and logical RAID devices may be
dangerous.

Signed-off-by: Ivan Mironov <mironov.ivan@gmail.com>
---
 drivers/scsi/hpsa.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 60f1f7949d8d..0b5b3a651b70 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -4364,10 +4364,11 @@ static int hpsa_nvram_hba_flag_enabled(struct ctlr_info *h, bool *flag_enabled)
 	return rc;
 }
 
-static int hpsa_update_nvram_hba_mode(struct ctlr_info *h)
+static int hpsa_update_nvram_hba_mode(struct ctlr_info *h, u32 nlogicals)
 {
 	int rc;
 	bool flag_enabled;
+	bool ignore;
 
 	if (!hpsa_use_nvram_hba_flag)
 		return 0;
@@ -4378,10 +4379,13 @@ static int hpsa_update_nvram_hba_mode(struct ctlr_info *h)
 	if (rc)
 		return rc;
 
-	dev_info(&h->pdev->dev, "NVRAM HBA flag: %s\n",
-		flag_enabled ? "enabled" : "disabled");
+	ignore = flag_enabled && nlogicals;
 
-	h->nvram_hba_mode_enabled = flag_enabled;
+	dev_info(&h->pdev->dev, "NVRAM HBA flag: %s%s\n",
+		flag_enabled ? "enabled" : "disabled",
+		ignore ? " (ignored because of existing logical devices)" : "");
+
+	h->nvram_hba_mode_enabled = flag_enabled && !ignore;
 
 	return 0;
 }
@@ -4442,7 +4446,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
 			__func__);
 	}
 
-	if (hpsa_update_nvram_hba_mode(h)) {
+	if (hpsa_update_nvram_hba_mode(h, nlogicals)) {
 		h->drv_req_rescan = 1;
 		goto out;
 	}
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/6] scsi: hpsa: Name more fields in "struct bmic_identify_controller"
  2018-12-14 13:21 [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Ivan Mironov
                   ` (3 preceding siblings ...)
  2018-12-14 13:21 ` [PATCH 4/6] scsi: hpsa: Ignore HBA flag from NVRAM if logical devices exist Ivan Mironov
@ 2018-12-14 13:21 ` Ivan Mironov
  2018-12-14 13:21 ` [PATCH 6/6] scsi: hpsa: Do not use HBA flag from NVRAM if HBA is not supported Ivan Mironov
  2018-12-14 19:38 ` [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Don.Brace
  6 siblings, 0 replies; 11+ messages in thread
From: Ivan Mironov @ 2018-12-14 13:21 UTC (permalink / raw)
  To: linux-scsi, mironov.ivan
  Cc: linux-kernel, Don Brace, James E.J. Bottomley,
	Martin K. Petersen, esc.storagedev

Based on information from "struct identify_controller" from
cciss_vol_status.c from the cciss_vol_status tool[1].

[1] https://sourceforge.net/projects/cciss/files/cciss_vol_status/

Signed-off-by: Ivan Mironov <mironov.ivan@gmail.com>
---
 drivers/scsi/hpsa_cmd.h | 109 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 106 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index 21a726e2eec6..64100a33f844 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -695,11 +695,114 @@ struct hpsa_pci_info {
 
 struct bmic_identify_controller {
 	u8	configured_logical_drive_count;	/* offset 0 */
-	u8	pad1[153];
+	__le32	signature;
+	char	running_firm_rev[4];
+	char	rom_firm_rev[4];
+	u8	hardware_rev;
+	u8	reserved_1[4];
+	__le32	drive_present_bit_map;
+	__le32	external_drive_bit_map;
+	__le32	board_id;
+	u8	reserved_2;
+	__le32	non_disk_map;
+	u8	reserved_3[5];
+	u8	marketing_revision;
+	u8	controller_flags;
+	u8	host_flags;
+	u8	expand_disable_code;
+	u8	scsi_chip_count;
+	u8	reserved_4[4];
+	__le32	ctlr_clock;
+	u8	drives_per_scsi_bus;
+	__le16	big_drive_present_map[8];
+	__le16	big_ext_drive_map[8];
+	__le16	big_non_disk_map[8];
+
+	/* used for FW debugging */
+	__le16	task_flags;
+	/* Bitmap used for ICL between controllers */
+	u8	icl_bus_map;
+	/* See REDUNDANT MODE VALUES */
+	u8	redund_ctlr_modes_support;
+	/* See REDUNDANT MODE VALUES */
+	u8	curr_redund_ctlr_mode;
+	/* See REDUNDANT STATUS FLAG */
+	u8	redund_ctlr_status;
+	/* See REDUNDANT FAILURE VALUES */
+	u8	redund_op_failure_code;
+	u8	unsupported_nile_bus;
+	u8	host_i2c_autorev;
+	u8	cpld_revision;
+	u8	fibre_chip_count;
+	u8	daughterboard_type;
+	u8	reserved_5[2];
+
+	u8	access_module_status;
+	u8	features_supported[12];
+	/* Recovery ROM inactive f/w revision */
+	char	rec_rom_inactive_rev[4];
+	/* Recovery ROM flags */
+	u8	rec_rom_flags;
+	u8	pci_to_pci_bridge_status;
+	/* Reserved for future use */
+	u8	reserved_6[4];
+	/* Percent of memory allocated to write cache */
+	u8	percent_write_cache;
+	/* Total cache board size */
+	__le16	daughter_board_cache_size;
+	/* Number of cache batteries */
+	u8	cache_battery_count;
+	/* Total size (MB) of atttached memory */
+	__le16	total_memory_size;
+	/* Additional controller flags byte */
+	u8	more_controller_flags;
+	/* 2nd byte of 3 byte autorev field */
+	u8	x_board_host_i2c_autorev;
+	/* BBWC PIC revision */
+	u8	battery_pic_rev;
+	/* DDFF update engine version */
+	u8	ddff_version[4];
+	/* Maximum logical units supported */
+	__le16	max_logical_units;
+	/* Big num configured logical units */
 	__le16	extended_logical_unit_count;	/* offset 154 */
-	u8	pad2[136];
+	/* Maximum physical devices supported */
+	__le16	max_physical_devices;
+	/* Max physical drive per logical unit */
+	__le16	max_phy_drv_per_logical_unit;
+	/* Number of attached enclosures */
+	u8	enclosure_count;
+	/* Number of expanders detected */
+	u8	expander_count;
+	/* Offset to extended drive present map*/
+	__le16	offset_to_edp_bitmap;
+	/* Offset to extended external drive present map */
+	__le16	offset_to_eedp_bitmap;
+	/* Offset to extended non-disk map */
+	__le16	offset_to_end_bitmap;
+	/* Internal port status bytes */
+	u8	internal_port_status[8];
+	/* External port status bytes */
+	u8	external_port_status[8];
+	/* Yet More Controller flags  */
+	__le32	yet_more_controller_flags;
+	/* Last lockup code */
+	u8	last_lockup;
+	/* PCI slot according to option ROM*/
+	u8	pci_slot;
+	/* Build number */
+	__le16	build_num;
+	/* Maximum safe full stripe size */
+	__le32	max_safe_full_stripe_size;
+	/* Total structure length */
+	__le32	total_length;
+	/* Vendor ID */
+	char	vendor_id[8];
+	/* Product ID */
+	char	product_id[16];
+	u8	reserved_7[68];
 	u8	controller_mode;	/* offset 292 */
-	u8	pad3[32];
+	u8	reserved_8[32];
 };
 
 
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 6/6] scsi: hpsa: Do not use HBA flag from NVRAM if HBA is not supported
  2018-12-14 13:21 [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Ivan Mironov
                   ` (4 preceding siblings ...)
  2018-12-14 13:21 ` [PATCH 5/6] scsi: hpsa: Name more fields in "struct bmic_identify_controller" Ivan Mironov
@ 2018-12-14 13:21 ` Ivan Mironov
  2018-12-14 19:38 ` [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Don.Brace
  6 siblings, 0 replies; 11+ messages in thread
From: Ivan Mironov @ 2018-12-14 13:21 UTC (permalink / raw)
  To: linux-scsi, mironov.ivan
  Cc: linux-kernel, Don Brace, James E.J. Bottomley,
	Martin K. Petersen, esc.storagedev

Check bmic_identify_controller.yet_more_controller_flags for HBA support
bit before trying to enable HBA mode.

HP's ssacli tool calls this bit "Hba Mode Supported" in full diagnostics
report.

Signed-off-by: Ivan Mironov <mironov.ivan@gmail.com>
---
 drivers/scsi/hpsa.c     | 16 ++++++++++++++--
 drivers/scsi/hpsa_cmd.h |  4 ++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 0b5b3a651b70..38026b82ac6b 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -4342,6 +4342,12 @@ static bool hpsa_skip_device(struct ctlr_info *h, u8 *lunaddrbytes,
 	return false;
 }
 
+static bool is_hba_supported(const struct bmic_identify_controller *id_ctlr)
+{
+	return le32_to_cpu(id_ctlr->yet_more_controller_flags) &
+			YET_MORE_CTLR_FLAG_HBA_MODE_SUPP;
+}
+
 static int hpsa_nvram_hba_flag_enabled(struct ctlr_info *h, bool *flag_enabled)
 {
 	int rc;
@@ -4364,7 +4370,8 @@ static int hpsa_nvram_hba_flag_enabled(struct ctlr_info *h, bool *flag_enabled)
 	return rc;
 }
 
-static int hpsa_update_nvram_hba_mode(struct ctlr_info *h, u32 nlogicals)
+static int hpsa_update_nvram_hba_mode(struct ctlr_info *h, u32 nlogicals,
+	const struct bmic_identify_controller *id_ctlr)
 {
 	int rc;
 	bool flag_enabled;
@@ -4373,6 +4380,11 @@ static int hpsa_update_nvram_hba_mode(struct ctlr_info *h, u32 nlogicals)
 	if (!hpsa_use_nvram_hba_flag)
 		return 0;
 
+	if (!is_hba_supported(id_ctlr)) {
+		dev_info(&h->pdev->dev, "NVRAM HBA flag: not supported\n");
+		return 0;
+	}
+
 	rc = hpsa_nvram_hba_flag_enabled(h, &flag_enabled);
 	if (rc == -ENOMEM)
 		dev_warn(&h->pdev->dev, "Out of memory.\n");
@@ -4446,7 +4458,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
 			__func__);
 	}
 
-	if (hpsa_update_nvram_hba_mode(h, nlogicals)) {
+	if (hpsa_update_nvram_hba_mode(h, nlogicals, id_ctlr)) {
 		h->drv_req_rescan = 1;
 		goto out;
 	}
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
index 64100a33f844..b27f94b257bc 100644
--- a/drivers/scsi/hpsa_cmd.h
+++ b/drivers/scsi/hpsa_cmd.h
@@ -806,6 +806,10 @@ struct bmic_identify_controller {
 };
 
 
+/* ssacli calls this bit "Hba Mode Supported". */
+#define YET_MORE_CTLR_FLAG_HBA_MODE_SUPP (1 << 25)
+
+
 struct bmic_identify_physical_device {
 	u8    scsi_bus;          /* SCSI Bus number on controller */
 	u8    scsi_id;           /* SCSI ID on this bus */
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/6] scsi: hpsa: Add function to check if device is a disk or a zoned device
  2018-12-14 13:21 ` [PATCH 1/6] scsi: hpsa: Add function to check if device is a disk or a zoned device Ivan Mironov
@ 2018-12-14 13:26   ` Johannes Thumshirn
  0 siblings, 0 replies; 11+ messages in thread
From: Johannes Thumshirn @ 2018-12-14 13:26 UTC (permalink / raw)
  To: Ivan Mironov, linux-scsi
  Cc: linux-kernel, Don Brace, James E.J. Bottomley,
	Martin K. Petersen, esc.storagedev

Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
-- 
Johannes Thumshirn                            SUSE Labs Filesystems
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers
  2018-12-14 13:21 [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Ivan Mironov
                   ` (5 preceding siblings ...)
  2018-12-14 13:21 ` [PATCH 6/6] scsi: hpsa: Do not use HBA flag from NVRAM if HBA is not supported Ivan Mironov
@ 2018-12-14 19:38 ` Don.Brace
  2018-12-14 20:30   ` Ivan Mironov
  6 siblings, 1 reply; 11+ messages in thread
From: Don.Brace @ 2018-12-14 19:38 UTC (permalink / raw)
  To: mironov.ivan, linux-scsi
  Cc: linux-kernel, don.brace, jejb, martin.petersen, esc.storagedev

-----Original Message-----
From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-owner@vger.kernel.org] On Behalf Of Ivan Mironov
Sent: Friday, December 14, 2018 7:21 AM
To: linux-scsi@vger.kernel.org; mironov.ivan@gmail.com
Cc: linux-kernel@vger.kernel.org; Don Brace <don.brace@microsemi.com>; James E.J. Bottomley <jejb@linux.vnet.ibm.com>; Martin K. Petersen <martin.petersen@oracle.com>; esc.storagedev@microsemi.com
Subject: [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers

This series of patches adds support of the HBA mode on HP Smart Array P410i RAID controllers.

This is not guaranteed to be correct as I do not have any access to documentation on these controllers. However, this works fine for me on hardware that I have. Also, these changes successfully passes blktests[1] and xfstests[2].

To make sure that this new functionality does not break anything, it is disabled by default and may be enabled only manually using new module parameter.

[1] https://github.com/osandov/blktests
[2] https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git

Ivan Mironov (6):
  scsi: hpsa: Add function to check if device is a disk or a zoned
    device
  scsi: hpsa: Support HBA mode on HP Smart Array P410i controllers
  scsi: hpsa: Add/mask existing devices on rescan if visibility changes
  scsi: hpsa: Ignore HBA flag from NVRAM if logical devices exist
  scsi: hpsa: Name more fields in "struct bmic_identify_controller"
  scsi: hpsa: Do not use HBA flag from NVRAM if HBA is not supported

 drivers/scsi/hpsa.c     | 145 ++++++++++++++++++++++++++++++++++++----
 drivers/scsi/hpsa.h     |   3 +
 drivers/scsi/hpsa_cmd.h | 113 ++++++++++++++++++++++++++++++-
 3 files changed, 244 insertions(+), 17 deletions(-)

--
2.19.2

NAKing this series.
- The P410 controllers do not fully support HBA mode and we do not support adding it to the hpsa driver.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers
  2018-12-14 19:38 ` [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Don.Brace
@ 2018-12-14 20:30   ` Ivan Mironov
  2018-12-17 16:32     ` Don.Brace
  0 siblings, 1 reply; 11+ messages in thread
From: Ivan Mironov @ 2018-12-14 20:30 UTC (permalink / raw)
  To: Don.Brace, linux-scsi
  Cc: linux-kernel, don.brace, jejb, martin.petersen, esc.storagedev

On Fri, 2018-12-14 at 19:38 +0000, Don.Brace@microchip.com wrote:
> NAKing this series.
> - The P410 controllers do not fully support HBA mode and we do not support adding it to the hpsa driver.
> 

Could you please elaborate on what exactly you mean by "do not fully
support HBA mode"?

HBA mode looks supported on P410i (at least to some degree) because:
*) There is an official method to enable/disable it on these
controllers. Only for itanium-based servers unfortunately.
*) This method is mentioned in various documents from HP regarding
Integrity servers.
*) Controller reacts on the change of corresponging bit in nvram_flags
by immediately removing any configured RAID arrays and by refusing to
configure new arrays. Which is totally expected for HBA mode.
*) HBA mode works for me on P410i with patched driver.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers
  2018-12-14 20:30   ` Ivan Mironov
@ 2018-12-17 16:32     ` Don.Brace
  0 siblings, 0 replies; 11+ messages in thread
From: Don.Brace @ 2018-12-17 16:32 UTC (permalink / raw)
  To: mironov.ivan, linux-scsi
  Cc: linux-kernel, don.brace, jejb, martin.petersen, esc.storagedev

-----Original Message-----
From: Ivan Mironov [mailto:mironov.ivan@gmail.com] 
Sent: Friday, December 14, 2018 2:30 PM
To: Don Brace - C33706 <Don.Brace@microchip.com>; linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org; don.brace@microsemi.com; jejb@linux.vnet.ibm.com; martin.petersen@oracle.com; esc.storagedev@microsemi.com
Subject: Re: [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers

EXTERNAL EMAIL


On Fri, 2018-12-14 at 19:38 +0000, Don.Brace@microchip.com wrote:
> NAKing this series.
> - The P410 controllers do not fully support HBA mode and we do not support adding it to the hpsa driver.
>

Could you please elaborate on what exactly you mean by "do not fully support HBA mode"?

Don> HBA mode may have started on this controller family, but was not fully developed.
Don> Regardless of the server, It's not a generic offering and should not be accepted into the general driver space.
Don> Adding this to kernel.org means it will find its way into other Linux vendors and we do not want this either.

HBA mode looks supported on P410i (at least to some degree) because:
*) There is an official method to enable/disable it on these controllers. Only for itanium-based servers unfortunately.
*) This method is mentioned in various documents from HP regarding Integrity servers.
*) Controller reacts on the change of corresponging bit in nvram_flags by immediately removing any configured RAID arrays and by refusing to configure new arrays. Which is totally expected for HBA mode.
*) HBA mode works for me on P410i with patched driver.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-12-17 16:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-14 13:21 [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Ivan Mironov
2018-12-14 13:21 ` [PATCH 1/6] scsi: hpsa: Add function to check if device is a disk or a zoned device Ivan Mironov
2018-12-14 13:26   ` Johannes Thumshirn
2018-12-14 13:21 ` [PATCH 2/6] scsi: hpsa: Support HBA mode on HP Smart Array P410i controllers Ivan Mironov
2018-12-14 13:21 ` [PATCH 3/6] scsi: hpsa: Add/mask existing devices on rescan if visibility changes Ivan Mironov
2018-12-14 13:21 ` [PATCH 4/6] scsi: hpsa: Ignore HBA flag from NVRAM if logical devices exist Ivan Mironov
2018-12-14 13:21 ` [PATCH 5/6] scsi: hpsa: Name more fields in "struct bmic_identify_controller" Ivan Mironov
2018-12-14 13:21 ` [PATCH 6/6] scsi: hpsa: Do not use HBA flag from NVRAM if HBA is not supported Ivan Mironov
2018-12-14 19:38 ` [PATCH 0/6] Add support of the HBA mode on HP Smart Array P410i controllers Don.Brace
2018-12-14 20:30   ` Ivan Mironov
2018-12-17 16:32     ` Don.Brace

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).