]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/scsi/cxlflash/main.c
scsi: cxlflash: Allow cards without WWPN VPD to configure
[mirror_ubuntu-artful-kernel.git] / drivers / scsi / cxlflash / main.c
index 6a4367cc9caabea8f0bbc1519d309ab50b55578f..7d850eaa10fc9b97c961fdb1339f553834f0147c 100644 (file)
@@ -1635,7 +1635,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));
@@ -1672,17 +1675,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]);
@@ -3146,7 +3156,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,