[ofw] [Patch 12/62] Reference implementation of NDv2
Fab Tillier
ftillier at microsoft.com
Wed Feb 20 17:25:17 PST 2013
Use KPROCESSOR_MODE when mapping I/O space.
Signed-off-by: Fab Tillier <ftillier at microsoft.com>
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\inc\ib_verbs_ex.h .\hw\mlx4\kernel\bus\inc\ib_verbs_ex.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\bus\inc\ib_verbs_ex.h Thu May 31 11:22:18 2012
+++ .\hw\mlx4\kernel\bus\inc\ib_verbs_ex.h Thu Jul 26 15:31:14 2012
@@ -83,7 +83,6 @@ typedef struct {
PVOID uva;
PMDL mdl;
PVOID kva;
- int mapped;
} umap_t;
struct ib_ucontext_ex
diff -dwup3 -x *svn* -r c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\hverbs.c .\hw\mlx4\kernel\hca\hverbs.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\hw\mlx4\kernel\hca\hverbs.c Thu May 31 11:22:19 2012
+++ .\hw\mlx4\kernel\hca\hverbs.c Thu Jul 26 15:31:14 2012
@@ -554,6 +554,7 @@ int ib_destroy_srq(struct ib_srq *srq)
IN io_addr_t addr,
IN SIZE_T size,
IN MEMORY_CACHING_TYPE mem_type,
+ IN KPROCESSOR_MODE mode,
OUT umap_t * p_map
)
{
@@ -561,8 +562,6 @@ static NTSTATUS __map_memory_for_user(
HCA_ENTER(HCA_DBG_SHIM);
- p_map->mapped = 0;
-
// map UAR to kernel
p_map->kva = ioremap(addr, size, mem_type);
if (!p_map->kva) {
@@ -572,6 +571,14 @@ static NTSTATUS __map_memory_for_user(
goto err_ioremap;
}
+ if( mode == KernelMode )
+ {
+ p_map->mdl = NULL;
+ p_map->uva = p_map->kva;
+ status = STATUS_SUCCESS;
+ goto done;
+ }
+
// build MDL
p_map->mdl = IoAllocateMdl( p_map->kva, (ULONG)size,
FALSE, TRUE, NULL );
@@ -591,15 +598,16 @@ static NTSTATUS __map_memory_for_user(
goto err_map;
}
- p_map->mapped = 1;
status = STATUS_SUCCESS;
goto done;
err_map:
IoFreeMdl(p_map->mdl);
+ p_map->mdl = NULL;
err_alloc_mdl:
iounmap(p_map->kva, PAGE_SIZE);
+ p_map->kva = NULL;
err_ioremap:
done:
@@ -611,11 +619,14 @@ static void __unmap_memory_for_user(
IN umap_t * p_map
)
{
- if (p_map->mapped) {
- p_map->mapped = 0;
+ if (p_map->mdl != NULL) {
MmUnmapLockedPages( p_map->uva, p_map->mdl );
IoFreeMdl(p_map->mdl);
+ p_map->mdl = NULL;
+ }
+ if( p_map->kva != NULL ){
iounmap(p_map->kva, PAGE_SIZE);
+ p_map->kva = NULL;
}
}
@@ -658,7 +669,7 @@ ib_api_status_t ibv_um_open(
// map uar to user space
status = __map_memory_for_user(
(io_addr_t)p_muctx->uar.pfn << PAGE_SHIFT,
- PAGE_SIZE, MmNonCached, &p_uctx->x.uar );
+ PAGE_SIZE, MmNonCached, mode, &p_uctx->x.uar );
if( !NT_SUCCESS(status) ) {
goto err_map_uar;
}
@@ -677,7 +688,7 @@ ib_api_status_t ibv_um_open(
status = __map_memory_for_user(
(io_addr_t)(p_muctx->uar.pfn +
to_mdev(p_ibdev)->dev->caps.num_uars) << PAGE_SHIFT,
- PAGE_SIZE, MmWriteCombined, &p_uctx->x.bf );
+ PAGE_SIZE, MmWriteCombined, mode, &p_uctx->x.bf );
if( !NT_SUCCESS(status) ) {
HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_SHIM,
("BlueFlame available, but failed to be mapped (%#x)\n", status));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ndv2.12.patch
Type: application/octet-stream
Size: 2952 bytes
Desc: ndv2.12.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20130221/b9f26aef/attachment.obj>
More information about the ofw
mailing list