Use only the low 32 bits of the bar object's vma offset as intended.

Should fix PR kern/50372, seen by everyone trying to use nouveau on
amd64 with hardware that uses nv50-style BARs and not nvc0-style
BARs.
This commit is contained in:
riastradh 2016-04-12 15:12:12 +00:00
parent 1db546b871
commit 168b6c715b

View File

@ -1,4 +1,4 @@
/* $NetBSD: nouveau_subdev_bar_base.c,v 1.4 2016/02/14 03:06:06 riastradh Exp $ */
/* $NetBSD: nouveau_subdev_bar_base.c,v 1.5 2016/04/12 15:12:12 riastradh Exp $ */
/*
* Copyright 2012 Red Hat Inc.
@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_bar_base.c,v 1.4 2016/02/14 03:06:06 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_bar_base.c,v 1.5 2016/04/12 15:12:12 riastradh Exp $");
#include <core/object.h>
@ -65,13 +65,21 @@ nouveau_barobj_ctor(struct nouveau_object *parent,
return ret;
#ifdef __NetBSD__
{
/* Yes, truncation is really intended here. */
uint32_t offset = barobj->vma.offset & 0xffffffffUL;
KASSERTMSG(offset < bar->iomemsz,
"bar object vma exceeds range: %"PRIx32" > %"PRIxMAX,
offset, (uintmax_t)bar->iomemsz);
barobj->iomemt = bar->iomemt;
/* XXX errno NetBSD->Linux */
ret = -bus_space_subregion(bar->iomemt, bar->iomemh,
barobj->vma.offset, bar->iomemsz - barobj->vma.offset,
&barobj->iomemh);
ret = -bus_space_subregion(bar->iomemt, bar->iomemh, offset,
bar->iomemsz - offset, &barobj->iomemh);
if (ret)
return ret;
}
#else
barobj->iomem = bar->iomem + (u32)barobj->vma.offset;
#endif