Author: asomers
Date: Tue Nov 28 19:57:16 2017
New Revision: 326341
URL: https://svnweb.freebsd.org/changeset/base/326341

Log:
  MFC r325363:
  
  Fix mpr(4) panics caused by bad drive mapping tables
  
  sys/dev/mpr/mpr_mapping.c
        If _mapping_process_dpm_pg0 detects inconsistencies in the drive
        mapping table (stored in the HBA's NVRAM), abort reading it and
        continue to boot as if the mapping table were blank.  I observed
        such inconsistencies in several HBAs after upgrading firmware from
        14.0.0.0 to 15.0.0.0.
  
  Reviewed by:  slm
  Sponsored by: Spectra Logic Corp
  Differential Revision:        https://reviews.freebsd.org/D12901

Modified:
  stable/10/sys/dev/mpr/mpr_mapping.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mpr/mpr_mapping.c
==============================================================================
--- stable/10/sys/dev/mpr/mpr_mapping.c Tue Nov 28 19:46:48 2017        
(r326340)
+++ stable/10/sys/dev/mpr/mpr_mapping.c Tue Nov 28 19:57:16 2017        
(r326341)
@@ -2210,7 +2210,7 @@ mpr_mapping_free_memory(struct mpr_softc *sc)
        free(sc->dpm_pg0, M_MPR);
 }
 
-static void
+static bool
 _mapping_process_dpm_pg0(struct mpr_softc *sc)
 {
        u8 missing_cnt, enc_idx;
@@ -2339,7 +2339,7 @@ _mapping_process_dpm_pg0(struct mpr_softc *sc)
                                            "%s: Conflict in mapping table for "
                                            " enclosure %d\n", __func__,
                                            enc_idx);
-                                       break;
+                                       goto fail;
                                }
                                physical_id =
                                    dpm_entry->PhysicalIdentifier.High;
@@ -2366,7 +2366,7 @@ _mapping_process_dpm_pg0(struct mpr_softc *sc)
                                mpr_dprint(sc, MPR_ERROR | MPR_MAPPING, "%s: "
                                    "Conflict in mapping table for device %d\n",
                                    __func__, map_idx);
-                               break;
+                               goto fail;
                        }
                        physical_id = dpm_entry->PhysicalIdentifier.High;
                        mt_entry->physical_id = (physical_id << 32) |
@@ -2378,6 +2378,18 @@ _mapping_process_dpm_pg0(struct mpr_softc *sc)
                        mt_entry->device_info = MPR_DEV_RESERVED;
                }
        } /*close the loop for DPM table */
+       return (true);
+
+fail:
+       for (entry_num = 0; entry_num < sc->max_dpm_entries; entry_num++) {
+               sc->dpm_entry_used[entry_num] = 0;
+               /*
+                * for IR firmware, it may be necessary to wipe out
+                * sc->mapping_table volumes tooi
+                */
+       }
+       sc->num_enc_table_entries = 0;
+       return (false);
 }
 
 /*
@@ -2617,9 +2629,11 @@ retry_read_dpm:
                }
        }
 
-       if (sc->is_dpm_enable)
-               _mapping_process_dpm_pg0(sc);
-       else {
+       if (sc->is_dpm_enable) {
+               if (!_mapping_process_dpm_pg0(sc))
+                       sc->is_dpm_enable = 0;
+       }
+       if (! sc->is_dpm_enable) {
                mpr_dprint(sc, MPR_MAPPING, "%s: DPM processing is disabled. "
                    "Device mappings will not persist across reboots or "
                    "resets.\n", __func__);
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to