Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/dist/drm/nouveau/core/engine Use bus_s...
details: https://anonhg.NetBSD.org/src/rev/5e10e91b21f6
branches: trunk
changeset: 345164:5e10e91b21f6
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed May 11 02:28:33 2016 +0000
description:
Use bus_space_subregion to get fifo channels out of mmio registers.
Evidently it is not enough to just map them separately. Ran out of
time to investigate why, last time I poked at this and confirmed this
change works.
diffstat:
sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c | 10 +-
sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_base.c | 73 ++++++++-
2 files changed, 66 insertions(+), 17 deletions(-)
diffs (125 lines):
diff -r d012b308d268 -r 5e10e91b21f6 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c Wed May 11 02:23:50 2016 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c Wed May 11 02:28:33 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_engine_device_base.c,v 1.10 2016/04/13 08:50:51 riastradh Exp $ */
+/* $NetBSD: nouveau_engine_device_base.c,v 1.11 2016/05/11 02:28:33 riastradh Exp $ */
/*
* Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_device_base.c,v 1.10 2016/04/13 08:50:51 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_device_base.c,v 1.11 2016/05/11 02:28:33 riastradh Exp $");
#include <core/object.h>
#include <core/device.h>
@@ -297,12 +297,6 @@
#ifdef __NetBSD__
if (!(args->disable & NV_DEVICE_DISABLE_MMIO) &&
!nv_subdev(device)->mmiosz) {
- /*
- * Map only through PRAMIN -- don't map the command
- * FIFO MMIO regions, which start at NV_FIFO_OFFSET =
- * 0x800000 and are mapped separately.
- */
- mmio_size = MIN(mmio_size, 0x800000);
/* XXX errno NetBSD->Linux */
ret = -bus_space_map(mmiot, mmio_base, mmio_size, 0, &mmioh);
if (ret) {
diff -r d012b308d268 -r 5e10e91b21f6 sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_base.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_base.c Wed May 11 02:23:50 2016 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_base.c Wed May 11 02:28:33 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nouveau_engine_fifo_base.c,v 1.4 2016/02/10 17:10:47 riastradh Exp $ */
+/* $NetBSD: nouveau_engine_fifo_base.c,v 1.5 2016/05/11 02:28:33 riastradh Exp $ */
/*
* Copyright 2012 Red Hat Inc.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_fifo_base.c,v 1.4 2016/02/10 17:10:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_engine_fifo_base.c,v 1.5 2016/05/11 02:28:33 riastradh Exp $");
#include <core/client.h>
#include <core/object.h>
@@ -92,13 +92,68 @@
/* map fifo control registers */
#ifdef __NetBSD__
- chan->bst = nv_device_resource_tag(device, bar);
- /* XXX errno NetBSD->Linux */
- ret = -bus_space_map(chan->bst, nv_device_resource_start(device, bar) +
- addr + (chan->chid * size), size, 0, &chan->bsh);
- if (ret)
- return ret;
- chan->mapped = true;
+ if (bar == 0) {
+ /*
+ * We already map BAR 0 in the engine device base, so
+ * grab a subregion of that.
+ */
+ bus_space_tag_t mmiot = nv_subdev(device)->mmiot;
+ bus_space_handle_t mmioh = nv_subdev(device)->mmioh;
+ bus_size_t mmiosz = nv_subdev(device)->mmiosz;
+
+ /* Check whether it lies inside the region. */
+ if (mmiosz < addr ||
+ mmiosz - addr < chan->chid*size ||
+ mmiosz - addr - chan->chid*size < size) {
+ ret = EIO;
+ nv_error(priv, "fifo channel out of range:"
+ " addr 0x%"PRIxMAX
+ " chid 0x%"PRIxMAX" size 0x%"PRIxMAX
+ " mmiosz 0x%"PRIxMAX"\n",
+ (uintmax_t)addr,
+ (uintmax_t)chan->chid, (uintmax_t)size,
+ (uintmax_t)mmiosz);
+ return ret;
+ }
+
+ /* Grab a subregion. */
+ /* XXX errno NetBSD->Linux */
+ ret = -bus_space_subregion(mmiot, mmioh,
+ (addr + chan->chid*size), size, &chan->bsh);
+ if (ret) {
+ nv_error(priv, "bus_space_subregion failed: %d\n",
+ ret);
+ return ret;
+ }
+
+ /* Success! No need to unmap a subregion. */
+ chan->mapped = false;
+ chan->bst = mmiot;
+ } else {
+ chan->bst = nv_device_resource_tag(device, bar);
+ /* XXX errno NetBSD->Linux */
+ ret = -bus_space_map(chan->bst,
+ (nv_device_resource_start(device, bar) +
+ addr + (chan->chid * size)),
+ size, 0, &chan->bsh);
+ if (ret) {
+ nv_error(priv, "failed to map fifo channel:"
+ " bar %d addr %"PRIxMAX" + %"PRIxMAX
+ " + (%"PRIxMAX" * %"PRIxMAX") = %"PRIxMAX
+ " size %"PRIxMAX": %d\n",
+ bar,
+ (uintmax_t)nv_device_resource_start(device, bar),
+ (uintmax_t)addr,
+ (uintmax_t)chan->chid,
+ (uintmax_t)size,
+ (uintmax_t)(nv_device_resource_start(device, bar) +
+ addr + (chan->chid * size)),
+ (uintmax_t)size,
+ ret);
+ return ret;
+ }
+ chan->mapped = true;
+ }
#else
chan->user = ioremap(nv_device_resource_start(device, bar) + addr +
(chan->chid * size), size);
Home |
Main Index |
Thread Index |
Old Index