[Openib-windows] [PATCH] HCA: Allocate MDLs for memory registration manually

Fab Tillier ftillier at silverstorm.com
Thu Oct 6 23:03:15 PDT 2005


Yossi,

The following patch changes how memory registration works.  Instead of calling
IoAllocateMdl to setup the MDL for a memory region, the code will manually
allocate a buffer large enough for the MDL and call MmInitializeMdl instead.
This is needed to allow buffers that exceed the limits of IoAllocateMdl to be
registered.  The DDK docs detail the limitations on size of IoAllocateMdl.

Note that the following patch is against the previous changes I sent to secure
the memory.

Let me know if this (and the previous) are OK to commit.

Thanks,

- Fab

Signed-off-by: Fab Tillier (ftillier at silverstorm.com)

Index: hw/mt23108/vapi/mlxsys/mosal/os_dep/win/mosal_iobuf.c
===================================================================
--- hw/mt23108/vapi/mlxsys/mosal/os_dep/win/mosal_iobuf.c   (revision 101)
+++ hw/mt23108/vapi/mlxsys/mosal/os_dep/win/mosal_iobuf.c   (working copy)
@@ -110,13 +110,16 @@
   }
    
   // allocate MDL 
-  mdl_p = IoAllocateMdl( (PVOID)va, (ULONG)size, FALSE,FALSE,NULL);
+  mdl_p = ExAllocatePoolWithTag( NonPagedPool,
+     MmSizeOfMdl( (PVOID)va, size ), 'geRM' );
   if (mdl_p == NULL) {
    MTL_ERROR4("MOSAL_iobuf_register: IoAllocateMdl failed, va %p, sz %d\n", va,
size);
    rc = MT_EKMALLOC;
    goto err1;
   }
 
+  MmInitializeMdl( mdl_p, (PVOID)va, size );
+
   // make context-dependent things
   if (prot_ctx == MOSAL_PROT_CTX_KERNEL) {  /* Mapping to kernel virtual
address */
 //    MmBuildMdlForNonPagedPool(mdl_p);   // fill MDL ??? - should we do that
really ?
@@ -238,7 +241,7 @@
   return MT_OK;
 
 err2:
-  IoFreeMdl(mdl_p);
+  ExFreePoolWithTag( mdl_p, 'geRM' );
 err1:  
   FREE((PVOID)new_iobuf);
 err0:  
@@ -250,7 +253,7 @@
    if( iobuf_seg_p->h_secure )
        MmUnsecureVirtualMemory( iobuf_seg_p->h_secure);
   MmUnlockPages( iobuf_seg_p->mdl_p );    // unlock the buffer 
-  IoFreeMdl( iobuf_seg_p->mdl_p );        // free MDL
+  ExFreePoolWithTag( iobuf_seg_p->mdl_p, 'geRM' );
   FREE(iobuf_seg_p);
 }

-------------- next part --------------
A non-text attachment was scrubbed...
Name: reg_mdl.patch
Type: application/octet-stream
Size: 1349 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20051006/430ef59b/attachment.obj>


More information about the ofw mailing list