Skip to content
Browse files

Use gdev_io_memcpy instead of using functions defined respectively

We define gdev_io_memcpy as utility function and use it for memcpy
on MMIO memory.
  • Loading branch information...
1 parent 9915a77 commit 4dab4995126428a36d491cb055bd03f7cc640e13 @Constellation Constellation committed
Showing with 51 additions and 26 deletions.
  1. +3 −12 lib/user/nouveau/nouveau_gdev.c
  2. +3 −12 lib/user/nvrm/nvrm_gdev.c
  3. +3 −2 lib/user/pscnv/pscnv_gdev.c
  4. +42 −0 util/gdev_io_memcpy.h
View
15 lib/user/nouveau/nouveau_gdev.c
@@ -24,6 +24,7 @@
#include "gdev_api.h"
#include "gdev_device.h"
+#include "gdev_io_memcpy.h"
#include "gdev_nvidia.h"
#include "gdev_nvidia_fifo.h"
#include "gdev_nvidia_nve4.h"
@@ -43,16 +44,6 @@ struct gdev_nouveau_ctx_objects {
struct nouveau_object *m2mf;
};
-/* this ensures that SSE is not applied to memcpy. */
-void* __nouveau_io_memcpy(void* s1, const void* s2, size_t n)
-{
- volatile char* out = (volatile char*)s1;
- const volatile char* in = (const volatile char*)s2;
- size_t i;
- for (i = 0; i < n; ++i) out[i] = in[i];
- return s1;
-}
-
void __nouveau_fifo_space(struct gdev_ctx *ctx, uint32_t len)
{
struct nouveau_pushbuf *push = (struct nouveau_pushbuf *)ctx->pctx;
@@ -654,7 +645,7 @@ int gdev_raw_read(struct gdev_mem *mem, void *buf, uint64_t addr, uint32_t size)
uint64_t offset = addr - bo->offset;
if (bo->map) {
- __nouveau_io_memcpy(buf, bo->map + offset, size);
+ gdev_io_memcpy(buf, bo->map + offset, size);
return 0;
}
else {
@@ -669,7 +660,7 @@ int gdev_raw_write(struct gdev_mem *mem, uint64_t addr, const void *buf, uint32_
uint64_t offset = addr - bo->offset;
if (bo->map) {
- __nouveau_io_memcpy(bo->map + offset, buf, size);
+ gdev_io_memcpy(bo->map + offset, buf, size);
return 0;
}
else {
View
15 lib/user/nvrm/nvrm_gdev.c
@@ -24,6 +24,7 @@
#include "gdev_api.h"
#include "gdev_device.h"
+#include "gdev_io_memcpy.h"
#include "gdev_nvidia.h"
#include "gdev_nvidia_fifo.h"
#include "nvrm.h"
@@ -37,16 +38,6 @@
struct gdev_device *lgdev; /* local gdev_device structure for user-space scheduling */
static struct nvrm_context *nvrm_ctx = 0;
-/* this ensures that SSE is not applied to memcpy. */
-void* __nvrm_io_memcpy(void* s1, const void* s2, size_t n)
-{
- volatile char* out = (volatile char*)s1;
- const volatile char* in = (const volatile char*)s2;
- size_t i;
- for (i = 0; i < n; ++i) out[i] = in[i];
- return s1;
-}
-
int gdev_raw_query(struct gdev_device *gdev, uint32_t type, uint64_t *result)
{
#ifndef GDEV_SCHED_DISABLED/* fix this */
@@ -498,7 +489,7 @@ int gdev_raw_read(struct gdev_mem *mem, void *buf, uint64_t addr, uint32_t size)
}
uint64_t offset = addr - mem->addr;
- __nvrm_io_memcpy(buf, ptr + offset, size);
+ gdev_io_memcpy(buf, ptr + offset, size);
if (!mem->map) {
nvrm_bo_host_unmap(bo);
@@ -517,7 +508,7 @@ int gdev_raw_write(struct gdev_mem *mem, uint64_t addr, const void *buf, uint32_
}
uint64_t offset = addr - mem->addr;
- __nvrm_io_memcpy(ptr + offset, buf, size);
+ gdev_io_memcpy(ptr + offset, buf, size);
if (!mem->map) {
nvrm_bo_host_unmap(bo);
View
5 lib/user/pscnv/pscnv_gdev.c
@@ -24,6 +24,7 @@
#include "gdev_api.h"
#include "gdev_device.h"
+#include "gdev_io_memcpy.h"
#include "gdev_nvidia.h"
#include "gdev_nvidia_fifo.h"
#include "libpscnv.h"
@@ -374,7 +375,7 @@ int gdev_raw_read(struct gdev_mem *mem, void *buf, uint64_t addr, uint32_t size)
uint64_t offset = addr - bo->vm_base;
if (bo->map) {
- memcpy(buf, bo->map + offset, size);
+ gdev_io_memcpy(buf, bo->map + offset, size);
return 0;
}
else
@@ -390,7 +391,7 @@ int gdev_raw_write(struct gdev_mem *mem, uint64_t addr, const void *buf, uint32_
uint64_t offset = addr - bo->vm_base;
if (bo->map) {
- memcpy(bo->map + offset, buf, size);
+ gdev_io_memcpy(bo->map + offset, buf, size);
return 0;
}
else
View
42 util/gdev_io_memcpy.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) Shinpei Kato and Yusuke Suzuki
+ *
+ * Nagoya University
+ * Keio University
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __GDEV_IO_MEMCPY_H__
+#define __GDEV_IO_MEMCPY_H__
+
+/* this ensures that SSE is not applied to memcpy. */
+static inline void* gdev_io_memcpy(void* s1, const void* s2, size_t n)
+{
+ volatile char* out = (volatile char*)s1;
+ const volatile char* in = (const volatile char*)s2;
+ size_t i;
+ for (i = 0; i < n; ++i) out[i] = in[i];
+ return s1;
+}
+
+#endif /* __GDEV_IO_MEMCPY_H__ */

0 comments on commit 4dab499

Please sign in to comment.
Something went wrong with that request. Please try again.