Path: blob/master/drivers/infiniband/hw/ehca/hcp_phyp.c
15112 views
/*1* IBM eServer eHCA Infiniband device driver for Linux on POWER2*3* load store abstraction for ehca register access with tracing4*5* Authors: Christoph Raisch <[email protected]>6* Hoang-Nam Nguyen <[email protected]>7*8* Copyright (c) 2005 IBM Corporation9*10* All rights reserved.11*12* This source code is distributed under a dual license of GPL v2.0 and OpenIB13* BSD.14*15* OpenIB BSD License16*17* Redistribution and use in source and binary forms, with or without18* modification, are permitted provided that the following conditions are met:19*20* Redistributions of source code must retain the above copyright notice, this21* list of conditions and the following disclaimer.22*23* Redistributions in binary form must reproduce the above copyright notice,24* this list of conditions and the following disclaimer in the documentation25* and/or other materials26* provided with the distribution.27*28* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"29* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE30* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE31* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE32* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR33* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF34* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR35* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER36* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)37* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE38* POSSIBILITY OF SUCH DAMAGE.39*/4041#include "ehca_classes.h"42#include "hipz_hw.h"4344u64 hcall_map_page(u64 physaddr)45{46return (u64)ioremap(physaddr, EHCA_PAGESIZE);47}4849int hcall_unmap_page(u64 mapaddr)50{51iounmap((volatile void __iomem *) mapaddr);52return 0;53}5455int hcp_galpas_ctor(struct h_galpas *galpas, int is_user,56u64 paddr_kernel, u64 paddr_user)57{58if (!is_user) {59galpas->kernel.fw_handle = hcall_map_page(paddr_kernel);60if (!galpas->kernel.fw_handle)61return -ENOMEM;62} else63galpas->kernel.fw_handle = 0;6465galpas->user.fw_handle = paddr_user;6667return 0;68}6970int hcp_galpas_dtor(struct h_galpas *galpas)71{72if (galpas->kernel.fw_handle) {73int ret = hcall_unmap_page(galpas->kernel.fw_handle);74if (ret)75return ret;76}7778galpas->user.fw_handle = galpas->kernel.fw_handle = 0;7980return 0;81}828384