From ac656c6f1d948b8701951ca4b4361b27dcadc75e Mon Sep 17 00:00:00 2001 From: kettenis Date: Fri, 24 Aug 2018 05:21:48 +0000 Subject: [PATCH] Allocate framebuffer PCI BAR if left uninitialized by firmware. ok mlarkin@ --- sys/dev/pci/drm/radeon/radeon_kms.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sys/dev/pci/drm/radeon/radeon_kms.c b/sys/dev/pci/drm/radeon/radeon_kms.c index 590b99da8de..acc0fbc95cb 100644 --- a/sys/dev/pci/drm/radeon/radeon_kms.c +++ b/sys/dev/pci/drm/radeon/radeon_kms.c @@ -485,6 +485,26 @@ radeondrm_attach_kms(struct device *parent, struct device *self, void *aux) printf(": can't get frambuffer info\n"); return; } +#if !defined(__sparc64__) + if (rdev->fb_aper_offset == 0) { + bus_size_t start, end; + bus_addr_t base; + + start = max(PCI_MEM_START, pa->pa_memex->ex_start); + end = min(PCI_MEM_END, pa->pa_memex->ex_end); + if (pa->pa_memex == NULL || + extent_alloc_subregion(pa->pa_memex, start, end, + rdev->fb_aper_size, rdev->fb_aper_size, 0, 0, 0, &base)) { + printf(": can't reserve framebuffer space\n"); + return; + } + pci_conf_write(pa->pa_pc, pa->pa_tag, RADEON_PCI_MEM, base); + if (PCI_MAPREG_MEM_TYPE(type) == PCI_MAPREG_MEM_TYPE_64BIT) + pci_conf_write(pa->pa_pc, pa->pa_tag, + RADEON_PCI_MEM + 4, (uint64_t)base >> 32); + rdev->fb_aper_offset = base; + } +#endif for (i = PCI_MAPREG_START; i < PCI_MAPREG_END ; i+= 4) { type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, i); -- 2.20.1