From: Ted Bullock Subject: Re: radeondrm: use the common KMS console path on sparc64 To: Jonathan Gray Cc: tech@openbsd.org Date: Fri, 09 Oct 2026 00:00:50 -0600 Hi Jonathan, The two calls initialize different objects. fbwscons_init() sets up rdev->sf.sf_ro for the firmware framebuffer, while the second call initializes rdev->ro for the framebuffer for the KMS. Removing the reassignment to sf.sf_ro is what makes the second initialization necessary including its RI_BSWAP. The revised patch below also removes RI_VCONS and RI_WRONLY from the early initialization. The KMS object is the only one to have virtual console allocation. I think there are two resources left behind after the handoff that could be cleaned up - the early font reference - kernel mapping of the firmware framebuffer I have not looked at doing that cleanup yet. Also the console isn't centered as per the firmware, I don't really like the centered console personally. Anyway here's a screenshot of my framebuffer right now. https://files.catbox.moe/nqc7f4.png Ted --- a/sys/dev/pci/drm/radeon/radeon_drv.c +++ b/sys/dev/pci/drm/radeon/radeon_drv.c @@ -741,13 +741,10 @@ void radeondrm_free_screen(void *, void *); int radeondrm_show_screen(void *, void *, int, void (*)(void *, int, int), void *); void radeondrm_doswitch(void *); void radeondrm_enter_ddb(void *, void *); -#ifdef __sparc64__ -void radeondrm_setcolor(void *, u_int, u_int8_t, u_int8_t, u_int8_t); -#endif void radeondrm_setpal(struct radeon_device *, struct rasops_info *); struct wsscreen_descr radeondrm_stdscreen = { "std", 0, 0, @@ -862,15 +859,11 @@ { struct rasops_info *ri = v; struct radeon_device *rdev = ri->ri_hw; rasops_show_screen(ri, rdev->switchcookie, 0, NULL, NULL); -#ifdef __sparc64__ - fbwscons_setcolormap(&rdev->sf, radeondrm_setcolor); -#else radeondrm_setpal(rdev, ri); -#endif drm_fb_helper_restore_fbdev_mode_unlocked(rdev_to_drm(rdev)->fb_helper, false); if (rdev->switchcb) (rdev->switchcb)(rdev->switchcbarg, 0, 0); @@ -887,29 +880,10 @@ return; rasops_show_screen(ri, cookie, 0, NULL, NULL); drm_fb_helper_debug_enter(fb_helper->info); } - -#ifdef __sparc64__ -void -radeondrm_setcolor(void *v, u_int index, u_int8_t r, u_int8_t g, u_int8_t b) -{ - struct sunfb *sf = v; - struct radeon_device *rdev = sf->sf_ro.ri_hw; - - /* see legacy_crtc_load_lut() */ - if (rdev->family < CHIP_RS600) { - WREG8(RADEON_PALETTE_INDEX, index); - WREG32(RADEON_PALETTE_30_DATA, - (r << 22) | (g << 12) | (b << 2)); - } else { - printf("%s: setcolor family %d not handled\n", - rdev->self.dv_xname, rdev->family); - } -} -#endif void radeondrm_setpal(struct radeon_device *rdev, struct rasops_info *ri) { struct drm_device *dev = rdev_to_drm(rdev); @@ -1167,11 +1141,11 @@ ri = &rdev->sf.sf_ro; ri->ri_bits = bus_space_vaddr(rdev->memt, rdev->memh); ri->ri_hw = rdev; ri->ri_updatecursor = NULL; - fbwscons_init(&rdev->sf, RI_VCONS | RI_WRONLY | RI_BSWAP, console); + fbwscons_init(&rdev->sf, RI_BSWAP, console); if (console) fbwscons_console_init(&rdev->sf, -1); } #endif @@ -1285,20 +1259,18 @@ drm_client_setup(dev, format); if (ri->ri_bits == NULL) return; -#ifdef __sparc64__ - fbwscons_setcolormap(&rdev->sf, radeondrm_setcolor); - ri = &rdev->sf.sf_ro; -#else radeondrm_setpal(rdev, ri); ri->ri_flg = RI_CENTER | RI_VCONS | RI_WRONLY; +#ifdef __sparc64__ + ri->ri_flg |= RI_BSWAP | RI_FULLCLEAR; +#endif rasops_init(ri, 160, 160); ri->ri_hw = rdev; -#endif radeondrm_stdscreen.capabilities = ri->ri_caps; radeondrm_stdscreen.nrows = ri->ri_rows; radeondrm_stdscreen.ncols = ri->ri_cols; radeondrm_stdscreen.textops = &ri->ri_ops; @@ -1314,10 +1286,13 @@ if (rdev->console) { uint32_t defattr; ri->ri_ops.pack_attr(ri->ri_active, 0, 0, 0, &defattr); +#ifdef __sparc64__ + ri->ri_ops.eraserows(ri->ri_active, 0, ri->ri_rows, defattr); +#endif wsdisplay_cnattach(&radeondrm_stdscreen, ri->ri_active, ri->ri_ccol, ri->ri_crow, defattr); } /*