Path: blob/master/drivers/infiniband/hw/qib/qib_pio_copy.c
15112 views
/*1* Copyright (c) 2009 QLogic Corporation. All rights reserved.2*3* This software is available to you under a choice of one of two4* licenses. You may choose to be licensed under the terms of the GNU5* General Public License (GPL) Version 2, available from the file6* COPYING in the main directory of this source tree, or the7* OpenIB.org BSD license below:8*9* Redistribution and use in source and binary forms, with or10* without modification, are permitted provided that the following11* conditions are met:12*13* - Redistributions of source code must retain the above14* copyright notice, this list of conditions and the following15* disclaimer.16*17* - Redistributions in binary form must reproduce the above18* copyright notice, this list of conditions and the following19* disclaimer in the documentation and/or other materials20* provided with the distribution.21*22* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,23* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF24* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS26* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN27* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN28* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE29* SOFTWARE.30*/3132#include "qib.h"3334/**35* qib_pio_copy - copy data to MMIO space, in multiples of 32-bits36* @to: destination, in MMIO space (must be 64-bit aligned)37* @from: source (must be 64-bit aligned)38* @count: number of 32-bit quantities to copy39*40* Copy data from kernel space to MMIO space, in multiples of 32 bits at a41* time. Order of access is not guaranteed, nor is a memory barrier42* performed afterwards.43*/44void qib_pio_copy(void __iomem *to, const void *from, size_t count)45{46#ifdef CONFIG_64BIT47u64 __iomem *dst = to;48const u64 *src = from;49const u64 *end = src + (count >> 1);5051while (src < end)52__raw_writeq(*src++, dst++);53if (count & 1)54__raw_writel(*(const u32 *)src, dst);55#else56u32 __iomem *dst = to;57const u32 *src = from;58const u32 *end = src + count;5960while (src < end)61__raw_writel(*src++, dst++);62#endif63}646566