]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[hermon] Perform clean MPT unmap on device shutdown
authorChristian Iversen <ci@iversenit.dk>
Tue, 26 Jan 2021 22:48:44 +0000 (23:48 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 29 Jan 2021 00:46:53 +0000 (00:46 +0000)
This change is ported from Flexboot sources.  When stopping a Hermon
device, perform hermon_unmap_mpt() which runs HERMON_HCR_HW2SW_MPT to
bring the Memory Protection Table (MPT) back to software control.

Signed-off-by: Christian Iversen <ci@iversenit.dk>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/infiniband/hermon.c
src/drivers/infiniband/hermon.h

index d766ed585dedc5e171c52804ac58eb0b877bdc67..2a9649de2d545e8dba0fff5bd27d816f7be780fb 100644 (file)
@@ -331,6 +331,13 @@ hermon_cmd_sw2hw_mpt ( struct hermon *hermon, unsigned int index,
                            0, mpt, index, NULL );
 }
 
+static inline int
+hermon_cmd_hw2sw_mpt ( struct hermon *hermon, unsigned int index ) {
+       return hermon_cmd ( hermon,
+                           HERMON_HCR_VOID_CMD ( HERMON_HCR_HW2SW_MPT ),
+                           0, NULL, index, NULL );
+}
+
 static inline int
 hermon_cmd_write_mtt ( struct hermon *hermon,
                       const struct hermonprm_write_mtt *write_mtt ) {
@@ -2807,6 +2814,25 @@ static int hermon_setup_mpt ( struct hermon *hermon ) {
        return 0;
 }
 
+/**
+ * Unmap memory protection table
+ *
+ * @v hermon           Hermon device
+ * @ret rc             Return status code
+ */
+static int hermon_unmap_mpt ( struct hermon *hermon ) {
+       int rc;
+
+       if ( ( rc = hermon_cmd_hw2sw_mpt ( hermon,
+                                          hermon->cap.reserved_mrws ) ) != 0 ){
+               DBGC ( hermon, "Hermon %p could not unmap MPT: %s\n",
+                      hermon, strerror ( rc ) );
+               return rc;
+       }
+
+       return 0;
+}
+
 /**
  * Configure special queue pairs
  *
@@ -2888,6 +2914,7 @@ static int hermon_start ( struct hermon *hermon, int running ) {
  err_conf_special_qps:
        hermon_destroy_eq ( hermon );
  err_create_eq:
+       hermon_unmap_mpt ( hermon );
  err_setup_mpt:
        hermon_cmd_close_hca ( hermon );
  err_init_hca:
@@ -2905,6 +2932,7 @@ static int hermon_start ( struct hermon *hermon, int running ) {
  */
 static void hermon_stop ( struct hermon *hermon ) {
        hermon_destroy_eq ( hermon );
+       hermon_unmap_mpt ( hermon );
        hermon_cmd_close_hca ( hermon );
        hermon_unmap_icm ( hermon );
        hermon_stop_firmware ( hermon );
index 381e2e462f090f69caa93abda8d8345a8445ae61..61f3b04186d40c00f89bc1e337fb4c25c65a6b05 100644 (file)
@@ -52,6 +52,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #define HERMON_HCR_CLOSE_PORT          0x000a
 #define HERMON_HCR_SET_PORT            0x000c
 #define HERMON_HCR_SW2HW_MPT           0x000d
+#define HERMON_HCR_HW2SW_MPT           0x000f
 #define HERMON_HCR_WRITE_MTT           0x0011
 #define HERMON_HCR_MAP_EQ              0x0012
 #define HERMON_HCR_SW2HW_EQ            0x0013