Skip to contentSkip to conversation

cxlflash: Miscellaneous fixes

PATCH Applied Uma Krishnan 2 participants 5 messages Oct 25, 2017 – Oct 31, 2017 SCSI

lore
Share & tools
lore
#0 lore raw

cover cxlflash: Miscellaneous fixes

This patch series contains miscellaneous fixes. All three patches resolve minor issues.

This series is intended for 4.15 and is bisectable.

Matthew R. Ochs (3):
cxlflash: Use derived maximum write same length
cxlflash: Allow cards without WWPN VPD to configure
cxlflash: Derive pid through accessors

 drivers/scsi/cxlflash/main.c      | 24 +++++++++++++++++-------
 drivers/scsi/cxlflash/main.h      |  3 ++-
 drivers/scsi/cxlflash/sislite.h   |  3 ---
 drivers/scsi/cxlflash/superpipe.c |  6 +++---
 drivers/scsi/cxlflash/vlun.c      |  6 ++++--
 5 files changed, 26 insertions(+), 16 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/3 cxlflash: Use derived maximum write same length

From: "Matthew R. Ochs" <[email protected]>

The existing write same routine within the cxlflash driver uses a statically defined value for the maximum write same transfer length. While this is close to the value reflected by the original device that was supported by cxlflash, newer devices are capable of much larger lengths. Supporting what the device is capable of offers substantial performance improvement as the scrub routine within cxlflash operates on 'chunk size' units (256MB with a 4K sector size).

Instead of a #define, use the write same maximum length that is stored in the block layer in units of 512 byte sectors. This value is initially determined from the block limits VPD page during device discovery and can also be manipulated from sysfs. As a general cleanup, designate the timeout used when executing the write same command as constant.

---
 drivers/scsi/cxlflash/sislite.h | 3 ---
 drivers/scsi/cxlflash/vlun.c    | 6 ++++--
 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/scsi/cxlflash/sislite.h +0 -3
index 09daa86..bedf1ce 100644
@@ -548,7 +548,4 @@ struct sisl_rht_entry_f1 {
 #define TMF_LUN_RESET  0x1U
 #define TMF_CLEAR_ACA  0x2U
 
-
-#define SISLITE_MAX_WS_BLOCKS 512
-
 #endif /* _SISLITE_H */
drivers/scsi/cxlflash/vlun.c +4 -2
index 703bf1e..5deef57 100644
@@ -428,12 +428,14 @@ static int write_same16(struct scsi_device *sdev,
 	u8 *sense_buf = NULL;
 	int rc = 0;
 	int result = 0;
-	int ws_limit = SISLITE_MAX_WS_BLOCKS;
 	u64 offset = lba;
 	int left = nblks;
-	u32 to = sdev->request_queue->rq_timeout;
 	struct cxlflash_cfg *cfg = shost_priv(sdev->host);
 	struct device *dev = &cfg->dev->dev;
+	const u32 s = ilog2(sdev->sector_size) - 9;
+	const u32 to = sdev->request_queue->rq_timeout;
+	const u32 ws_limit = blk_queue_get_max_sectors(sdev->request_queue,
+						       REQ_OP_WRITE_SAME) >> s;
 
 	cmd_buf = kzalloc(CMD_BUFSIZE, GFP_KERNEL);
 	scsi_cmd = kzalloc(MAX_COMMAND_SIZE, GFP_KERNEL);
Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/3 cxlflash: Allow cards without WWPN VPD to configure

In reply to Uma Krishnan

From: "Matthew R. Ochs" <[email protected]>

Currently, all adapters that cxlflash supports must have WWPN VPD keywords to complete configuration. This was required as cards with external FC ports needed to be programmed with WWPNs.

Newer supported cards do not have an external FC interface and therefore do not require WWPN. To support backwards compatibility, these devices have included 'dummy' WWPN VPD with WWPN values of zero. This however places a dependency that all future cards have WWPN VPD, which may not always be the case.

Allow for cards to not have WWPN, designating which cards are expected to have it in order to configure properly.

---
 drivers/scsi/cxlflash/main.c | 24 +++++++++++++++++-------
 drivers/scsi/cxlflash/main.h |  3 ++-
 2 files changed, 19 insertions(+), 8 deletions(-)
drivers/scsi/cxlflash/main.c +17 -7
index 76b8b7ee..6178028 100644
@@ -1634,7 +1634,10 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[])
 	ssize_t vpd_size;
 	char vpd_data[CXLFLASH_VPD_LEN];
 	char tmp_buf[WWPN_BUF_LEN] = { 0 };
-	char *wwpn_vpd_tags[MAX_FC_PORTS] = { "V5", "V6", "V7", "V8" };
+	const struct dev_dependent_vals *ddv = (struct dev_dependent_vals *)
+						cfg->dev_id->driver_data;
+	const bool wwpn_vpd_required = ddv->flags & CXLFLASH_WWPN_VPD_REQUIRED;
+	const char *wwpn_vpd_tags[MAX_FC_PORTS] = { "V5", "V6", "V7", "V8" };
 
 	/* Get the VPD data from the device */
 	vpd_size = cxl_read_adapter_vpd(pdev, vpd_data, sizeof(vpd_data));
@@ -1671,17 +1674,24 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[])
 	 * value. Note that we must copy to a temporary buffer
 	 * because the conversion service requires that the ASCII
 	 * string be terminated.
+	 *
+	 * Allow for WWPN not being found for all devices, setting
+	 * the returned WWPN to zero when not found. Notify with a
+	 * log error for cards that should have had WWPN keywords
+	 * in the VPD - cards requiring WWPN will not have their
+	 * ports programmed and operate in an undefined state.
 	 */
 	for (k = 0; k < cfg->num_fc_ports; k++) {
 		j = ro_size;
 		i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
 
 		i = pci_vpd_find_info_keyword(vpd_data, i, j, wwpn_vpd_tags[k]);
-		if (unlikely(i < 0)) {
-			dev_err(dev, "%s: Port %d WWPN not found in VPD\n",
-				__func__, k);
-			rc = -ENODEV;
-			goto out;
+		if (i < 0) {
+			if (wwpn_vpd_required)
+				dev_err(dev, "%s: Port %d WWPN not found\n",
+					__func__, k);
+			wwpn[k] = 0ULL;
+			continue;
 		}
 
 		j = pci_vpd_info_field_size(&vpd_data[i]);
@@ -3145,7 +3155,7 @@ static struct scsi_host_template driver_template = {
  * Device dependent values
  */
 static struct dev_dependent_vals dev_corsa_vals = { CXLFLASH_MAX_SECTORS,
-					0ULL };
+					CXLFLASH_WWPN_VPD_REQUIRED };
 static struct dev_dependent_vals dev_flash_gt_vals = { CXLFLASH_MAX_SECTORS,
 					CXLFLASH_NOTIFY_SHUTDOWN };
 static struct dev_dependent_vals dev_briard_vals = { CXLFLASH_MAX_SECTORS,
drivers/scsi/cxlflash/main.h +2 -1
index 880e348..ba0108a 100644
@@ -95,7 +95,8 @@ enum undo_level {
 struct dev_dependent_vals {
 	u64 max_sectors;
 	u64 flags;
-#define CXLFLASH_NOTIFY_SHUTDOWN   0x0000000000000001ULL
+#define CXLFLASH_NOTIFY_SHUTDOWN	0x0000000000000001ULL
+#define CXLFLASH_WWPN_VPD_REQUIRED	0x0000000000000002ULL
 };
 
 struct asyc_intr_info {
Signature · 1 line
2.1.0
#3 lore raw

PATCH 3/3 cxlflash: Derive pid through accessors

In reply to Uma Krishnan

From: "Matthew R. Ochs" <[email protected]>

The cxlflash driver tracks process IDs alongside contexts to validate context ownership. Currently, the process IDs are derived by directly accessing values from the 'current' task pointer. While this method of access is fine for the current process, it is incorrect when the parent process ID is needed as the access requires serialization.

To address the incorrect issue and provide a consistent means of deriving the process ID within the cxlflash driver, use the task accessors defined linux/sched.h.

---
 drivers/scsi/cxlflash/superpipe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/cxlflash/superpipe.c +3 -3
index ed46e8d..170fff5 100644
@@ -165,7 +165,7 @@ struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxid,
 	struct llun_info *lli = arg;
 	u64 ctxid = DECODE_CTXID(rctxid);
 	int rc;
-	pid_t pid = current->tgid, ctxpid = 0;
+	pid_t pid = task_tgid_nr(current), ctxpid = 0;
 
 	if (ctx_ctrl & CTX_CTRL_FILE) {
 		lli = NULL;
@@ -173,7 +173,7 @@ struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxid,
 	}
 
 	if (ctx_ctrl & CTX_CTRL_CLONE)
-		pid = current->parent->tgid;
+		pid = task_ppid_nr(current);
 
 	if (likely(ctxid < MAX_CONTEXT)) {
 		while (true) {
@@ -824,7 +824,7 @@ static void init_context(struct ctx_info *ctxi, struct cxlflash_cfg *cfg,
 	ctxi->rht_perms = perms;
 	ctxi->ctrl_map = &afu->afu_map->ctrls[ctxid].ctrl;
 	ctxi->ctxid = ENCODE_CTXID(ctxi, ctxid);
-	ctxi->pid = current->tgid; /* tgid = pid */
+	ctxi->pid = task_tgid_nr(current); /* tgid = pid */
 	ctxi->ctx = ctx;
 	ctxi->cfg = cfg;
 	ctxi->file = file;
Signature · 1 line
2.1.0
#4 lore raw
In reply to Uma Krishnan

Uma,

Quoted 4 lines

This patch series contains miscellaneous fixes. All three patches resolve minor issues.

This series is intended for 4.15 and is bisectable.

Applied to 4.15/scsi-queue. Thank you!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering