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/radeon Use bus_space_read rat...
details: https://anonhg.NetBSD.org/src/rev/04fb75abe627
branches: trunk
changeset: 339066:04fb75abe627
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jun 24 18:23:23 2015 +0000
description:
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@.
diffstat:
sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c | 26 +++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diffs (43 lines):
diff -r 3f4c6716081b -r 04fb75abe627 sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c
--- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c Wed Jun 24 18:20:36 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_bios.c Wed Jun 24 18:23:23 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;
}
Home |
Main Index |
Thread Index |
Old Index