[SRU,Bionic,1/4] UBUNTU: SAUCE: (no-up) cxlflash: OCXL diff between v2 and v3

Message ID 0ec6074bff9bbde200fa035251a1a24d9ef27cd6.1527865668.git.joseph.salisbury@canonical.com
State New
Headers show
Series
  • Fixes for LP:1768431
Related show

Commit Message

Joseph Salisbury June 1, 2018, 3:23 p.m.
From: Uma Krishnan <ukrishn@linux.vnet.ibm.com>

BugLink: http://bugs.launchpad.net/bugs/1768431

This is a SAUCE commit specific to Ubuntu 18.04 (bionic) release.
After sending the OCXL feature patches (v2) to community, a request
was submitted to Canonical to pick them as SAUCE patches. There was
a small revision made to the v2 set and was submitted as v3 to the
community. This revision did not make it on time to be included in
bionic GA. To bring the bionic code upto speed with what is accepted
in the community I'm submitting this revision patch which contains
only the revision. That way, the entire series of 38 patches need
not be reverted and reapplied with the latest version.

Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
---
 drivers/scsi/cxlflash/ocxl_hw.c | 18 +++++++++++++-----
 drivers/scsi/cxlflash/ocxl_hw.h |  1 +
 2 files changed, 14 insertions(+), 5 deletions(-)

Patch

diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
index 3c311f315d90..0a95b5f25380 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.c
+++ b/drivers/scsi/cxlflash/ocxl_hw.c
@@ -776,10 +776,13 @@  static int ocxlflash_config_fn(struct pci_dev *pdev, struct ocxl_hw_afu *afu)
 		goto out;
 	}
 
-	/* Only one AFU per function is supported by ocxlflash */
-	if (fcfg->max_afu_index != 0)
-		dev_warn(dev, "%s: Unexpected AFU index value %d\n",
-			 __func__, fcfg->max_afu_index);
+	/* Check if function has AFUs defined, only 1 per function supported */
+	if (fcfg->max_afu_index >= 0) {
+		afu->is_present = true;
+		if (fcfg->max_afu_index != 0)
+			dev_warn(dev, "%s: Unexpected AFU index value %d\n",
+				 __func__, fcfg->max_afu_index);
+	}
 
 	rc = ocxl_config_get_actag_info(pdev, &base, &enabled, &supported);
 	if (unlikely(rc)) {
@@ -894,6 +897,10 @@  static int ocxlflash_config_afu(struct pci_dev *pdev, struct ocxl_hw_afu *afu)
 	int pos;
 	int rc = 0;
 
+	/* This HW AFU function does not have any AFUs defined */
+	if (!afu->is_present)
+		goto out;
+
 	/* Read AFU config at index 0 */
 	rc = ocxl_config_read_afu(pdev, fcfg, acfg, 0);
 	if (unlikely(rc)) {
@@ -949,6 +956,7 @@  static void *ocxlflash_create_afu(struct pci_dev *pdev)
 
 	afu->pdev = pdev;
 	afu->dev = dev;
+	idr_init(&afu->idr);
 
 	rc = ocxlflash_config_fn(pdev, afu);
 	if (unlikely(rc)) {
@@ -972,7 +980,6 @@  static void *ocxlflash_create_afu(struct pci_dev *pdev)
 		goto err3;
 	}
 
-	idr_init(&afu->idr);
 	afu->ocxl_ctx = ctx;
 out:
 	return afu;
@@ -981,6 +988,7 @@  static void *ocxlflash_create_afu(struct pci_dev *pdev)
 err2:
 	ocxlflash_unconfig_fn(pdev, afu);
 err1:
+	idr_destroy(&afu->idr);
 	kfree(afu);
 	afu = NULL;
 	goto out;
diff --git a/drivers/scsi/cxlflash/ocxl_hw.h b/drivers/scsi/cxlflash/ocxl_hw.h
index eb1c24afeae3..9270d35c4620 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.h
+++ b/drivers/scsi/cxlflash/ocxl_hw.h
@@ -43,6 +43,7 @@  struct ocxl_hw_afu {
 	void *link_token;		/* Link token for the SPA */
 	struct idr idr;			/* IDR to manage contexts */
 	int max_pasid;			/* Maximum number of contexts */
+	bool is_present;		/* Function has AFUs defined */
 };
 
 enum ocxlflash_ctx_state {