Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * IBM eServer eHCA Infiniband device driver for Linux on POWER |
| 3 | * |
| 4 | * load store abstraction for ehca register access with tracing |
| 5 | * |
| 6 | * Authors: Christoph Raisch <raisch@de.ibm.com> |
| 7 | * Hoang-Nam Nguyen <hnguyen@de.ibm.com> |
| 8 | * |
| 9 | * Copyright (c) 2005 IBM Corporation |
| 10 | * |
| 11 | * All rights reserved. |
| 12 | * |
| 13 | * This source code is distributed under a dual license of GPL v2.0 and OpenIB |
| 14 | * BSD. |
| 15 | * |
| 16 | * OpenIB BSD License |
| 17 | * |
| 18 | * Redistribution and use in source and binary forms, with or without |
| 19 | * modification, are permitted provided that the following conditions are met: |
| 20 | * |
| 21 | * Redistributions of source code must retain the above copyright notice, this |
| 22 | * list of conditions and the following disclaimer. |
| 23 | * |
| 24 | * Redistributions in binary form must reproduce the above copyright notice, |
| 25 | * this list of conditions and the following disclaimer in the documentation |
| 26 | * and/or other materials |
| 27 | * provided with the distribution. |
| 28 | * |
| 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 30 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 33 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 34 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 35 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 36 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| 37 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 38 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 39 | * POSSIBILITY OF SUCH DAMAGE. |
| 40 | */ |
| 41 | |
| 42 | #include "ehca_classes.h" |
| 43 | #include "hipz_hw.h" |
| 44 | |
Alexander Schmidt | e675b6d | 2010-07-05 16:19:25 +0000 | [diff] [blame] | 45 | u64 hcall_map_page(u64 physaddr) |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 46 | { |
Alexander Schmidt | e675b6d | 2010-07-05 16:19:25 +0000 | [diff] [blame] | 47 | return (u64)ioremap(physaddr, EHCA_PAGESIZE); |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | int hcall_unmap_page(u64 mapaddr) |
| 51 | { |
Hoang-Nam Nguyen | 2b94397 | 2007-07-12 17:53:47 +0200 | [diff] [blame] | 52 | iounmap((volatile void __iomem *) mapaddr); |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 53 | return 0; |
| 54 | } |
| 55 | |
Stefan Roscher | 1988d1f | 2009-05-13 16:52:43 -0700 | [diff] [blame] | 56 | int hcp_galpas_ctor(struct h_galpas *galpas, int is_user, |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 57 | u64 paddr_kernel, u64 paddr_user) |
| 58 | { |
Stefan Roscher | 1988d1f | 2009-05-13 16:52:43 -0700 | [diff] [blame] | 59 | if (!is_user) { |
Alexander Schmidt | e675b6d | 2010-07-05 16:19:25 +0000 | [diff] [blame] | 60 | galpas->kernel.fw_handle = hcall_map_page(paddr_kernel); |
| 61 | if (!galpas->kernel.fw_handle) |
| 62 | return -ENOMEM; |
Stefan Roscher | 1988d1f | 2009-05-13 16:52:43 -0700 | [diff] [blame] | 63 | } else |
| 64 | galpas->kernel.fw_handle = 0; |
Heiko J Schick | fab9722 | 2006-09-22 15:22:22 -0700 | [diff] [blame] | 65 | |
| 66 | galpas->user.fw_handle = paddr_user; |
| 67 | |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | int hcp_galpas_dtor(struct h_galpas *galpas) |
| 72 | { |
| 73 | if (galpas->kernel.fw_handle) { |
| 74 | int ret = hcall_unmap_page(galpas->kernel.fw_handle); |
| 75 | if (ret) |
| 76 | return ret; |
| 77 | } |
| 78 | |
| 79 | galpas->user.fw_handle = galpas->kernel.fw_handle = 0; |
| 80 | |
| 81 | return 0; |
| 82 | } |