Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/sys/external/bsd/drm2 Pull up following revision(s) (requ...
details: https://anonhg.NetBSD.org/src/rev/6998fe241b3c
branches: netbsd-7
changeset: 799515:6998fe241b3c
user: snj <snj%NetBSD.org@localhost>
date: Thu Jul 30 15:46:41 2015 +0000
description:
Pull up following revision(s) (requested by riastradh in ticket #906):
sys/external/bsd/drm2/include/linux/pci.h: revisions 1.18, 1.19
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c: revision 1.4
Save the location of the found ROM so caller can bus_space_read it.
--
Use bus_space_read rather than kmemdup to read ROM.
jakllsch@ reports that on some 64-bit systems, kmemdup does 8-byte
reads, which yield garbage in the high word. bus_space_read_region_1
does 1-byte reads instead, which seem to work.
Derived from a patch from jakllsch@.
--
Fix type of pd_rom_found_size: it's a size, not a handle.
diffstat:
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c | 26 +++++++++++++++++++++
sys/external/bsd/drm2/include/linux/pci.h | 16 +++++++-----
2 files changed, 35 insertions(+), 7 deletions(-)
diffs (91 lines):
diff -r 4eef8c9b2b9d -r 6998fe241b3c sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c
--- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c Thu Jul 30 15:43:36 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c Thu Jul 30 15:46:41 2015 +0000
@@ -116,6 +116,31 @@
return false;
}
+#ifdef __NetBSD__
+ /*
+ * Using kmemdup results in >4-byte memory access on 64-bit
+ * systems, which yields bogus answers on some devices. So we
+ * use bus_space(9) to do guaranteed byte access with
+ * bus_space_read_region_1 which seems to work better.
+ */
+ {
+ const bus_space_tag_t bst = rdev->pdev->pd_rom_bst;
+ const bus_space_handle_t bsh = rdev->pdev->pd_rom_found_bsh;
+
+ if (size == 0 ||
+ bus_space_read_1(bst, bsh, 0) != 0x55 ||
+ bus_space_read_1(bst, bsh, 1) != 0xaa) {
+ pci_unmap_rom(rdev->pdev, bios);
+ return false;
+ }
+ rdev->bios = kmalloc(size, GFP_KERNEL);
+ if (rdev->bios == NULL) {
+ pci_unmap_rom(rdev->pdev, bios);
+ return false;
+ }
+ bus_space_read_region_1(bst, bsh, 0, rdev->bios, size);
+ }
+#else
if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) {
pci_unmap_rom(rdev->pdev, bios);
return false;
@@ -125,6 +150,7 @@
pci_unmap_rom(rdev->pdev, bios);
return false;
}
+#endif
pci_unmap_rom(rdev->pdev, bios);
return true;
}
diff -r 4eef8c9b2b9d -r 6998fe241b3c sys/external/bsd/drm2/include/linux/pci.h
--- a/sys/external/bsd/drm2/include/linux/pci.h Thu Jul 30 15:43:36 2015 +0000
+++ b/sys/external/bsd/drm2/include/linux/pci.h Thu Jul 30 15:46:41 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci.h,v 1.7.2.6 2015/04/23 07:31:17 snj Exp $ */
+/* $NetBSD: pci.h,v 1.7.2.7 2015/07/30 15:46:41 snj Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -126,6 +126,8 @@
bus_space_tag_t pd_rom_bst;
bus_space_handle_t pd_rom_bsh;
bus_size_t pd_rom_size;
+ bus_space_handle_t pd_rom_found_bsh;
+ bus_size_t pd_rom_found_size;
void *pd_rom_vaddr;
device_t pd_dev;
struct drm_device *pd_drm_dev; /* XXX Nouveau kludge! */
@@ -504,8 +506,6 @@
static inline void __pci_rom_iomem *
pci_map_rom(struct pci_dev *pdev, size_t *sizep)
{
- bus_space_handle_t bsh;
- bus_size_t size;
KASSERT(!ISSET(pdev->pd_kludges, NBPCI_KLUDGE_MAP_ROM));
@@ -519,14 +519,16 @@
/* XXX This type is obviously wrong in general... */
if (pci_find_rom(&pdev->pd_pa, pdev->pd_rom_bst, pdev->pd_rom_bsh,
- pdev->pd_rom_size, PCI_ROM_CODE_TYPE_X86, &bsh, &size)) {
+ pdev->pd_rom_size, PCI_ROM_CODE_TYPE_X86,
+ &pdev->pd_rom_found_bsh, &pdev->pd_rom_found_size)) {
pci_unmap_rom(pdev, NULL);
return NULL;
}
- KASSERT(size <= SIZE_T_MAX);
- *sizep = size;
- pdev->pd_rom_vaddr = bus_space_vaddr(pdev->pd_rom_bst, bsh);
+ KASSERT(pdev->pd_rom_found_size <= SIZE_T_MAX);
+ *sizep = pdev->pd_rom_found_size;
+ pdev->pd_rom_vaddr = bus_space_vaddr(pdev->pd_rom_bst,
+ pdev->pd_rom_found_bsh);
return pdev->pd_rom_vaddr;
}
Home |
Main Index |
Thread Index |
Old Index