diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-12-14 12:48:16 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-12-14 12:48:16 +0000 |
commit | 1421aec3eeb8f880da8d57be5424c733ce6f0f2b (patch) | |
tree | aca0821d15cec238c7be4f5ddb67727b518b7fc7 /sys/dev | |
parent | 325b99dbc4f25688c286cd987610cb80cd965751 (diff) |
use bus_space_read_region_1() when reading bios from pci rom
Avoids 'BIOS signature incorrect 0 0' warning seen on sparc64
(where pci is mapped little endian) reported by Ted Bullock.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/drm/amd/amdgpu/amdgpu_bios.c | 15 | ||||
-rw-r--r-- | sys/dev/pci/drm/radeon/radeon_bios.c | 48 |
2 files changed, 19 insertions, 44 deletions
diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_bios.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_bios.c index 91727d200e8..ab945875207 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_bios.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_bios.c @@ -200,7 +200,6 @@ bool amdgpu_read_bios(struct amdgpu_device *adev) #else bool amdgpu_read_bios(struct amdgpu_device *adev) { - uint8_t __iomem *bios; size_t size; pcireg_t address, mask; bus_space_handle_t romh; @@ -218,25 +217,15 @@ bool amdgpu_read_bios(struct amdgpu_device *adev) size = PCI_ROM_SIZE(mask); if (size == 0) return false; - rc = bus_space_map(adev->memt, PCI_ROM_ADDR(address), size, - BUS_SPACE_MAP_LINEAR, &romh); + rc = bus_space_map(adev->memt, PCI_ROM_ADDR(address), size, 0, &romh); if (rc != 0) { printf(": can't map PCI ROM (%d)\n", rc); return false; } - bios = (uint8_t *)bus_space_vaddr(adev->memt, romh); - if (!bios) { - printf(": bus_space_vaddr failed\n"); - return false; - } adev->bios = kzalloc(size, GFP_KERNEL); - if (adev->bios == NULL) { - bus_space_unmap(adev->memt, romh, size); - return false; - } adev->bios_size = size; - memcpy_fromio(adev->bios, bios, size); + bus_space_read_region_1(adev->memt, romh, 0, adev->bios, size); bus_space_unmap(adev->memt, romh, size); if (!check_atom_bios(adev->bios, size)) { diff --git a/sys/dev/pci/drm/radeon/radeon_bios.c b/sys/dev/pci/drm/radeon/radeon_bios.c index f0282c83240..121b286991e 100644 --- a/sys/dev/pci/drm/radeon/radeon_bios.c +++ b/sys/dev/pci/drm/radeon/radeon_bios.c @@ -89,7 +89,6 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev) #else static bool igp_read_bios_from_vram(struct radeon_device *rdev) { - uint8_t __iomem *bios; bus_size_t size = 256 * 1024; /* ??? */ bus_space_handle_t bsh; bus_space_tag_t bst = rdev->memt; @@ -100,26 +99,19 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev) rdev->bios = NULL; - if (bus_space_map(bst, rdev->fb_aper_offset, size, BUS_SPACE_MAP_LINEAR, &bsh) != 0) - return false; - - bios = bus_space_vaddr(rdev->memt, bsh); - if (bios == NULL) { - bus_space_unmap(bst, bsh, size); + if (bus_space_map(bst, rdev->fb_aper_offset, size, 0, &bsh) != 0) return false; - } - if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { - bus_space_unmap(bst, bsh, size); - return false; - } rdev->bios = kmalloc(size, GFP_KERNEL); - if (rdev->bios == NULL) { - bus_space_unmap(bst, bsh, size); + bus_space_read_region_1(rdev->memt, bsh, 0, rdev->bios, size); + bus_space_unmap(bst, bsh, size); + + if (size == 0 || rdev->bios[0] != 0x55 || rdev->bios[1] != 0xaa) { + kfree(rdev->bios); + rdev->bios = NULL; return false; } - memcpy_fromio(rdev->bios, bios, size); - bus_space_unmap(bst, bsh, size); + return true; } #endif @@ -156,7 +148,6 @@ static bool radeon_read_bios(struct radeon_device *rdev) #else static bool radeon_read_bios(struct radeon_device *rdev) { - uint8_t __iomem *bios; bus_size_t size; pcireg_t address, mask; bus_space_handle_t romh; @@ -174,27 +165,22 @@ static bool radeon_read_bios(struct radeon_device *rdev) size = PCI_ROM_SIZE(mask); if (size == 0) return false; - rc = bus_space_map(rdev->memt, PCI_ROM_ADDR(address), size, - BUS_SPACE_MAP_LINEAR, &romh); + rc = bus_space_map(rdev->memt, PCI_ROM_ADDR(address), size, 0, &romh); if (rc != 0) { printf(": can't map PCI ROM (%d)\n", rc); return false; } - bios = (uint8_t *)bus_space_vaddr(rdev->memt, romh); - if (!bios) { - printf(": bus_space_vaddr failed\n"); - return false; - } - - if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) - goto fail; + rdev->bios = kmalloc(size, GFP_KERNEL); - memcpy(rdev->bios, bios, size); + bus_space_read_region_1(rdev->memt, romh, 0, rdev->bios, size); bus_space_unmap(rdev->memt, romh, size); + + if (size == 0 || rdev->bios[0] != 0x55 || rdev->bios[1] != 0xaa) { + kfree(rdev->bios); + rdev->bios = NULL; + return false; + } return true; -fail: - bus_space_unmap(rdev->memt, romh, size); - return false; } #endif |